From 9c116834d523a295d0410fe3c67c1c54d67ce908 Mon Sep 17 00:00:00 2001 From: Niel Drummond Date: Sat, 19 Oct 2024 21:17:54 +0100 Subject: [PATCH] chore: Refactor to allow external adapters --- Cargo.toml | 6 +- codegen/templates/api.mustache | 55 +- codegen/templates/lib.mustache | 4 +- src/adapters/mod.rs | 126 +- src/adapters/reqwest.rs | 120 +- src/adapters/ureq.rs | 128 +- src/adapters/wasm.rs | 119 +- src/endpoints/actions.rs | 6650 ++++++++++++------- src/endpoints/activity.rs | 1487 +++-- src/endpoints/apps.rs | 1743 ++--- src/endpoints/billing.rs | 236 +- src/endpoints/checks.rs | 492 +- src/endpoints/classroom.rs | 251 +- src/endpoints/code_scanning.rs | 1002 +-- src/endpoints/code_security.rs | 561 +- src/endpoints/codes_of_conduct.rs | 99 +- src/endpoints/codespaces.rs | 2613 ++++---- src/endpoints/copilot.rs | 742 ++- src/endpoints/dependabot.rs | 868 +-- src/endpoints/dependency_graph.rs | 144 +- src/endpoints/emojis.rs | 51 +- src/endpoints/gists.rs | 1056 +-- src/endpoints/git.rs | 679 +- src/endpoints/gitignore.rs | 94 +- src/endpoints/interactions.rs | 381 +- src/endpoints/issues.rs | 1939 +++--- src/endpoints/licenses.rs | 147 +- src/endpoints/markdown.rs | 98 +- src/endpoints/meta.rs | 208 +- src/endpoints/migrations.rs | 1091 ++-- src/endpoints/mod.rs | 54 +- src/endpoints/oidc.rs | 96 +- src/endpoints/orgs.rs | 3389 +++++----- src/endpoints/packages.rs | 1314 ++-- src/endpoints/projects.rs | 1490 +++-- src/endpoints/pulls.rs | 1270 ++-- src/endpoints/rate_limit.rs | 56 +- src/endpoints/reactions.rs | 1066 +-- src/endpoints/repos.rs | 9039 ++++++++++++++------------ src/endpoints/search.rs | 374 +- src/endpoints/secret_scanning.rs | 373 +- src/endpoints/security_advisories.rs | 524 +- src/endpoints/teams.rs | 2582 ++++---- src/endpoints/users.rs | 2365 ++++--- src/lib.rs | 45 +- src/models.rs | 1120 ++-- tests/simple.rs | 33 +- tests/sync.rs | 11 +- 48 files changed, 27723 insertions(+), 20668 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d6afff1..2c06058 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/fussybeaver/roctogen" documentation = "https://docs.rs/roctogen" readme = "README.md" keywords = ["github"] -edition = "2018" +edition = "2021" [lib] crate-type = ["cdylib", "rlib"] @@ -17,6 +17,7 @@ path = "src/lib.rs" [features] default = [] +reqwest = ["dep:reqwest", "dep:bytes"] # Activate mock base url mock = [] @@ -31,9 +32,10 @@ serde_json = {version = "1.0"} serde_urlencoded = { version = "0.7" } thiserror = "1" log = "0.4" +bytes = { version = "1", optional = true } # reqwest -reqwest = { version = "0.12", optional = true, features = ["json"] } +reqwest = { version = "0.12", optional = true, features = [] } # ureq ureq = { version = "3.0.0-rc1", optional = true, features = ["json"] } diff --git a/codegen/templates/api.mustache b/codegen/templates/api.mustache index dc59caa..a5f2a8a 100644 --- a/codegen/templates/api.mustache +++ b/codegen/templates/api.mustache @@ -6,7 +6,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -14,11 +14,11 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct {{classname}}<'api, C: Client> { +pub struct {{classname}}<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> {{classname}} { +pub fn new(client: &C) -> {{classname}} where AdapterError: From<::Err> { {{classname}} { client } } @@ -26,16 +26,6 @@ pub fn new>(client: &C) -> {{classname}} for AdapterError { + fn from(err: {{classname}}{{operationIdCamelCase}}Error) -> Self { + let (description, status_code) = match err { + {{#responses}}{{^vendorExtensions.x-is-default}} + {{classname}}{{operationIdCamelCase}}Error::Status{{code}}{{#dataType}}(_){{/dataType}} => (String::from("{{{message}}}"), {{code}}), + {{/vendorExtensions.x-is-default}}{{/responses}} + {{classname}}{{operationIdCamelCase}}Error::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + {{/contents}}{{/operation}} {{#operation}}{{#contents}}{{#hasQueryParams}} @@ -86,7 +93,7 @@ impl<'enc> From<&'enc PerPage> for {{classname}}{{operationIdCamelCase}}Params{{ {{/hasQueryParams}} {{/contents}}{{/operation}} -impl<'api, C: Client> {{classname}}<'api, C> { +impl<'api, C: Client> {{classname}}<'api, C> where AdapterError: From<::Err> { {{#operation}}{{#contents}} /// --- /// @@ -105,7 +112,7 @@ impl<'api, C: Client> {{classname}}<'api, C> { /// /// --- {{#vendorExtensions.x-github.previews}}#[cfg(feature = "{{name}}")] - {{/vendorExtensions.x-github.previews}}pub async fn {{operationId}}_async(&self{{#hasParams}}, {{/hasParams}}{{#pathParams}}{{paramName}}: {{#nullable}}Option<{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{{dataType}}}{{/isUuid}}{{/isString}}>{{/nullable}}{{^nullable}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{{dataType}}}{{/isUuid}}{{/isString}}{{/nullable}}{{#hasMore}}, {{/hasMore}}{{/pathParams}}{{#hasQueryParams}}{{#hasPathParams}}, {{/hasPathParams}}query_params: {{#vendorExtensions.x-codegen-has-optional-query-params}}Option<{{/vendorExtensions.x-codegen-has-optional-query-params}}impl Into<{{classname}}{{operationIdCamelCase}}Params{{#vendorExtensions.x-codegen-has-string-params}}<'api>{{/vendorExtensions.x-codegen-has-string-params}}>{{#vendorExtensions.x-codegen-has-optional-query-params}}>{{/vendorExtensions.x-codegen-has-optional-query-params}}{{#hasBodyParam}}, {{/hasBodyParam}}{{/hasQueryParams}}{{#hasBodyParam}}{{^hasQueryParams}}{{#hasPathParams}}, {{/hasPathParams}}{{/hasQueryParams}}body: {{#bodyParam}}{{{dataType}}}{{/bodyParam}}{{/hasBodyParam}}) -> Result<{{#responses}}{{#vendorExtensions.x-is-default}}{{{dataType}}}{{/vendorExtensions.x-is-default}}{{/responses}}{{#vendorExtensions.x-codegen-response-empty-default}}(){{/vendorExtensions.x-codegen-response-empty-default}}, {{classname}}{{operationIdCamelCase}}Error> { + {{/vendorExtensions.x-github.previews}}pub async fn {{operationId}}_async(&self{{#hasParams}}, {{/hasParams}}{{#pathParams}}{{paramName}}: {{#nullable}}Option<{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{{dataType}}}{{/isUuid}}{{/isString}}>{{/nullable}}{{^nullable}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{{dataType}}}{{/isUuid}}{{/isString}}{{/nullable}}{{#hasMore}}, {{/hasMore}}{{/pathParams}}{{#hasQueryParams}}{{#hasPathParams}}, {{/hasPathParams}}query_params: {{#vendorExtensions.x-codegen-has-optional-query-params}}Option<{{/vendorExtensions.x-codegen-has-optional-query-params}}impl Into<{{classname}}{{operationIdCamelCase}}Params{{#vendorExtensions.x-codegen-has-string-params}}<'api>{{/vendorExtensions.x-codegen-has-string-params}}>{{#vendorExtensions.x-codegen-has-optional-query-params}}>{{/vendorExtensions.x-codegen-has-optional-query-params}}{{#hasBodyParam}}, {{/hasBodyParam}}{{/hasQueryParams}}{{#hasBodyParam}}{{^hasQueryParams}}{{#hasPathParams}}, {{/hasPathParams}}{{/hasQueryParams}}body: {{#bodyParam}}{{{dataType}}}{{/bodyParam}}{{/hasBodyParam}}) -> Result<{{#responses}}{{#vendorExtensions.x-is-default}}{{{dataType}}}{{/vendorExtensions.x-is-default}}{{/responses}}{{#vendorExtensions.x-codegen-response-empty-default}}(){{/vendorExtensions.x-codegen-response-empty-default}}, AdapterError> { let {{#hasQueryParams}}mut {{/hasQueryParams}}request_uri = format!("{}{{path}}", super::GITHUB_BASE_API_URL{{#hasPathParams}}, {{/hasPathParams}}{{#pathParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/pathParams}}); @@ -124,12 +131,12 @@ impl<'api, C: Client> {{classname}}<'api, C> { let req = GitHubRequest { uri: request_uri, - body: {{#hasBodyParam}}Some({{#bodyParam}}{{^vendorExtensions.x-codegen-body-bytes}}{{#vendorExtensions.x-is-map-container}}HashMap{{/vendorExtensions.x-is-map-container}}{{^vendorExtensions.x-is-map-container}}{{{dataType}}}{{/vendorExtensions.x-is-map-container}}::from_json(body)?{{/vendorExtensions.x-codegen-body-bytes}}{{#vendorExtensions.x-codegen-body-bytes}}body.into(){{/vendorExtensions.x-codegen-body-bytes}}{{/bodyParam}}){{/hasBodyParam}}{{^hasBodyParam}}None{{/hasBodyParam}}, + body: {{#hasBodyParam}}Some(C::from_json::<{{#bodyParam}}{{^vendorExtensions.x-codegen-body-bytes}}{{#vendorExtensions.x-is-map-container}}HashMap{{/vendorExtensions.x-is-map-container}}{{^vendorExtensions.x-is-map-container}}{{{dataType}}}{{/vendorExtensions.x-is-map-container}}>(body)?{{/vendorExtensions.x-codegen-body-bytes}}{{#vendorExtensions.x-codegen-body-bytes}}Vec>(body)?{{/vendorExtensions.x-codegen-body-bytes}}{{/bodyParam}}){{/hasBodyParam}}{{^hasBodyParam}}None::{{/hasBodyParam}}, method: "{{httpMethod}}", headers: vec![{{#vendorExtensions.x-github.previews}}("Accept", "application/vnd.github.{{name}}-preview+json"), {{/vendorExtensions.x-github.previews}}] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -142,9 +149,9 @@ impl<'api, C: Client> {{classname}}<'api, C> { } else { match github_response.status_code() { {{#responses}}{{#vendorExtensions}}{{^x-is-default}} - {{code}} => {{#dataType}}Err({{classname}}{{operationIdCamelCase}}Error::Status{{code}}(github_response.to_json_async().await?)){{/dataType}}{{^dataType}}Err({{classname}}{{operationIdCamelCase}}Error::Status{{code}}){{/dataType}}, + {{code}} => {{#dataType}}Err({{classname}}{{operationIdCamelCase}}Error::Status{{code}}(github_response.to_json_async().await?).into()){{/dataType}}{{^dataType}}Err({{classname}}{{operationIdCamelCase}}Error::Status{{code}}.into()){{/dataType}}, {{/x-is-default}}{{/vendorExtensions}}{{/responses}} - code => Err({{classname}}{{operationIdCamelCase}}Error::Generic { code }), + code => Err({{classname}}{{operationIdCamelCase}}Error::Generic { code }.into()), } } } @@ -167,7 +174,7 @@ impl<'api, C: Client> {{classname}}<'api, C> { /// --- #[cfg(not(target_arch = "wasm32"))] {{#vendorExtensions.x-github.previews}}#[cfg(feature = "{{name}}")] - {{/vendorExtensions.x-github.previews}}pub fn {{operationId}}(&self{{#hasParams}}, {{/hasParams}}{{#pathParams}}{{paramName}}: {{#nullable}}Option<{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{{dataType}}}{{/isUuid}}{{/isString}}>{{/nullable}}{{^nullable}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{{dataType}}}{{/isUuid}}{{/isString}}{{/nullable}}{{#hasMore}}, {{/hasMore}}{{/pathParams}}{{#hasQueryParams}}{{#hasPathParams}}, {{/hasPathParams}}query_params: {{#vendorExtensions.x-codegen-has-optional-query-params}}Option<{{/vendorExtensions.x-codegen-has-optional-query-params}}impl Into<{{classname}}{{operationIdCamelCase}}Params{{#vendorExtensions.x-codegen-has-string-params}}<'api>{{/vendorExtensions.x-codegen-has-string-params}}>{{#vendorExtensions.x-codegen-has-optional-query-params}}>{{/vendorExtensions.x-codegen-has-optional-query-params}}{{#hasBodyParam}}, {{/hasBodyParam}}{{/hasQueryParams}}{{#hasBodyParam}}{{^hasQueryParams}}{{#hasPathParams}}, {{/hasPathParams}}{{/hasQueryParams}}body: {{#bodyParam}}{{{dataType}}}{{/bodyParam}}{{/hasBodyParam}}) -> Result<{{#responses}}{{#vendorExtensions.x-is-default}}{{{dataType}}}{{/vendorExtensions.x-is-default}}{{/responses}}{{#vendorExtensions.x-codegen-response-empty-default}}(){{/vendorExtensions.x-codegen-response-empty-default}}, {{classname}}{{operationIdCamelCase}}Error> { + {{/vendorExtensions.x-github.previews}}pub fn {{operationId}}(&self{{#hasParams}}, {{/hasParams}}{{#pathParams}}{{paramName}}: {{#nullable}}Option<{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{{dataType}}}{{/isUuid}}{{/isString}}>{{/nullable}}{{^nullable}}{{#isString}}&str{{/isString}}{{#isUuid}}&str{{/isUuid}}{{^isString}}{{^isUuid}}{{{dataType}}}{{/isUuid}}{{/isString}}{{/nullable}}{{#hasMore}}, {{/hasMore}}{{/pathParams}}{{#hasQueryParams}}{{#hasPathParams}}, {{/hasPathParams}}query_params: {{#vendorExtensions.x-codegen-has-optional-query-params}}Option<{{/vendorExtensions.x-codegen-has-optional-query-params}}impl Into<{{classname}}{{operationIdCamelCase}}Params{{#vendorExtensions.x-codegen-has-string-params}}<'api>{{/vendorExtensions.x-codegen-has-string-params}}>{{#vendorExtensions.x-codegen-has-optional-query-params}}>{{/vendorExtensions.x-codegen-has-optional-query-params}}{{#hasBodyParam}}, {{/hasBodyParam}}{{/hasQueryParams}}{{#hasBodyParam}}{{^hasQueryParams}}{{#hasPathParams}}, {{/hasPathParams}}{{/hasQueryParams}}body: {{#bodyParam}}{{{dataType}}}{{/bodyParam}}{{/hasBodyParam}}) -> Result<{{#responses}}{{#vendorExtensions.x-is-default}}{{{dataType}}}{{/vendorExtensions.x-is-default}}{{/responses}}{{#vendorExtensions.x-codegen-response-empty-default}}(){{/vendorExtensions.x-codegen-response-empty-default}}, AdapterError> { let {{#hasQueryParams}}mut {{/hasQueryParams}}request_uri = format!("{}{{path}}", super::GITHUB_BASE_API_URL{{#hasPathParams}}, {{/hasPathParams}}{{#pathParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/pathParams}}); @@ -188,12 +195,12 @@ impl<'api, C: Client> {{classname}}<'api, C> { let req = GitHubRequest { uri: request_uri, - body: {{#hasBodyParam}}Some({{#bodyParam}}{{^vendorExtensions.x-codegen-body-bytes}}{{#vendorExtensions.x-is-map-container}}HashMap{{/vendorExtensions.x-is-map-container}}{{^vendorExtensions.x-is-map-container}}{{{dataType}}}{{/vendorExtensions.x-is-map-container}}::from_json(body)?{{/vendorExtensions.x-codegen-body-bytes}}{{#vendorExtensions.x-codegen-body-bytes}}body.into(){{/vendorExtensions.x-codegen-body-bytes}}{{/bodyParam}}){{/hasBodyParam}}{{^hasBodyParam}}None{{/hasBodyParam}}, + body: {{#hasBodyParam}}Some(C::from_json::<{{#bodyParam}}{{^vendorExtensions.x-codegen-body-bytes}}{{#vendorExtensions.x-is-map-container}}HashMap{{/vendorExtensions.x-is-map-container}}{{^vendorExtensions.x-is-map-container}}{{{dataType}}}{{/vendorExtensions.x-is-map-container}}>(body)?{{/vendorExtensions.x-codegen-body-bytes}}{{#vendorExtensions.x-codegen-body-bytes}}Vec>(body)?{{/vendorExtensions.x-codegen-body-bytes}}{{/bodyParam}}){{/hasBodyParam}}{{^hasBodyParam}}None{{/hasBodyParam}}, method: "{{httpMethod}}", headers: vec![{{#vendorExtensions.x-github.previews}}("Accept", "application/vnd.github.{{name}}-preview+json"), {{/vendorExtensions.x-github.previews}}] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -206,9 +213,9 @@ impl<'api, C: Client> {{classname}}<'api, C> { } else { match github_response.status_code() { {{#responses}}{{#vendorExtensions}}{{^x-is-default}} - {{code}} => {{#dataType}}Err({{classname}}{{operationIdCamelCase}}Error::Status{{code}}(github_response.to_json()?)){{/dataType}}{{^dataType}}Err({{classname}}{{operationIdCamelCase}}Error::Status{{code}}){{/dataType}}, + {{code}} => {{#dataType}}Err({{classname}}{{operationIdCamelCase}}Error::Status{{code}}(github_response.to_json()?).into()){{/dataType}}{{^dataType}}Err({{classname}}{{operationIdCamelCase}}Error::Status{{code}}.into()){{/dataType}}, {{/x-is-default}}{{/vendorExtensions}}{{/responses}} - code => Err({{classname}}{{operationIdCamelCase}}Error::Generic { code }), + code => Err({{classname}}{{operationIdCamelCase}}Error::Generic { code }.into()), } } } diff --git a/codegen/templates/lib.mustache b/codegen/templates/lib.mustache index e4f5eee..ffb461f 100644 --- a/codegen/templates/lib.mustache +++ b/codegen/templates/lib.mustache @@ -40,15 +40,17 @@ //! //! ```no_run //! use roctogen::api::{self, repos}; +//! use roctogen::adapters::client; //! use roctogen::auth::Auth; //! //! let auth = Auth::None; +//! let client = client(&auth).expect("Cannot create new client"); //! let per_page = api::PerPage::new(10); //! //! let mut params: repos::ReposListCommitsParams = per_page.as_ref().into(); //! params = params.author("fussybeaver").page(2); //! -//! repos::new(&auth).list_commits("fussybeaver", "bollard", Some(params)); +//! repos::new(&client).list_commits("fussybeaver", "bollard", Some(params)); //! ``` //! //! ## Async diff --git a/src/adapters/mod.rs b/src/adapters/mod.rs index ef00e52..7970b3e 100644 --- a/src/adapters/mod.rs +++ b/src/adapters/mod.rs @@ -6,44 +6,33 @@ use crate::auth::Auth; #[cfg(target_arch = "wasm32")] pub mod wasm; -#[cfg(target_arch = "wasm32")] -pub type Req = web_sys::Request; - -#[cfg(target_arch = "wasm32")] -pub use wasm::AdapterError; - #[cfg(feature = "reqwest")] pub mod reqwest; -#[cfg(feature = "reqwest")] -pub use self::reqwest::AdapterError; - -#[cfg(feature = "reqwest")] -pub type Req = ::reqwest::Request; - #[cfg(feature = "ureq")] pub mod ureq; -#[cfg(feature = "ureq")] -pub use self::ureq::AdapterError; - -#[cfg(feature = "ureq")] -pub type Req = self::ureq::RequestWithBody; - -#[cfg(all( - not(feature = "reqwest"), - not(feature = "ureq"), - not(target_arch = "wasm32") -))] #[derive(thiserror::Error, Debug)] -pub enum AdapterError {} +pub enum AdapterError { + #[error(transparent)] + SerdeJson(#[from] serde_json::Error), + #[error(transparent)] + SerdeUrl(#[from] serde_urlencoded::ser::Error), + #[error("client error: {description}")] + Client { + description: String, + #[source] + source: Option>, + }, + #[error("endpoint error: {description}")] + Endpoint { + description: String, + status_code: u16, + #[source] + source: Option>, + }, +} -#[cfg(all( - not(feature = "reqwest"), - not(feature = "ureq"), - not(target_arch = "wasm32") -))] -pub type Req = http::Request>; #[cfg(all( not(feature = "reqwest"), @@ -59,95 +48,64 @@ impl GitHubResponseExt for http::Response> { unimplemented!("Use a client adapter feature, or target wasm"); } #[allow(refining_impl_trait)] - fn to_json Deserialize<'de> + std::fmt::Debug>(self) -> Result { + fn to_json Deserialize<'de> + std::fmt::Debug>(self) -> Result { unimplemented!("Use a client adapter feature, or target wasm"); } async fn to_json_async Deserialize<'de> + Unpin + std::fmt::Debug>( self, - ) -> Result { - unimplemented!("Use a client adapter feature, or target wasm"); - } -} - -#[cfg(all( - not(feature = "reqwest"), - not(feature = "ureq"), - not(target_arch = "wasm32") -))] -impl GitHubRequestBuilder, C> for http::Request> { - fn build(_req: GitHubRequest>, _client: &C) -> Result { + ) -> Result { unimplemented!("Use a client adapter feature, or target wasm"); } } -#[cfg(all( - not(feature = "reqwest"), - not(feature = "ureq"), - not(target_arch = "wasm32") -))] -impl FromJson for E -where - E: ser::Serialize + std::fmt::Debug, -{ - fn from_json(_model: E) -> Result { - unimplemented!("Use a client adapter feature, or target wasm"); - } -} - -pub trait FromJson -where - A: ser::Serialize, -{ - fn from_json(model: A) -> Result; -} - #[allow(dead_code)] -pub struct GitHubRequest { +pub struct GitHubRequest<'a, T> { pub uri: String, - pub method: &'static str, + pub method: &'a str, pub body: Option, - pub headers: Vec<(&'static str, &'static str)>, -} - -pub trait GitHubRequestBuilder -where - Self: Sized, -{ - fn build(req: GitHubRequest, client: &C) -> Result; + pub headers: Vec<(&'a str, &'a str)>, } pub trait GitHubResponseExt { fn is_success(&self) -> bool; fn status_code(&self) -> u16; - fn to_json Deserialize<'de> + std::fmt::Debug>(self) -> Result; + fn to_json Deserialize<'de> + std::fmt::Debug>( + self, + ) -> Result; #[allow(async_fn_in_trait)] async fn to_json_async Deserialize<'de> + Unpin + std::fmt::Debug>( self, - ) -> Result; + ) -> Result; } -pub trait Client { +pub trait Client +where + AdapterError: From, +{ type Req; + type Body; + type Err; - fn new(auth: &Auth) -> Result + fn new(auth: &Auth) -> Result where Self: Sized; - fn get_auth(&self) -> &Auth; - fn fetch(&self, req: Self::Req) -> Result; + fn build(&self, req: GitHubRequest) -> Result; + fn fetch(&self, req: Self::Req) -> Result; #[allow(async_fn_in_trait)] - async fn fetch_async(&self, req: Self::Req) -> Result; + async fn fetch_async(&self, req: Self::Req) -> Result; + fn from_json(model: A) -> Result; } #[cfg(target_arch = "wasm32")] -pub fn client(auth: &Auth) -> Result, AdapterError> { +pub fn client(auth: &Auth) -> Result { wasm::Client::new(auth) } #[cfg(feature = "ureq")] -pub fn client(auth: &Auth) -> Result, AdapterError> { +pub fn client(auth: &Auth) -> Result { ureq::Client::new(auth) } #[cfg(feature = "reqwest")] -pub fn client(auth: &Auth) -> Result, AdapterError> { +pub fn client(auth: &Auth) -> Result { reqwest::Client::new(auth) } diff --git a/src/adapters/reqwest.rs b/src/adapters/reqwest.rs index e40146f..12d2fa5 100644 --- a/src/adapters/reqwest.rs +++ b/src/adapters/reqwest.rs @@ -2,9 +2,9 @@ use base64::{prelude::BASE64_STANDARD, Engine}; use http::header::{ACCEPT, AUTHORIZATION, CONTENT_TYPE, USER_AGENT}; use log::debug; -use reqwest::{Body, Client as ReqwestClient, Request, RequestBuilder, Response}; +use reqwest::{Body, Client as ReqwestClient, Request, RequestBuilder}; -use super::{FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use super::{GitHubRequest, GitHubResponseExt}; use crate::auth::Auth; use serde::{ser, Deserialize}; @@ -18,13 +18,31 @@ pub enum AdapterError { #[error(transparent)] Reqwest(#[from] reqwest::Error), #[error(transparent)] + Serde(#[from] serde_json::Error), + #[error(transparent)] IOError(#[from] std::io::Error), #[error("Reqwest adapter only has async fetch implemented")] UnimplementedSync, } +impl From for crate::adapters::AdapterError { + fn from(err: AdapterError) -> Self { + Self::Client { + description: err.to_string(), + source: Some(Box::new(err)), + } + } +} + +struct Response { + pub(crate) bytes: bytes::Bytes, + pub(crate) status_code: u16, +} + impl super::Client for Client { type Req = ::reqwest::Request; + type Body = Body; + type Err = AdapterError where crate::adapters::AdapterError: From; fn new(auth: &Auth) -> Result { Ok(Self { @@ -33,68 +51,23 @@ impl super::Client for Client { }) } - fn get_auth(&self) -> &Auth { - &self.auth - } - - fn fetch(&self, _request: Self::Req) -> Result { + fn fetch(&self, _req: Self::Req) -> Result { Err::(AdapterError::UnimplementedSync) } - async fn fetch_async( - &self, - request: Self::Req, - ) -> Result { + async fn fetch_async(&self, request: Self::Req) -> Result { let res = self.pool.execute(request).await?; debug!("Response: {:?}", &res); - Ok(res) - } -} - -pub struct Client { - auth: Auth, - pool: reqwest::Client, -} - -impl GitHubResponseExt for Response { - fn is_success(&self) -> bool { - self.status().is_success() - } - - fn status_code(&self) -> u16 { - self.status().as_u16() - } - - fn to_json Deserialize<'de> + std::fmt::Debug>(self) -> Result { - unimplemented!("Reqwest adapter only has async json conversion implemented"); - } - - async fn to_json_async Deserialize<'de> + Unpin + std::fmt::Debug>( - self, - ) -> Result { - let json = self.json().await?; - - debug!("Body: {:?}", json); - - Ok(json) - } -} - -impl FromJson for E -where - E: ser::Serialize + std::fmt::Debug, -{ - fn from_json(model: E) -> Result { - debug!("Error: {:?}", model); - - Ok(serde_json::to_vec(&model)?.into()) + let code = res.status(); + Ok(Response { + bytes: res.bytes().await?, + status_code: u16::from(code), + }) } -} -impl GitHubRequestBuilder for Request { - fn build(req: GitHubRequest, client: &C) -> Result { + fn build(&self, req: GitHubRequest) -> Result { let mut builder = http::Request::builder(); builder = builder @@ -108,7 +81,7 @@ impl GitHubRequestBuilder for Request { builder = builder.header(header.0, header.1); } - builder = match client.get_auth() { + builder = match &self.auth { Auth::Basic { user, pass } => { let creds = format!("{}:{}", user, pass); builder.header( @@ -127,4 +100,39 @@ impl GitHubRequestBuilder for Request { Ok(Request::try_from(builder.body(Vec::::new())?)?) } } + + fn from_json(model: E) -> Result { + Ok(serde_json::to_vec(&model)?.into()) + } +} + +pub struct Client { + auth: Auth, + pool: reqwest::Client, +} + +impl GitHubResponseExt for Response { + fn is_success(&self) -> bool { + 300 > self.status_code && self.status_code >= 200 + } + + fn status_code(&self) -> u16 { + self.status_code + } + + fn to_json Deserialize<'de> + std::fmt::Debug>( + self, + ) -> Result { + unimplemented!("Reqwest adapter only has async json conversion implemented"); + } + + async fn to_json_async Deserialize<'de> + Unpin + std::fmt::Debug>( + self, + ) -> Result { + let json = serde_json::from_slice(&self.bytes)?; + + debug!("Body: {:?}", json); + + Ok(json) + } } diff --git a/src/adapters/ureq.rs b/src/adapters/ureq.rs index 5865d86..f3edf84 100644 --- a/src/adapters/ureq.rs +++ b/src/adapters/ureq.rs @@ -10,16 +10,13 @@ use ureq::{Agent, AsSendBody}; use log::debug; -use super::{FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use super::{GitHubRequest, GitHubResponseExt}; use crate::auth::Auth; use serde::{de::DeserializeOwned, ser, Deserialize}; use serde_json::value::Value; -pub struct RequestWithBody { - pub(crate) req: http::request::Builder, - pub(crate) body: Option>, -} +use std::error::Error; #[derive(thiserror::Error, Debug)] pub enum AdapterError { @@ -35,28 +32,35 @@ pub enum AdapterError { UnimplementedAsync, } +impl From for crate::adapters::AdapterError { + fn from(err: AdapterError) -> Self { + Self::Client { + description: err.to_string(), + source: Some(Box::new(err)), + } + } +} + impl super::Client for Client { type Req = RequestWithBody; + type Body = Vec; + type Err = AdapterError where crate::adapters::AdapterError: From; - fn new(auth: &Auth) -> Result { + fn new(auth: &Auth) -> Result { Ok(Self { auth: auth.to_owned(), - agent: Agent::new_with_config(ureq::Config { + agent: Agent::new_with_config(::ureq::Config { http_status_as_error: false, ..Default::default() }), }) } - fn get_auth(&self) -> &Auth { - &self.auth - } - - fn fetch(&self, request: Self::Req) -> Result { - let res = if let Some(body) = request.body { - self.agent.run(request.req.body(body)?) + fn fetch(&self, req: Self::Req) -> Result { + let res = if let Some(body) = req.body { + self.agent.run(req.req.body(body)?) } else { - self.agent.run(request.req.body(())?) + self.agent.run(req.req.body(())?) }; match res { @@ -65,63 +69,11 @@ impl super::Client for Client { } } - async fn fetch_async( - &self, - _request: Self::Req, - ) -> Result { + async fn fetch_async(&self, _request: Self::Req) -> Result { Err::, _>(AdapterError::UnimplementedAsync) } -} - -pub struct Client { - auth: Auth, - agent: Agent, -} - -impl GitHubResponseExt for Response { - fn is_success(&self) -> bool { - 300 > self.status().as_u16() && self.status().as_u16() >= 200 - } - - fn status_code(&self) -> u16 { - self.status().as_u16() - } - - fn to_json Deserialize<'de> + std::fmt::Debug>(self) -> Result { - Ok(serde_json::from_reader(self.into_body().as_reader())?) - } - - async fn to_json_async Deserialize<'de> + Unpin + std::fmt::Debug>( - self, - ) -> Result { - unimplemented!("Ureq adapter only has sync json conversion implemented"); - } -} - -impl FromJson for E -where - E: ser::Serialize + std::fmt::Debug, -{ - fn from_json(model: E) -> Result { - debug!("Error: {:?}", model); - - Ok(serde_json::to_value(&model)?.into()) - } -} -impl FromJson> for E -where - E: ser::Serialize + std::fmt::Debug, -{ - fn from_json(model: E) -> Result, serde_json::Error> { - debug!("Error: {:?}", model); - - Ok(serde_json::to_vec(&model)?) - } -} - -impl GitHubRequestBuilder, C> for RequestWithBody { - fn build(req: GitHubRequest>, client: &C) -> Result { + fn build(&self, req: GitHubRequest) -> Result { let mut builder = http::Request::builder(); builder = builder @@ -135,7 +87,7 @@ impl GitHubRequestBuilder, C> for RequestWithBody { builder = builder.header(header.0, header.1); } - builder = match client.get_auth() { + builder = match &self.auth { Auth::Basic { user, pass } => { let creds = format!("{}:{}", user, pass); builder.header( @@ -153,4 +105,40 @@ impl GitHubRequestBuilder, C> for RequestWithBody { body: req.body, }) } + + fn from_json(model: E) -> Result { + Ok(serde_json::to_vec(&model)?) + } +} + +pub struct Client { + auth: Auth, + agent: Agent, +} + +impl GitHubResponseExt for Response { + fn is_success(&self) -> bool { + 300 > self.status().as_u16() && self.status().as_u16() >= 200 + } + + fn status_code(&self) -> u16 { + self.status().as_u16() + } + + fn to_json Deserialize<'de> + std::fmt::Debug>( + self, + ) -> Result { + Ok(serde_json::from_reader(self.into_body().as_reader())?) + } + + async fn to_json_async Deserialize<'de> + Unpin + std::fmt::Debug>( + self, + ) -> Result { + unimplemented!("Ureq adapter only has sync json conversion implemented"); + } +} + +pub struct RequestWithBody { + pub(crate) req: http::request::Builder, + pub(crate) body: Option>, } diff --git a/src/adapters/wasm.rs b/src/adapters/wasm.rs index 2bd182b..45cb205 100644 --- a/src/adapters/wasm.rs +++ b/src/adapters/wasm.rs @@ -1,4 +1,4 @@ -use super::{FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use super::{GitHubRequest, GitHubResponseExt}; use crate::auth::Auth; use base64::{prelude::BASE64_STANDARD, Engine}; @@ -52,6 +52,15 @@ pub enum AdapterError { UnimplementedSync, } +impl From for crate::adapters::AdapterError { + fn from(err: AdapterError) -> Self { + Self::Client { + description: err.to_string(), + source: Some(Box::new(err)), + } + } +} + #[derive(thiserror::Error, Debug)] #[error("{msg}")] pub struct JsValueError { @@ -68,26 +77,21 @@ pub struct ObjectError { impl super::Client for Client { type Req = web_sys::Request; + type Body = JsValue; + type Err = AdapterError where crate::adapters::AdapterError: From; - fn new(auth: &Auth) -> Result { + fn new(auth: &Auth) -> Result { Ok(Self { auth: auth.to_owned(), scope: scope()?, }) } - fn get_auth(&self) -> &Auth { - &self.auth - } - - fn fetch(&self, _request: Self::Req) -> Result { + fn fetch(&self, _req: Self::Req) -> Result { Err::(AdapterError::UnimplementedSync) } - async fn fetch_async( - &self, - request: Self::Req, - ) -> Result { + async fn fetch_async(&self, request: Self::Req) -> Result { let resp_value = JsFuture::from(self.scope.fetch(&request)).await?; debug!("Response: {:?}", &resp_value); @@ -99,6 +103,47 @@ impl super::Client for Client { Ok(GitHubResponse { json, resp }) } + +fn build(&self, req: GitHubRequest) -> Result { + let opts = RequestInit::new(); + opts.set_method(&req.method); + if let Some(body) = req.body { + debug!("Adding request body: {:?}", &body); + + opts.set_body(&js_sys::JSON::stringify(&body)?.into()); + } + + let request = Request::new_with_str_and_init(&req.uri, &opts)?; + let headers = request.headers(); + headers.set("Accept", "application/vnd.github.v3+json")?; + headers.set("Content-Type", "application/json")?; + headers.set("User-Agent", "roctogen")?; + + for header in req.headers.iter() { + headers.set(header.0, header.1)?; + } + + match &self.auth { + Auth::Basic { user, pass } => { + let creds = format!("{}:{}", user, pass); + headers.set( + "Authorization", + &format!("Basic {}", BASE64_STANDARD.encode(creds.as_bytes())), + )?; + } + Auth::Token(token) => headers.set("Authorization", &format!("token {}", token))?, + Auth::Bearer(bearer) => headers.set("Authorization", &format!("Bearer {}", bearer))?, + Auth::None => (), + } + + debug!("Built request object: {:?}", &request); + + Ok(request) + } + + fn from_json(model: E) -> Result { + Ok(JsValue::from_serde(&model)?) + } } pub struct Client { @@ -137,61 +182,13 @@ impl GitHubResponseExt for GitHubResponse { fn status_code(&self) -> u16 { self.resp.status() } - fn to_json Deserialize<'de> + std::fmt::Debug>(self) -> Result { + fn to_json Deserialize<'de> + std::fmt::Debug>(self) -> Result { unimplemented!("Reqwest adapter only has async json conversion implemented"); } async fn to_json_async Deserialize<'de> + Unpin + std::fmt::Debug>( self, - ) -> Result { + ) -> Result { Ok(self.json.into_serde()?) } } - -impl FromJson for E -where - E: ser::Serialize, -{ - fn from_json(model: E) -> Result { - JsValue::from_serde(&model) - } -} - -impl GitHubRequestBuilder for Request { - fn build(req: GitHubRequest, client: &C) -> Result { - let opts = RequestInit::new(); - opts.set_method(&req.method); - if let Some(body) = req.body { - debug!("Adding request body: {:?}", &body); - - opts.set_body(&js_sys::JSON::stringify(&body)?.into()); - } - - let request = Request::new_with_str_and_init(&req.uri, &opts)?; - let headers = request.headers(); - headers.set("Accept", "application/vnd.github.v3+json")?; - headers.set("Content-Type", "application/json")?; - headers.set("User-Agent", "roctogen")?; - - for header in req.headers.iter() { - headers.set(header.0, header.1)?; - } - - match client.get_auth() { - Auth::Basic { user, pass } => { - let creds = format!("{}:{}", user, pass); - headers.set( - "Authorization", - &format!("Basic {}", BASE64_STANDARD.encode(creds.as_bytes())), - )?; - } - Auth::Token(token) => headers.set("Authorization", &format!("token {}", token))?, - Auth::Bearer(bearer) => headers.set("Authorization", &format!("Bearer {}", bearer))?, - Auth::None => (), - } - - debug!("Built request object: {:?}", &request); - - Ok(request) - } -} diff --git a/src/endpoints/actions.rs b/src/endpoints/actions.rs index d6327aa..43290a2 100644 --- a/src/endpoints/actions.rs +++ b/src/endpoints/actions.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Actions<'api, C: Client> { +pub struct Actions<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Actions { +pub fn new(client: &C) -> Actions where AdapterError: From<::Err> { Actions { client } } /// 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, or the endpoint has been spammed.")] @@ -51,19 +41,25 @@ pub enum ActionsAddCustomLabelsToSelfHostedRunnerForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsAddCustomLabelsToSelfHostedRunnerForOrgError) -> Self { + let (description, status_code) = match err { + ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status404(_) => (String::from("Resource not found"), 404), + ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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, or the endpoint has been spammed.")] @@ -72,57 +68,115 @@ pub enum ActionsAddCustomLabelsToSelfHostedRunnerForRepoError { Generic { code: u16 }, } -/// Errors for the [Add selected repository to an organization secret](Actions::add_selected_repo_to_org_secret_async()) endpoint. +impl From for AdapterError { + fn from(err: ActionsAddCustomLabelsToSelfHostedRunnerForRepoError) -> Self { + let (description, status_code) = match err { + ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status404(_) => (String::from("Resource not found"), 404), + ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + +/// 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 ActionsAddSelectedRepoToOrgSecretError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), +pub enum ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError { + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError) -> Self { + let (description, status_code) = match err { + ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Add selected repository to an organization secret](Actions::add_selected_repo_to_org_secret_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsAddSelectedRepoToOrgSecretError { #[error("Conflict when visibility type is not set to selected")] Status409, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsAddSelectedRepoToOrgSecretError) -> Self { + let (description, status_code) = match err { + ActionsAddSelectedRepoToOrgSecretError::Status409 => (String::from("Conflict when visibility type is not set to selected"), 409), + ActionsAddSelectedRepoToOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add selected repository to an organization variable](Actions::add_selected_repo_to_org_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsAddSelectedRepoToOrgVariableError { - #[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 visibility of the variable is not set to `selected`")] Status409, #[error("Status code: {}", code)] Generic { code: u16 }, } -/// Errors for the [Approve a workflow run for a fork pull request](Actions::approve_workflow_run_async()) endpoint. +impl From for AdapterError { + fn from(err: ActionsAddSelectedRepoToOrgVariableError) -> Self { + let (description, status_code) = match err { + ActionsAddSelectedRepoToOrgVariableError::Status409 => (String::from("Response when the visibility of the variable is not set to `selected`"), 409), + ActionsAddSelectedRepoToOrgVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + +/// Errors for the [Add a self-hosted runner to a group for an organization](Actions::add_self_hosted_runner_to_group_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] -pub enum ActionsApproveWorkflowRunError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), +pub enum ActionsAddSelfHostedRunnerToGroupForOrgError { + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsAddSelfHostedRunnerToGroupForOrgError) -> Self { + let (description, status_code) = match err { + ActionsAddSelfHostedRunnerToGroupForOrgError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Approve a workflow run for a fork pull request](Actions::approve_workflow_run_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsApproveWorkflowRunError { #[error("Resource not found")] Status404(BasicError), #[error("Forbidden")] @@ -131,435 +185,583 @@ pub enum ActionsApproveWorkflowRunError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsApproveWorkflowRunError) -> Self { + let (description, status_code) = match err { + ActionsApproveWorkflowRunError::Status404(_) => (String::from("Resource not found"), 404), + ActionsApproveWorkflowRunError::Status403(_) => (String::from("Forbidden"), 403), + ActionsApproveWorkflowRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Cancel a workflow run](Actions::cancel_workflow_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCancelWorkflowRunError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Conflict")] Status409(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsCancelWorkflowRunError) -> Self { + let (description, status_code) = match err { + ActionsCancelWorkflowRunError::Status409(_) => (String::from("Conflict"), 409), + ActionsCancelWorkflowRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an environment variable](Actions::create_environment_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCreateEnvironmentVariableError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsCreateEnvironmentVariableError) -> Self { + let (description, status_code) = match err { + ActionsCreateEnvironmentVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update an environment secret](Actions::create_or_update_environment_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCreateOrUpdateEnvironmentSecretError { - #[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 updating a secret")] Status204, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsCreateOrUpdateEnvironmentSecretError) -> Self { + let (description, status_code) = match err { + ActionsCreateOrUpdateEnvironmentSecretError::Status204 => (String::from("Response when updating a secret"), 204), + ActionsCreateOrUpdateEnvironmentSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update an organization secret](Actions::create_or_update_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCreateOrUpdateOrgSecretError { - #[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 updating a secret")] Status204, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsCreateOrUpdateOrgSecretError) -> Self { + let (description, status_code) = match err { + ActionsCreateOrUpdateOrgSecretError::Status204 => (String::from("Response when updating a secret"), 204), + ActionsCreateOrUpdateOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update a repository secret](Actions::create_or_update_repo_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCreateOrUpdateRepoSecretError { - #[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 updating a secret")] Status204, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsCreateOrUpdateRepoSecretError) -> Self { + let (description, status_code) = match err { + ActionsCreateOrUpdateRepoSecretError::Status204 => (String::from("Response when updating a secret"), 204), + ActionsCreateOrUpdateRepoSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an organization variable](Actions::create_org_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCreateOrgVariableError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsCreateOrgVariableError) -> Self { + let (description, status_code) = match err { + ActionsCreateOrgVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a registration token for an organization](Actions::create_registration_token_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCreateRegistrationTokenForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsCreateRegistrationTokenForOrgError) -> Self { + let (description, status_code) = match err { + ActionsCreateRegistrationTokenForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a registration token for a repository](Actions::create_registration_token_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCreateRegistrationTokenForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsCreateRegistrationTokenForRepoError) -> Self { + let (description, status_code) = match err { + ActionsCreateRegistrationTokenForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a remove token for an organization](Actions::create_remove_token_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCreateRemoveTokenForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsCreateRemoveTokenForOrgError) -> Self { + let (description, status_code) = match err { + ActionsCreateRemoveTokenForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a remove token for a repository](Actions::create_remove_token_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCreateRemoveTokenForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsCreateRemoveTokenForRepoError) -> Self { + let (description, status_code) = match err { + ActionsCreateRemoveTokenForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a repository variable](Actions::create_repo_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCreateRepoVariableError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsCreateRepoVariableError) -> Self { + let (description, status_code) = match err { + ActionsCreateRepoVariableError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Create a self-hosted runner group for an organization](Actions::create_self_hosted_runner_group_for_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsCreateSelfHostedRunnerGroupForOrgError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsCreateSelfHostedRunnerGroupForOrgError) -> Self { + let (description, status_code) = match err { + ActionsCreateSelfHostedRunnerGroupForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a workflow dispatch event](Actions::create_workflow_dispatch_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsCreateWorkflowDispatchError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsCreateWorkflowDispatchError) -> Self { + let (description, status_code) = match err { + ActionsCreateWorkflowDispatchError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a GitHub Actions cache for a repository (using a cache ID)](Actions::delete_actions_cache_by_id_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteActionsCacheByIdError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteActionsCacheByIdError) -> Self { + let (description, status_code) = match err { + ActionsDeleteActionsCacheByIdError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete GitHub Actions caches for a repository (using a cache key)](Actions::delete_actions_cache_by_key_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteActionsCacheByKeyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteActionsCacheByKeyError) -> Self { + let (description, status_code) = match err { + ActionsDeleteActionsCacheByKeyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an artifact](Actions::delete_artifact_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteArtifactError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteArtifactError) -> Self { + let (description, status_code) = match err { + ActionsDeleteArtifactError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an environment secret](Actions::delete_environment_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteEnvironmentSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteEnvironmentSecretError) -> Self { + let (description, status_code) = match err { + ActionsDeleteEnvironmentSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an environment variable](Actions::delete_environment_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteEnvironmentVariableError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteEnvironmentVariableError) -> Self { + let (description, status_code) = match err { + ActionsDeleteEnvironmentVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an organization secret](Actions::delete_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteOrgSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteOrgSecretError) -> Self { + let (description, status_code) = match err { + ActionsDeleteOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an organization variable](Actions::delete_org_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteOrgVariableError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteOrgVariableError) -> Self { + let (description, status_code) = match err { + ActionsDeleteOrgVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a repository secret](Actions::delete_repo_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteRepoSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteRepoSecretError) -> Self { + let (description, status_code) = match err { + ActionsDeleteRepoSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a repository variable](Actions::delete_repo_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteRepoVariableError { - #[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 [Delete a self-hosted runner from an organization](Actions::delete_self_hosted_runner_from_org_async()) endpoint. -#[derive(Debug, thiserror::Error)] -pub enum ActionsDeleteSelfHostedRunnerFromOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - +impl From for AdapterError { + fn from(err: ActionsDeleteRepoVariableError) -> Self { + let (description, status_code) = match err { + ActionsDeleteRepoVariableError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Delete a self-hosted runner from an organization](Actions::delete_self_hosted_runner_from_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsDeleteSelfHostedRunnerFromOrgError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteSelfHostedRunnerFromOrgError) -> Self { + let (description, status_code) = match err { + ActionsDeleteSelfHostedRunnerFromOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a self-hosted runner from a repository](Actions::delete_self_hosted_runner_from_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteSelfHostedRunnerFromRepoError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsDeleteSelfHostedRunnerFromRepoError) -> Self { + let (description, status_code) = match err { + ActionsDeleteSelfHostedRunnerFromRepoError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Delete a self-hosted runner group from an organization](Actions::delete_self_hosted_runner_group_from_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsDeleteSelfHostedRunnerGroupFromOrgError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteSelfHostedRunnerGroupFromOrgError) -> Self { + let (description, status_code) = match err { + ActionsDeleteSelfHostedRunnerGroupFromOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a workflow run](Actions::delete_workflow_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteWorkflowRunError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteWorkflowRunError) -> Self { + let (description, status_code) = match err { + ActionsDeleteWorkflowRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete workflow run logs](Actions::delete_workflow_run_logs_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDeleteWorkflowRunLogsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Internal Error")] @@ -568,53 +770,67 @@ pub enum ActionsDeleteWorkflowRunLogsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsDeleteWorkflowRunLogsError) -> Self { + let (description, status_code) = match err { + ActionsDeleteWorkflowRunLogsError::Status403(_) => (String::from("Forbidden"), 403), + ActionsDeleteWorkflowRunLogsError::Status500(_) => (String::from("Internal Error"), 500), + ActionsDeleteWorkflowRunLogsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Disable a selected repository for GitHub Actions in an organization](Actions::disable_selected_repository_github_actions_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDisableSelectedRepositoryGithubActionsOrganizationError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsDisableSelectedRepositoryGithubActionsOrganizationError) -> Self { + let (description, status_code) = match err { + ActionsDisableSelectedRepositoryGithubActionsOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Disable a workflow](Actions::disable_workflow_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDisableWorkflowError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsDisableWorkflowError) -> Self { + let (description, status_code) = match err { + ActionsDisableWorkflowError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Download an artifact](Actions::download_artifact_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDownloadArtifactError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status302, #[error("Gone")] @@ -623,129 +839,163 @@ pub enum ActionsDownloadArtifactError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsDownloadArtifactError) -> Self { + let (description, status_code) = match err { + ActionsDownloadArtifactError::Status302 => (String::from("Response"), 302), + ActionsDownloadArtifactError::Status410(_) => (String::from("Gone"), 410), + ActionsDownloadArtifactError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Download job logs for a workflow run](Actions::download_job_logs_for_workflow_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDownloadJobLogsForWorkflowRunError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status302, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsDownloadJobLogsForWorkflowRunError) -> Self { + let (description, status_code) = match err { + ActionsDownloadJobLogsForWorkflowRunError::Status302 => (String::from("Response"), 302), + ActionsDownloadJobLogsForWorkflowRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Download workflow run attempt logs](Actions::download_workflow_run_attempt_logs_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDownloadWorkflowRunAttemptLogsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status302, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsDownloadWorkflowRunAttemptLogsError) -> Self { + let (description, status_code) = match err { + ActionsDownloadWorkflowRunAttemptLogsError::Status302 => (String::from("Response"), 302), + ActionsDownloadWorkflowRunAttemptLogsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Download workflow run logs](Actions::download_workflow_run_logs_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsDownloadWorkflowRunLogsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status302, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsDownloadWorkflowRunLogsError) -> Self { + let (description, status_code) = match err { + ActionsDownloadWorkflowRunLogsError::Status302 => (String::from("Response"), 302), + ActionsDownloadWorkflowRunLogsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Enable a selected repository for GitHub Actions in an organization](Actions::enable_selected_repository_github_actions_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsEnableSelectedRepositoryGithubActionsOrganizationError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsEnableSelectedRepositoryGithubActionsOrganizationError) -> Self { + let (description, status_code) = match err { + ActionsEnableSelectedRepositoryGithubActionsOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Enable a workflow](Actions::enable_workflow_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsEnableWorkflowError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsEnableWorkflowError) -> Self { + let (description, status_code) = match err { + ActionsEnableWorkflowError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Force cancel a workflow run](Actions::force_cancel_workflow_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsForceCancelWorkflowRunError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Conflict")] Status409(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsForceCancelWorkflowRunError) -> Self { + let (description, status_code) = match err { + ActionsForceCancelWorkflowRunError::Status409(_) => (String::from("Conflict"), 409), + ActionsForceCancelWorkflowRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create configuration for a just-in-time runner for an organization](Actions::generate_runner_jitconfig_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGenerateRunnerJitconfigForOrgError { - #[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, or the endpoint has been spammed.")] @@ -754,19 +1004,25 @@ pub enum ActionsGenerateRunnerJitconfigForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsGenerateRunnerJitconfigForOrgError) -> Self { + let (description, status_code) = match err { + ActionsGenerateRunnerJitconfigForOrgError::Status404(_) => (String::from("Resource not found"), 404), + ActionsGenerateRunnerJitconfigForOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ActionsGenerateRunnerJitconfigForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create configuration for a just-in-time runner for a repository](Actions::generate_runner_jitconfig_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGenerateRunnerJitconfigForRepoError { - #[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, or the endpoint has been spammed.")] @@ -775,138 +1031,172 @@ pub enum ActionsGenerateRunnerJitconfigForRepoError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsGenerateRunnerJitconfigForRepoError) -> Self { + let (description, status_code) = match err { + ActionsGenerateRunnerJitconfigForRepoError::Status404(_) => (String::from("Resource not found"), 404), + ActionsGenerateRunnerJitconfigForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ActionsGenerateRunnerJitconfigForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List GitHub Actions caches for a repository](Actions::get_actions_cache_list_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetActionsCacheListError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetActionsCacheListError) -> Self { + let (description, status_code) = match err { + ActionsGetActionsCacheListError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get GitHub Actions cache usage for a repository](Actions::get_actions_cache_usage_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetActionsCacheUsageError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetActionsCacheUsageError) -> Self { + let (description, status_code) = match err { + ActionsGetActionsCacheUsageError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories with GitHub Actions cache usage for an organization](Actions::get_actions_cache_usage_by_repo_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetActionsCacheUsageByRepoForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetActionsCacheUsageByRepoForOrgError) -> Self { + let (description, status_code) = match err { + ActionsGetActionsCacheUsageByRepoForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get GitHub Actions cache usage for an organization](Actions::get_actions_cache_usage_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetActionsCacheUsageForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetActionsCacheUsageForOrgError) -> Self { + let (description, status_code) = match err { + ActionsGetActionsCacheUsageForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get allowed actions and reusable workflows for an organization](Actions::get_allowed_actions_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetAllowedActionsOrganizationError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetAllowedActionsOrganizationError) -> Self { + let (description, status_code) = match err { + ActionsGetAllowedActionsOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get allowed actions and reusable workflows for a repository](Actions::get_allowed_actions_repository_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetAllowedActionsRepositoryError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetAllowedActionsRepositoryError) -> Self { + let (description, status_code) = match err { + ActionsGetAllowedActionsRepositoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an artifact](Actions::get_artifact_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetArtifactError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetArtifactError) -> Self { + let (description, status_code) = match err { + ActionsGetArtifactError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the customization template for an OIDC subject claim for a repository](Actions::get_custom_oidc_sub_claim_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetCustomOidcSubClaimForRepoError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Resource not found")] @@ -915,934 +1205,1243 @@ pub enum ActionsGetCustomOidcSubClaimForRepoError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsGetCustomOidcSubClaimForRepoError) -> Self { + let (description, status_code) = match err { + ActionsGetCustomOidcSubClaimForRepoError::Status400(_) => (String::from("Bad Request"), 400), + ActionsGetCustomOidcSubClaimForRepoError::Status404(_) => (String::from("Resource not found"), 404), + ActionsGetCustomOidcSubClaimForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an environment public key](Actions::get_environment_public_key_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetEnvironmentPublicKeyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetEnvironmentPublicKeyError) -> Self { + let (description, status_code) = match err { + ActionsGetEnvironmentPublicKeyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an environment secret](Actions::get_environment_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetEnvironmentSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetEnvironmentSecretError) -> Self { + let (description, status_code) = match err { + ActionsGetEnvironmentSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an environment variable](Actions::get_environment_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetEnvironmentVariableError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetEnvironmentVariableError) -> Self { + let (description, status_code) = match err { + ActionsGetEnvironmentVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get default workflow permissions for an organization](Actions::get_github_actions_default_workflow_permissions_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetGithubActionsDefaultWorkflowPermissionsOrganizationError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetGithubActionsDefaultWorkflowPermissionsOrganizationError) -> Self { + let (description, status_code) = match err { + ActionsGetGithubActionsDefaultWorkflowPermissionsOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get default workflow permissions for a repository](Actions::get_github_actions_default_workflow_permissions_repository_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetGithubActionsDefaultWorkflowPermissionsRepositoryError { - #[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 GitHub Actions permissions for an organization](Actions::get_github_actions_permissions_organization_async()) endpoint. -#[derive(Debug, thiserror::Error)] -pub enum ActionsGetGithubActionsPermissionsOrganizationError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - +impl From for AdapterError { + fn from(err: ActionsGetGithubActionsDefaultWorkflowPermissionsRepositoryError) -> Self { + let (description, status_code) = match err { + ActionsGetGithubActionsDefaultWorkflowPermissionsRepositoryError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Get GitHub Actions permissions for an organization](Actions::get_github_actions_permissions_organization_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsGetGithubActionsPermissionsOrganizationError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsGetGithubActionsPermissionsOrganizationError) -> Self { + let (description, status_code) = match err { + ActionsGetGithubActionsPermissionsOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get GitHub Actions permissions for a repository](Actions::get_github_actions_permissions_repository_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetGithubActionsPermissionsRepositoryError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetGithubActionsPermissionsRepositoryError) -> Self { + let (description, status_code) = match err { + ActionsGetGithubActionsPermissionsRepositoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a job for a workflow run](Actions::get_job_for_workflow_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetJobForWorkflowRunError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetJobForWorkflowRunError) -> Self { + let (description, status_code) = match err { + ActionsGetJobForWorkflowRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization public key](Actions::get_org_public_key_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetOrgPublicKeyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetOrgPublicKeyError) -> Self { + let (description, status_code) = match err { + ActionsGetOrgPublicKeyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization secret](Actions::get_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetOrgSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetOrgSecretError) -> Self { + let (description, status_code) = match err { + ActionsGetOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization variable](Actions::get_org_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetOrgVariableError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetOrgVariableError) -> Self { + let (description, status_code) = match err { + ActionsGetOrgVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get pending deployments for a workflow run](Actions::get_pending_deployments_for_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetPendingDeploymentsForRunError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetPendingDeploymentsForRunError) -> Self { + let (description, status_code) = match err { + ActionsGetPendingDeploymentsForRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository public key](Actions::get_repo_public_key_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetRepoPublicKeyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetRepoPublicKeyError) -> Self { + let (description, status_code) = match err { + ActionsGetRepoPublicKeyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository secret](Actions::get_repo_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetRepoSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetRepoSecretError) -> Self { + let (description, status_code) = match err { + ActionsGetRepoSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository variable](Actions::get_repo_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetRepoVariableError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetRepoVariableError) -> Self { + let (description, status_code) = match err { + ActionsGetRepoVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the review history for a workflow run](Actions::get_reviews_for_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetReviewsForRunError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetReviewsForRunError) -> Self { + let (description, status_code) = match err { + ActionsGetReviewsForRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a self-hosted runner for an organization](Actions::get_self_hosted_runner_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetSelfHostedRunnerForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetSelfHostedRunnerForOrgError) -> Self { + let (description, status_code) = match err { + ActionsGetSelfHostedRunnerForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a self-hosted runner for a repository](Actions::get_self_hosted_runner_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetSelfHostedRunnerForRepoError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsGetSelfHostedRunnerForRepoError) -> Self { + let (description, status_code) = match err { + ActionsGetSelfHostedRunnerForRepoError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Get a self-hosted runner group for an organization](Actions::get_self_hosted_runner_group_for_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsGetSelfHostedRunnerGroupForOrgError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsGetSelfHostedRunnerGroupForOrgError) -> Self { + let (description, status_code) = match err { + ActionsGetSelfHostedRunnerGroupForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a workflow](Actions::get_workflow_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetWorkflowError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetWorkflowError) -> Self { + let (description, status_code) = match err { + ActionsGetWorkflowError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the level of access for workflows outside of the repository](Actions::get_workflow_access_to_repository_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetWorkflowAccessToRepositoryError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetWorkflowAccessToRepositoryError) -> Self { + let (description, status_code) = match err { + ActionsGetWorkflowAccessToRepositoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a workflow run](Actions::get_workflow_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetWorkflowRunError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetWorkflowRunError) -> Self { + let (description, status_code) = match err { + ActionsGetWorkflowRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a workflow run attempt](Actions::get_workflow_run_attempt_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetWorkflowRunAttemptError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetWorkflowRunAttemptError) -> Self { + let (description, status_code) = match err { + ActionsGetWorkflowRunAttemptError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get workflow run usage](Actions::get_workflow_run_usage_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetWorkflowRunUsageError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetWorkflowRunUsageError) -> Self { + let (description, status_code) = match err { + ActionsGetWorkflowRunUsageError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get workflow usage](Actions::get_workflow_usage_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsGetWorkflowUsageError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsGetWorkflowUsageError) -> Self { + let (description, status_code) = match err { + ActionsGetWorkflowUsageError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List artifacts for a repository](Actions::list_artifacts_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListArtifactsForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListArtifactsForRepoError) -> Self { + let (description, status_code) = match err { + ActionsListArtifactsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List environment secrets](Actions::list_environment_secrets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListEnvironmentSecretsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListEnvironmentSecretsError) -> Self { + let (description, status_code) = match err { + ActionsListEnvironmentSecretsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List environment variables](Actions::list_environment_variables_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListEnvironmentVariablesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListEnvironmentVariablesError) -> Self { + let (description, status_code) = match err { + ActionsListEnvironmentVariablesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List jobs for a workflow run](Actions::list_jobs_for_workflow_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListJobsForWorkflowRunError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListJobsForWorkflowRunError) -> Self { + let (description, status_code) = match err { + ActionsListJobsForWorkflowRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List jobs for a workflow run attempt](Actions::list_jobs_for_workflow_run_attempt_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListJobsForWorkflowRunAttemptError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListJobsForWorkflowRunAttemptError) -> Self { + let (description, status_code) = match err { + ActionsListJobsForWorkflowRunAttemptError::Status404(_) => (String::from("Resource not found"), 404), + ActionsListJobsForWorkflowRunAttemptError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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 }, } +impl From for AdapterError { + fn from(err: ActionsListLabelsForSelfHostedRunnerForOrgError) -> Self { + let (description, status_code) = match err { + ActionsListLabelsForSelfHostedRunnerForOrgError::Status404(_) => (String::from("Resource not found"), 404), + ActionsListLabelsForSelfHostedRunnerForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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 }, } +impl From for AdapterError { + fn from(err: ActionsListLabelsForSelfHostedRunnerForRepoError) -> Self { + let (description, status_code) = match err { + ActionsListLabelsForSelfHostedRunnerForRepoError::Status404(_) => (String::from("Resource not found"), 404), + ActionsListLabelsForSelfHostedRunnerForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization secrets](Actions::list_org_secrets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListOrgSecretsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListOrgSecretsError) -> Self { + let (description, status_code) = match err { + ActionsListOrgSecretsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization variables](Actions::list_org_variables_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListOrgVariablesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsListOrgVariablesError) -> Self { + let (description, status_code) = match err { + ActionsListOrgVariablesError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [List repository access to a self-hosted runner group in an organization](Actions::list_repo_access_to_self_hosted_runner_group_in_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsListRepoAccessToSelfHostedRunnerGroupInOrgError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsListRepoAccessToSelfHostedRunnerGroupInOrgError) -> Self { + let (description, status_code) = match err { + ActionsListRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository organization secrets](Actions::list_repo_organization_secrets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListRepoOrganizationSecretsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListRepoOrganizationSecretsError) -> Self { + let (description, status_code) = match err { + ActionsListRepoOrganizationSecretsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository organization variables](Actions::list_repo_organization_variables_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListRepoOrganizationVariablesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListRepoOrganizationVariablesError) -> Self { + let (description, status_code) = match err { + ActionsListRepoOrganizationVariablesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository secrets](Actions::list_repo_secrets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListRepoSecretsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListRepoSecretsError) -> Self { + let (description, status_code) = match err { + ActionsListRepoSecretsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository variables](Actions::list_repo_variables_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListRepoVariablesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListRepoVariablesError) -> Self { + let (description, status_code) = match err { + ActionsListRepoVariablesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository workflows](Actions::list_repo_workflows_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListRepoWorkflowsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListRepoWorkflowsError) -> Self { + let (description, status_code) = match err { + ActionsListRepoWorkflowsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List runner applications for an organization](Actions::list_runner_applications_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListRunnerApplicationsForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListRunnerApplicationsForOrgError) -> Self { + let (description, status_code) = match err { + ActionsListRunnerApplicationsForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List runner applications for a repository](Actions::list_runner_applications_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListRunnerApplicationsForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListRunnerApplicationsForRepoError) -> Self { + let (description, status_code) = match err { + ActionsListRunnerApplicationsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List selected repositories for an organization secret](Actions::list_selected_repos_for_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListSelectedReposForOrgSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListSelectedReposForOrgSecretError) -> Self { + let (description, status_code) = match err { + ActionsListSelectedReposForOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List selected repositories for an organization variable](Actions::list_selected_repos_for_org_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListSelectedReposForOrgVariableError { - #[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 visibility of the variable is not set to `selected`")] Status409, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsListSelectedReposForOrgVariableError) -> Self { + let (description, status_code) = match err { + ActionsListSelectedReposForOrgVariableError::Status409 => (String::from("Response when the visibility of the variable is not set to `selected`"), 409), + ActionsListSelectedReposForOrgVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List selected repositories enabled for GitHub Actions in an organization](Actions::list_selected_repositories_enabled_github_actions_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListSelectedRepositoriesEnabledGithubActionsOrganizationError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsListSelectedRepositoriesEnabledGithubActionsOrganizationError) -> Self { + let (description, status_code) = match err { + ActionsListSelectedRepositoriesEnabledGithubActionsOrganizationError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [List self-hosted runner groups for an organization](Actions::list_self_hosted_runner_groups_for_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsListSelfHostedRunnerGroupsForOrgError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsListSelfHostedRunnerGroupsForOrgError) -> Self { + let (description, status_code) = match err { + ActionsListSelfHostedRunnerGroupsForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List self-hosted runners for an organization](Actions::list_self_hosted_runners_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListSelfHostedRunnersForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListSelfHostedRunnersForOrgError) -> Self { + let (description, status_code) = match err { + ActionsListSelfHostedRunnersForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List self-hosted runners for a repository](Actions::list_self_hosted_runners_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListSelfHostedRunnersForRepoError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsListSelfHostedRunnersForRepoError) -> Self { + let (description, status_code) = match err { + ActionsListSelfHostedRunnersForRepoError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [List self-hosted runners in a group for an organization](Actions::list_self_hosted_runners_in_group_for_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsListSelfHostedRunnersInGroupForOrgError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsListSelfHostedRunnersInGroupForOrgError) -> Self { + let (description, status_code) = match err { + ActionsListSelfHostedRunnersInGroupForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List workflow run artifacts](Actions::list_workflow_run_artifacts_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListWorkflowRunArtifactsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListWorkflowRunArtifactsError) -> Self { + let (description, status_code) = match err { + ActionsListWorkflowRunArtifactsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List workflow runs for a workflow](Actions::list_workflow_runs_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListWorkflowRunsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListWorkflowRunsError) -> Self { + let (description, status_code) = match err { + ActionsListWorkflowRunsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List workflow runs for a repository](Actions::list_workflow_runs_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsListWorkflowRunsForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsListWorkflowRunsForRepoError) -> Self { + let (description, status_code) = match err { + ActionsListWorkflowRunsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Re-run a job from a workflow run](Actions::re_run_job_for_workflow_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsReRunJobForWorkflowRunError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsReRunJobForWorkflowRunError) -> Self { + let (description, status_code) = match err { + ActionsReRunJobForWorkflowRunError::Status403(_) => (String::from("Forbidden"), 403), + ActionsReRunJobForWorkflowRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Re-run a workflow](Actions::re_run_workflow_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsReRunWorkflowError { - #[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 [Re-run failed jobs from a workflow run](Actions::re_run_workflow_failed_jobs_async()) endpoint. -#[derive(Debug, thiserror::Error)] -pub enum ActionsReRunWorkflowFailedJobsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - +impl From for AdapterError { + fn from(err: ActionsReRunWorkflowError) -> Self { + let (description, status_code) = match err { + ActionsReRunWorkflowError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Re-run failed jobs from a workflow run](Actions::re_run_workflow_failed_jobs_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsReRunWorkflowFailedJobsError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsReRunWorkflowFailedJobsError) -> Self { + let (description, status_code) = match err { + ActionsReRunWorkflowFailedJobsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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 }, } +impl From for AdapterError { + fn from(err: ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError) -> Self { + let (description, status_code) = match err { + ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Status404(_) => (String::from("Resource not found"), 404), + ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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 }, } +impl From for AdapterError { + fn from(err: ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError) -> Self { + let (description, status_code) = match err { + ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Status404(_) => (String::from("Resource not found"), 404), + ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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, or the endpoint has been spammed.")] @@ -1851,19 +2450,25 @@ pub enum ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError) -> Self { + let (description, status_code) = match err { + ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status404(_) => (String::from("Resource not found"), 404), + ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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, or the endpoint has been spammed.")] @@ -1872,125 +2477,199 @@ pub enum ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError { Generic { code: u16 }, } -/// Errors for the [Remove selected repository from an organization secret](Actions::remove_selected_repo_from_org_secret_async()) endpoint. +impl From for AdapterError { + fn from(err: ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError) -> Self { + let (description, status_code) = match err { + ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status404(_) => (String::from("Resource not found"), 404), + ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + +/// 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 ActionsRemoveSelectedRepoFromOrgSecretError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), +pub enum ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError { + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError) -> Self { + let (description, status_code) = match err { + ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Remove selected repository from an organization secret](Actions::remove_selected_repo_from_org_secret_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsRemoveSelectedRepoFromOrgSecretError { #[error("Conflict when visibility type not set to selected")] Status409, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsRemoveSelectedRepoFromOrgSecretError) -> Self { + let (description, status_code) = match err { + ActionsRemoveSelectedRepoFromOrgSecretError::Status409 => (String::from("Conflict when visibility type not set to selected"), 409), + ActionsRemoveSelectedRepoFromOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove selected repository from an organization variable](Actions::remove_selected_repo_from_org_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsRemoveSelectedRepoFromOrgVariableError { - #[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 visibility of the variable is not set to `selected`")] Status409, #[error("Status code: {}", code)] Generic { code: u16 }, } -/// Errors for the [Review custom deployment protection rules for a workflow run](Actions::review_custom_gates_for_run_async()) endpoint. +impl From for AdapterError { + fn from(err: ActionsRemoveSelectedRepoFromOrgVariableError) -> Self { + let (description, status_code) = match err { + ActionsRemoveSelectedRepoFromOrgVariableError::Status409 => (String::from("Response when the visibility of the variable is not set to `selected`"), 409), + ActionsRemoveSelectedRepoFromOrgVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + +/// Errors for the [Remove a self-hosted runner from a group for an organization](Actions::remove_self_hosted_runner_from_group_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] -pub enum ActionsReviewCustomGatesForRunError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), +pub enum ActionsRemoveSelfHostedRunnerFromGroupForOrgError { + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsRemoveSelfHostedRunnerFromGroupForOrgError) -> Self { + let (description, status_code) = match err { + ActionsRemoveSelfHostedRunnerFromGroupForOrgError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Review custom deployment protection rules for a workflow run](Actions::review_custom_gates_for_run_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsReviewCustomGatesForRunError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsReviewCustomGatesForRunError) -> Self { + let (description, status_code) = match err { + ActionsReviewCustomGatesForRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Review pending deployments for a workflow run](Actions::review_pending_deployments_for_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsReviewPendingDeploymentsForRunError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsReviewPendingDeploymentsForRunError) -> Self { + let (description, status_code) = match err { + ActionsReviewPendingDeploymentsForRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set allowed actions and reusable workflows for an organization](Actions::set_allowed_actions_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsSetAllowedActionsOrganizationError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsSetAllowedActionsOrganizationError) -> Self { + let (description, status_code) = match err { + ActionsSetAllowedActionsOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set allowed actions and reusable workflows for a repository](Actions::set_allowed_actions_repository_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsSetAllowedActionsRepositoryError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsSetAllowedActionsRepositoryError) -> Self { + let (description, status_code) = match err { + ActionsSetAllowedActionsRepositoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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, or the endpoint has been spammed.")] @@ -1999,19 +2678,25 @@ pub enum ActionsSetCustomLabelsForSelfHostedRunnerForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsSetCustomLabelsForSelfHostedRunnerForOrgError) -> Self { + let (description, status_code) = match err { + ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status404(_) => (String::from("Resource not found"), 404), + ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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, or the endpoint has been spammed.")] @@ -2020,19 +2705,25 @@ pub enum ActionsSetCustomLabelsForSelfHostedRunnerForRepoError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsSetCustomLabelsForSelfHostedRunnerForRepoError) -> Self { + let (description, status_code) = match err { + ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status404(_) => (String::from("Resource not found"), 404), + ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set the customization template for an OIDC subject claim for a repository](Actions::set_custom_oidc_sub_claim_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsSetCustomOidcSubClaimForRepoError { - #[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("Bad Request")] @@ -2043,195 +2734,321 @@ pub enum ActionsSetCustomOidcSubClaimForRepoError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsSetCustomOidcSubClaimForRepoError) -> Self { + let (description, status_code) = match err { + ActionsSetCustomOidcSubClaimForRepoError::Status404(_) => (String::from("Resource not found"), 404), + ActionsSetCustomOidcSubClaimForRepoError::Status400(_) => (String::from("Bad Request"), 400), + ActionsSetCustomOidcSubClaimForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ActionsSetCustomOidcSubClaimForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set default workflow permissions for an organization](Actions::set_github_actions_default_workflow_permissions_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsSetGithubActionsDefaultWorkflowPermissionsOrganizationError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsSetGithubActionsDefaultWorkflowPermissionsOrganizationError) -> Self { + let (description, status_code) = match err { + ActionsSetGithubActionsDefaultWorkflowPermissionsOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set default workflow permissions for a repository](Actions::set_github_actions_default_workflow_permissions_repository_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Conflict response when changing a setting is prevented by the owning organization")] Status409, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError) -> Self { + let (description, status_code) = match err { + ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError::Status409 => (String::from("Conflict response when changing a setting is prevented by the owning organization"), 409), + ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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 { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsSetGithubActionsPermissionsOrganizationError) -> Self { + let (description, status_code) = match err { + ActionsSetGithubActionsPermissionsOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set GitHub Actions permissions for a repository](Actions::set_github_actions_permissions_repository_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsSetGithubActionsPermissionsRepositoryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsSetGithubActionsPermissionsRepositoryError) -> Self { + let (description, status_code) = match err { + ActionsSetGithubActionsPermissionsRepositoryError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Set repository access for a self-hosted runner group in an organization](Actions::set_repo_access_to_self_hosted_runner_group_in_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsSetRepoAccessToSelfHostedRunnerGroupInOrgError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsSetRepoAccessToSelfHostedRunnerGroupInOrgError) -> Self { + let (description, status_code) = match err { + ActionsSetRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set selected repositories for an organization secret](Actions::set_selected_repos_for_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsSetSelectedReposForOrgSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsSetSelectedReposForOrgSecretError) -> Self { + let (description, status_code) = match err { + ActionsSetSelectedReposForOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set selected repositories for an organization variable](Actions::set_selected_repos_for_org_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsSetSelectedReposForOrgVariableError { - #[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 visibility of the variable is not set to `selected`")] Status409, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsSetSelectedReposForOrgVariableError) -> Self { + let (description, status_code) = match err { + ActionsSetSelectedReposForOrgVariableError::Status409 => (String::from("Response when the visibility of the variable is not set to `selected`"), 409), + ActionsSetSelectedReposForOrgVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set selected repositories enabled for GitHub Actions in an organization](Actions::set_selected_repositories_enabled_github_actions_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsSetSelectedRepositoriesEnabledGithubActionsOrganizationError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} +impl From for AdapterError { + fn from(err: ActionsSetSelectedRepositoriesEnabledGithubActionsOrganizationError) -> Self { + let (description, status_code) = match err { + ActionsSetSelectedRepositoriesEnabledGithubActionsOrganizationError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Set self-hosted runners in a group for an organization](Actions::set_self_hosted_runners_in_group_for_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsSetSelfHostedRunnersInGroupForOrgError { #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActionsSetSelfHostedRunnersInGroupForOrgError) -> Self { + let (description, status_code) = match err { + ActionsSetSelfHostedRunnersInGroupForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set the level of access for workflows outside of the repository](Actions::set_workflow_access_to_repository_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsSetWorkflowAccessToRepositoryError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsSetWorkflowAccessToRepositoryError) -> Self { + let (description, status_code) = match err { + ActionsSetWorkflowAccessToRepositoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update an environment variable](Actions::update_environment_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsUpdateEnvironmentVariableError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsUpdateEnvironmentVariableError) -> Self { + let (description, status_code) = match err { + ActionsUpdateEnvironmentVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update an organization variable](Actions::update_org_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsUpdateOrgVariableError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActionsUpdateOrgVariableError) -> Self { + let (description, status_code) = match err { + ActionsUpdateOrgVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a repository variable](Actions::update_repo_variable_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActionsUpdateRepoVariableError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), + #[error("Status code: {}", code)] + Generic { code: u16 }, +} + +impl From for AdapterError { + fn from(err: ActionsUpdateRepoVariableError) -> Self { + let (description, status_code) = match err { + ActionsUpdateRepoVariableError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Update a self-hosted runner group for an organization](Actions::update_self_hosted_runner_group_for_org_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ActionsUpdateSelfHostedRunnerGroupForOrgError { + #[error("Status code: {}", code)] + Generic { code: u16 }, +} - // -- endpoint errors +impl From for AdapterError { + fn from(err: ActionsUpdateSelfHostedRunnerGroupForOrgError) -> Self { + let (description, status_code) = match err { + ActionsUpdateSelfHostedRunnerGroupForOrgError::Generic { code } => (String::from("Generic"), code) + }; - #[error("Status code: {}", code)] - Generic { code: u16 }, + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } } @@ -2756,6 +3573,46 @@ impl<'enc> From<&'enc PerPage> for ActionsListOrgVariablesParams { } } } +/// Query parameters for the [List repository access to a self-hosted runner group in an organization](Actions::list_repo_access_to_self_hosted_runner_group_in_org_async()) endpoint. +#[derive(Default, Serialize)] +pub struct ActionsListRepoAccessToSelfHostedRunnerGroupInOrgParams { + /// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + page: Option, + /// 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 +} + +impl ActionsListRepoAccessToSelfHostedRunnerGroupInOrgParams { + pub fn new() -> Self { + Self::default() + } + + /// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + pub fn page(self, page: u16) -> Self { + Self { + page: Some(page), + per_page: self.per_page, + } + } + + /// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + pub fn per_page(self, per_page: u16) -> Self { + Self { + page: self.page, + per_page: Some(per_page), + } + } +} + +impl<'enc> From<&'enc PerPage> for ActionsListRepoAccessToSelfHostedRunnerGroupInOrgParams { + 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 repository organization secrets](Actions::list_repo_organization_secrets_async()) endpoint. #[derive(Default, Serialize)] pub struct ActionsListRepoOrganizationSecretsParams { @@ -3076,6 +3933,59 @@ impl<'enc> From<&'enc PerPage> for ActionsListSelectedRepositoriesEnabledGithubA } } } +/// Query parameters for the [List self-hosted runner groups for an organization](Actions::list_self_hosted_runner_groups_for_org_async()) endpoint. +#[derive(Default, Serialize)] +pub struct ActionsListSelfHostedRunnerGroupsForOrgParams<'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, + /// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + page: Option, + /// Only return runner groups that are allowed to be used by this repository. + visible_to_repository: Option<&'req str> +} + +impl<'req> ActionsListSelfHostedRunnerGroupsForOrgParams<'req> { + pub fn new() -> Self { + Self::default() + } + + /// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + pub fn per_page(self, per_page: u16) -> Self { + Self { + per_page: Some(per_page), + page: self.page, + visible_to_repository: self.visible_to_repository, + } + } + + /// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + pub fn page(self, page: u16) -> Self { + Self { + per_page: self.per_page, + page: Some(page), + visible_to_repository: self.visible_to_repository, + } + } + + /// Only return runner groups that are allowed to be used by this repository. + pub fn visible_to_repository(self, visible_to_repository: &'req str) -> Self { + Self { + per_page: self.per_page, + page: self.page, + visible_to_repository: Some(visible_to_repository), + } + } +} + +impl<'enc> From<&'enc PerPage> for ActionsListSelfHostedRunnerGroupsForOrgParams<'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 self-hosted runners for an organization](Actions::list_self_hosted_runners_for_org_async()) endpoint. #[derive(Default, Serialize)] pub struct ActionsListSelfHostedRunnersForOrgParams<'req> { @@ -3182,6 +4092,46 @@ impl<'enc> From<&'enc PerPage> for ActionsListSelfHostedRunnersForRepoParams<'en } } } +/// Query parameters for the [List self-hosted runners in a group for an organization](Actions::list_self_hosted_runners_in_group_for_org_async()) endpoint. +#[derive(Default, Serialize)] +pub struct ActionsListSelfHostedRunnersInGroupForOrgParams { + /// 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, + /// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + page: Option +} + +impl ActionsListSelfHostedRunnersInGroupForOrgParams { + pub fn new() -> Self { + Self::default() + } + + /// The number of results per page (max 100). For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + pub fn per_page(self, per_page: u16) -> Self { + Self { + per_page: Some(per_page), + page: self.page, + } + } + + /// The page number of the results to fetch. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + pub fn page(self, page: u16) -> Self { + Self { + per_page: self.per_page, + page: Some(page), + } + } +} + +impl<'enc> From<&'enc PerPage> for ActionsListSelfHostedRunnersInGroupForOrgParams { + 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 workflow run artifacts](Actions::list_workflow_run_artifacts_async()) endpoint. #[derive(Default, Serialize)] pub struct ActionsListWorkflowRunArtifactsParams<'req> { @@ -3636,7 +4586,7 @@ impl<'enc> From<&'enc PerPage> for ActionsListWorkflowRunsForRepoParams<'enc> { } } -impl<'api, C: Client> Actions<'api, C> { +impl<'api, C: Client> Actions<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Add custom labels to a self-hosted runner for an organization @@ -3650,19 +4600,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for add_custom_labels_to_self_hosted_runner_for_org](https://docs.github.com/rest/actions/self-hosted-runners#add-custom-labels-to-a-self-hosted-runner-for-an-organization) /// /// --- - pub async fn add_custom_labels_to_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32, body: PostActionsAddCustomLabelsToSelfHostedRunnerForOrg) -> Result { + 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/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsAddCustomLabelsToSelfHostedRunnerForOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3674,9 +4624,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status404(github_response.to_json_async().await?)), - 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status422(github_response.to_json_async().await?)), - code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Generic { code }), + 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status422(github_response.to_json_async().await?).into()), + code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -3695,19 +4645,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_custom_labels_to_self_hosted_runner_for_org(&self, org: &str, runner_id: i32, body: PostActionsAddCustomLabelsToSelfHostedRunnerForOrg) -> Result { + 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/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsAddCustomLabelsToSelfHostedRunnerForOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3719,9 +4669,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status404(github_response.to_json()?)), - 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status422(github_response.to_json()?)), - code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Generic { code }), + 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status404(github_response.to_json()?).into()), + 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Status422(github_response.to_json()?).into()), + code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -3739,19 +4689,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for add_custom_labels_to_self_hosted_runner_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#add-custom-labels-to-a-self-hosted-runner-for-a-repository) /// /// --- - pub async fn add_custom_labels_to_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32, body: PostActionsAddCustomLabelsToSelfHostedRunnerForRepo) -> Result { + 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!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsAddCustomLabelsToSelfHostedRunnerForRepo::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3763,9 +4713,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status404(github_response.to_json_async().await?)), - 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status422(github_response.to_json_async().await?)), - code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Generic { code }), + 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status422(github_response.to_json_async().await?).into()), + code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Generic { code }.into()), } } } @@ -3784,19 +4734,102 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_custom_labels_to_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32, body: PostActionsAddCustomLabelsToSelfHostedRunnerForRepo) -> Result { + 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!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsAddCustomLabelsToSelfHostedRunnerForRepo::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + 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() { + 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status404(github_response.to_json()?).into()), + 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status422(github_response.to_json()?).into()), + code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Add repository access to a self-hosted runner group in an organization + /// + /// Adds a repository to the list of repositories that can access a self-hosted runner group. The runner group must have `visibility` set to `selected`. For more information, see "[Create a self-hosted runner group for an organization](#create-a-self-hosted-runner-group-for-an-organization)." + /// + /// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for add_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#add-repository-access-to-a-self-hosted-runner-group-in-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<(), AdapterError> { + + 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: "PUT", + 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() { + code => Err(ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Add repository access to a self-hosted runner group in an organization + /// + /// Adds a repository to the list of repositories that can access a self-hosted runner group. The runner group must have `visibility` set to `selected`. For more information, see "[Create a self-hosted runner group for an organization](#create-a-self-hosted-runner-group-for-an-organization)." + /// + /// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for add_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#add-repository-access-to-a-self-hosted-runner-group-in-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<(), AdapterError> { + + 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: "PUT", + headers: vec![] + }; + + let request = self.client.build(req)?; // -- @@ -3808,9 +4841,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status404(github_response.to_json()?)), - 422 => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Status422(github_response.to_json()?)), - code => Err(ActionsAddCustomLabelsToSelfHostedRunnerForRepoError::Generic { code }), + code => Err(ActionsAddRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }.into()), } } } @@ -3830,19 +4861,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for add_selected_repo_to_org_secret](https://docs.github.com/rest/actions/secrets#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> { + pub async fn add_selected_repo_to_org_secret_async(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { 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, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3854,8 +4885,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ActionsAddSelectedRepoToOrgSecretError::Status409), - code => Err(ActionsAddSelectedRepoToOrgSecretError::Generic { code }), + 409 => Err(ActionsAddSelectedRepoToOrgSecretError::Status409.into()), + code => Err(ActionsAddSelectedRepoToOrgSecretError::Generic { code }.into()), } } } @@ -3876,7 +4907,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[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_selected_repo_to_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); @@ -3888,7 +4919,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3900,8 +4931,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ActionsAddSelectedRepoToOrgSecretError::Status409), - code => Err(ActionsAddSelectedRepoToOrgSecretError::Generic { code }), + 409 => Err(ActionsAddSelectedRepoToOrgSecretError::Status409.into()), + code => Err(ActionsAddSelectedRepoToOrgSecretError::Generic { code }.into()), } } } @@ -3920,19 +4951,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for add_selected_repo_to_org_variable](https://docs.github.com/rest/actions/variables#add-selected-repository-to-an-organization-variable) /// /// --- - pub async fn add_selected_repo_to_org_variable_async(&self, org: &str, name: &str, repository_id: i32) -> Result<(), ActionsAddSelectedRepoToOrgVariableError> { + pub async fn add_selected_repo_to_org_variable_async(&self, org: &str, name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, name, repository_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3944,8 +4975,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ActionsAddSelectedRepoToOrgVariableError::Status409), - code => Err(ActionsAddSelectedRepoToOrgVariableError::Generic { code }), + 409 => Err(ActionsAddSelectedRepoToOrgVariableError::Status409.into()), + code => Err(ActionsAddSelectedRepoToOrgVariableError::Generic { code }.into()), } } } @@ -3965,7 +4996,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_selected_repo_to_org_variable(&self, org: &str, name: &str, repository_id: i32) -> Result<(), ActionsAddSelectedRepoToOrgVariableError> { + pub fn add_selected_repo_to_org_variable(&self, org: &str, name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, name, repository_id); @@ -3977,7 +5008,89 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + 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() { + 409 => Err(ActionsAddSelectedRepoToOrgVariableError::Status409.into()), + code => Err(ActionsAddSelectedRepoToOrgVariableError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Add a self-hosted runner to a group for an organization + /// + /// Adds a self-hosted runner to a runner group configured in an organization. + /// + /// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for add_self_hosted_runner_to_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#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<(), AdapterError> { + + 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 = 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() { + code => Err(ActionsAddSelfHostedRunnerToGroupForOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Add a self-hosted runner to a group for an organization + /// + /// Adds a self-hosted runner to a runner group configured in an organization. + /// + /// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for add_self_hosted_runner_to_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#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<(), AdapterError> { + + 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 = self.client.build(req)?; // -- @@ -3989,8 +5102,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ActionsAddSelectedRepoToOrgVariableError::Status409), - code => Err(ActionsAddSelectedRepoToOrgVariableError::Generic { code }), + code => Err(ActionsAddSelfHostedRunnerToGroupForOrgError::Generic { code }.into()), } } } @@ -4006,19 +5118,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for approve_workflow_run](https://docs.github.com/rest/actions/workflow-runs#approve-a-workflow-run-for-a-fork-pull-request) /// /// --- - pub async fn approve_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result { + pub async fn approve_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/approve", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4030,9 +5142,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsApproveWorkflowRunError::Status404(github_response.to_json_async().await?)), - 403 => Err(ActionsApproveWorkflowRunError::Status403(github_response.to_json_async().await?)), - code => Err(ActionsApproveWorkflowRunError::Generic { code }), + 404 => Err(ActionsApproveWorkflowRunError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(ActionsApproveWorkflowRunError::Status403(github_response.to_json_async().await?).into()), + code => Err(ActionsApproveWorkflowRunError::Generic { code }.into()), } } } @@ -4049,7 +5161,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn approve_workflow_run(&self, owner: &str, repo: &str, run_id: i32) -> Result { + pub fn approve_workflow_run(&self, owner: &str, repo: &str, run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/approve", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -4061,7 +5173,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4073,9 +5185,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsApproveWorkflowRunError::Status404(github_response.to_json()?)), - 403 => Err(ActionsApproveWorkflowRunError::Status403(github_response.to_json()?)), - code => Err(ActionsApproveWorkflowRunError::Generic { code }), + 404 => Err(ActionsApproveWorkflowRunError::Status404(github_response.to_json()?).into()), + 403 => Err(ActionsApproveWorkflowRunError::Status403(github_response.to_json()?).into()), + code => Err(ActionsApproveWorkflowRunError::Generic { code }.into()), } } } @@ -4091,19 +5203,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for cancel_workflow_run](https://docs.github.com/rest/actions/workflow-runs#cancel-a-workflow-run) /// /// --- - pub async fn cancel_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result { + pub async fn cancel_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/cancel", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4115,8 +5227,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ActionsCancelWorkflowRunError::Status409(github_response.to_json_async().await?)), - code => Err(ActionsCancelWorkflowRunError::Generic { code }), + 409 => Err(ActionsCancelWorkflowRunError::Status409(github_response.to_json_async().await?).into()), + code => Err(ActionsCancelWorkflowRunError::Generic { code }.into()), } } } @@ -4133,7 +5245,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn cancel_workflow_run(&self, owner: &str, repo: &str, run_id: i32) -> Result { + pub fn cancel_workflow_run(&self, owner: &str, repo: &str, run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/cancel", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -4145,7 +5257,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4157,8 +5269,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ActionsCancelWorkflowRunError::Status409(github_response.to_json()?)), - code => Err(ActionsCancelWorkflowRunError::Generic { code }), + 409 => Err(ActionsCancelWorkflowRunError::Status409(github_response.to_json()?).into()), + code => Err(ActionsCancelWorkflowRunError::Generic { code }.into()), } } } @@ -4176,19 +5288,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for create_environment_variable](https://docs.github.com/rest/actions/variables#create-an-environment-variable) /// /// --- - pub async fn create_environment_variable_async(&self, owner: &str, repo: &str, environment_name: &str, body: PostActionsCreateEnvironmentVariable) -> Result { + pub async fn create_environment_variable_async(&self, owner: &str, repo: &str, environment_name: &str, body: PostActionsCreateEnvironmentVariable) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/variables", super::GITHUB_BASE_API_URL, owner, repo, environment_name); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsCreateEnvironmentVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4200,7 +5312,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsCreateEnvironmentVariableError::Generic { code }), + code => Err(ActionsCreateEnvironmentVariableError::Generic { code }.into()), } } } @@ -4219,19 +5331,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_environment_variable(&self, owner: &str, repo: &str, environment_name: &str, body: PostActionsCreateEnvironmentVariable) -> Result { + pub fn create_environment_variable(&self, owner: &str, repo: &str, environment_name: &str, body: PostActionsCreateEnvironmentVariable) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/variables", super::GITHUB_BASE_API_URL, owner, repo, environment_name); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsCreateEnvironmentVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4243,7 +5355,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsCreateEnvironmentVariableError::Generic { code }), + code => Err(ActionsCreateEnvironmentVariableError::Generic { code }.into()), } } } @@ -4262,19 +5374,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for create_or_update_environment_secret](https://docs.github.com/rest/actions/secrets#create-or-update-an-environment-secret) /// /// --- - pub async fn create_or_update_environment_secret_async(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str, body: PutActionsCreateOrUpdateEnvironmentSecret) -> Result { + pub async fn create_or_update_environment_secret_async(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str, body: PutActionsCreateOrUpdateEnvironmentSecret) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsCreateOrUpdateEnvironmentSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4286,8 +5398,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(ActionsCreateOrUpdateEnvironmentSecretError::Status204), - code => Err(ActionsCreateOrUpdateEnvironmentSecretError::Generic { code }), + 204 => Err(ActionsCreateOrUpdateEnvironmentSecretError::Status204.into()), + code => Err(ActionsCreateOrUpdateEnvironmentSecretError::Generic { code }.into()), } } } @@ -4307,19 +5419,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_environment_secret(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str, body: PutActionsCreateOrUpdateEnvironmentSecret) -> Result { + pub fn create_or_update_environment_secret(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str, body: PutActionsCreateOrUpdateEnvironmentSecret) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsCreateOrUpdateEnvironmentSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4331,8 +5443,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(ActionsCreateOrUpdateEnvironmentSecretError::Status204), - code => Err(ActionsCreateOrUpdateEnvironmentSecretError::Generic { code }), + 204 => Err(ActionsCreateOrUpdateEnvironmentSecretError::Status204.into()), + code => Err(ActionsCreateOrUpdateEnvironmentSecretError::Generic { code }.into()), } } } @@ -4351,19 +5463,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for create_or_update_org_secret](https://docs.github.com/rest/actions/secrets#create-or-update-an-organization-secret) /// /// --- - pub async fn create_or_update_org_secret_async(&self, org: &str, secret_name: &str, body: PutActionsCreateOrUpdateOrgSecret) -> Result { + pub async fn create_or_update_org_secret_async(&self, org: &str, secret_name: &str, body: PutActionsCreateOrUpdateOrgSecret) -> Result { let request_uri = format!("{}/orgs/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsCreateOrUpdateOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4375,8 +5487,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(ActionsCreateOrUpdateOrgSecretError::Status204), - code => Err(ActionsCreateOrUpdateOrgSecretError::Generic { code }), + 204 => Err(ActionsCreateOrUpdateOrgSecretError::Status204.into()), + code => Err(ActionsCreateOrUpdateOrgSecretError::Generic { code }.into()), } } } @@ -4396,19 +5508,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_org_secret(&self, org: &str, secret_name: &str, body: PutActionsCreateOrUpdateOrgSecret) -> Result { + pub fn create_or_update_org_secret(&self, org: &str, secret_name: &str, body: PutActionsCreateOrUpdateOrgSecret) -> Result { let request_uri = format!("{}/orgs/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsCreateOrUpdateOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4420,8 +5532,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(ActionsCreateOrUpdateOrgSecretError::Status204), - code => Err(ActionsCreateOrUpdateOrgSecretError::Generic { code }), + 204 => Err(ActionsCreateOrUpdateOrgSecretError::Status204.into()), + code => Err(ActionsCreateOrUpdateOrgSecretError::Generic { code }.into()), } } } @@ -4440,19 +5552,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for create_or_update_repo_secret](https://docs.github.com/rest/actions/secrets#create-or-update-a-repository-secret) /// /// --- - pub async fn create_or_update_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str, body: PutActionsCreateOrUpdateRepoSecret) -> Result { + pub async fn create_or_update_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str, body: PutActionsCreateOrUpdateRepoSecret) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsCreateOrUpdateRepoSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4464,8 +5576,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(ActionsCreateOrUpdateRepoSecretError::Status204), - code => Err(ActionsCreateOrUpdateRepoSecretError::Generic { code }), + 204 => Err(ActionsCreateOrUpdateRepoSecretError::Status204.into()), + code => Err(ActionsCreateOrUpdateRepoSecretError::Generic { code }.into()), } } } @@ -4485,19 +5597,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_repo_secret(&self, owner: &str, repo: &str, secret_name: &str, body: PutActionsCreateOrUpdateRepoSecret) -> Result { + pub fn create_or_update_repo_secret(&self, owner: &str, repo: &str, secret_name: &str, body: PutActionsCreateOrUpdateRepoSecret) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsCreateOrUpdateRepoSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4509,8 +5621,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(ActionsCreateOrUpdateRepoSecretError::Status204), - code => Err(ActionsCreateOrUpdateRepoSecretError::Generic { code }), + 204 => Err(ActionsCreateOrUpdateRepoSecretError::Status204.into()), + code => Err(ActionsCreateOrUpdateRepoSecretError::Generic { code }.into()), } } } @@ -4528,19 +5640,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for create_org_variable](https://docs.github.com/rest/actions/variables#create-an-organization-variable) /// /// --- - pub async fn create_org_variable_async(&self, org: &str, body: PostActionsCreateOrgVariable) -> Result { + pub async fn create_org_variable_async(&self, org: &str, body: PostActionsCreateOrgVariable) -> Result { let request_uri = format!("{}/orgs/{}/actions/variables", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsCreateOrgVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4552,7 +5664,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsCreateOrgVariableError::Generic { code }), + code => Err(ActionsCreateOrgVariableError::Generic { code }.into()), } } } @@ -4571,19 +5683,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_org_variable(&self, org: &str, body: PostActionsCreateOrgVariable) -> Result { + pub fn create_org_variable(&self, org: &str, body: PostActionsCreateOrgVariable) -> Result { let request_uri = format!("{}/orgs/{}/actions/variables", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsCreateOrgVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4595,7 +5707,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsCreateOrgVariableError::Generic { code }), + code => Err(ActionsCreateOrgVariableError::Generic { code }.into()), } } } @@ -4619,19 +5731,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for create_registration_token_for_org](https://docs.github.com/rest/actions/self-hosted-runners#create-a-registration-token-for-an-organization) /// /// --- - pub async fn create_registration_token_for_org_async(&self, org: &str) -> Result { + pub async fn create_registration_token_for_org_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/runners/registration-token", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4643,7 +5755,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsCreateRegistrationTokenForOrgError::Generic { code }), + code => Err(ActionsCreateRegistrationTokenForOrgError::Generic { code }.into()), } } } @@ -4668,7 +5780,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_registration_token_for_org(&self, org: &str) -> Result { + pub fn create_registration_token_for_org(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/runners/registration-token", super::GITHUB_BASE_API_URL, org); @@ -4680,7 +5792,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4692,7 +5804,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsCreateRegistrationTokenForOrgError::Generic { code }), + code => Err(ActionsCreateRegistrationTokenForOrgError::Generic { code }.into()), } } } @@ -4716,19 +5828,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for create_registration_token_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#create-a-registration-token-for-a-repository) /// /// --- - pub async fn create_registration_token_for_repo_async(&self, owner: &str, repo: &str) -> Result { + pub async fn create_registration_token_for_repo_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runners/registration-token", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4740,7 +5852,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsCreateRegistrationTokenForRepoError::Generic { code }), + code => Err(ActionsCreateRegistrationTokenForRepoError::Generic { code }.into()), } } } @@ -4765,7 +5877,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_registration_token_for_repo(&self, owner: &str, repo: &str) -> Result { + pub fn create_registration_token_for_repo(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runners/registration-token", super::GITHUB_BASE_API_URL, owner, repo); @@ -4777,7 +5889,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4789,7 +5901,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsCreateRegistrationTokenForRepoError::Generic { code }), + code => Err(ActionsCreateRegistrationTokenForRepoError::Generic { code }.into()), } } } @@ -4813,19 +5925,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for create_remove_token_for_org](https://docs.github.com/rest/actions/self-hosted-runners#create-a-remove-token-for-an-organization) /// /// --- - pub async fn create_remove_token_for_org_async(&self, org: &str) -> Result { + pub async fn create_remove_token_for_org_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/runners/remove-token", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4837,7 +5949,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsCreateRemoveTokenForOrgError::Generic { code }), + code => Err(ActionsCreateRemoveTokenForOrgError::Generic { code }.into()), } } } @@ -4862,7 +5974,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_remove_token_for_org(&self, org: &str) -> Result { + pub fn create_remove_token_for_org(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/runners/remove-token", super::GITHUB_BASE_API_URL, org); @@ -4874,7 +5986,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4886,7 +5998,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsCreateRemoveTokenForOrgError::Generic { code }), + code => Err(ActionsCreateRemoveTokenForOrgError::Generic { code }.into()), } } } @@ -4910,19 +6022,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for create_remove_token_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#create-a-remove-token-for-a-repository) /// /// --- - pub async fn create_remove_token_for_repo_async(&self, owner: &str, repo: &str) -> Result { + pub async fn create_remove_token_for_repo_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runners/remove-token", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4934,7 +6046,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsCreateRemoveTokenForRepoError::Generic { code }), + code => Err(ActionsCreateRemoveTokenForRepoError::Generic { code }.into()), } } } @@ -4959,7 +6071,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_remove_token_for_repo(&self, owner: &str, repo: &str) -> Result { + pub fn create_remove_token_for_repo(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runners/remove-token", super::GITHUB_BASE_API_URL, owner, repo); @@ -4971,7 +6083,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4983,7 +6095,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsCreateRemoveTokenForRepoError::Generic { code }), + code => Err(ActionsCreateRemoveTokenForRepoError::Generic { code }.into()), } } } @@ -5001,19 +6113,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for create_repo_variable](https://docs.github.com/rest/actions/variables#create-a-repository-variable) /// /// --- - pub async fn create_repo_variable_async(&self, owner: &str, repo: &str, body: PostActionsCreateRepoVariable) -> Result { + pub async fn create_repo_variable_async(&self, owner: &str, repo: &str, body: PostActionsCreateRepoVariable) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/variables", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsCreateRepoVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5025,7 +6137,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsCreateRepoVariableError::Generic { code }), + code => Err(ActionsCreateRepoVariableError::Generic { code }.into()), } } } @@ -5044,19 +6156,100 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_repo_variable(&self, owner: &str, repo: &str, body: PostActionsCreateRepoVariable) -> Result { + pub fn create_repo_variable(&self, owner: &str, repo: &str, body: PostActionsCreateRepoVariable) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/variables", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsCreateRepoVariable::from_json(body)?), + body: Some(C::from_json::(body)?), + method: "POST", + 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() { + code => Err(ActionsCreateRepoVariableError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Create a self-hosted runner group for an organization + /// + /// Creates a new self-hosted runner group for an organization. + /// + /// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for create_self_hosted_runner_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#create-a-self-hosted-runner-group-for-an-organization) + /// + /// --- + pub async fn create_self_hosted_runner_group_for_org_async(&self, org: &str, body: PostActionsCreateSelfHostedRunnerGroupForOrg) -> Result { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups", super::GITHUB_BASE_API_URL, org); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(C::from_json::(body)?), + method: "POST", + 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() { + code => Err(ActionsCreateSelfHostedRunnerGroupForOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Create a self-hosted runner group for an organization + /// + /// Creates a new self-hosted runner group for an organization. + /// + /// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for create_self_hosted_runner_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#create-a-self-hosted-runner-group-for-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn create_self_hosted_runner_group_for_org(&self, org: &str, body: PostActionsCreateSelfHostedRunnerGroupForOrg) -> Result { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups", super::GITHUB_BASE_API_URL, org); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5068,7 +6261,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsCreateRepoVariableError::Generic { code }), + code => Err(ActionsCreateSelfHostedRunnerGroupForOrgError::Generic { code }.into()), } } } @@ -5086,19 +6279,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for create_workflow_dispatch](https://docs.github.com/rest/actions/workflows#create-a-workflow-dispatch-event) /// /// --- - pub async fn create_workflow_dispatch_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId, body: PostActionsCreateWorkflowDispatch) -> Result<(), ActionsCreateWorkflowDispatchError> { + pub async fn create_workflow_dispatch_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId, body: PostActionsCreateWorkflowDispatch) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/workflows/{}/dispatches", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsCreateWorkflowDispatch::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5110,7 +6303,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsCreateWorkflowDispatchError::Generic { code }), + code => Err(ActionsCreateWorkflowDispatchError::Generic { code }.into()), } } } @@ -5129,19 +6322,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_workflow_dispatch(&self, owner: &str, repo: &str, workflow_id: WorkflowId, body: PostActionsCreateWorkflowDispatch) -> Result<(), ActionsCreateWorkflowDispatchError> { + pub fn create_workflow_dispatch(&self, owner: &str, repo: &str, workflow_id: WorkflowId, body: PostActionsCreateWorkflowDispatch) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/workflows/{}/dispatches", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsCreateWorkflowDispatch::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5153,7 +6346,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsCreateWorkflowDispatchError::Generic { code }), + code => Err(ActionsCreateWorkflowDispatchError::Generic { code }.into()), } } } @@ -5169,19 +6362,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_actions_cache_by_id](https://docs.github.com/rest/actions/cache#delete-a-github-actions-cache-for-a-repository-using-a-cache-id) /// /// --- - pub async fn delete_actions_cache_by_id_async(&self, owner: &str, repo: &str, cache_id: i32) -> Result<(), ActionsDeleteActionsCacheByIdError> { + pub async fn delete_actions_cache_by_id_async(&self, owner: &str, repo: &str, cache_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/caches/{}", super::GITHUB_BASE_API_URL, owner, repo, cache_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5193,7 +6386,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteActionsCacheByIdError::Generic { code }), + code => Err(ActionsDeleteActionsCacheByIdError::Generic { code }.into()), } } } @@ -5210,7 +6403,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_actions_cache_by_id(&self, owner: &str, repo: &str, cache_id: i32) -> Result<(), ActionsDeleteActionsCacheByIdError> { + pub fn delete_actions_cache_by_id(&self, owner: &str, repo: &str, cache_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/caches/{}", super::GITHUB_BASE_API_URL, owner, repo, cache_id); @@ -5222,7 +6415,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5234,7 +6427,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteActionsCacheByIdError::Generic { code }), + code => Err(ActionsDeleteActionsCacheByIdError::Generic { code }.into()), } } } @@ -5250,7 +6443,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_actions_cache_by_key](https://docs.github.com/rest/actions/cache#delete-github-actions-caches-for-a-repository-using-a-cache-key) /// /// --- - pub async fn delete_actions_cache_by_key_async(&self, owner: &str, repo: &str, query_params: impl Into>) -> Result { + pub async fn delete_actions_cache_by_key_async(&self, owner: &str, repo: &str, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/caches", super::GITHUB_BASE_API_URL, owner, repo); @@ -5259,12 +6452,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5276,7 +6469,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteActionsCacheByKeyError::Generic { code }), + code => Err(ActionsDeleteActionsCacheByKeyError::Generic { code }.into()), } } } @@ -5293,7 +6486,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_actions_cache_by_key(&self, owner: &str, repo: &str, query_params: impl Into>) -> Result { + pub fn delete_actions_cache_by_key(&self, owner: &str, repo: &str, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/caches", super::GITHUB_BASE_API_URL, owner, repo); @@ -5308,7 +6501,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5320,7 +6513,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteActionsCacheByKeyError::Generic { code }), + code => Err(ActionsDeleteActionsCacheByKeyError::Generic { code }.into()), } } } @@ -5335,19 +6528,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_artifact](https://docs.github.com/rest/actions/artifacts#delete-an-artifact) /// /// --- - pub async fn delete_artifact_async(&self, owner: &str, repo: &str, artifact_id: i32) -> Result<(), ActionsDeleteArtifactError> { + pub async fn delete_artifact_async(&self, owner: &str, repo: &str, artifact_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/artifacts/{}", super::GITHUB_BASE_API_URL, owner, repo, artifact_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5359,7 +6552,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteArtifactError::Generic { code }), + code => Err(ActionsDeleteArtifactError::Generic { code }.into()), } } } @@ -5375,7 +6568,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_artifact(&self, owner: &str, repo: &str, artifact_id: i32) -> Result<(), ActionsDeleteArtifactError> { + pub fn delete_artifact(&self, owner: &str, repo: &str, artifact_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/artifacts/{}", super::GITHUB_BASE_API_URL, owner, repo, artifact_id); @@ -5387,7 +6580,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5399,7 +6592,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteArtifactError::Generic { code }), + code => Err(ActionsDeleteArtifactError::Generic { code }.into()), } } } @@ -5417,19 +6610,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_environment_secret](https://docs.github.com/rest/actions/secrets#delete-an-environment-secret) /// /// --- - pub async fn delete_environment_secret_async(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str) -> Result<(), ActionsDeleteEnvironmentSecretError> { + pub async fn delete_environment_secret_async(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5441,7 +6634,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteEnvironmentSecretError::Generic { code }), + code => Err(ActionsDeleteEnvironmentSecretError::Generic { code }.into()), } } } @@ -5460,7 +6653,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_environment_secret(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str) -> Result<(), ActionsDeleteEnvironmentSecretError> { + pub fn delete_environment_secret(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, secret_name); @@ -5472,7 +6665,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5484,7 +6677,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteEnvironmentSecretError::Generic { code }), + code => Err(ActionsDeleteEnvironmentSecretError::Generic { code }.into()), } } } @@ -5502,19 +6695,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_environment_variable](https://docs.github.com/rest/actions/variables#delete-an-environment-variable) /// /// --- - pub async fn delete_environment_variable_async(&self, owner: &str, repo: &str, name: &str, environment_name: &str) -> Result<(), ActionsDeleteEnvironmentVariableError> { + pub async fn delete_environment_variable_async(&self, owner: &str, repo: &str, name: &str, environment_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, name, environment_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5526,7 +6719,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteEnvironmentVariableError::Generic { code }), + code => Err(ActionsDeleteEnvironmentVariableError::Generic { code }.into()), } } } @@ -5545,7 +6738,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_environment_variable(&self, owner: &str, repo: &str, name: &str, environment_name: &str) -> Result<(), ActionsDeleteEnvironmentVariableError> { + pub fn delete_environment_variable(&self, owner: &str, repo: &str, name: &str, environment_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, name, environment_name); @@ -5557,7 +6750,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5569,7 +6762,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteEnvironmentVariableError::Generic { code }), + code => Err(ActionsDeleteEnvironmentVariableError::Generic { code }.into()), } } } @@ -5587,19 +6780,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_org_secret](https://docs.github.com/rest/actions/secrets#delete-an-organization-secret) /// /// --- - pub async fn delete_org_secret_async(&self, org: &str, secret_name: &str) -> Result<(), ActionsDeleteOrgSecretError> { + pub async fn delete_org_secret_async(&self, org: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5611,7 +6804,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteOrgSecretError::Generic { code }), + code => Err(ActionsDeleteOrgSecretError::Generic { code }.into()), } } } @@ -5630,7 +6823,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_org_secret(&self, org: &str, secret_name: &str) -> Result<(), ActionsDeleteOrgSecretError> { + pub fn delete_org_secret(&self, org: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); @@ -5642,7 +6835,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5654,7 +6847,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteOrgSecretError::Generic { code }), + code => Err(ActionsDeleteOrgSecretError::Generic { code }.into()), } } } @@ -5672,19 +6865,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_org_variable](https://docs.github.com/rest/actions/variables#delete-an-organization-variable) /// /// --- - pub async fn delete_org_variable_async(&self, org: &str, name: &str) -> Result<(), ActionsDeleteOrgVariableError> { + pub async fn delete_org_variable_async(&self, org: &str, name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, org, name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5696,7 +6889,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteOrgVariableError::Generic { code }), + code => Err(ActionsDeleteOrgVariableError::Generic { code }.into()), } } } @@ -5715,7 +6908,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_org_variable(&self, org: &str, name: &str) -> Result<(), ActionsDeleteOrgVariableError> { + pub fn delete_org_variable(&self, org: &str, name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, org, name); @@ -5727,7 +6920,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5739,7 +6932,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteOrgVariableError::Generic { code }), + code => Err(ActionsDeleteOrgVariableError::Generic { code }.into()), } } } @@ -5757,19 +6950,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_repo_secret](https://docs.github.com/rest/actions/secrets#delete-a-repository-secret) /// /// --- - pub async fn delete_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), ActionsDeleteRepoSecretError> { + pub async fn delete_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5781,7 +6974,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteRepoSecretError::Generic { code }), + code => Err(ActionsDeleteRepoSecretError::Generic { code }.into()), } } } @@ -5800,7 +6993,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), ActionsDeleteRepoSecretError> { + pub fn delete_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); @@ -5812,7 +7005,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5824,7 +7017,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteRepoSecretError::Generic { code }), + code => Err(ActionsDeleteRepoSecretError::Generic { code }.into()), } } } @@ -5842,19 +7035,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_repo_variable](https://docs.github.com/rest/actions/variables#delete-a-repository-variable) /// /// --- - pub async fn delete_repo_variable_async(&self, owner: &str, repo: &str, name: &str) -> Result<(), ActionsDeleteRepoVariableError> { + pub async fn delete_repo_variable_async(&self, owner: &str, repo: &str, name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5866,7 +7059,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteRepoVariableError::Generic { code }), + code => Err(ActionsDeleteRepoVariableError::Generic { code }.into()), } } } @@ -5885,7 +7078,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_repo_variable(&self, owner: &str, repo: &str, name: &str) -> Result<(), ActionsDeleteRepoVariableError> { + pub fn delete_repo_variable(&self, owner: &str, repo: &str, name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, name); @@ -5897,7 +7090,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5909,7 +7102,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteRepoVariableError::Generic { code }), + code => Err(ActionsDeleteRepoVariableError::Generic { code }.into()), } } } @@ -5927,19 +7120,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_self_hosted_runner_from_org](https://docs.github.com/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-an-organization) /// /// --- - pub async fn delete_self_hosted_runner_from_org_async(&self, org: &str, runner_id: i32) -> Result<(), ActionsDeleteSelfHostedRunnerFromOrgError> { + pub async fn delete_self_hosted_runner_from_org_async(&self, org: &str, runner_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/runners/{}", super::GITHUB_BASE_API_URL, org, runner_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5951,7 +7144,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteSelfHostedRunnerFromOrgError::Generic { code }), + code => Err(ActionsDeleteSelfHostedRunnerFromOrgError::Generic { code }.into()), } } } @@ -5970,7 +7163,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_self_hosted_runner_from_org(&self, org: &str, runner_id: i32) -> Result<(), ActionsDeleteSelfHostedRunnerFromOrgError> { + pub fn delete_self_hosted_runner_from_org(&self, org: &str, runner_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/runners/{}", super::GITHUB_BASE_API_URL, org, runner_id); @@ -5982,7 +7175,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5994,7 +7187,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteSelfHostedRunnerFromOrgError::Generic { code }), + code => Err(ActionsDeleteSelfHostedRunnerFromOrgError::Generic { code }.into()), } } } @@ -6012,19 +7205,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_self_hosted_runner_from_repo](https://docs.github.com/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-a-repository) /// /// --- - pub async fn delete_self_hosted_runner_from_repo_async(&self, owner: &str, repo: &str, runner_id: i32) -> Result<(), ActionsDeleteSelfHostedRunnerFromRepoError> { + pub async fn delete_self_hosted_runner_from_repo_async(&self, owner: &str, repo: &str, runner_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runners/{}", super::GITHUB_BASE_API_URL, owner, repo, runner_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6036,7 +7229,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteSelfHostedRunnerFromRepoError::Generic { code }), + code => Err(ActionsDeleteSelfHostedRunnerFromRepoError::Generic { code }.into()), } } } @@ -6055,7 +7248,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_self_hosted_runner_from_repo(&self, owner: &str, repo: &str, runner_id: i32) -> Result<(), ActionsDeleteSelfHostedRunnerFromRepoError> { + pub fn delete_self_hosted_runner_from_repo(&self, owner: &str, repo: &str, runner_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runners/{}", super::GITHUB_BASE_API_URL, owner, repo, runner_id); @@ -6067,7 +7260,88 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + 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() { + code => Err(ActionsDeleteSelfHostedRunnerFromRepoError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Delete a self-hosted runner group from an organization + /// + /// Deletes a self-hosted runner group for an organization. + /// + /// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for delete_self_hosted_runner_group_from_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#delete-a-self-hosted-runner-group-from-an-organization) + /// + /// --- + pub async fn delete_self_hosted_runner_group_from_org_async(&self, org: &str, runner_group_id: i32) -> Result<(), AdapterError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}", super::GITHUB_BASE_API_URL, org, runner_group_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None::, + 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() { + code => Err(ActionsDeleteSelfHostedRunnerGroupFromOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Delete a self-hosted runner group from an organization + /// + /// Deletes a self-hosted runner group for an organization. + /// + /// OAuth tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for delete_self_hosted_runner_group_from_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#delete-a-self-hosted-runner-group-from-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn delete_self_hosted_runner_group_from_org(&self, org: &str, runner_group_id: i32) -> Result<(), AdapterError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}", super::GITHUB_BASE_API_URL, org, runner_group_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "DELETE", + headers: vec![] + }; + + let request = self.client.build(req)?; // -- @@ -6079,7 +7353,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteSelfHostedRunnerFromRepoError::Generic { code }), + code => Err(ActionsDeleteSelfHostedRunnerGroupFromOrgError::Generic { code }.into()), } } } @@ -6097,19 +7371,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_workflow_run](https://docs.github.com/rest/actions/workflow-runs#delete-a-workflow-run) /// /// --- - pub async fn delete_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), ActionsDeleteWorkflowRunError> { + pub async fn delete_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6121,7 +7395,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDeleteWorkflowRunError::Generic { code }), + code => Err(ActionsDeleteWorkflowRunError::Generic { code }.into()), } } } @@ -6140,7 +7414,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_workflow_run(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), ActionsDeleteWorkflowRunError> { + pub fn delete_workflow_run(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -6152,7 +7426,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6164,7 +7438,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDeleteWorkflowRunError::Generic { code }), + code => Err(ActionsDeleteWorkflowRunError::Generic { code }.into()), } } } @@ -6180,19 +7454,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for delete_workflow_run_logs](https://docs.github.com/rest/actions/workflow-runs#delete-workflow-run-logs) /// /// --- - pub async fn delete_workflow_run_logs_async(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), ActionsDeleteWorkflowRunLogsError> { + pub async fn delete_workflow_run_logs_async(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/logs", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6204,9 +7478,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ActionsDeleteWorkflowRunLogsError::Status403(github_response.to_json_async().await?)), - 500 => Err(ActionsDeleteWorkflowRunLogsError::Status500(github_response.to_json_async().await?)), - code => Err(ActionsDeleteWorkflowRunLogsError::Generic { code }), + 403 => Err(ActionsDeleteWorkflowRunLogsError::Status403(github_response.to_json_async().await?).into()), + 500 => Err(ActionsDeleteWorkflowRunLogsError::Status500(github_response.to_json_async().await?).into()), + code => Err(ActionsDeleteWorkflowRunLogsError::Generic { code }.into()), } } } @@ -6223,7 +7497,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_workflow_run_logs(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), ActionsDeleteWorkflowRunLogsError> { + pub fn delete_workflow_run_logs(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/logs", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -6235,7 +7509,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6247,9 +7521,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ActionsDeleteWorkflowRunLogsError::Status403(github_response.to_json()?)), - 500 => Err(ActionsDeleteWorkflowRunLogsError::Status500(github_response.to_json()?)), - code => Err(ActionsDeleteWorkflowRunLogsError::Generic { code }), + 403 => Err(ActionsDeleteWorkflowRunLogsError::Status403(github_response.to_json()?).into()), + 500 => Err(ActionsDeleteWorkflowRunLogsError::Status500(github_response.to_json()?).into()), + code => Err(ActionsDeleteWorkflowRunLogsError::Generic { code }.into()), } } } @@ -6265,19 +7539,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for disable_selected_repository_github_actions_organization](https://docs.github.com/rest/actions/permissions#disable-a-selected-repository-for-github-actions-in-an-organization) /// /// --- - pub async fn disable_selected_repository_github_actions_organization_async(&self, org: &str, repository_id: i32) -> Result<(), ActionsDisableSelectedRepositoryGithubActionsOrganizationError> { + pub async fn disable_selected_repository_github_actions_organization_async(&self, org: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions/repositories/{}", super::GITHUB_BASE_API_URL, org, repository_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6289,7 +7563,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDisableSelectedRepositoryGithubActionsOrganizationError::Generic { code }), + code => Err(ActionsDisableSelectedRepositoryGithubActionsOrganizationError::Generic { code }.into()), } } } @@ -6306,7 +7580,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn disable_selected_repository_github_actions_organization(&self, org: &str, repository_id: i32) -> Result<(), ActionsDisableSelectedRepositoryGithubActionsOrganizationError> { + pub fn disable_selected_repository_github_actions_organization(&self, org: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions/repositories/{}", super::GITHUB_BASE_API_URL, org, repository_id); @@ -6318,7 +7592,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6330,7 +7604,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDisableSelectedRepositoryGithubActionsOrganizationError::Generic { code }), + code => Err(ActionsDisableSelectedRepositoryGithubActionsOrganizationError::Generic { code }.into()), } } } @@ -6346,19 +7620,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for disable_workflow](https://docs.github.com/rest/actions/workflows#disable-a-workflow) /// /// --- - pub async fn disable_workflow_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result<(), ActionsDisableWorkflowError> { + pub async fn disable_workflow_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/workflows/{}/disable", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6370,7 +7644,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsDisableWorkflowError::Generic { code }), + code => Err(ActionsDisableWorkflowError::Generic { code }.into()), } } } @@ -6387,7 +7661,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn disable_workflow(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result<(), ActionsDisableWorkflowError> { + pub fn disable_workflow(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/workflows/{}/disable", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); @@ -6399,7 +7673,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6411,7 +7685,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsDisableWorkflowError::Generic { code }), + code => Err(ActionsDisableWorkflowError::Generic { code }.into()), } } } @@ -6428,19 +7702,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for download_artifact](https://docs.github.com/rest/actions/artifacts#download-an-artifact) /// /// --- - pub async fn download_artifact_async(&self, owner: &str, repo: &str, artifact_id: i32, archive_format: &str) -> Result<(), ActionsDownloadArtifactError> { + pub async fn download_artifact_async(&self, owner: &str, repo: &str, artifact_id: i32, archive_format: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/artifacts/{}/{}", super::GITHUB_BASE_API_URL, owner, repo, artifact_id, archive_format); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6452,9 +7726,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 302 => Err(ActionsDownloadArtifactError::Status302), - 410 => Err(ActionsDownloadArtifactError::Status410(github_response.to_json_async().await?)), - code => Err(ActionsDownloadArtifactError::Generic { code }), + 302 => Err(ActionsDownloadArtifactError::Status302.into()), + 410 => Err(ActionsDownloadArtifactError::Status410(github_response.to_json_async().await?).into()), + code => Err(ActionsDownloadArtifactError::Generic { code }.into()), } } } @@ -6472,7 +7746,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn download_artifact(&self, owner: &str, repo: &str, artifact_id: i32, archive_format: &str) -> Result<(), ActionsDownloadArtifactError> { + pub fn download_artifact(&self, owner: &str, repo: &str, artifact_id: i32, archive_format: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/artifacts/{}/{}", super::GITHUB_BASE_API_URL, owner, repo, artifact_id, archive_format); @@ -6484,7 +7758,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6496,9 +7770,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 302 => Err(ActionsDownloadArtifactError::Status302), - 410 => Err(ActionsDownloadArtifactError::Status410(github_response.to_json()?)), - code => Err(ActionsDownloadArtifactError::Generic { code }), + 302 => Err(ActionsDownloadArtifactError::Status302.into()), + 410 => Err(ActionsDownloadArtifactError::Status410(github_response.to_json()?).into()), + code => Err(ActionsDownloadArtifactError::Generic { code }.into()), } } } @@ -6517,19 +7791,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for download_job_logs_for_workflow_run](https://docs.github.com/rest/actions/workflow-jobs#download-job-logs-for-a-workflow-run) /// /// --- - pub async fn download_job_logs_for_workflow_run_async(&self, owner: &str, repo: &str, job_id: i32) -> Result<(), ActionsDownloadJobLogsForWorkflowRunError> { + pub async fn download_job_logs_for_workflow_run_async(&self, owner: &str, repo: &str, job_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/jobs/{}/logs", super::GITHUB_BASE_API_URL, owner, repo, job_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6541,8 +7815,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 302 => Err(ActionsDownloadJobLogsForWorkflowRunError::Status302), - code => Err(ActionsDownloadJobLogsForWorkflowRunError::Generic { code }), + 302 => Err(ActionsDownloadJobLogsForWorkflowRunError::Status302.into()), + code => Err(ActionsDownloadJobLogsForWorkflowRunError::Generic { code }.into()), } } } @@ -6562,7 +7836,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn download_job_logs_for_workflow_run(&self, owner: &str, repo: &str, job_id: i32) -> Result<(), ActionsDownloadJobLogsForWorkflowRunError> { + pub fn download_job_logs_for_workflow_run(&self, owner: &str, repo: &str, job_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/jobs/{}/logs", super::GITHUB_BASE_API_URL, owner, repo, job_id); @@ -6574,7 +7848,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6586,8 +7860,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 302 => Err(ActionsDownloadJobLogsForWorkflowRunError::Status302), - code => Err(ActionsDownloadJobLogsForWorkflowRunError::Generic { code }), + 302 => Err(ActionsDownloadJobLogsForWorkflowRunError::Status302.into()), + code => Err(ActionsDownloadJobLogsForWorkflowRunError::Generic { code }.into()), } } } @@ -6606,19 +7880,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for download_workflow_run_attempt_logs](https://docs.github.com/rest/actions/workflow-runs#download-workflow-run-attempt-logs) /// /// --- - pub async fn download_workflow_run_attempt_logs_async(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32) -> Result<(), ActionsDownloadWorkflowRunAttemptLogsError> { + pub async fn download_workflow_run_attempt_logs_async(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/attempts/{}/logs", super::GITHUB_BASE_API_URL, owner, repo, run_id, attempt_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6630,8 +7904,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 302 => Err(ActionsDownloadWorkflowRunAttemptLogsError::Status302), - code => Err(ActionsDownloadWorkflowRunAttemptLogsError::Generic { code }), + 302 => Err(ActionsDownloadWorkflowRunAttemptLogsError::Status302.into()), + code => Err(ActionsDownloadWorkflowRunAttemptLogsError::Generic { code }.into()), } } } @@ -6651,7 +7925,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn download_workflow_run_attempt_logs(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32) -> Result<(), ActionsDownloadWorkflowRunAttemptLogsError> { + pub fn download_workflow_run_attempt_logs(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/attempts/{}/logs", super::GITHUB_BASE_API_URL, owner, repo, run_id, attempt_number); @@ -6663,7 +7937,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6675,8 +7949,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 302 => Err(ActionsDownloadWorkflowRunAttemptLogsError::Status302), - code => Err(ActionsDownloadWorkflowRunAttemptLogsError::Generic { code }), + 302 => Err(ActionsDownloadWorkflowRunAttemptLogsError::Status302.into()), + code => Err(ActionsDownloadWorkflowRunAttemptLogsError::Generic { code }.into()), } } } @@ -6695,19 +7969,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for download_workflow_run_logs](https://docs.github.com/rest/actions/workflow-runs#download-workflow-run-logs) /// /// --- - pub async fn download_workflow_run_logs_async(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), ActionsDownloadWorkflowRunLogsError> { + pub async fn download_workflow_run_logs_async(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/logs", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6719,8 +7993,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 302 => Err(ActionsDownloadWorkflowRunLogsError::Status302), - code => Err(ActionsDownloadWorkflowRunLogsError::Generic { code }), + 302 => Err(ActionsDownloadWorkflowRunLogsError::Status302.into()), + code => Err(ActionsDownloadWorkflowRunLogsError::Generic { code }.into()), } } } @@ -6740,7 +8014,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn download_workflow_run_logs(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), ActionsDownloadWorkflowRunLogsError> { + pub fn download_workflow_run_logs(&self, owner: &str, repo: &str, run_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/logs", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -6752,7 +8026,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6764,8 +8038,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 302 => Err(ActionsDownloadWorkflowRunLogsError::Status302), - code => Err(ActionsDownloadWorkflowRunLogsError::Generic { code }), + 302 => Err(ActionsDownloadWorkflowRunLogsError::Status302.into()), + code => Err(ActionsDownloadWorkflowRunLogsError::Generic { code }.into()), } } } @@ -6781,19 +8055,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for enable_selected_repository_github_actions_organization](https://docs.github.com/rest/actions/permissions#enable-a-selected-repository-for-github-actions-in-an-organization) /// /// --- - pub async fn enable_selected_repository_github_actions_organization_async(&self, org: &str, repository_id: i32) -> Result<(), ActionsEnableSelectedRepositoryGithubActionsOrganizationError> { + pub async fn enable_selected_repository_github_actions_organization_async(&self, org: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions/repositories/{}", super::GITHUB_BASE_API_URL, org, repository_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6805,7 +8079,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsEnableSelectedRepositoryGithubActionsOrganizationError::Generic { code }), + code => Err(ActionsEnableSelectedRepositoryGithubActionsOrganizationError::Generic { code }.into()), } } } @@ -6822,7 +8096,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn enable_selected_repository_github_actions_organization(&self, org: &str, repository_id: i32) -> Result<(), ActionsEnableSelectedRepositoryGithubActionsOrganizationError> { + pub fn enable_selected_repository_github_actions_organization(&self, org: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions/repositories/{}", super::GITHUB_BASE_API_URL, org, repository_id); @@ -6834,7 +8108,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6846,7 +8120,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsEnableSelectedRepositoryGithubActionsOrganizationError::Generic { code }), + code => Err(ActionsEnableSelectedRepositoryGithubActionsOrganizationError::Generic { code }.into()), } } } @@ -6862,19 +8136,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for enable_workflow](https://docs.github.com/rest/actions/workflows#enable-a-workflow) /// /// --- - pub async fn enable_workflow_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result<(), ActionsEnableWorkflowError> { + pub async fn enable_workflow_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/workflows/{}/enable", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6886,7 +8160,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsEnableWorkflowError::Generic { code }), + code => Err(ActionsEnableWorkflowError::Generic { code }.into()), } } } @@ -6903,7 +8177,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn enable_workflow(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result<(), ActionsEnableWorkflowError> { + pub fn enable_workflow(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/workflows/{}/enable", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); @@ -6915,7 +8189,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6927,7 +8201,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsEnableWorkflowError::Generic { code }), + code => Err(ActionsEnableWorkflowError::Generic { code }.into()), } } } @@ -6944,19 +8218,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for force_cancel_workflow_run](https://docs.github.com/rest/actions/workflow-runs#force-cancel-a-workflow-run) /// /// --- - pub async fn force_cancel_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result { + pub async fn force_cancel_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/force-cancel", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6968,8 +8242,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ActionsForceCancelWorkflowRunError::Status409(github_response.to_json_async().await?)), - code => Err(ActionsForceCancelWorkflowRunError::Generic { code }), + 409 => Err(ActionsForceCancelWorkflowRunError::Status409(github_response.to_json_async().await?).into()), + code => Err(ActionsForceCancelWorkflowRunError::Generic { code }.into()), } } } @@ -6987,7 +8261,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn force_cancel_workflow_run(&self, owner: &str, repo: &str, run_id: i32) -> Result { + pub fn force_cancel_workflow_run(&self, owner: &str, repo: &str, run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/force-cancel", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -6999,7 +8273,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7011,8 +8285,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ActionsForceCancelWorkflowRunError::Status409(github_response.to_json()?)), - code => Err(ActionsForceCancelWorkflowRunError::Generic { code }), + 409 => Err(ActionsForceCancelWorkflowRunError::Status409(github_response.to_json()?).into()), + code => Err(ActionsForceCancelWorkflowRunError::Generic { code }.into()), } } } @@ -7030,19 +8304,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for generate_runner_jitconfig_for_org](https://docs.github.com/rest/actions/self-hosted-runners#create-configuration-for-a-just-in-time-runner-for-an-organization) /// /// --- - pub async fn generate_runner_jitconfig_for_org_async(&self, org: &str, body: PostActionsGenerateRunnerJitconfigForOrg) -> Result { + pub async fn generate_runner_jitconfig_for_org_async(&self, org: &str, body: PostActionsGenerateRunnerJitconfigForOrg) -> Result { let request_uri = format!("{}/orgs/{}/actions/runners/generate-jitconfig", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsGenerateRunnerJitconfigForOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7054,9 +8328,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsGenerateRunnerJitconfigForOrgError::Status404(github_response.to_json_async().await?)), - 422 => Err(ActionsGenerateRunnerJitconfigForOrgError::Status422(github_response.to_json_async().await?)), - code => Err(ActionsGenerateRunnerJitconfigForOrgError::Generic { code }), + 404 => Err(ActionsGenerateRunnerJitconfigForOrgError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ActionsGenerateRunnerJitconfigForOrgError::Status422(github_response.to_json_async().await?).into()), + code => Err(ActionsGenerateRunnerJitconfigForOrgError::Generic { code }.into()), } } } @@ -7075,19 +8349,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn generate_runner_jitconfig_for_org(&self, org: &str, body: PostActionsGenerateRunnerJitconfigForOrg) -> Result { + pub fn generate_runner_jitconfig_for_org(&self, org: &str, body: PostActionsGenerateRunnerJitconfigForOrg) -> Result { let request_uri = format!("{}/orgs/{}/actions/runners/generate-jitconfig", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsGenerateRunnerJitconfigForOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7099,9 +8373,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsGenerateRunnerJitconfigForOrgError::Status404(github_response.to_json()?)), - 422 => Err(ActionsGenerateRunnerJitconfigForOrgError::Status422(github_response.to_json()?)), - code => Err(ActionsGenerateRunnerJitconfigForOrgError::Generic { code }), + 404 => Err(ActionsGenerateRunnerJitconfigForOrgError::Status404(github_response.to_json()?).into()), + 422 => Err(ActionsGenerateRunnerJitconfigForOrgError::Status422(github_response.to_json()?).into()), + code => Err(ActionsGenerateRunnerJitconfigForOrgError::Generic { code }.into()), } } } @@ -7119,19 +8393,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for generate_runner_jitconfig_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#create-configuration-for-a-just-in-time-runner-for-a-repository) /// /// --- - pub async fn generate_runner_jitconfig_for_repo_async(&self, owner: &str, repo: &str, body: PostActionsGenerateRunnerJitconfigForRepo) -> Result { + pub async fn generate_runner_jitconfig_for_repo_async(&self, owner: &str, repo: &str, body: PostActionsGenerateRunnerJitconfigForRepo) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runners/generate-jitconfig", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsGenerateRunnerJitconfigForRepo::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7143,9 +8417,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsGenerateRunnerJitconfigForRepoError::Status404(github_response.to_json_async().await?)), - 422 => Err(ActionsGenerateRunnerJitconfigForRepoError::Status422(github_response.to_json_async().await?)), - code => Err(ActionsGenerateRunnerJitconfigForRepoError::Generic { code }), + 404 => Err(ActionsGenerateRunnerJitconfigForRepoError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ActionsGenerateRunnerJitconfigForRepoError::Status422(github_response.to_json_async().await?).into()), + code => Err(ActionsGenerateRunnerJitconfigForRepoError::Generic { code }.into()), } } } @@ -7164,19 +8438,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn generate_runner_jitconfig_for_repo(&self, owner: &str, repo: &str, body: PostActionsGenerateRunnerJitconfigForRepo) -> Result { + pub fn generate_runner_jitconfig_for_repo(&self, owner: &str, repo: &str, body: PostActionsGenerateRunnerJitconfigForRepo) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runners/generate-jitconfig", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsGenerateRunnerJitconfigForRepo::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7188,9 +8462,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsGenerateRunnerJitconfigForRepoError::Status404(github_response.to_json()?)), - 422 => Err(ActionsGenerateRunnerJitconfigForRepoError::Status422(github_response.to_json()?)), - code => Err(ActionsGenerateRunnerJitconfigForRepoError::Generic { code }), + 404 => Err(ActionsGenerateRunnerJitconfigForRepoError::Status404(github_response.to_json()?).into()), + 422 => Err(ActionsGenerateRunnerJitconfigForRepoError::Status422(github_response.to_json()?).into()), + code => Err(ActionsGenerateRunnerJitconfigForRepoError::Generic { code }.into()), } } } @@ -7206,7 +8480,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_actions_cache_list](https://docs.github.com/rest/actions/cache#list-github-actions-caches-for-a-repository) /// /// --- - pub async fn get_actions_cache_list_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub async fn get_actions_cache_list_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/caches", super::GITHUB_BASE_API_URL, owner, repo); @@ -7217,12 +8491,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7234,7 +8508,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetActionsCacheListError::Generic { code }), + code => Err(ActionsGetActionsCacheListError::Generic { code }.into()), } } } @@ -7251,7 +8525,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_actions_cache_list(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub fn get_actions_cache_list(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/caches", super::GITHUB_BASE_API_URL, owner, repo); @@ -7268,7 +8542,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7280,7 +8554,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetActionsCacheListError::Generic { code }), + code => Err(ActionsGetActionsCacheListError::Generic { code }.into()), } } } @@ -7299,19 +8573,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_actions_cache_usage](https://docs.github.com/rest/actions/cache#get-github-actions-cache-usage-for-a-repository) /// /// --- - pub async fn get_actions_cache_usage_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_actions_cache_usage_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/cache/usage", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7323,7 +8597,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetActionsCacheUsageError::Generic { code }), + code => Err(ActionsGetActionsCacheUsageError::Generic { code }.into()), } } } @@ -7343,7 +8617,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_actions_cache_usage(&self, owner: &str, repo: &str) -> Result { + pub fn get_actions_cache_usage(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/cache/usage", super::GITHUB_BASE_API_URL, owner, repo); @@ -7355,7 +8629,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7367,7 +8641,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetActionsCacheUsageError::Generic { code }), + code => Err(ActionsGetActionsCacheUsageError::Generic { code }.into()), } } } @@ -7384,7 +8658,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_actions_cache_usage_by_repo_for_org](https://docs.github.com/rest/actions/cache#list-repositories-with-github-actions-cache-usage-for-an-organization) /// /// --- - pub async fn get_actions_cache_usage_by_repo_for_org_async(&self, org: &str, query_params: Option>) -> Result { + pub async fn get_actions_cache_usage_by_repo_for_org_async(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/actions/cache/usage-by-repository", super::GITHUB_BASE_API_URL, org); @@ -7395,12 +8669,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7412,7 +8686,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetActionsCacheUsageByRepoForOrgError::Generic { code }), + code => Err(ActionsGetActionsCacheUsageByRepoForOrgError::Generic { code }.into()), } } } @@ -7430,7 +8704,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_actions_cache_usage_by_repo_for_org(&self, org: &str, query_params: Option>) -> Result { + pub fn get_actions_cache_usage_by_repo_for_org(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/actions/cache/usage-by-repository", super::GITHUB_BASE_API_URL, org); @@ -7447,7 +8721,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7459,7 +8733,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetActionsCacheUsageByRepoForOrgError::Generic { code }), + code => Err(ActionsGetActionsCacheUsageByRepoForOrgError::Generic { code }.into()), } } } @@ -7476,19 +8750,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_actions_cache_usage_for_org](https://docs.github.com/rest/actions/cache#get-github-actions-cache-usage-for-an-organization) /// /// --- - pub async fn get_actions_cache_usage_for_org_async(&self, org: &str) -> Result { + pub async fn get_actions_cache_usage_for_org_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/cache/usage", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7500,7 +8774,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetActionsCacheUsageForOrgError::Generic { code }), + code => Err(ActionsGetActionsCacheUsageForOrgError::Generic { code }.into()), } } } @@ -7518,7 +8792,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_actions_cache_usage_for_org(&self, org: &str) -> Result { + pub fn get_actions_cache_usage_for_org(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/cache/usage", super::GITHUB_BASE_API_URL, org); @@ -7530,7 +8804,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7542,7 +8816,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetActionsCacheUsageForOrgError::Generic { code }), + code => Err(ActionsGetActionsCacheUsageForOrgError::Generic { code }.into()), } } } @@ -7558,19 +8832,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_allowed_actions_organization](https://docs.github.com/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-an-organization) /// /// --- - pub async fn get_allowed_actions_organization_async(&self, org: &str) -> Result { + pub async fn get_allowed_actions_organization_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/permissions/selected-actions", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7582,7 +8856,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetAllowedActionsOrganizationError::Generic { code }), + code => Err(ActionsGetAllowedActionsOrganizationError::Generic { code }.into()), } } } @@ -7599,7 +8873,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_allowed_actions_organization(&self, org: &str) -> Result { + pub fn get_allowed_actions_organization(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/permissions/selected-actions", super::GITHUB_BASE_API_URL, org); @@ -7611,7 +8885,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7623,7 +8897,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetAllowedActionsOrganizationError::Generic { code }), + code => Err(ActionsGetAllowedActionsOrganizationError::Generic { code }.into()), } } } @@ -7639,19 +8913,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_allowed_actions_repository](https://docs.github.com/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-a-repository) /// /// --- - pub async fn get_allowed_actions_repository_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_allowed_actions_repository_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/permissions/selected-actions", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7663,7 +8937,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetAllowedActionsRepositoryError::Generic { code }), + code => Err(ActionsGetAllowedActionsRepositoryError::Generic { code }.into()), } } } @@ -7680,7 +8954,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_allowed_actions_repository(&self, owner: &str, repo: &str) -> Result { + pub fn get_allowed_actions_repository(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/permissions/selected-actions", super::GITHUB_BASE_API_URL, owner, repo); @@ -7692,7 +8966,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7704,7 +8978,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetAllowedActionsRepositoryError::Generic { code }), + code => Err(ActionsGetAllowedActionsRepositoryError::Generic { code }.into()), } } } @@ -7722,19 +8996,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_artifact](https://docs.github.com/rest/actions/artifacts#get-an-artifact) /// /// --- - pub async fn get_artifact_async(&self, owner: &str, repo: &str, artifact_id: i32) -> Result { + pub async fn get_artifact_async(&self, owner: &str, repo: &str, artifact_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/artifacts/{}", super::GITHUB_BASE_API_URL, owner, repo, artifact_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7746,7 +9020,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetArtifactError::Generic { code }), + code => Err(ActionsGetArtifactError::Generic { code }.into()), } } } @@ -7765,7 +9039,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_artifact(&self, owner: &str, repo: &str, artifact_id: i32) -> Result { + pub fn get_artifact(&self, owner: &str, repo: &str, artifact_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/artifacts/{}", super::GITHUB_BASE_API_URL, owner, repo, artifact_id); @@ -7777,7 +9051,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7789,7 +9063,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetArtifactError::Generic { code }), + code => Err(ActionsGetArtifactError::Generic { code }.into()), } } } @@ -7805,19 +9079,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_custom_oidc_sub_claim_for_repo](https://docs.github.com/rest/actions/oidc#get-the-customization-template-for-an-oidc-subject-claim-for-a-repository) /// /// --- - pub async fn get_custom_oidc_sub_claim_for_repo_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_custom_oidc_sub_claim_for_repo_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/oidc/customization/sub", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7829,9 +9103,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(ActionsGetCustomOidcSubClaimForRepoError::Status400(github_response.to_json_async().await?)), - 404 => Err(ActionsGetCustomOidcSubClaimForRepoError::Status404(github_response.to_json_async().await?)), - code => Err(ActionsGetCustomOidcSubClaimForRepoError::Generic { code }), + 400 => Err(ActionsGetCustomOidcSubClaimForRepoError::Status400(github_response.to_json_async().await?).into()), + 404 => Err(ActionsGetCustomOidcSubClaimForRepoError::Status404(github_response.to_json_async().await?).into()), + code => Err(ActionsGetCustomOidcSubClaimForRepoError::Generic { code }.into()), } } } @@ -7848,7 +9122,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_custom_oidc_sub_claim_for_repo(&self, owner: &str, repo: &str) -> Result { + pub fn get_custom_oidc_sub_claim_for_repo(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/oidc/customization/sub", super::GITHUB_BASE_API_URL, owner, repo); @@ -7860,7 +9134,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7872,9 +9146,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(ActionsGetCustomOidcSubClaimForRepoError::Status400(github_response.to_json()?)), - 404 => Err(ActionsGetCustomOidcSubClaimForRepoError::Status404(github_response.to_json()?)), - code => Err(ActionsGetCustomOidcSubClaimForRepoError::Generic { code }), + 400 => Err(ActionsGetCustomOidcSubClaimForRepoError::Status400(github_response.to_json()?).into()), + 404 => Err(ActionsGetCustomOidcSubClaimForRepoError::Status404(github_response.to_json()?).into()), + code => Err(ActionsGetCustomOidcSubClaimForRepoError::Generic { code }.into()), } } } @@ -7893,19 +9167,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_environment_public_key](https://docs.github.com/rest/actions/secrets#get-an-environment-public-key) /// /// --- - pub async fn get_environment_public_key_async(&self, owner: &str, repo: &str, environment_name: &str) -> Result { + pub async fn get_environment_public_key_async(&self, owner: &str, repo: &str, environment_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/secrets/public-key", super::GITHUB_BASE_API_URL, owner, repo, environment_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7917,7 +9191,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetEnvironmentPublicKeyError::Generic { code }), + code => Err(ActionsGetEnvironmentPublicKeyError::Generic { code }.into()), } } } @@ -7937,7 +9211,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_environment_public_key(&self, owner: &str, repo: &str, environment_name: &str) -> Result { + pub fn get_environment_public_key(&self, owner: &str, repo: &str, environment_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/secrets/public-key", super::GITHUB_BASE_API_URL, owner, repo, environment_name); @@ -7949,7 +9223,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7961,7 +9235,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetEnvironmentPublicKeyError::Generic { code }), + code => Err(ActionsGetEnvironmentPublicKeyError::Generic { code }.into()), } } } @@ -7979,19 +9253,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_environment_secret](https://docs.github.com/rest/actions/secrets#get-an-environment-secret) /// /// --- - pub async fn get_environment_secret_async(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str) -> Result { + pub async fn get_environment_secret_async(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8003,7 +9277,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetEnvironmentSecretError::Generic { code }), + code => Err(ActionsGetEnvironmentSecretError::Generic { code }.into()), } } } @@ -8022,7 +9296,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_environment_secret(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str) -> Result { + pub fn get_environment_secret(&self, owner: &str, repo: &str, environment_name: &str, secret_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, secret_name); @@ -8034,7 +9308,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8046,7 +9320,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetEnvironmentSecretError::Generic { code }), + code => Err(ActionsGetEnvironmentSecretError::Generic { code }.into()), } } } @@ -8064,19 +9338,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_environment_variable](https://docs.github.com/rest/actions/variables#get-an-environment-variable) /// /// --- - pub async fn get_environment_variable_async(&self, owner: &str, repo: &str, environment_name: &str, name: &str) -> Result { + pub async fn get_environment_variable_async(&self, owner: &str, repo: &str, environment_name: &str, name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8088,7 +9362,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetEnvironmentVariableError::Generic { code }), + code => Err(ActionsGetEnvironmentVariableError::Generic { code }.into()), } } } @@ -8107,7 +9381,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_environment_variable(&self, owner: &str, repo: &str, environment_name: &str, name: &str) -> Result { + pub fn get_environment_variable(&self, owner: &str, repo: &str, environment_name: &str, name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, name); @@ -8119,7 +9393,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8131,7 +9405,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetEnvironmentVariableError::Generic { code }), + code => Err(ActionsGetEnvironmentVariableError::Generic { code }.into()), } } } @@ -8149,19 +9423,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_github_actions_default_workflow_permissions_organization](https://docs.github.com/rest/actions/permissions#get-default-workflow-permissions-for-an-organization) /// /// --- - pub async fn get_github_actions_default_workflow_permissions_organization_async(&self, org: &str) -> Result { + pub async fn get_github_actions_default_workflow_permissions_organization_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/permissions/workflow", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8173,7 +9447,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetGithubActionsDefaultWorkflowPermissionsOrganizationError::Generic { code }), + code => Err(ActionsGetGithubActionsDefaultWorkflowPermissionsOrganizationError::Generic { code }.into()), } } } @@ -8192,7 +9466,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_github_actions_default_workflow_permissions_organization(&self, org: &str) -> Result { + pub fn get_github_actions_default_workflow_permissions_organization(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/permissions/workflow", super::GITHUB_BASE_API_URL, org); @@ -8204,7 +9478,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8216,7 +9490,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetGithubActionsDefaultWorkflowPermissionsOrganizationError::Generic { code }), + code => Err(ActionsGetGithubActionsDefaultWorkflowPermissionsOrganizationError::Generic { code }.into()), } } } @@ -8234,19 +9508,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_github_actions_default_workflow_permissions_repository](https://docs.github.com/rest/actions/permissions#get-default-workflow-permissions-for-a-repository) /// /// --- - pub async fn get_github_actions_default_workflow_permissions_repository_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_github_actions_default_workflow_permissions_repository_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/permissions/workflow", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8258,7 +9532,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetGithubActionsDefaultWorkflowPermissionsRepositoryError::Generic { code }), + code => Err(ActionsGetGithubActionsDefaultWorkflowPermissionsRepositoryError::Generic { code }.into()), } } } @@ -8277,7 +9551,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_github_actions_default_workflow_permissions_repository(&self, owner: &str, repo: &str) -> Result { + pub fn get_github_actions_default_workflow_permissions_repository(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/permissions/workflow", super::GITHUB_BASE_API_URL, owner, repo); @@ -8289,7 +9563,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8301,7 +9575,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetGithubActionsDefaultWorkflowPermissionsRepositoryError::Generic { code }), + code => Err(ActionsGetGithubActionsDefaultWorkflowPermissionsRepositoryError::Generic { code }.into()), } } } @@ -8317,19 +9591,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_github_actions_permissions_organization](https://docs.github.com/rest/actions/permissions#get-github-actions-permissions-for-an-organization) /// /// --- - pub async fn get_github_actions_permissions_organization_async(&self, org: &str) -> Result { + pub async fn get_github_actions_permissions_organization_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/permissions", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8341,7 +9615,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetGithubActionsPermissionsOrganizationError::Generic { code }), + code => Err(ActionsGetGithubActionsPermissionsOrganizationError::Generic { code }.into()), } } } @@ -8358,7 +9632,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_github_actions_permissions_organization(&self, org: &str) -> Result { + pub fn get_github_actions_permissions_organization(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/permissions", super::GITHUB_BASE_API_URL, org); @@ -8370,7 +9644,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8382,7 +9656,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetGithubActionsPermissionsOrganizationError::Generic { code }), + code => Err(ActionsGetGithubActionsPermissionsOrganizationError::Generic { code }.into()), } } } @@ -8398,19 +9672,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_github_actions_permissions_repository](https://docs.github.com/rest/actions/permissions#get-github-actions-permissions-for-a-repository) /// /// --- - pub async fn get_github_actions_permissions_repository_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_github_actions_permissions_repository_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/permissions", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8422,7 +9696,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetGithubActionsPermissionsRepositoryError::Generic { code }), + code => Err(ActionsGetGithubActionsPermissionsRepositoryError::Generic { code }.into()), } } } @@ -8439,7 +9713,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_github_actions_permissions_repository(&self, owner: &str, repo: &str) -> Result { + pub fn get_github_actions_permissions_repository(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/permissions", super::GITHUB_BASE_API_URL, owner, repo); @@ -8451,7 +9725,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8463,7 +9737,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetGithubActionsPermissionsRepositoryError::Generic { code }), + code => Err(ActionsGetGithubActionsPermissionsRepositoryError::Generic { code }.into()), } } } @@ -8481,19 +9755,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_job_for_workflow_run](https://docs.github.com/rest/actions/workflow-jobs#get-a-job-for-a-workflow-run) /// /// --- - pub async fn get_job_for_workflow_run_async(&self, owner: &str, repo: &str, job_id: i32) -> Result { + pub async fn get_job_for_workflow_run_async(&self, owner: &str, repo: &str, job_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/jobs/{}", super::GITHUB_BASE_API_URL, owner, repo, job_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8505,7 +9779,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetJobForWorkflowRunError::Generic { code }), + code => Err(ActionsGetJobForWorkflowRunError::Generic { code }.into()), } } } @@ -8524,7 +9798,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_job_for_workflow_run(&self, owner: &str, repo: &str, job_id: i32) -> Result { + pub fn get_job_for_workflow_run(&self, owner: &str, repo: &str, job_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/jobs/{}", super::GITHUB_BASE_API_URL, owner, repo, job_id); @@ -8536,7 +9810,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8548,7 +9822,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetJobForWorkflowRunError::Generic { code }), + code => Err(ActionsGetJobForWorkflowRunError::Generic { code }.into()), } } } @@ -8567,19 +9841,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_org_public_key](https://docs.github.com/rest/actions/secrets#get-an-organization-public-key) /// /// --- - pub async fn get_org_public_key_async(&self, org: &str) -> Result { + pub async fn get_org_public_key_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/secrets/public-key", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8591,7 +9865,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetOrgPublicKeyError::Generic { code }), + code => Err(ActionsGetOrgPublicKeyError::Generic { code }.into()), } } } @@ -8611,7 +9885,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_public_key(&self, org: &str) -> Result { + pub fn get_org_public_key(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/secrets/public-key", super::GITHUB_BASE_API_URL, org); @@ -8623,7 +9897,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8635,7 +9909,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetOrgPublicKeyError::Generic { code }), + code => Err(ActionsGetOrgPublicKeyError::Generic { code }.into()), } } } @@ -8653,19 +9927,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_org_secret](https://docs.github.com/rest/actions/secrets#get-an-organization-secret) /// /// --- - pub async fn get_org_secret_async(&self, org: &str, secret_name: &str) -> Result { + pub async fn get_org_secret_async(&self, org: &str, secret_name: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8677,7 +9951,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetOrgSecretError::Generic { code }), + code => Err(ActionsGetOrgSecretError::Generic { code }.into()), } } } @@ -8696,7 +9970,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_secret(&self, org: &str, secret_name: &str) -> Result { + pub fn get_org_secret(&self, org: &str, secret_name: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); @@ -8708,7 +9982,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8720,7 +9994,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetOrgSecretError::Generic { code }), + code => Err(ActionsGetOrgSecretError::Generic { code }.into()), } } } @@ -8738,19 +10012,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_org_variable](https://docs.github.com/rest/actions/variables#get-an-organization-variable) /// /// --- - pub async fn get_org_variable_async(&self, org: &str, name: &str) -> Result { + pub async fn get_org_variable_async(&self, org: &str, name: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, org, name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8762,7 +10036,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetOrgVariableError::Generic { code }), + code => Err(ActionsGetOrgVariableError::Generic { code }.into()), } } } @@ -8781,7 +10055,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_variable(&self, org: &str, name: &str) -> Result { + pub fn get_org_variable(&self, org: &str, name: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, org, name); @@ -8793,7 +10067,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8805,7 +10079,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetOrgVariableError::Generic { code }), + code => Err(ActionsGetOrgVariableError::Generic { code }.into()), } } } @@ -8823,19 +10097,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_pending_deployments_for_run](https://docs.github.com/rest/actions/workflow-runs#get-pending-deployments-for-a-workflow-run) /// /// --- - pub async fn get_pending_deployments_for_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result, ActionsGetPendingDeploymentsForRunError> { + pub async fn get_pending_deployments_for_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result, AdapterError> { 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: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8847,7 +10121,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetPendingDeploymentsForRunError::Generic { code }), + code => Err(ActionsGetPendingDeploymentsForRunError::Generic { code }.into()), } } } @@ -8866,7 +10140,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_pending_deployments_for_run(&self, owner: &str, repo: &str, run_id: i32) -> Result, ActionsGetPendingDeploymentsForRunError> { + pub fn get_pending_deployments_for_run(&self, owner: &str, repo: &str, run_id: i32) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/pending_deployments", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -8878,7 +10152,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8890,7 +10164,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetPendingDeploymentsForRunError::Generic { code }), + code => Err(ActionsGetPendingDeploymentsForRunError::Generic { code }.into()), } } } @@ -8909,19 +10183,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_repo_public_key](https://docs.github.com/rest/actions/secrets#get-a-repository-public-key) /// /// --- - pub async fn get_repo_public_key_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_repo_public_key_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/secrets/public-key", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8933,7 +10207,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetRepoPublicKeyError::Generic { code }), + code => Err(ActionsGetRepoPublicKeyError::Generic { code }.into()), } } } @@ -8953,7 +10227,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_public_key(&self, owner: &str, repo: &str) -> Result { + pub fn get_repo_public_key(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/secrets/public-key", super::GITHUB_BASE_API_URL, owner, repo); @@ -8965,7 +10239,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8977,7 +10251,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetRepoPublicKeyError::Generic { code }), + code => Err(ActionsGetRepoPublicKeyError::Generic { code }.into()), } } } @@ -8995,19 +10269,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_repo_secret](https://docs.github.com/rest/actions/secrets#get-a-repository-secret) /// /// --- - pub async fn get_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result { + pub async fn get_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9019,7 +10293,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetRepoSecretError::Generic { code }), + code => Err(ActionsGetRepoSecretError::Generic { code }.into()), } } } @@ -9038,7 +10312,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result { + pub fn get_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); @@ -9050,7 +10324,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9062,7 +10336,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetRepoSecretError::Generic { code }), + code => Err(ActionsGetRepoSecretError::Generic { code }.into()), } } } @@ -9080,19 +10354,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_repo_variable](https://docs.github.com/rest/actions/variables#get-a-repository-variable) /// /// --- - pub async fn get_repo_variable_async(&self, owner: &str, repo: &str, name: &str) -> Result { + pub async fn get_repo_variable_async(&self, owner: &str, repo: &str, name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9104,7 +10378,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetRepoVariableError::Generic { code }), + code => Err(ActionsGetRepoVariableError::Generic { code }.into()), } } } @@ -9123,7 +10397,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_variable(&self, owner: &str, repo: &str, name: &str) -> Result { + pub fn get_repo_variable(&self, owner: &str, repo: &str, name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, name); @@ -9135,7 +10409,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9147,7 +10421,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetRepoVariableError::Generic { code }), + code => Err(ActionsGetRepoVariableError::Generic { code }.into()), } } } @@ -9163,19 +10437,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_reviews_for_run](https://docs.github.com/rest/actions/workflow-runs#get-the-review-history-for-a-workflow-run) /// /// --- - pub async fn get_reviews_for_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result, ActionsGetReviewsForRunError> { + pub async fn get_reviews_for_run_async(&self, owner: &str, repo: &str, run_id: i32) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/approvals", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9187,7 +10461,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetReviewsForRunError::Generic { code }), + code => Err(ActionsGetReviewsForRunError::Generic { code }.into()), } } } @@ -9204,7 +10478,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_reviews_for_run(&self, owner: &str, repo: &str, run_id: i32) -> Result, ActionsGetReviewsForRunError> { + pub fn get_reviews_for_run(&self, owner: &str, repo: &str, run_id: i32) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/approvals", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -9216,7 +10490,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9228,7 +10502,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetReviewsForRunError::Generic { code }), + code => Err(ActionsGetReviewsForRunError::Generic { code }.into()), } } } @@ -9246,19 +10520,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_self_hosted_runner_for_org](https://docs.github.com/rest/actions/self-hosted-runners#get-a-self-hosted-runner-for-an-organization) /// /// --- - pub async fn get_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32) -> Result { + pub async fn get_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/actions/runners/{}", super::GITHUB_BASE_API_URL, org, runner_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9270,7 +10544,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetSelfHostedRunnerForOrgError::Generic { code }), + code => Err(ActionsGetSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -9289,7 +10563,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_self_hosted_runner_for_org(&self, org: &str, runner_id: i32) -> Result { + pub fn get_self_hosted_runner_for_org(&self, org: &str, runner_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/actions/runners/{}", super::GITHUB_BASE_API_URL, org, runner_id); @@ -9301,7 +10575,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9313,7 +10587,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetSelfHostedRunnerForOrgError::Generic { code }), + code => Err(ActionsGetSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -9331,19 +10605,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_self_hosted_runner_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#get-a-self-hosted-runner-for-a-repository) /// /// --- - pub async fn get_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32) -> Result { + pub async fn get_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runners/{}", super::GITHUB_BASE_API_URL, owner, repo, runner_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9355,7 +10629,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetSelfHostedRunnerForRepoError::Generic { code }), + code => Err(ActionsGetSelfHostedRunnerForRepoError::Generic { code }.into()), } } } @@ -9374,7 +10648,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32) -> Result { + pub fn get_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runners/{}", super::GITHUB_BASE_API_URL, owner, repo, runner_id); @@ -9386,7 +10660,88 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + 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() { + code => Err(ActionsGetSelfHostedRunnerForRepoError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Get a self-hosted runner group for an organization + /// + /// Gets a specific self-hosted runner group for an organization. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for get_self_hosted_runner_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#get-a-self-hosted-runner-group-for-an-organization) + /// + /// --- + pub async fn get_self_hosted_runner_group_for_org_async(&self, org: &str, runner_group_id: i32) -> Result { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}", super::GITHUB_BASE_API_URL, org, runner_group_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None::, + method: "GET", + 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() { + code => Err(ActionsGetSelfHostedRunnerGroupForOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Get a self-hosted runner group for an organization + /// + /// Gets a specific self-hosted runner group for an organization. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for get_self_hosted_runner_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#get-a-self-hosted-runner-group-for-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn get_self_hosted_runner_group_for_org(&self, org: &str, runner_group_id: i32) -> Result { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}", super::GITHUB_BASE_API_URL, org, runner_group_id); + + + let req = GitHubRequest { + uri: request_uri, + body: None, + method: "GET", + headers: vec![] + }; + + let request = self.client.build(req)?; // -- @@ -9398,7 +10753,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetSelfHostedRunnerForRepoError::Generic { code }), + code => Err(ActionsGetSelfHostedRunnerGroupForOrgError::Generic { code }.into()), } } } @@ -9417,19 +10772,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_workflow](https://docs.github.com/rest/actions/workflows#get-a-workflow) /// /// --- - pub async fn get_workflow_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result { + pub async fn get_workflow_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/workflows/{}", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9441,7 +10796,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowError::Generic { code }), + code => Err(ActionsGetWorkflowError::Generic { code }.into()), } } } @@ -9461,7 +10816,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_workflow(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result { + pub fn get_workflow(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/workflows/{}", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); @@ -9473,7 +10828,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9485,7 +10840,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowError::Generic { code }), + code => Err(ActionsGetWorkflowError::Generic { code }.into()), } } } @@ -9503,19 +10858,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_workflow_access_to_repository](https://docs.github.com/rest/actions/permissions#get-the-level-of-access-for-workflows-outside-of-the-repository) /// /// --- - pub async fn get_workflow_access_to_repository_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_workflow_access_to_repository_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/permissions/access", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9527,7 +10882,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowAccessToRepositoryError::Generic { code }), + code => Err(ActionsGetWorkflowAccessToRepositoryError::Generic { code }.into()), } } } @@ -9546,7 +10901,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_workflow_access_to_repository(&self, owner: &str, repo: &str) -> Result { + pub fn get_workflow_access_to_repository(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/permissions/access", super::GITHUB_BASE_API_URL, owner, repo); @@ -9558,7 +10913,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9570,7 +10925,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowAccessToRepositoryError::Generic { code }), + code => Err(ActionsGetWorkflowAccessToRepositoryError::Generic { code }.into()), } } } @@ -9588,7 +10943,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_workflow_run](https://docs.github.com/rest/actions/workflow-runs#get-a-workflow-run) /// /// --- - pub async fn get_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>) -> Result { + pub async fn get_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs/{}", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -9599,12 +10954,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9616,7 +10971,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowRunError::Generic { code }), + code => Err(ActionsGetWorkflowRunError::Generic { code }.into()), } } } @@ -9635,7 +10990,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_workflow_run(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>) -> Result { + pub fn get_workflow_run(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs/{}", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -9652,7 +11007,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9664,7 +11019,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowRunError::Generic { code }), + code => Err(ActionsGetWorkflowRunError::Generic { code }.into()), } } } @@ -9682,7 +11037,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_workflow_run_attempt](https://docs.github.com/rest/actions/workflow-runs#get-a-workflow-run-attempt) /// /// --- - pub async fn get_workflow_run_attempt_async(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32, query_params: Option>) -> Result { + pub async fn get_workflow_run_attempt_async(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs/{}/attempts/{}", super::GITHUB_BASE_API_URL, owner, repo, run_id, attempt_number); @@ -9693,12 +11048,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9710,7 +11065,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowRunAttemptError::Generic { code }), + code => Err(ActionsGetWorkflowRunAttemptError::Generic { code }.into()), } } } @@ -9729,7 +11084,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_workflow_run_attempt(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32, query_params: Option>) -> Result { + pub fn get_workflow_run_attempt(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs/{}/attempts/{}", super::GITHUB_BASE_API_URL, owner, repo, run_id, attempt_number); @@ -9746,7 +11101,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9758,7 +11113,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowRunAttemptError::Generic { code }), + code => Err(ActionsGetWorkflowRunAttemptError::Generic { code }.into()), } } } @@ -9776,19 +11131,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_workflow_run_usage](https://docs.github.com/rest/actions/workflow-runs#get-workflow-run-usage) /// /// --- - pub async fn get_workflow_run_usage_async(&self, owner: &str, repo: &str, run_id: i32) -> Result { + pub async fn get_workflow_run_usage_async(&self, owner: &str, repo: &str, run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/timing", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9800,7 +11155,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowRunUsageError::Generic { code }), + code => Err(ActionsGetWorkflowRunUsageError::Generic { code }.into()), } } } @@ -9819,7 +11174,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_workflow_run_usage(&self, owner: &str, repo: &str, run_id: i32) -> Result { + pub fn get_workflow_run_usage(&self, owner: &str, repo: &str, run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/timing", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -9831,7 +11186,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9843,7 +11198,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowRunUsageError::Generic { code }), + code => Err(ActionsGetWorkflowRunUsageError::Generic { code }.into()), } } } @@ -9863,19 +11218,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for get_workflow_usage](https://docs.github.com/rest/actions/workflows#get-workflow-usage) /// /// --- - pub async fn get_workflow_usage_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result { + pub async fn get_workflow_usage_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/workflows/{}/timing", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9887,7 +11242,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowUsageError::Generic { code }), + code => Err(ActionsGetWorkflowUsageError::Generic { code }.into()), } } } @@ -9908,7 +11263,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_workflow_usage(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result { + pub fn get_workflow_usage(&self, owner: &str, repo: &str, workflow_id: WorkflowId) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/workflows/{}/timing", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); @@ -9920,7 +11275,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9932,7 +11287,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsGetWorkflowUsageError::Generic { code }), + code => Err(ActionsGetWorkflowUsageError::Generic { code }.into()), } } } @@ -9950,7 +11305,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_artifacts_for_repo](https://docs.github.com/rest/actions/artifacts#list-artifacts-for-a-repository) /// /// --- - pub async fn list_artifacts_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub async fn list_artifacts_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/artifacts", super::GITHUB_BASE_API_URL, owner, repo); @@ -9961,12 +11316,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9978,7 +11333,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListArtifactsForRepoError::Generic { code }), + code => Err(ActionsListArtifactsForRepoError::Generic { code }.into()), } } } @@ -9997,7 +11352,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_artifacts_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub fn list_artifacts_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/artifacts", super::GITHUB_BASE_API_URL, owner, repo); @@ -10014,7 +11369,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10026,7 +11381,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListArtifactsForRepoError::Generic { code }), + code => Err(ActionsListArtifactsForRepoError::Generic { code }.into()), } } } @@ -10045,7 +11400,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_environment_secrets](https://docs.github.com/rest/actions/secrets#list-environment-secrets) /// /// --- - pub async fn list_environment_secrets_async(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { + pub async fn list_environment_secrets_async(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/environments/{}/secrets", super::GITHUB_BASE_API_URL, owner, repo, environment_name); @@ -10056,12 +11411,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10073,7 +11428,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListEnvironmentSecretsError::Generic { code }), + code => Err(ActionsListEnvironmentSecretsError::Generic { code }.into()), } } } @@ -10093,7 +11448,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_environment_secrets(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { + pub fn list_environment_secrets(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/environments/{}/secrets", super::GITHUB_BASE_API_URL, owner, repo, environment_name); @@ -10110,7 +11465,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10122,7 +11477,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListEnvironmentSecretsError::Generic { code }), + code => Err(ActionsListEnvironmentSecretsError::Generic { code }.into()), } } } @@ -10140,7 +11495,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_environment_variables](https://docs.github.com/rest/actions/variables#list-environment-variables) /// /// --- - pub async fn list_environment_variables_async(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { + pub async fn list_environment_variables_async(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/environments/{}/variables", super::GITHUB_BASE_API_URL, owner, repo, environment_name); @@ -10151,12 +11506,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10168,7 +11523,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListEnvironmentVariablesError::Generic { code }), + code => Err(ActionsListEnvironmentVariablesError::Generic { code }.into()), } } } @@ -10187,7 +11542,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_environment_variables(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { + pub fn list_environment_variables(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/environments/{}/variables", super::GITHUB_BASE_API_URL, owner, repo, environment_name); @@ -10204,7 +11559,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10216,7 +11571,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListEnvironmentVariablesError::Generic { code }), + code => Err(ActionsListEnvironmentVariablesError::Generic { code }.into()), } } } @@ -10235,7 +11590,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_jobs_for_workflow_run](https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run) /// /// --- - pub async fn list_jobs_for_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>>) -> Result { + pub async fn list_jobs_for_workflow_run_async(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs/{}/jobs", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -10246,12 +11601,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10263,7 +11618,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListJobsForWorkflowRunError::Generic { code }), + code => Err(ActionsListJobsForWorkflowRunError::Generic { code }.into()), } } } @@ -10283,7 +11638,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_jobs_for_workflow_run(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>>) -> Result { + pub fn list_jobs_for_workflow_run(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs/{}/jobs", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -10300,7 +11655,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10312,7 +11667,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListJobsForWorkflowRunError::Generic { code }), + code => Err(ActionsListJobsForWorkflowRunError::Generic { code }.into()), } } } @@ -10331,7 +11686,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_jobs_for_workflow_run_attempt](https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run-attempt) /// /// --- - pub async fn list_jobs_for_workflow_run_attempt_async(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32, query_params: Option>) -> Result { + pub async fn list_jobs_for_workflow_run_attempt_async(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs/{}/attempts/{}/jobs", super::GITHUB_BASE_API_URL, owner, repo, run_id, attempt_number); @@ -10342,12 +11697,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10359,8 +11714,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsListJobsForWorkflowRunAttemptError::Status404(github_response.to_json_async().await?)), - code => Err(ActionsListJobsForWorkflowRunAttemptError::Generic { code }), + 404 => Err(ActionsListJobsForWorkflowRunAttemptError::Status404(github_response.to_json_async().await?).into()), + code => Err(ActionsListJobsForWorkflowRunAttemptError::Generic { code }.into()), } } } @@ -10380,7 +11735,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_jobs_for_workflow_run_attempt(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32, query_params: Option>) -> Result { + pub fn list_jobs_for_workflow_run_attempt(&self, owner: &str, repo: &str, run_id: i32, attempt_number: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs/{}/attempts/{}/jobs", super::GITHUB_BASE_API_URL, owner, repo, run_id, attempt_number); @@ -10397,7 +11752,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10409,8 +11764,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsListJobsForWorkflowRunAttemptError::Status404(github_response.to_json()?)), - code => Err(ActionsListJobsForWorkflowRunAttemptError::Generic { code }), + 404 => Err(ActionsListJobsForWorkflowRunAttemptError::Status404(github_response.to_json()?).into()), + code => Err(ActionsListJobsForWorkflowRunAttemptError::Generic { code }.into()), } } } @@ -10428,19 +11783,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_labels_for_self_hosted_runner_for_org](https://docs.github.com/rest/actions/self-hosted-runners#list-labels-for-a-self-hosted-runner-for-an-organization) /// /// --- - pub async fn list_labels_for_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32) -> Result { + pub async fn list_labels_for_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10452,8 +11807,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Status404(github_response.to_json_async().await?)), - code => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Generic { code }), + 404 => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Status404(github_response.to_json_async().await?).into()), + code => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -10472,7 +11827,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_labels_for_self_hosted_runner_for_org(&self, org: &str, runner_id: i32) -> Result { + pub fn list_labels_for_self_hosted_runner_for_org(&self, org: &str, runner_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); @@ -10484,7 +11839,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10496,8 +11851,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Status404(github_response.to_json()?)), - code => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Generic { code }), + 404 => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Status404(github_response.to_json()?).into()), + code => Err(ActionsListLabelsForSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -10515,19 +11870,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_labels_for_self_hosted_runner_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#list-labels-for-a-self-hosted-runner-for-a-repository) /// /// --- - pub async fn list_labels_for_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32) -> Result { + pub async fn list_labels_for_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32) -> 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: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10539,8 +11894,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Status404(github_response.to_json_async().await?)), - code => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Generic { code }), + 404 => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Status404(github_response.to_json_async().await?).into()), + code => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Generic { code }.into()), } } } @@ -10559,7 +11914,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_labels_for_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32) -> Result { + pub fn list_labels_for_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); @@ -10571,7 +11926,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10583,8 +11938,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Status404(github_response.to_json()?)), - code => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Generic { code }), + 404 => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Status404(github_response.to_json()?).into()), + code => Err(ActionsListLabelsForSelfHostedRunnerForRepoError::Generic { code }.into()), } } } @@ -10603,7 +11958,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_org_secrets](https://docs.github.com/rest/actions/secrets#list-organization-secrets) /// /// --- - pub async fn list_org_secrets_async(&self, org: &str, query_params: Option>) -> Result { + pub async fn list_org_secrets_async(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/actions/secrets", super::GITHUB_BASE_API_URL, org); @@ -10614,12 +11969,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10631,7 +11986,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListOrgSecretsError::Generic { code }), + code => Err(ActionsListOrgSecretsError::Generic { code }.into()), } } } @@ -10651,7 +12006,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_org_secrets(&self, org: &str, query_params: Option>) -> Result { + pub fn list_org_secrets(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/actions/secrets", super::GITHUB_BASE_API_URL, org); @@ -10668,7 +12023,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10680,7 +12035,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListOrgSecretsError::Generic { code }), + code => Err(ActionsListOrgSecretsError::Generic { code }.into()), } } } @@ -10698,7 +12053,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_org_variables](https://docs.github.com/rest/actions/variables#list-organization-variables) /// /// --- - pub async fn list_org_variables_async(&self, org: &str, query_params: Option>) -> Result { + pub async fn list_org_variables_async(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/actions/variables", super::GITHUB_BASE_API_URL, org); @@ -10709,12 +12064,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10726,7 +12081,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListOrgVariablesError::Generic { code }), + code => Err(ActionsListOrgVariablesError::Generic { code }.into()), } } } @@ -10745,7 +12100,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_org_variables(&self, org: &str, query_params: Option>) -> Result { + pub fn list_org_variables(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/actions/variables", super::GITHUB_BASE_API_URL, org); @@ -10762,7 +12117,97 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + 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() { + code => Err(ActionsListOrgVariablesError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # List repository access to a self-hosted runner group in an organization + /// + /// Lists the repositories with access to a self-hosted runner group configured in an organization. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for list_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#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 = 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() { + code => Err(ActionsListRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # List repository access to a self-hosted runner group in an organization + /// + /// Lists the repositories with access to a self-hosted runner group configured in an organization. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for list_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#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 = self.client.build(req)?; // -- @@ -10774,7 +12219,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListOrgVariablesError::Generic { code }), + code => Err(ActionsListRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }.into()), } } } @@ -10793,7 +12238,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_repo_organization_secrets](https://docs.github.com/rest/actions/secrets#list-repository-organization-secrets) /// /// --- - pub async fn list_repo_organization_secrets_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub async fn list_repo_organization_secrets_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/organization-secrets", super::GITHUB_BASE_API_URL, owner, repo); @@ -10804,12 +12249,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10821,7 +12266,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListRepoOrganizationSecretsError::Generic { code }), + code => Err(ActionsListRepoOrganizationSecretsError::Generic { code }.into()), } } } @@ -10841,7 +12286,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repo_organization_secrets(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub fn list_repo_organization_secrets(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/organization-secrets", super::GITHUB_BASE_API_URL, owner, repo); @@ -10858,7 +12303,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10870,7 +12315,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListRepoOrganizationSecretsError::Generic { code }), + code => Err(ActionsListRepoOrganizationSecretsError::Generic { code }.into()), } } } @@ -10888,7 +12333,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_repo_organization_variables](https://docs.github.com/rest/actions/variables#list-repository-organization-variables) /// /// --- - pub async fn list_repo_organization_variables_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub async fn list_repo_organization_variables_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/organization-variables", super::GITHUB_BASE_API_URL, owner, repo); @@ -10899,12 +12344,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10916,7 +12361,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListRepoOrganizationVariablesError::Generic { code }), + code => Err(ActionsListRepoOrganizationVariablesError::Generic { code }.into()), } } } @@ -10935,7 +12380,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repo_organization_variables(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub fn list_repo_organization_variables(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/organization-variables", super::GITHUB_BASE_API_URL, owner, repo); @@ -10952,7 +12397,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10964,7 +12409,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListRepoOrganizationVariablesError::Generic { code }), + code => Err(ActionsListRepoOrganizationVariablesError::Generic { code }.into()), } } } @@ -10983,7 +12428,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_repo_secrets](https://docs.github.com/rest/actions/secrets#list-repository-secrets) /// /// --- - pub async fn list_repo_secrets_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + 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); @@ -10994,12 +12439,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11011,7 +12456,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListRepoSecretsError::Generic { code }), + code => Err(ActionsListRepoSecretsError::Generic { code }.into()), } } } @@ -11031,7 +12476,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repo_secrets(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + 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); @@ -11048,7 +12493,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11060,7 +12505,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListRepoSecretsError::Generic { code }), + code => Err(ActionsListRepoSecretsError::Generic { code }.into()), } } } @@ -11078,7 +12523,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_repo_variables](https://docs.github.com/rest/actions/variables#list-repository-variables) /// /// --- - pub async fn list_repo_variables_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub async fn list_repo_variables_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/variables", super::GITHUB_BASE_API_URL, owner, repo); @@ -11089,12 +12534,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11106,7 +12551,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListRepoVariablesError::Generic { code }), + code => Err(ActionsListRepoVariablesError::Generic { code }.into()), } } } @@ -11125,7 +12570,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repo_variables(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub fn list_repo_variables(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/variables", super::GITHUB_BASE_API_URL, owner, repo); @@ -11142,7 +12587,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11154,7 +12599,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListRepoVariablesError::Generic { code }), + code => Err(ActionsListRepoVariablesError::Generic { code }.into()), } } } @@ -11172,7 +12617,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_repo_workflows](https://docs.github.com/rest/actions/workflows#list-repository-workflows) /// /// --- - pub async fn list_repo_workflows_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub async fn list_repo_workflows_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/workflows", super::GITHUB_BASE_API_URL, owner, repo); @@ -11183,12 +12628,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11200,7 +12645,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListRepoWorkflowsError::Generic { code }), + code => Err(ActionsListRepoWorkflowsError::Generic { code }.into()), } } } @@ -11219,7 +12664,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repo_workflows(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub fn list_repo_workflows(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/workflows", super::GITHUB_BASE_API_URL, owner, repo); @@ -11236,7 +12681,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11248,7 +12693,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListRepoWorkflowsError::Generic { code }), + code => Err(ActionsListRepoWorkflowsError::Generic { code }.into()), } } } @@ -11266,19 +12711,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_runner_applications_for_org](https://docs.github.com/rest/actions/self-hosted-runners#list-runner-applications-for-an-organization) /// /// --- - pub async fn list_runner_applications_for_org_async(&self, org: &str) -> Result, ActionsListRunnerApplicationsForOrgError> { + pub async fn list_runner_applications_for_org_async(&self, org: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/actions/runners/downloads", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11290,7 +12735,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListRunnerApplicationsForOrgError::Generic { code }), + code => Err(ActionsListRunnerApplicationsForOrgError::Generic { code }.into()), } } } @@ -11309,7 +12754,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_runner_applications_for_org(&self, org: &str) -> Result, ActionsListRunnerApplicationsForOrgError> { + pub fn list_runner_applications_for_org(&self, org: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/actions/runners/downloads", super::GITHUB_BASE_API_URL, org); @@ -11321,7 +12766,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11333,7 +12778,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListRunnerApplicationsForOrgError::Generic { code }), + code => Err(ActionsListRunnerApplicationsForOrgError::Generic { code }.into()), } } } @@ -11351,19 +12796,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_runner_applications_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#list-runner-applications-for-a-repository) /// /// --- - pub async fn list_runner_applications_for_repo_async(&self, owner: &str, repo: &str) -> Result, ActionsListRunnerApplicationsForRepoError> { + pub async fn list_runner_applications_for_repo_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runners/downloads", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11375,7 +12820,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListRunnerApplicationsForRepoError::Generic { code }), + code => Err(ActionsListRunnerApplicationsForRepoError::Generic { code }.into()), } } } @@ -11394,7 +12839,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_runner_applications_for_repo(&self, owner: &str, repo: &str) -> Result, ActionsListRunnerApplicationsForRepoError> { + pub fn list_runner_applications_for_repo(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runners/downloads", super::GITHUB_BASE_API_URL, owner, repo); @@ -11406,7 +12851,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11418,7 +12863,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListRunnerApplicationsForRepoError::Generic { code }), + code => Err(ActionsListRunnerApplicationsForRepoError::Generic { code }.into()), } } } @@ -11437,7 +12882,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_selected_repos_for_org_secret](https://docs.github.com/rest/actions/secrets#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); @@ -11448,12 +12893,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11465,7 +12910,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListSelectedReposForOrgSecretError::Generic { code }), + code => Err(ActionsListSelectedReposForOrgSecretError::Generic { code }.into()), } } } @@ -11479,19 +12924,207 @@ impl<'api, C: Client> Actions<'api, C> { /// /// Authenticated users must have collaborator access to a repository to create, update, or read secrets. /// - /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + /// + /// [GitHub API docs for list_selected_repos_for_org_secret](https://docs.github.com/rest/actions/secrets#list-selected-repositories-for-an-organization-secret) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + 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); + + if let Some(params) = query_params { + request_uri.push_str("?"); + let qp: ActionsListSelectedReposForOrgSecretParams = 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 = 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() { + code => Err(ActionsListSelectedReposForOrgSecretError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # List selected repositories for an organization variable + /// + /// Lists all repositories that can access an organization variable + /// that is available to selected repositories. + /// + /// Authenticated users must have collaborator access to a repository to create, update, or read variables. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + /// + /// [GitHub API docs for list_selected_repos_for_org_variable](https://docs.github.com/rest/actions/variables#list-selected-repositories-for-an-organization-variable) + /// + /// --- + pub async fn list_selected_repos_for_org_variable_async(&self, org: &str, name: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories", super::GITHUB_BASE_API_URL, org, name); + + 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 = 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() { + 409 => Err(ActionsListSelectedReposForOrgVariableError::Status409.into()), + code => Err(ActionsListSelectedReposForOrgVariableError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # List selected repositories for an organization variable + /// + /// Lists all repositories that can access an organization variable + /// that is available to selected repositories. + /// + /// Authenticated users must have collaborator access to a repository to create, update, or read variables. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + /// + /// [GitHub API docs for list_selected_repos_for_org_variable](https://docs.github.com/rest/actions/variables#list-selected-repositories-for-an-organization-variable) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn list_selected_repos_for_org_variable(&self, org: &str, name: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories", super::GITHUB_BASE_API_URL, org, name); + + if let Some(params) = query_params { + request_uri.push_str("?"); + let qp: ActionsListSelectedReposForOrgVariableParams = 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 = 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() { + 409 => Err(ActionsListSelectedReposForOrgVariableError::Status409.into()), + code => Err(ActionsListSelectedReposForOrgVariableError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # List selected repositories enabled for GitHub Actions in an organization + /// + /// Lists the selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for list_selected_repositories_enabled_github_actions_organization](https://docs.github.com/rest/actions/permissions#list-selected-repositories-enabled-for-github-actions-in-an-organization) + /// + /// --- + pub async fn list_selected_repositories_enabled_github_actions_organization_async(&self, org: &str, query_params: Option>) -> Result { + + let mut request_uri = format!("{}/orgs/{}/actions/permissions/repositories", 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 = 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() { + code => Err(ActionsListSelectedRepositoriesEnabledGithubActionsOrganizationError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # List selected repositories enabled for GitHub Actions in an organization + /// + /// Lists the selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for list_selected_repos_for_org_secret](https://docs.github.com/rest/actions/secrets#list-selected-repositories-for-an-organization-secret) + /// [GitHub API docs for list_selected_repositories_enabled_github_actions_organization](https://docs.github.com/rest/actions/permissions#list-selected-repositories-enabled-for-github-actions-in-an-organization) /// /// --- #[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_repositories_enabled_github_actions_organization(&self, org: &str, query_params: Option>) -> Result { - let mut request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); + let mut request_uri = format!("{}/orgs/{}/actions/permissions/repositories", super::GITHUB_BASE_API_URL, org); if let Some(params) = query_params { request_uri.push_str("?"); - let qp: ActionsListSelectedReposForOrgSecretParams = params.into(); + let qp: ActionsListSelectedRepositoriesEnabledGithubActionsOrganizationParams = params.into(); request_uri.push_str(&serde_urlencoded::to_string(qp)?); } @@ -11502,7 +13135,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11514,28 +13147,25 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListSelectedReposForOrgSecretError::Generic { code }), + code => Err(ActionsListSelectedRepositoriesEnabledGithubActionsOrganizationError::Generic { code }.into()), } } } /// --- /// - /// # List selected repositories for an organization variable + /// # List self-hosted runner groups for an organization /// - /// Lists all repositories that can access an organization variable - /// that is available to selected repositories. - /// - /// Authenticated users must have collaborator access to a repository to create, update, or read variables. + /// Lists all self-hosted runner groups configured in an organization and inherited from an enterprise. /// - /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for list_selected_repos_for_org_variable](https://docs.github.com/rest/actions/variables#list-selected-repositories-for-an-organization-variable) + /// [GitHub API docs for list_self_hosted_runner_groups_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#list-self-hosted-runner-groups-for-an-organization) /// /// --- - pub async fn list_selected_repos_for_org_variable_async(&self, org: &str, name: &str, query_params: Option>) -> Result { + pub async fn list_self_hosted_runner_groups_for_org_async(&self, org: &str, query_params: Option>>) -> Result { - let mut request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories", super::GITHUB_BASE_API_URL, org, name); + let mut request_uri = format!("{}/orgs/{}/actions/runner-groups", super::GITHUB_BASE_API_URL, org); if let Some(params) = query_params { request_uri.push_str("?"); @@ -11544,12 +13174,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11561,34 +13191,30 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ActionsListSelectedReposForOrgVariableError::Status409), - code => Err(ActionsListSelectedReposForOrgVariableError::Generic { code }), + code => Err(ActionsListSelfHostedRunnerGroupsForOrgError::Generic { code }.into()), } } } /// --- /// - /// # List selected repositories for an organization variable + /// # List self-hosted runner groups for an organization /// - /// Lists all repositories that can access an organization variable - /// that is available to selected repositories. - /// - /// Authenticated users must have collaborator access to a repository to create, update, or read variables. + /// Lists all self-hosted runner groups configured in an organization and inherited from an enterprise. /// - /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for list_selected_repos_for_org_variable](https://docs.github.com/rest/actions/variables#list-selected-repositories-for-an-organization-variable) + /// [GitHub API docs for list_self_hosted_runner_groups_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#list-self-hosted-runner-groups-for-an-organization) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_selected_repos_for_org_variable(&self, org: &str, name: &str, query_params: Option>) -> Result { + pub fn list_self_hosted_runner_groups_for_org(&self, org: &str, query_params: Option>>) -> Result { - let mut request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories", super::GITHUB_BASE_API_URL, org, name); + let mut request_uri = format!("{}/orgs/{}/actions/runner-groups", super::GITHUB_BASE_API_URL, org); if let Some(params) = query_params { request_uri.push_str("?"); - let qp: ActionsListSelectedReposForOrgVariableParams = params.into(); + let qp: ActionsListSelfHostedRunnerGroupsForOrgParams = params.into(); request_uri.push_str(&serde_urlencoded::to_string(qp)?); } @@ -11599,7 +13225,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11611,26 +13237,27 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ActionsListSelectedReposForOrgVariableError::Status409), - code => Err(ActionsListSelectedReposForOrgVariableError::Generic { code }), + code => Err(ActionsListSelfHostedRunnerGroupsForOrgError::Generic { code }.into()), } } } /// --- /// - /// # List selected repositories enabled for GitHub Actions in an organization + /// # List self-hosted runners for an organization /// - /// Lists the selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." + /// Lists all self-hosted runners configured in an organization. /// - /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// Authenticated users must have admin access to the organization to use this endpoint. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. /// - /// [GitHub API docs for list_selected_repositories_enabled_github_actions_organization](https://docs.github.com/rest/actions/permissions#list-selected-repositories-enabled-for-github-actions-in-an-organization) + /// [GitHub API docs for list_self_hosted_runners_for_org](https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-organization) /// /// --- - pub async fn list_selected_repositories_enabled_github_actions_organization_async(&self, org: &str, query_params: Option>) -> Result { + pub async fn list_self_hosted_runners_for_org_async(&self, org: &str, query_params: Option>>) -> Result { - let mut request_uri = format!("{}/orgs/{}/actions/permissions/repositories", super::GITHUB_BASE_API_URL, org); + let mut request_uri = format!("{}/orgs/{}/actions/runners", super::GITHUB_BASE_API_URL, org); if let Some(params) = query_params { request_uri.push_str("?"); @@ -11639,12 +13266,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11656,30 +13283,32 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListSelectedRepositoriesEnabledGithubActionsOrganizationError::Generic { code }), + code => Err(ActionsListSelfHostedRunnersForOrgError::Generic { code }.into()), } } } /// --- /// - /// # List selected repositories enabled for GitHub Actions in an organization + /// # List self-hosted runners for an organization /// - /// Lists the selected repositories that are enabled for GitHub Actions in an organization. To use this endpoint, the organization permission policy for `enabled_repositories` must be configured to `selected`. For more information, see "[Set GitHub Actions permissions for an organization](#set-github-actions-permissions-for-an-organization)." + /// Lists all self-hosted runners configured in an organization. /// - /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// Authenticated users must have admin access to the organization to use this endpoint. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. /// - /// [GitHub API docs for list_selected_repositories_enabled_github_actions_organization](https://docs.github.com/rest/actions/permissions#list-selected-repositories-enabled-for-github-actions-in-an-organization) + /// [GitHub API docs for list_self_hosted_runners_for_org](https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-organization) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_selected_repositories_enabled_github_actions_organization(&self, org: &str, query_params: Option>) -> Result { + pub fn list_self_hosted_runners_for_org(&self, org: &str, query_params: Option>>) -> Result { - let mut request_uri = format!("{}/orgs/{}/actions/permissions/repositories", super::GITHUB_BASE_API_URL, org); + let mut request_uri = format!("{}/orgs/{}/actions/runners", super::GITHUB_BASE_API_URL, org); if let Some(params) = query_params { request_uri.push_str("?"); - let qp: ActionsListSelectedRepositoriesEnabledGithubActionsOrganizationParams = params.into(); + let qp: ActionsListSelfHostedRunnersForOrgParams = params.into(); request_uri.push_str(&serde_urlencoded::to_string(qp)?); } @@ -11690,7 +13319,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11702,27 +13331,27 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListSelectedRepositoriesEnabledGithubActionsOrganizationError::Generic { code }), + code => Err(ActionsListSelfHostedRunnersForOrgError::Generic { code }.into()), } } } /// --- /// - /// # List self-hosted runners for an organization + /// # List self-hosted runners for a repository /// - /// Lists all self-hosted runners configured in an organization. + /// Lists all self-hosted runners configured in a repository. /// - /// Authenticated users must have admin access to the organization to use this endpoint. + /// Authenticated users must have admin access to the repository to use this endpoint. /// - /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + /// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. /// - /// [GitHub API docs for list_self_hosted_runners_for_org](https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-organization) + /// [GitHub API docs for list_self_hosted_runners_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-a-repository) /// /// --- - pub async fn list_self_hosted_runners_for_org_async(&self, org: &str, query_params: Option>>) -> Result { + pub async fn list_self_hosted_runners_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { - let mut request_uri = format!("{}/orgs/{}/actions/runners", super::GITHUB_BASE_API_URL, org); + let mut request_uri = format!("{}/repos/{}/{}/actions/runners", super::GITHUB_BASE_API_URL, owner, repo); if let Some(params) = query_params { request_uri.push_str("?"); @@ -11731,12 +13360,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11748,32 +13377,32 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListSelfHostedRunnersForOrgError::Generic { code }), + code => Err(ActionsListSelfHostedRunnersForRepoError::Generic { code }.into()), } } } /// --- /// - /// # List self-hosted runners for an organization + /// # List self-hosted runners for a repository /// - /// Lists all self-hosted runners configured in an organization. + /// Lists all self-hosted runners configured in a repository. /// - /// Authenticated users must have admin access to the organization to use this endpoint. + /// Authenticated users must have admin access to the repository to use this endpoint. /// - /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + /// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. /// - /// [GitHub API docs for list_self_hosted_runners_for_org](https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-organization) + /// [GitHub API docs for list_self_hosted_runners_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-a-repository) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_self_hosted_runners_for_org(&self, org: &str, query_params: Option>>) -> Result { + pub fn list_self_hosted_runners_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { - let mut request_uri = format!("{}/orgs/{}/actions/runners", super::GITHUB_BASE_API_URL, org); + let mut request_uri = format!("{}/repos/{}/{}/actions/runners", super::GITHUB_BASE_API_URL, owner, repo); if let Some(params) = query_params { request_uri.push_str("?"); - let qp: ActionsListSelfHostedRunnersForOrgParams = params.into(); + let qp: ActionsListSelfHostedRunnersForRepoParams = params.into(); request_uri.push_str(&serde_urlencoded::to_string(qp)?); } @@ -11784,7 +13413,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11796,27 +13425,25 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListSelfHostedRunnersForOrgError::Generic { code }), + code => Err(ActionsListSelfHostedRunnersForRepoError::Generic { code }.into()), } } } /// --- /// - /// # List self-hosted runners for a repository + /// # List self-hosted runners in a group for an organization /// - /// Lists all self-hosted runners configured in a repository. + /// Lists self-hosted runners that are in a specific organization group. /// - /// Authenticated users must have admin access to the repository to use this endpoint. - /// - /// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for list_self_hosted_runners_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-a-repository) + /// [GitHub API docs for list_self_hosted_runners_in_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#list-self-hosted-runners-in-a-group-for-an-organization) /// /// --- - pub async fn list_self_hosted_runners_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub async fn list_self_hosted_runners_in_group_for_org_async(&self, org: &str, runner_group_id: i32, query_params: Option>) -> Result { - let mut request_uri = format!("{}/repos/{}/{}/actions/runners", super::GITHUB_BASE_API_URL, owner, repo); + let mut request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners", super::GITHUB_BASE_API_URL, org, runner_group_id); if let Some(params) = query_params { request_uri.push_str("?"); @@ -11825,12 +13452,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11842,32 +13469,30 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListSelfHostedRunnersForRepoError::Generic { code }), + code => Err(ActionsListSelfHostedRunnersInGroupForOrgError::Generic { code }.into()), } } } /// --- /// - /// # List self-hosted runners for a repository + /// # List self-hosted runners in a group for an organization /// - /// Lists all self-hosted runners configured in a repository. - /// - /// Authenticated users must have admin access to the repository to use this endpoint. + /// Lists self-hosted runners that are in a specific organization group. /// - /// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for list_self_hosted_runners_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#list-self-hosted-runners-for-a-repository) + /// [GitHub API docs for list_self_hosted_runners_in_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#list-self-hosted-runners-in-a-group-for-an-organization) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_self_hosted_runners_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub fn list_self_hosted_runners_in_group_for_org(&self, org: &str, runner_group_id: i32, query_params: Option>) -> Result { - let mut request_uri = format!("{}/repos/{}/{}/actions/runners", super::GITHUB_BASE_API_URL, owner, repo); + let mut request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners", super::GITHUB_BASE_API_URL, org, runner_group_id); if let Some(params) = query_params { request_uri.push_str("?"); - let qp: ActionsListSelfHostedRunnersForRepoParams = params.into(); + let qp: ActionsListSelfHostedRunnersInGroupForOrgParams = params.into(); request_uri.push_str(&serde_urlencoded::to_string(qp)?); } @@ -11878,7 +13503,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11890,7 +13515,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListSelfHostedRunnersForRepoError::Generic { code }), + code => Err(ActionsListSelfHostedRunnersInGroupForOrgError::Generic { code }.into()), } } } @@ -11908,7 +13533,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_workflow_run_artifacts](https://docs.github.com/rest/actions/artifacts#list-workflow-run-artifacts) /// /// --- - pub async fn list_workflow_run_artifacts_async(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>>) -> Result { + pub async fn list_workflow_run_artifacts_async(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs/{}/artifacts", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -11919,12 +13544,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11936,7 +13561,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListWorkflowRunArtifactsError::Generic { code }), + code => Err(ActionsListWorkflowRunArtifactsError::Generic { code }.into()), } } } @@ -11955,7 +13580,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_workflow_run_artifacts(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>>) -> Result { + pub fn list_workflow_run_artifacts(&self, owner: &str, repo: &str, run_id: i32, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs/{}/artifacts", super::GITHUB_BASE_API_URL, owner, repo, run_id); @@ -11972,7 +13597,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11984,7 +13609,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListWorkflowRunArtifactsError::Generic { code }), + code => Err(ActionsListWorkflowRunArtifactsError::Generic { code }.into()), } } } @@ -12002,7 +13627,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_workflow_runs](https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-workflow) /// /// --- - pub async fn list_workflow_runs_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId, query_params: Option>>) -> Result { + pub async fn list_workflow_runs_async(&self, owner: &str, repo: &str, workflow_id: WorkflowId, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/workflows/{}/runs", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); @@ -12013,12 +13638,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12030,7 +13655,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListWorkflowRunsError::Generic { code }), + code => Err(ActionsListWorkflowRunsError::Generic { code }.into()), } } } @@ -12049,7 +13674,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_workflow_runs(&self, owner: &str, repo: &str, workflow_id: WorkflowId, query_params: Option>>) -> Result { + pub fn list_workflow_runs(&self, owner: &str, repo: &str, workflow_id: WorkflowId, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/workflows/{}/runs", super::GITHUB_BASE_API_URL, owner, repo, workflow_id); @@ -12066,7 +13691,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12078,7 +13703,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListWorkflowRunsError::Generic { code }), + code => Err(ActionsListWorkflowRunsError::Generic { code }.into()), } } } @@ -12098,7 +13723,7 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for list_workflow_runs_for_repo](https://docs.github.com/rest/actions/workflow-runs#list-workflow-runs-for-a-repository) /// /// --- - pub async fn list_workflow_runs_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub async fn list_workflow_runs_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs", super::GITHUB_BASE_API_URL, owner, repo); @@ -12109,12 +13734,12 @@ impl<'api, C: Client> Actions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12126,7 +13751,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsListWorkflowRunsForRepoError::Generic { code }), + code => Err(ActionsListWorkflowRunsForRepoError::Generic { code }.into()), } } } @@ -12147,7 +13772,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_workflow_runs_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub fn list_workflow_runs_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/actions/runs", super::GITHUB_BASE_API_URL, owner, repo); @@ -12164,7 +13789,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12176,7 +13801,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsListWorkflowRunsForRepoError::Generic { code }), + code => Err(ActionsListWorkflowRunsForRepoError::Generic { code }.into()), } } } @@ -12192,19 +13817,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for re_run_job_for_workflow_run](https://docs.github.com/rest/actions/workflow-runs#re-run-a-job-from-a-workflow-run) /// /// --- - pub async fn re_run_job_for_workflow_run_async(&self, owner: &str, repo: &str, job_id: i32, body: PostActionsReRunJobForWorkflowRun) -> Result { + pub async fn re_run_job_for_workflow_run_async(&self, owner: &str, repo: &str, job_id: i32, body: PostActionsReRunJobForWorkflowRun) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/jobs/{}/rerun", super::GITHUB_BASE_API_URL, owner, repo, job_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsReRunJobForWorkflowRun::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12216,8 +13841,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ActionsReRunJobForWorkflowRunError::Status403(github_response.to_json_async().await?)), - code => Err(ActionsReRunJobForWorkflowRunError::Generic { code }), + 403 => Err(ActionsReRunJobForWorkflowRunError::Status403(github_response.to_json_async().await?).into()), + code => Err(ActionsReRunJobForWorkflowRunError::Generic { code }.into()), } } } @@ -12234,19 +13859,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn re_run_job_for_workflow_run(&self, owner: &str, repo: &str, job_id: i32, body: PostActionsReRunJobForWorkflowRun) -> Result { + pub fn re_run_job_for_workflow_run(&self, owner: &str, repo: &str, job_id: i32, body: PostActionsReRunJobForWorkflowRun) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/jobs/{}/rerun", super::GITHUB_BASE_API_URL, owner, repo, job_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsReRunJobForWorkflowRun::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12258,8 +13883,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ActionsReRunJobForWorkflowRunError::Status403(github_response.to_json()?)), - code => Err(ActionsReRunJobForWorkflowRunError::Generic { code }), + 403 => Err(ActionsReRunJobForWorkflowRunError::Status403(github_response.to_json()?).into()), + code => Err(ActionsReRunJobForWorkflowRunError::Generic { code }.into()), } } } @@ -12275,19 +13900,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for re_run_workflow](https://docs.github.com/rest/actions/workflow-runs#re-run-a-workflow) /// /// --- - pub async fn re_run_workflow_async(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReRunWorkflow) -> Result { + pub async fn re_run_workflow_async(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReRunWorkflow) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/rerun", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsReRunWorkflow::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12299,7 +13924,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsReRunWorkflowError::Generic { code }), + code => Err(ActionsReRunWorkflowError::Generic { code }.into()), } } } @@ -12316,19 +13941,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn re_run_workflow(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReRunWorkflow) -> Result { + pub fn re_run_workflow(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReRunWorkflow) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/rerun", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsReRunWorkflow::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12340,7 +13965,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsReRunWorkflowError::Generic { code }), + code => Err(ActionsReRunWorkflowError::Generic { code }.into()), } } } @@ -12356,19 +13981,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for re_run_workflow_failed_jobs](https://docs.github.com/rest/actions/workflow-runs#re-run-failed-jobs-from-a-workflow-run) /// /// --- - pub async fn re_run_workflow_failed_jobs_async(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReRunWorkflowFailedJobs) -> Result { + pub async fn re_run_workflow_failed_jobs_async(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReRunWorkflowFailedJobs) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/rerun-failed-jobs", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsReRunWorkflowFailedJobs::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12380,7 +14005,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsReRunWorkflowFailedJobsError::Generic { code }), + code => Err(ActionsReRunWorkflowFailedJobsError::Generic { code }.into()), } } } @@ -12397,19 +14022,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn re_run_workflow_failed_jobs(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReRunWorkflowFailedJobs) -> Result { + pub fn re_run_workflow_failed_jobs(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReRunWorkflowFailedJobs) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/rerun-failed-jobs", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsReRunWorkflowFailedJobs::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12421,7 +14046,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsReRunWorkflowFailedJobsError::Generic { code }), + code => Err(ActionsReRunWorkflowFailedJobsError::Generic { code }.into()), } } } @@ -12440,19 +14065,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for remove_all_custom_labels_from_self_hosted_runner_for_org](https://docs.github.com/rest/actions/self-hosted-runners#remove-all-custom-labels-from-a-self-hosted-runner-for-an-organization) /// /// --- - pub async fn remove_all_custom_labels_from_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32) -> Result { + 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/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12464,8 +14089,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Status404(github_response.to_json_async().await?)), - code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Generic { code }), + 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Status404(github_response.to_json_async().await?).into()), + code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -12485,7 +14110,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_all_custom_labels_from_self_hosted_runner_for_org(&self, org: &str, runner_id: i32) -> Result { + 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/runners/{}/labels", super::GITHUB_BASE_API_URL, org, runner_id); @@ -12497,7 +14122,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12509,8 +14134,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Status404(github_response.to_json()?)), - code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Generic { code }), + 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Status404(github_response.to_json()?).into()), + code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -12529,19 +14154,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for remove_all_custom_labels_from_self_hosted_runner_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#remove-all-custom-labels-from-a-self-hosted-runner-for-a-repository) /// /// --- - pub async fn remove_all_custom_labels_from_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32) -> Result { + 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!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12553,8 +14178,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Status404(github_response.to_json_async().await?)), - code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Generic { code }), + 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Status404(github_response.to_json_async().await?).into()), + code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Generic { code }.into()), } } } @@ -12574,7 +14199,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_all_custom_labels_from_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32) -> Result { + 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!("{}/repos/{}/{}/actions/runners/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, runner_id); @@ -12586,7 +14211,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12598,8 +14223,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Status404(github_response.to_json()?)), - code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Generic { code }), + 404 => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Status404(github_response.to_json()?).into()), + code => Err(ActionsRemoveAllCustomLabelsFromSelfHostedRunnerForRepoError::Generic { code }.into()), } } } @@ -12621,19 +14246,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for remove_custom_label_from_self_hosted_runner_for_org](https://docs.github.com/rest/actions/self-hosted-runners#remove-a-custom-label-from-a-self-hosted-runner-for-an-organization) /// /// --- - pub async fn remove_custom_label_from_self_hosted_runner_for_org_async(&self, org: &str, runner_id: i32, name: &str) -> Result { + 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/runners/{}/labels/{}", super::GITHUB_BASE_API_URL, org, runner_id, name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12645,9 +14270,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status404(github_response.to_json_async().await?)), - 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status422(github_response.to_json_async().await?)), - code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Generic { code }), + 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status422(github_response.to_json_async().await?).into()), + code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -12670,7 +14295,7 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_custom_label_from_self_hosted_runner_for_org(&self, org: &str, runner_id: i32, name: &str) -> Result { + 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/runners/{}/labels/{}", super::GITHUB_BASE_API_URL, org, runner_id, name); @@ -12682,7 +14307,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12694,9 +14319,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status404(github_response.to_json()?)), - 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status422(github_response.to_json()?)), - code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Generic { code }), + 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status404(github_response.to_json()?).into()), + 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Status422(github_response.to_json()?).into()), + code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -12718,19 +14343,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for remove_custom_label_from_self_hosted_runner_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#remove-a-custom-label-from-a-self-hosted-runner-for-a-repository) /// /// --- - pub async fn remove_custom_label_from_self_hosted_runner_for_repo_async(&self, owner: &str, repo: &str, runner_id: i32, name: &str) -> Result { + 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/runners/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, runner_id, name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12742,9 +14367,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status404(github_response.to_json_async().await?)), - 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status422(github_response.to_json_async().await?)), - code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Generic { code }), + 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status422(github_response.to_json_async().await?).into()), + code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Generic { code }.into()), } } } @@ -12759,17 +14384,190 @@ impl<'api, C: Client> Actions<'api, C> { /// This endpoint returns a `404 Not Found` status if the custom label is not /// present on the runner. /// - /// Authenticated users must have admin access to the repository to use this endpoint. + /// Authenticated users must have admin access to the repository to use this endpoint. + /// + /// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + /// + /// [GitHub API docs for remove_custom_label_from_self_hosted_runner_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#remove-a-custom-label-from-a-self-hosted-runner-for-a-repository) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + 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 = 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() { + 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status404(github_response.to_json()?).into()), + 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status422(github_response.to_json()?).into()), + code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Remove repository access to a self-hosted runner group in an organization + /// + /// Removes a repository from the list of selected repositories that can access a self-hosted runner group. The runner group must have `visibility` set to `selected`. For more information, see "[Create a self-hosted runner group for an organization](#create-a-self-hosted-runner-group-for-an-organization)." + /// + /// OAuth app tokens and personal access tokens (classic) need 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/actions/self-hosted-runner-groups#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<(), AdapterError> { + + 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 = 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() { + code => Err(ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Remove repository access to a self-hosted runner group in an organization + /// + /// Removes a repository from the list of selected repositories that can access a self-hosted runner group. The runner group must have `visibility` set to `selected`. For more information, see "[Create a self-hosted runner group for an organization](#create-a-self-hosted-runner-group-for-an-organization)." + /// + /// OAuth app tokens and personal access tokens (classic) need 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/actions/self-hosted-runner-groups#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<(), AdapterError> { + + 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 = 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() { + code => Err(ActionsRemoveRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # 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/actions/secrets#create-or-update-an-organization-secret). + /// + /// Authenticated users must have collaborator access to a repository to create, update, or read secrets. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + /// + /// [GitHub API docs for remove_selected_repo_from_org_secret](https://docs.github.com/rest/actions/secrets#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<(), AdapterError> { + + 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 = 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() { + 409 => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Status409.into()), + code => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # 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/actions/secrets#create-or-update-an-organization-secret). + /// + /// Authenticated users must have collaborator access to a repository to create, update, or read secrets. /// - /// OAuth app tokens and personal access tokens (classic) need the `repo` scope to use this endpoint. + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. /// - /// [GitHub API docs for remove_custom_label_from_self_hosted_runner_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#remove-a-custom-label-from-a-self-hosted-runner-for-a-repository) + /// [GitHub API docs for remove_selected_repo_from_org_secret](https://docs.github.com/rest/actions/secrets#remove-selected-repository-from-an-organization-secret) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_custom_label_from_self_hosted_runner_for_repo(&self, owner: &str, repo: &str, runner_id: i32, name: &str) -> Result { + pub fn remove_selected_repo_from_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { - let request_uri = format!("{}/repos/{}/{}/actions/runners/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, runner_id, name); + let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); let req = GitHubRequest { @@ -12779,7 +14577,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12791,41 +14589,40 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status404(github_response.to_json()?)), - 422 => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Status422(github_response.to_json()?)), - code => Err(ActionsRemoveCustomLabelFromSelfHostedRunnerForRepoError::Generic { code }), + 409 => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Status409.into()), + code => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Generic { code }.into()), } } } /// --- /// - /// # Remove selected repository from an organization secret + /// # Remove selected repository from an organization variable /// - /// Removes a repository from an organization secret when the `visibility` - /// for repository access is set to `selected`. The visibility is set when you [Create - /// or update an organization secret](https://docs.github.com/rest/actions/secrets#create-or-update-an-organization-secret). + /// Removes a repository from an organization variable that is + /// available to selected repositories. Organization variables that are available to + /// selected repositories have their `visibility` field set to `selected`. /// - /// Authenticated users must have collaborator access to a repository to create, update, or read secrets. + /// Authenticated users must have collaborator access to a repository to create, update, or read variables. /// /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. /// - /// [GitHub API docs for remove_selected_repo_from_org_secret](https://docs.github.com/rest/actions/secrets#remove-selected-repository-from-an-organization-secret) + /// [GitHub API docs for remove_selected_repo_from_org_variable](https://docs.github.com/rest/actions/variables#remove-selected-repository-from-an-organization-variable) /// /// --- - 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_selected_repo_from_org_variable_async(&self, org: &str, name: &str, repository_id: i32) -> Result<(), AdapterError> { - let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); + let request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, name, repository_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12837,31 +14634,31 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Status409), - code => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Generic { code }), + 409 => Err(ActionsRemoveSelectedRepoFromOrgVariableError::Status409.into()), + code => Err(ActionsRemoveSelectedRepoFromOrgVariableError::Generic { code }.into()), } } } /// --- /// - /// # Remove selected repository from an organization secret + /// # Remove selected repository from an organization variable /// - /// Removes a repository from an organization secret when the `visibility` - /// for repository access is set to `selected`. The visibility is set when you [Create - /// or update an organization secret](https://docs.github.com/rest/actions/secrets#create-or-update-an-organization-secret). + /// Removes a repository from an organization variable that is + /// available to selected repositories. Organization variables that are available to + /// selected repositories have their `visibility` field set to `selected`. /// - /// Authenticated users must have collaborator access to a repository to create, update, or read secrets. + /// Authenticated users must have collaborator access to a repository to create, update, or read variables. /// /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. /// - /// [GitHub API docs for remove_selected_repo_from_org_secret](https://docs.github.com/rest/actions/secrets#remove-selected-repository-from-an-organization-secret) + /// [GitHub API docs for remove_selected_repo_from_org_variable](https://docs.github.com/rest/actions/variables#remove-selected-repository-from-an-organization-variable) /// /// --- #[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_selected_repo_from_org_variable(&self, org: &str, name: &str, repository_id: i32) -> Result<(), AdapterError> { - let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); + let request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, name, repository_id); let req = GitHubRequest { @@ -12871,7 +14668,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12883,40 +14680,36 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Status409), - code => Err(ActionsRemoveSelectedRepoFromOrgSecretError::Generic { code }), + 409 => Err(ActionsRemoveSelectedRepoFromOrgVariableError::Status409.into()), + code => Err(ActionsRemoveSelectedRepoFromOrgVariableError::Generic { code }.into()), } } } /// --- /// - /// # Remove selected repository from an organization variable + /// # Remove a self-hosted runner from a group for an organization /// - /// Removes a repository from an organization variable that is - /// available to selected repositories. Organization variables that are available to - /// selected repositories have their `visibility` field set to `selected`. + /// Removes a self-hosted runner from a group configured in an organization. The runner is then returned to the default group. /// - /// Authenticated users must have collaborator access to a repository to create, update, or read variables. - /// - /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for remove_selected_repo_from_org_variable](https://docs.github.com/rest/actions/variables#remove-selected-repository-from-an-organization-variable) + /// [GitHub API docs for remove_self_hosted_runner_from_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#remove-a-self-hosted-runner-from-a-group-for-an-organization) /// /// --- - pub async fn remove_selected_repo_from_org_variable_async(&self, org: &str, name: &str, repository_id: i32) -> Result<(), ActionsRemoveSelectedRepoFromOrgVariableError> { + pub async fn remove_self_hosted_runner_from_group_for_org_async(&self, org: &str, runner_group_id: i32, runner_id: i32) -> Result<(), AdapterError> { - let request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, name, repository_id); + 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, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12928,31 +14721,26 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ActionsRemoveSelectedRepoFromOrgVariableError::Status409), - code => Err(ActionsRemoveSelectedRepoFromOrgVariableError::Generic { code }), + code => Err(ActionsRemoveSelfHostedRunnerFromGroupForOrgError::Generic { code }.into()), } } } /// --- /// - /// # Remove selected repository from an organization variable + /// # Remove a self-hosted runner from a group for an organization /// - /// Removes a repository from an organization variable that is - /// available to selected repositories. Organization variables that are available to - /// selected repositories have their `visibility` field set to `selected`. - /// - /// Authenticated users must have collaborator access to a repository to create, update, or read variables. + /// Removes a self-hosted runner from a group configured in an organization. The runner is then returned to the default group. /// - /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. If the repository is private, the `repo` scope is also required. + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. /// - /// [GitHub API docs for remove_selected_repo_from_org_variable](https://docs.github.com/rest/actions/variables#remove-selected-repository-from-an-organization-variable) + /// [GitHub API docs for remove_self_hosted_runner_from_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#remove-a-self-hosted-runner-from-a-group-for-an-organization) /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_selected_repo_from_org_variable(&self, org: &str, name: &str, repository_id: i32) -> Result<(), ActionsRemoveSelectedRepoFromOrgVariableError> { + pub fn remove_self_hosted_runner_from_group_for_org(&self, org: &str, runner_group_id: i32, runner_id: i32) -> Result<(), AdapterError> { - let request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, name, repository_id); + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners/{}", super::GITHUB_BASE_API_URL, org, runner_group_id, runner_id); let req = GitHubRequest { @@ -12962,7 +14750,7 @@ impl<'api, C: Client> Actions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12974,8 +14762,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ActionsRemoveSelectedRepoFromOrgVariableError::Status409), - code => Err(ActionsRemoveSelectedRepoFromOrgVariableError::Generic { code }), + code => Err(ActionsRemoveSelfHostedRunnerFromGroupForOrgError::Generic { code }.into()), } } } @@ -12994,19 +14781,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for review_custom_gates_for_run](https://docs.github.com/rest/actions/workflow-runs#review-custom-deployment-protection-rules-for-a-workflow-run) /// /// --- - pub async fn review_custom_gates_for_run_async(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReviewCustomGatesForRun) -> Result<(), ActionsReviewCustomGatesForRunError> { + pub async fn review_custom_gates_for_run_async(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReviewCustomGatesForRun) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/deployment_protection_rule", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsReviewCustomGatesForRun::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13018,7 +14805,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsReviewCustomGatesForRunError::Generic { code }), + code => Err(ActionsReviewCustomGatesForRunError::Generic { code }.into()), } } } @@ -13038,19 +14825,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn review_custom_gates_for_run(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReviewCustomGatesForRun) -> Result<(), ActionsReviewCustomGatesForRunError> { + pub fn review_custom_gates_for_run(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReviewCustomGatesForRun) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/runs/{}/deployment_protection_rule", super::GITHUB_BASE_API_URL, owner, repo, run_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostActionsReviewCustomGatesForRun::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13062,7 +14849,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsReviewCustomGatesForRunError::Generic { code }), + code => Err(ActionsReviewCustomGatesForRunError::Generic { code }.into()), } } } @@ -13080,19 +14867,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for review_pending_deployments_for_run](https://docs.github.com/rest/actions/workflow-runs#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> { + pub async fn review_pending_deployments_for_run_async(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReviewPendingDeploymentsForRun) -> Result, AdapterError> { 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)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13104,7 +14891,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsReviewPendingDeploymentsForRunError::Generic { code }), + code => Err(ActionsReviewPendingDeploymentsForRunError::Generic { code }.into()), } } } @@ -13123,19 +14910,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[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 review_pending_deployments_for_run(&self, owner: &str, repo: &str, run_id: i32, body: PostActionsReviewPendingDeploymentsForRun) -> Result, AdapterError> { 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)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13147,7 +14934,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsReviewPendingDeploymentsForRunError::Generic { code }), + code => Err(ActionsReviewPendingDeploymentsForRunError::Generic { code }.into()), } } } @@ -13163,19 +14950,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_allowed_actions_organization](https://docs.github.com/rest/actions/permissions#set-allowed-actions-and-reusable-workflows-for-an-organization) /// /// --- - pub async fn set_allowed_actions_organization_async(&self, org: &str, body: PutActionsSetAllowedActionsRepository) -> Result<(), ActionsSetAllowedActionsOrganizationError> { + pub async fn set_allowed_actions_organization_async(&self, org: &str, body: PutActionsSetAllowedActionsRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions/selected-actions", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetAllowedActionsRepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13187,7 +14974,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsSetAllowedActionsOrganizationError::Generic { code }), + code => Err(ActionsSetAllowedActionsOrganizationError::Generic { code }.into()), } } } @@ -13204,19 +14991,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_allowed_actions_organization(&self, org: &str, body: PutActionsSetAllowedActionsRepository) -> Result<(), ActionsSetAllowedActionsOrganizationError> { + pub fn set_allowed_actions_organization(&self, org: &str, body: PutActionsSetAllowedActionsRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions/selected-actions", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetAllowedActionsRepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13228,7 +15015,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsSetAllowedActionsOrganizationError::Generic { code }), + code => Err(ActionsSetAllowedActionsOrganizationError::Generic { code }.into()), } } } @@ -13244,19 +15031,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_allowed_actions_repository](https://docs.github.com/rest/actions/permissions#set-allowed-actions-and-reusable-workflows-for-a-repository) /// /// --- - pub async fn set_allowed_actions_repository_async(&self, owner: &str, repo: &str, body: PutActionsSetAllowedActionsRepository) -> Result<(), ActionsSetAllowedActionsRepositoryError> { + pub async fn set_allowed_actions_repository_async(&self, owner: &str, repo: &str, body: PutActionsSetAllowedActionsRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/permissions/selected-actions", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetAllowedActionsRepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13268,7 +15055,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsSetAllowedActionsRepositoryError::Generic { code }), + code => Err(ActionsSetAllowedActionsRepositoryError::Generic { code }.into()), } } } @@ -13285,19 +15072,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_allowed_actions_repository(&self, owner: &str, repo: &str, body: PutActionsSetAllowedActionsRepository) -> Result<(), ActionsSetAllowedActionsRepositoryError> { + pub fn set_allowed_actions_repository(&self, owner: &str, repo: &str, body: PutActionsSetAllowedActionsRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/permissions/selected-actions", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetAllowedActionsRepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13309,7 +15096,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsSetAllowedActionsRepositoryError::Generic { code }), + code => Err(ActionsSetAllowedActionsRepositoryError::Generic { code }.into()), } } } @@ -13328,19 +15115,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_custom_labels_for_self_hosted_runner_for_org](https://docs.github.com/rest/actions/self-hosted-runners#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 { + 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)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13352,9 +15139,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status404(github_response.to_json_async().await?)), - 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status422(github_response.to_json_async().await?)), - code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Generic { code }), + 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status422(github_response.to_json_async().await?).into()), + code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -13374,19 +15161,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[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 { + 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)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13398,9 +15185,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status404(github_response.to_json()?)), - 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status422(github_response.to_json()?)), - code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Generic { code }), + 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status404(github_response.to_json()?).into()), + 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Status422(github_response.to_json()?).into()), + code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForOrgError::Generic { code }.into()), } } } @@ -13419,19 +15206,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_custom_labels_for_self_hosted_runner_for_repo](https://docs.github.com/rest/actions/self-hosted-runners#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 { + 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)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13443,9 +15230,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status404(github_response.to_json_async().await?)), - 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status422(github_response.to_json_async().await?)), - code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Generic { code }), + 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status422(github_response.to_json_async().await?).into()), + code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Generic { code }.into()), } } } @@ -13465,19 +15252,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[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 { + 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)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13489,9 +15276,9 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status404(github_response.to_json()?)), - 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status422(github_response.to_json()?)), - code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Generic { code }), + 404 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status404(github_response.to_json()?).into()), + 422 => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Status422(github_response.to_json()?).into()), + code => Err(ActionsSetCustomLabelsForSelfHostedRunnerForRepoError::Generic { code }.into()), } } } @@ -13507,19 +15294,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_custom_oidc_sub_claim_for_repo](https://docs.github.com/rest/actions/oidc#set-the-customization-template-for-an-oidc-subject-claim-for-a-repository) /// /// --- - pub async fn set_custom_oidc_sub_claim_for_repo_async(&self, owner: &str, repo: &str, body: ActionsOidcSubjectCustomizationForARepository) -> Result { + pub async fn set_custom_oidc_sub_claim_for_repo_async(&self, owner: &str, repo: &str, body: ActionsOidcSubjectCustomizationForARepository) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/oidc/customization/sub", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(ActionsOidcSubjectCustomizationForARepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13531,10 +15318,10 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status404(github_response.to_json_async().await?)), - 400 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status400(github_response.to_json_async().await?)), - 422 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status422(github_response.to_json_async().await?)), - code => Err(ActionsSetCustomOidcSubClaimForRepoError::Generic { code }), + 404 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status404(github_response.to_json_async().await?).into()), + 400 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status422(github_response.to_json_async().await?).into()), + code => Err(ActionsSetCustomOidcSubClaimForRepoError::Generic { code }.into()), } } } @@ -13551,19 +15338,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_custom_oidc_sub_claim_for_repo(&self, owner: &str, repo: &str, body: ActionsOidcSubjectCustomizationForARepository) -> Result { + pub fn set_custom_oidc_sub_claim_for_repo(&self, owner: &str, repo: &str, body: ActionsOidcSubjectCustomizationForARepository) -> Result { let request_uri = format!("{}/repos/{}/{}/actions/oidc/customization/sub", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(ActionsOidcSubjectCustomizationForARepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13575,10 +15362,10 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status404(github_response.to_json()?)), - 400 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status400(github_response.to_json()?)), - 422 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status422(github_response.to_json()?)), - code => Err(ActionsSetCustomOidcSubClaimForRepoError::Generic { code }), + 404 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status404(github_response.to_json()?).into()), + 400 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status400(github_response.to_json()?).into()), + 422 => Err(ActionsSetCustomOidcSubClaimForRepoError::Status422(github_response.to_json()?).into()), + code => Err(ActionsSetCustomOidcSubClaimForRepoError::Generic { code }.into()), } } } @@ -13596,19 +15383,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_github_actions_default_workflow_permissions_organization](https://docs.github.com/rest/actions/permissions#set-default-workflow-permissions-for-an-organization) /// /// --- - pub async fn set_github_actions_default_workflow_permissions_organization_async(&self, org: &str, body: PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository) -> Result<(), ActionsSetGithubActionsDefaultWorkflowPermissionsOrganizationError> { + pub async fn set_github_actions_default_workflow_permissions_organization_async(&self, org: &str, body: PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions/workflow", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13620,7 +15407,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsOrganizationError::Generic { code }), + code => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsOrganizationError::Generic { code }.into()), } } } @@ -13639,19 +15426,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_github_actions_default_workflow_permissions_organization(&self, org: &str, body: PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository) -> Result<(), ActionsSetGithubActionsDefaultWorkflowPermissionsOrganizationError> { + pub fn set_github_actions_default_workflow_permissions_organization(&self, org: &str, body: PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions/workflow", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13663,7 +15450,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsOrganizationError::Generic { code }), + code => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsOrganizationError::Generic { code }.into()), } } } @@ -13681,19 +15468,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_github_actions_default_workflow_permissions_repository](https://docs.github.com/rest/actions/permissions#set-default-workflow-permissions-for-a-repository) /// /// --- - pub async fn set_github_actions_default_workflow_permissions_repository_async(&self, owner: &str, repo: &str, body: PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository) -> Result<(), ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError> { + pub async fn set_github_actions_default_workflow_permissions_repository_async(&self, owner: &str, repo: &str, body: PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/permissions/workflow", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13705,8 +15492,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError::Status409), - code => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError::Generic { code }), + 409 => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError::Status409.into()), + code => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError::Generic { code }.into()), } } } @@ -13725,19 +15512,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_github_actions_default_workflow_permissions_repository(&self, owner: &str, repo: &str, body: PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository) -> Result<(), ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError> { + pub fn set_github_actions_default_workflow_permissions_repository(&self, owner: &str, repo: &str, body: PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/permissions/workflow", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetGithubActionsDefaultWorkflowPermissionsRepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13749,8 +15536,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError::Status409), - code => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError::Generic { code }), + 409 => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError::Status409.into()), + code => Err(ActionsSetGithubActionsDefaultWorkflowPermissionsRepositoryError::Generic { code }.into()), } } } @@ -13766,19 +15553,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_github_actions_permissions_organization](https://docs.github.com/rest/actions/permissions#set-github-actions-permissions-for-an-organization) /// /// --- - pub async fn set_github_actions_permissions_organization_async(&self, org: &str, body: PutActionsSetGithubActionsPermissionsOrganization) -> Result<(), ActionsSetGithubActionsPermissionsOrganizationError> { + pub async fn set_github_actions_permissions_organization_async(&self, org: &str, body: PutActionsSetGithubActionsPermissionsOrganization) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetGithubActionsPermissionsOrganization::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13790,7 +15577,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsSetGithubActionsPermissionsOrganizationError::Generic { code }), + code => Err(ActionsSetGithubActionsPermissionsOrganizationError::Generic { code }.into()), } } } @@ -13807,19 +15594,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_github_actions_permissions_organization(&self, org: &str, body: PutActionsSetGithubActionsPermissionsOrganization) -> Result<(), ActionsSetGithubActionsPermissionsOrganizationError> { + pub fn set_github_actions_permissions_organization(&self, org: &str, body: PutActionsSetGithubActionsPermissionsOrganization) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetGithubActionsPermissionsOrganization::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13831,7 +15618,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsSetGithubActionsPermissionsOrganizationError::Generic { code }), + code => Err(ActionsSetGithubActionsPermissionsOrganizationError::Generic { code }.into()), } } } @@ -13847,19 +15634,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_github_actions_permissions_repository](https://docs.github.com/rest/actions/permissions#set-github-actions-permissions-for-a-repository) /// /// --- - pub async fn set_github_actions_permissions_repository_async(&self, owner: &str, repo: &str, body: PutActionsSetGithubActionsPermissionsRepository) -> Result<(), ActionsSetGithubActionsPermissionsRepositoryError> { + pub async fn set_github_actions_permissions_repository_async(&self, owner: &str, repo: &str, body: PutActionsSetGithubActionsPermissionsRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/permissions", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetGithubActionsPermissionsRepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13871,7 +15658,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsSetGithubActionsPermissionsRepositoryError::Generic { code }), + code => Err(ActionsSetGithubActionsPermissionsRepositoryError::Generic { code }.into()), } } } @@ -13888,19 +15675,100 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_github_actions_permissions_repository(&self, owner: &str, repo: &str, body: PutActionsSetGithubActionsPermissionsRepository) -> Result<(), ActionsSetGithubActionsPermissionsRepositoryError> { + pub fn set_github_actions_permissions_repository(&self, owner: &str, repo: &str, body: PutActionsSetGithubActionsPermissionsRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/permissions", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetGithubActionsPermissionsRepository::from_json(body)?), + body: Some(C::from_json::(body)?), + method: "PUT", + 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() { + code => Err(ActionsSetGithubActionsPermissionsRepositoryError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Set repository access for a self-hosted runner group in an organization + /// + /// Replaces the list of repositories that have access to a self-hosted runner group configured in an organization. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for set_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#set-repository-access-for-a-self-hosted-runner-group-in-an-organization) + /// + /// --- + pub async fn set_repo_access_to_self_hosted_runner_group_in_org_async(&self, org: &str, runner_group_id: i32, body: PutActionsSetRepoAccessToSelfHostedRunnerGroupInOrg) -> Result<(), AdapterError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories", super::GITHUB_BASE_API_URL, org, runner_group_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(C::from_json::(body)?), + method: "PUT", + 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() { + code => Err(ActionsSetRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Set repository access for a self-hosted runner group in an organization + /// + /// Replaces the list of repositories that have access to a self-hosted runner group configured in an organization. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for set_repo_access_to_self_hosted_runner_group_in_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#set-repository-access-for-a-self-hosted-runner-group-in-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn set_repo_access_to_self_hosted_runner_group_in_org(&self, org: &str, runner_group_id: i32, body: PutActionsSetRepoAccessToSelfHostedRunnerGroupInOrg) -> Result<(), AdapterError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/repositories", super::GITHUB_BASE_API_URL, org, runner_group_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13912,7 +15780,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsSetGithubActionsPermissionsRepositoryError::Generic { code }), + code => Err(ActionsSetRepoAccessToSelfHostedRunnerGroupInOrgError::Generic { code }.into()), } } } @@ -13932,19 +15800,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_selected_repos_for_org_secret](https://docs.github.com/rest/actions/secrets#set-selected-repositories-for-an-organization-secret) /// /// --- - pub async fn set_selected_repos_for_org_secret_async(&self, org: &str, secret_name: &str, body: PutActionsSetSelectedReposForOrgSecret) -> Result<(), ActionsSetSelectedReposForOrgSecretError> { + pub async fn set_selected_repos_for_org_secret_async(&self, org: &str, secret_name: &str, body: PutActionsSetSelectedReposForOrgSecret) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetSelectedReposForOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13956,7 +15824,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsSetSelectedReposForOrgSecretError::Generic { code }), + code => Err(ActionsSetSelectedReposForOrgSecretError::Generic { code }.into()), } } } @@ -13977,19 +15845,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_selected_repos_for_org_secret(&self, org: &str, secret_name: &str, body: PutActionsSetSelectedReposForOrgSecret) -> Result<(), ActionsSetSelectedReposForOrgSecretError> { + pub fn set_selected_repos_for_org_secret(&self, org: &str, secret_name: &str, body: PutActionsSetSelectedReposForOrgSecret) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetSelectedReposForOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14001,7 +15869,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsSetSelectedReposForOrgSecretError::Generic { code }), + code => Err(ActionsSetSelectedReposForOrgSecretError::Generic { code }.into()), } } } @@ -14021,19 +15889,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_selected_repos_for_org_variable](https://docs.github.com/rest/actions/variables#set-selected-repositories-for-an-organization-variable) /// /// --- - pub async fn set_selected_repos_for_org_variable_async(&self, org: &str, name: &str, body: PutActionsSetSelectedReposForOrgVariable) -> Result<(), ActionsSetSelectedReposForOrgVariableError> { + pub async fn set_selected_repos_for_org_variable_async(&self, org: &str, name: &str, body: PutActionsSetSelectedReposForOrgVariable) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories", super::GITHUB_BASE_API_URL, org, name); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetSelectedReposForOrgVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14045,8 +15913,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ActionsSetSelectedReposForOrgVariableError::Status409), - code => Err(ActionsSetSelectedReposForOrgVariableError::Generic { code }), + 409 => Err(ActionsSetSelectedReposForOrgVariableError::Status409.into()), + code => Err(ActionsSetSelectedReposForOrgVariableError::Generic { code }.into()), } } } @@ -14067,19 +15935,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_selected_repos_for_org_variable(&self, org: &str, name: &str, body: PutActionsSetSelectedReposForOrgVariable) -> Result<(), ActionsSetSelectedReposForOrgVariableError> { + pub fn set_selected_repos_for_org_variable(&self, org: &str, name: &str, body: PutActionsSetSelectedReposForOrgVariable) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/variables/{}/repositories", super::GITHUB_BASE_API_URL, org, name); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetSelectedReposForOrgVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14091,8 +15959,8 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ActionsSetSelectedReposForOrgVariableError::Status409), - code => Err(ActionsSetSelectedReposForOrgVariableError::Generic { code }), + 409 => Err(ActionsSetSelectedReposForOrgVariableError::Status409.into()), + code => Err(ActionsSetSelectedReposForOrgVariableError::Generic { code }.into()), } } } @@ -14109,19 +15977,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_selected_repositories_enabled_github_actions_organization](https://docs.github.com/rest/actions/permissions#set-selected-repositories-enabled-for-github-actions-in-an-organization) /// /// --- - pub async fn set_selected_repositories_enabled_github_actions_organization_async(&self, org: &str, body: PutActionsSetSelectedRepositoriesEnabledGithubActionsOrganization) -> Result<(), ActionsSetSelectedRepositoriesEnabledGithubActionsOrganizationError> { + pub async fn set_selected_repositories_enabled_github_actions_organization_async(&self, org: &str, body: PutActionsSetSelectedRepositoriesEnabledGithubActionsOrganization) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions/repositories", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetSelectedRepositoriesEnabledGithubActionsOrganization::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14133,7 +16001,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsSetSelectedRepositoriesEnabledGithubActionsOrganizationError::Generic { code }), + code => Err(ActionsSetSelectedRepositoriesEnabledGithubActionsOrganizationError::Generic { code }.into()), } } } @@ -14151,19 +16019,100 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_selected_repositories_enabled_github_actions_organization(&self, org: &str, body: PutActionsSetSelectedRepositoriesEnabledGithubActionsOrganization) -> Result<(), ActionsSetSelectedRepositoriesEnabledGithubActionsOrganizationError> { + pub fn set_selected_repositories_enabled_github_actions_organization(&self, org: &str, body: PutActionsSetSelectedRepositoriesEnabledGithubActionsOrganization) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/permissions/repositories", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutActionsSetSelectedRepositoriesEnabledGithubActionsOrganization::from_json(body)?), + body: Some(C::from_json::(body)?), + method: "PUT", + 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() { + code => Err(ActionsSetSelectedRepositoriesEnabledGithubActionsOrganizationError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Set self-hosted runners in a group for an organization + /// + /// Replaces the list of self-hosted runners that are part of an organization runner group. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for set_self_hosted_runners_in_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#set-self-hosted-runners-in-a-group-for-an-organization) + /// + /// --- + pub async fn set_self_hosted_runners_in_group_for_org_async(&self, org: &str, runner_group_id: i32, body: PutActionsSetSelfHostedRunnersInGroupForOrg) -> Result<(), AdapterError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners", super::GITHUB_BASE_API_URL, org, runner_group_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(C::from_json::(body)?), + method: "PUT", + 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() { + code => Err(ActionsSetSelfHostedRunnersInGroupForOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Set self-hosted runners in a group for an organization + /// + /// Replaces the list of self-hosted runners that are part of an organization runner group. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for set_self_hosted_runners_in_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#set-self-hosted-runners-in-a-group-for-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn set_self_hosted_runners_in_group_for_org(&self, org: &str, runner_group_id: i32, body: PutActionsSetSelfHostedRunnersInGroupForOrg) -> Result<(), AdapterError> { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}/runners", super::GITHUB_BASE_API_URL, org, runner_group_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14175,7 +16124,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsSetSelectedRepositoriesEnabledGithubActionsOrganizationError::Generic { code }), + code => Err(ActionsSetSelfHostedRunnersInGroupForOrgError::Generic { code }.into()), } } } @@ -14193,19 +16142,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for set_workflow_access_to_repository](https://docs.github.com/rest/actions/permissions#set-the-level-of-access-for-workflows-outside-of-the-repository) /// /// --- - pub async fn set_workflow_access_to_repository_async(&self, owner: &str, repo: &str, body: ActionsWorkflowAccessToRepository) -> Result<(), ActionsSetWorkflowAccessToRepositoryError> { + pub async fn set_workflow_access_to_repository_async(&self, owner: &str, repo: &str, body: ActionsWorkflowAccessToRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/permissions/access", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(ActionsWorkflowAccessToRepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14217,7 +16166,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsSetWorkflowAccessToRepositoryError::Generic { code }), + code => Err(ActionsSetWorkflowAccessToRepositoryError::Generic { code }.into()), } } } @@ -14236,19 +16185,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_workflow_access_to_repository(&self, owner: &str, repo: &str, body: ActionsWorkflowAccessToRepository) -> Result<(), ActionsSetWorkflowAccessToRepositoryError> { + pub fn set_workflow_access_to_repository(&self, owner: &str, repo: &str, body: ActionsWorkflowAccessToRepository) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/permissions/access", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(ActionsWorkflowAccessToRepository::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14260,7 +16209,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsSetWorkflowAccessToRepositoryError::Generic { code }), + code => Err(ActionsSetWorkflowAccessToRepositoryError::Generic { code }.into()), } } } @@ -14278,19 +16227,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for update_environment_variable](https://docs.github.com/rest/actions/variables#update-an-environment-variable) /// /// --- - pub async fn update_environment_variable_async(&self, owner: &str, repo: &str, name: &str, environment_name: &str, body: PatchActionsUpdateEnvironmentVariable) -> Result<(), ActionsUpdateEnvironmentVariableError> { + pub async fn update_environment_variable_async(&self, owner: &str, repo: &str, name: &str, environment_name: &str, body: PatchActionsUpdateEnvironmentVariable) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, name, environment_name); let req = GitHubRequest { uri: request_uri, - body: Some(PatchActionsUpdateEnvironmentVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14302,7 +16251,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsUpdateEnvironmentVariableError::Generic { code }), + code => Err(ActionsUpdateEnvironmentVariableError::Generic { code }.into()), } } } @@ -14321,19 +16270,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_environment_variable(&self, owner: &str, repo: &str, name: &str, environment_name: &str, body: PatchActionsUpdateEnvironmentVariable) -> Result<(), ActionsUpdateEnvironmentVariableError> { + pub fn update_environment_variable(&self, owner: &str, repo: &str, name: &str, environment_name: &str, body: PatchActionsUpdateEnvironmentVariable) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, name, environment_name); let req = GitHubRequest { uri: request_uri, - body: Some(PatchActionsUpdateEnvironmentVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14345,7 +16294,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsUpdateEnvironmentVariableError::Generic { code }), + code => Err(ActionsUpdateEnvironmentVariableError::Generic { code }.into()), } } } @@ -14363,19 +16312,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for update_org_variable](https://docs.github.com/rest/actions/variables#update-an-organization-variable) /// /// --- - pub async fn update_org_variable_async(&self, org: &str, name: &str, body: PatchActionsUpdateOrgVariable) -> Result<(), ActionsUpdateOrgVariableError> { + pub async fn update_org_variable_async(&self, org: &str, name: &str, body: PatchActionsUpdateOrgVariable) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, org, name); let req = GitHubRequest { uri: request_uri, - body: Some(PatchActionsUpdateOrgVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14387,7 +16336,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsUpdateOrgVariableError::Generic { code }), + code => Err(ActionsUpdateOrgVariableError::Generic { code }.into()), } } } @@ -14406,19 +16355,19 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_org_variable(&self, org: &str, name: &str, body: PatchActionsUpdateOrgVariable) -> Result<(), ActionsUpdateOrgVariableError> { + pub fn update_org_variable(&self, org: &str, name: &str, body: PatchActionsUpdateOrgVariable) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, org, name); let req = GitHubRequest { uri: request_uri, - body: Some(PatchActionsUpdateOrgVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14430,7 +16379,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsUpdateOrgVariableError::Generic { code }), + code => Err(ActionsUpdateOrgVariableError::Generic { code }.into()), } } } @@ -14448,19 +16397,19 @@ impl<'api, C: Client> Actions<'api, C> { /// [GitHub API docs for update_repo_variable](https://docs.github.com/rest/actions/variables#update-a-repository-variable) /// /// --- - pub async fn update_repo_variable_async(&self, owner: &str, repo: &str, name: &str, body: PatchActionsUpdateRepoVariable) -> Result<(), ActionsUpdateRepoVariableError> { + pub async fn update_repo_variable_async(&self, owner: &str, repo: &str, name: &str, body: PatchActionsUpdateRepoVariable) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, name); let req = GitHubRequest { uri: request_uri, - body: Some(PatchActionsUpdateRepoVariable::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14472,7 +16421,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActionsUpdateRepoVariableError::Generic { code }), + code => Err(ActionsUpdateRepoVariableError::Generic { code }.into()), } } } @@ -14491,19 +16440,100 @@ impl<'api, C: Client> Actions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_repo_variable(&self, owner: &str, repo: &str, name: &str, body: PatchActionsUpdateRepoVariable) -> Result<(), ActionsUpdateRepoVariableError> { + pub fn update_repo_variable(&self, owner: &str, repo: &str, name: &str, body: PatchActionsUpdateRepoVariable) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/actions/variables/{}", super::GITHUB_BASE_API_URL, owner, repo, name); let req = GitHubRequest { uri: request_uri, - body: Some(PatchActionsUpdateRepoVariable::from_json(body)?), + body: Some(C::from_json::(body)?), + method: "PATCH", + 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() { + code => Err(ActionsUpdateRepoVariableError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Update a self-hosted runner group for an organization + /// + /// Updates the `name` and `visibility` of a self-hosted runner group in an organization. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for update_self_hosted_runner_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#update-a-self-hosted-runner-group-for-an-organization) + /// + /// --- + pub async fn update_self_hosted_runner_group_for_org_async(&self, org: &str, runner_group_id: i32, body: PatchActionsUpdateSelfHostedRunnerGroupForOrg) -> Result { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}", super::GITHUB_BASE_API_URL, org, runner_group_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(C::from_json::(body)?), + method: "PATCH", + 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() { + code => Err(ActionsUpdateSelfHostedRunnerGroupForOrgError::Generic { code }.into()), + } + } + } + + /// --- + /// + /// # Update a self-hosted runner group for an organization + /// + /// Updates the `name` and `visibility` of a self-hosted runner group in an organization. + /// + /// OAuth app tokens and personal access tokens (classic) need the `admin:org` scope to use this endpoint. + /// + /// [GitHub API docs for update_self_hosted_runner_group_for_org](https://docs.github.com/rest/actions/self-hosted-runner-groups#update-a-self-hosted-runner-group-for-an-organization) + /// + /// --- + #[cfg(not(target_arch = "wasm32"))] + pub fn update_self_hosted_runner_group_for_org(&self, org: &str, runner_group_id: i32, body: PatchActionsUpdateSelfHostedRunnerGroupForOrg) -> Result { + + let request_uri = format!("{}/orgs/{}/actions/runner-groups/{}", super::GITHUB_BASE_API_URL, org, runner_group_id); + + + let req = GitHubRequest { + uri: request_uri, + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14515,7 +16545,7 @@ impl<'api, C: Client> Actions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActionsUpdateRepoVariableError::Generic { code }), + code => Err(ActionsUpdateSelfHostedRunnerGroupForOrgError::Generic { code }.into()), } } } diff --git a/src/endpoints/activity.rs b/src/endpoints/activity.rs index 17d7ac8..5a274f0 100644 --- a/src/endpoints/activity.rs +++ b/src/endpoints/activity.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Activity<'api, C: Client> { +pub struct Activity<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Activity { +pub fn new(client: &C) -> Activity where AdapterError: From<::Err> { Activity { client } } /// Errors for the [Check if a repository is starred by the authenticated user](Activity::check_repo_is_starred_by_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityCheckRepoIsStarredByAuthenticatedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if this repository is not starred by you")] Status404(BasicError), #[error("Requires authentication")] @@ -55,36 +45,48 @@ pub enum ActivityCheckRepoIsStarredByAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityCheckRepoIsStarredByAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ActivityCheckRepoIsStarredByAuthenticatedUserError::Status404(_) => (String::from("Not Found if this repository is not starred by you"), 404), + ActivityCheckRepoIsStarredByAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + ActivityCheckRepoIsStarredByAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ActivityCheckRepoIsStarredByAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ActivityCheckRepoIsStarredByAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a repository subscription](Activity::delete_repo_subscription_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityDeleteRepoSubscriptionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityDeleteRepoSubscriptionError) -> Self { + let (description, status_code) = match err { + ActivityDeleteRepoSubscriptionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a thread subscription](Activity::delete_thread_subscription_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityDeleteThreadSubscriptionError { - #[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("Forbidden")] @@ -95,36 +97,47 @@ pub enum ActivityDeleteThreadSubscriptionError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityDeleteThreadSubscriptionError) -> Self { + let (description, status_code) = match err { + ActivityDeleteThreadSubscriptionError::Status304 => (String::from("Not modified"), 304), + ActivityDeleteThreadSubscriptionError::Status403(_) => (String::from("Forbidden"), 403), + ActivityDeleteThreadSubscriptionError::Status401(_) => (String::from("Requires authentication"), 401), + ActivityDeleteThreadSubscriptionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get feeds](Activity::get_feeds_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityGetFeedsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityGetFeedsError) -> Self { + let (description, status_code) = match err { + ActivityGetFeedsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository subscription](Activity::get_repo_subscription_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityGetRepoSubscriptionError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if you don't subscribe to the repository")] Status404, #[error("Forbidden")] @@ -133,19 +146,25 @@ pub enum ActivityGetRepoSubscriptionError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityGetRepoSubscriptionError) -> Self { + let (description, status_code) = match err { + ActivityGetRepoSubscriptionError::Status404 => (String::from("Not Found if you don't subscribe to the repository"), 404), + ActivityGetRepoSubscriptionError::Status403(_) => (String::from("Forbidden"), 403), + ActivityGetRepoSubscriptionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a thread](Activity::get_thread_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityGetThreadError { - #[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("Forbidden")] @@ -156,19 +175,26 @@ pub enum ActivityGetThreadError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityGetThreadError) -> Self { + let (description, status_code) = match err { + ActivityGetThreadError::Status304 => (String::from("Not modified"), 304), + ActivityGetThreadError::Status403(_) => (String::from("Forbidden"), 403), + ActivityGetThreadError::Status401(_) => (String::from("Requires authentication"), 401), + ActivityGetThreadError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a thread subscription for the authenticated user](Activity::get_thread_subscription_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityGetThreadSubscriptionForAuthenticatedUserError { - #[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("Forbidden")] @@ -179,36 +205,47 @@ pub enum ActivityGetThreadSubscriptionForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityGetThreadSubscriptionForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ActivityGetThreadSubscriptionForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ActivityGetThreadSubscriptionForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ActivityGetThreadSubscriptionForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + ActivityGetThreadSubscriptionForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List events for the authenticated user](Activity::list_events_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListEventsForAuthenticatedUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityListEventsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ActivityListEventsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List notifications for the authenticated user](Activity::list_notifications_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListNotificationsForAuthenticatedUserError { - #[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("Forbidden")] @@ -221,36 +258,48 @@ pub enum ActivityListNotificationsForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityListNotificationsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ActivityListNotificationsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ActivityListNotificationsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ActivityListNotificationsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + ActivityListNotificationsForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ActivityListNotificationsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization events for the authenticated user](Activity::list_org_events_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListOrgEventsForAuthenticatedUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityListOrgEventsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ActivityListOrgEventsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List public events](Activity::list_public_events_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListPublicEventsError { - #[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("Forbidden")] @@ -261,19 +310,26 @@ pub enum ActivityListPublicEventsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityListPublicEventsError) -> Self { + let (description, status_code) = match err { + ActivityListPublicEventsError::Status304 => (String::from("Not modified"), 304), + ActivityListPublicEventsError::Status403(_) => (String::from("Forbidden"), 403), + ActivityListPublicEventsError::Status503(_) => (String::from("Service unavailable"), 503), + ActivityListPublicEventsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List public events for a network of repositories](Activity::list_public_events_for_repo_network_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListPublicEventsForRepoNetworkError { - #[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("Forbidden")] @@ -286,121 +342,153 @@ pub enum ActivityListPublicEventsForRepoNetworkError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityListPublicEventsForRepoNetworkError) -> Self { + let (description, status_code) = match err { + ActivityListPublicEventsForRepoNetworkError::Status404(_) => (String::from("Resource not found"), 404), + ActivityListPublicEventsForRepoNetworkError::Status403(_) => (String::from("Forbidden"), 403), + ActivityListPublicEventsForRepoNetworkError::Status304 => (String::from("Not modified"), 304), + ActivityListPublicEventsForRepoNetworkError::Status301(_) => (String::from("Moved permanently"), 301), + ActivityListPublicEventsForRepoNetworkError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List public events for a user](Activity::list_public_events_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListPublicEventsForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityListPublicEventsForUserError) -> Self { + let (description, status_code) = match err { + ActivityListPublicEventsForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List public organization events](Activity::list_public_org_events_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListPublicOrgEventsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityListPublicOrgEventsError) -> Self { + let (description, status_code) = match err { + ActivityListPublicOrgEventsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List events received by the authenticated user](Activity::list_received_events_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListReceivedEventsForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityListReceivedEventsForUserError) -> Self { + let (description, status_code) = match err { + ActivityListReceivedEventsForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List public events received by a user](Activity::list_received_public_events_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListReceivedPublicEventsForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityListReceivedPublicEventsForUserError) -> Self { + let (description, status_code) = match err { + ActivityListReceivedPublicEventsForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository events](Activity::list_repo_events_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListRepoEventsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityListRepoEventsError) -> Self { + let (description, status_code) = match err { + ActivityListRepoEventsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository notifications for the authenticated user](Activity::list_repo_notifications_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListRepoNotificationsForAuthenticatedUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityListRepoNotificationsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ActivityListRepoNotificationsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories starred by the authenticated user](Activity::list_repos_starred_by_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListReposStarredByAuthenticatedUserError { - #[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("Forbidden")] @@ -411,72 +499,92 @@ pub enum ActivityListReposStarredByAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityListReposStarredByAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ActivityListReposStarredByAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ActivityListReposStarredByAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ActivityListReposStarredByAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + ActivityListReposStarredByAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories starred by a user](Activity::list_repos_starred_by_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListReposStarredByUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityListReposStarredByUserError) -> Self { + let (description, status_code) = match err { + ActivityListReposStarredByUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories watched by a user](Activity::list_repos_watched_by_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListReposWatchedByUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityListReposWatchedByUserError) -> Self { + let (description, status_code) = match err { + ActivityListReposWatchedByUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List stargazers](Activity::list_stargazers_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListStargazersForRepoError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityListStargazersForRepoError) -> Self { + let (description, status_code) = match err { + ActivityListStargazersForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ActivityListStargazersForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories watched by the authenticated user](Activity::list_watched_repos_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListWatchedReposForAuthenticatedUserError { - #[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("Forbidden")] @@ -487,36 +595,47 @@ pub enum ActivityListWatchedReposForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityListWatchedReposForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ActivityListWatchedReposForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ActivityListWatchedReposForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ActivityListWatchedReposForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + ActivityListWatchedReposForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List watchers](Activity::list_watchers_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityListWatchersForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityListWatchersForRepoError) -> Self { + let (description, status_code) = match err { + ActivityListWatchersForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Mark notifications as read](Activity::mark_notifications_as_read_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityMarkNotificationsAsReadError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Reset Content")] Status205, #[error("Not modified")] @@ -529,55 +648,72 @@ pub enum ActivityMarkNotificationsAsReadError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityMarkNotificationsAsReadError) -> Self { + let (description, status_code) = match err { + ActivityMarkNotificationsAsReadError::Status205 => (String::from("Reset Content"), 205), + ActivityMarkNotificationsAsReadError::Status304 => (String::from("Not modified"), 304), + ActivityMarkNotificationsAsReadError::Status403(_) => (String::from("Forbidden"), 403), + ActivityMarkNotificationsAsReadError::Status401(_) => (String::from("Requires authentication"), 401), + ActivityMarkNotificationsAsReadError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Mark repository notifications as read](Activity::mark_repo_notifications_as_read_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityMarkRepoNotificationsAsReadError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Reset Content")] Status205, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityMarkRepoNotificationsAsReadError) -> Self { + let (description, status_code) = match err { + ActivityMarkRepoNotificationsAsReadError::Status205 => (String::from("Reset Content"), 205), + ActivityMarkRepoNotificationsAsReadError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Mark a thread as done](Activity::mark_thread_as_done_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityMarkThreadAsDoneError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivityMarkThreadAsDoneError) -> Self { + let (description, status_code) = match err { + ActivityMarkThreadAsDoneError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Mark a thread as read](Activity::mark_thread_as_read_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityMarkThreadAsReadError { - #[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("Forbidden")] @@ -586,36 +722,46 @@ pub enum ActivityMarkThreadAsReadError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityMarkThreadAsReadError) -> Self { + let (description, status_code) = match err { + ActivityMarkThreadAsReadError::Status304 => (String::from("Not modified"), 304), + ActivityMarkThreadAsReadError::Status403(_) => (String::from("Forbidden"), 403), + ActivityMarkThreadAsReadError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set a repository subscription](Activity::set_repo_subscription_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivitySetRepoSubscriptionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ActivitySetRepoSubscriptionError) -> Self { + let (description, status_code) = match err { + ActivitySetRepoSubscriptionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set a thread subscription](Activity::set_thread_subscription_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivitySetThreadSubscriptionError { - #[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("Forbidden")] @@ -626,19 +772,26 @@ pub enum ActivitySetThreadSubscriptionError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivitySetThreadSubscriptionError) -> Self { + let (description, status_code) = match err { + ActivitySetThreadSubscriptionError::Status304 => (String::from("Not modified"), 304), + ActivitySetThreadSubscriptionError::Status403(_) => (String::from("Forbidden"), 403), + ActivitySetThreadSubscriptionError::Status401(_) => (String::from("Requires authentication"), 401), + ActivitySetThreadSubscriptionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Star a repository for the authenticated user](Activity::star_repo_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityStarRepoForAuthenticatedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -651,19 +804,27 @@ pub enum ActivityStarRepoForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityStarRepoForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ActivityStarRepoForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ActivityStarRepoForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + ActivityStarRepoForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + ActivityStarRepoForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ActivityStarRepoForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Unstar a repository for the authenticated user](Activity::unstar_repo_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ActivityUnstarRepoForAuthenticatedUserError { - #[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("Requires authentication")] @@ -676,6 +837,24 @@ pub enum ActivityUnstarRepoForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ActivityUnstarRepoForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ActivityUnstarRepoForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + ActivityUnstarRepoForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + ActivityUnstarRepoForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ActivityUnstarRepoForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ActivityUnstarRepoForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List events for the authenticated user](Activity::list_events_for_authenticated_user_async()) endpoint. #[derive(Default, Serialize)] @@ -1542,7 +1721,7 @@ impl<'enc> From<&'enc PerPage> for ActivityListWatchersForRepoParams { } } -impl<'api, C: Client> Activity<'api, C> { +impl<'api, C: Client> Activity<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Check if a repository is starred by the authenticated user @@ -1552,19 +1731,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for check_repo_is_starred_by_authenticated_user](https://docs.github.com/rest/activity/starring#check-if-a-repository-is-starred-by-the-authenticated-user) /// /// --- - pub async fn check_repo_is_starred_by_authenticated_user_async(&self, owner: &str, repo: &str) -> Result<(), ActivityCheckRepoIsStarredByAuthenticatedUserError> { + pub async fn check_repo_is_starred_by_authenticated_user_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/starred/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1576,11 +1755,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 401 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 304 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status304), - 403 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - code => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Generic { code }), + 404 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 401 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 304 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + code => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Generic { code }.into()), } } } @@ -1595,7 +1774,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_repo_is_starred_by_authenticated_user(&self, owner: &str, repo: &str) -> Result<(), ActivityCheckRepoIsStarredByAuthenticatedUserError> { + pub fn check_repo_is_starred_by_authenticated_user(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/starred/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); @@ -1607,7 +1786,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1619,11 +1798,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status404(github_response.to_json()?)), - 401 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status401(github_response.to_json()?)), - 304 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status304), - 403 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status403(github_response.to_json()?)), - code => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Generic { code }), + 404 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 401 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 304 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Status403(github_response.to_json()?).into()), + code => Err(ActivityCheckRepoIsStarredByAuthenticatedUserError::Generic { code }.into()), } } } @@ -1637,19 +1816,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for delete_repo_subscription](https://docs.github.com/rest/activity/watching#delete-a-repository-subscription) /// /// --- - pub async fn delete_repo_subscription_async(&self, owner: &str, repo: &str) -> Result<(), ActivityDeleteRepoSubscriptionError> { + pub async fn delete_repo_subscription_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/subscription", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1661,7 +1840,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityDeleteRepoSubscriptionError::Generic { code }), + code => Err(ActivityDeleteRepoSubscriptionError::Generic { code }.into()), } } } @@ -1676,7 +1855,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_repo_subscription(&self, owner: &str, repo: &str) -> Result<(), ActivityDeleteRepoSubscriptionError> { + pub fn delete_repo_subscription(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/subscription", super::GITHUB_BASE_API_URL, owner, repo); @@ -1688,7 +1867,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1700,7 +1879,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityDeleteRepoSubscriptionError::Generic { code }), + code => Err(ActivityDeleteRepoSubscriptionError::Generic { code }.into()), } } } @@ -1714,19 +1893,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for delete_thread_subscription](https://docs.github.com/rest/activity/notifications#delete-a-thread-subscription) /// /// --- - pub async fn delete_thread_subscription_async(&self, thread_id: i32) -> Result<(), ActivityDeleteThreadSubscriptionError> { + pub async fn delete_thread_subscription_async(&self, thread_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/notifications/threads/{}/subscription", super::GITHUB_BASE_API_URL, thread_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1738,10 +1917,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ActivityDeleteThreadSubscriptionError::Status304), - 403 => Err(ActivityDeleteThreadSubscriptionError::Status403(github_response.to_json_async().await?)), - 401 => Err(ActivityDeleteThreadSubscriptionError::Status401(github_response.to_json_async().await?)), - code => Err(ActivityDeleteThreadSubscriptionError::Generic { code }), + 304 => Err(ActivityDeleteThreadSubscriptionError::Status304.into()), + 403 => Err(ActivityDeleteThreadSubscriptionError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ActivityDeleteThreadSubscriptionError::Status401(github_response.to_json_async().await?).into()), + code => Err(ActivityDeleteThreadSubscriptionError::Generic { code }.into()), } } } @@ -1756,7 +1935,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_thread_subscription(&self, thread_id: i32) -> Result<(), ActivityDeleteThreadSubscriptionError> { + pub fn delete_thread_subscription(&self, thread_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/notifications/threads/{}/subscription", super::GITHUB_BASE_API_URL, thread_id); @@ -1768,7 +1947,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1780,10 +1959,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ActivityDeleteThreadSubscriptionError::Status304), - 403 => Err(ActivityDeleteThreadSubscriptionError::Status403(github_response.to_json()?)), - 401 => Err(ActivityDeleteThreadSubscriptionError::Status401(github_response.to_json()?)), - code => Err(ActivityDeleteThreadSubscriptionError::Generic { code }), + 304 => Err(ActivityDeleteThreadSubscriptionError::Status304.into()), + 403 => Err(ActivityDeleteThreadSubscriptionError::Status403(github_response.to_json()?).into()), + 401 => Err(ActivityDeleteThreadSubscriptionError::Status401(github_response.to_json()?).into()), + code => Err(ActivityDeleteThreadSubscriptionError::Generic { code }.into()), } } } @@ -1810,19 +1989,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for get_feeds](https://docs.github.com/rest/activity/feeds#get-feeds) /// /// --- - pub async fn get_feeds_async(&self) -> Result { + pub async fn get_feeds_async(&self) -> Result { let request_uri = format!("{}/feeds", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1834,7 +2013,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityGetFeedsError::Generic { code }), + code => Err(ActivityGetFeedsError::Generic { code }.into()), } } } @@ -1862,7 +2041,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_feeds(&self) -> Result { + pub fn get_feeds(&self) -> Result { let request_uri = format!("{}/feeds", super::GITHUB_BASE_API_URL); @@ -1874,7 +2053,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1886,7 +2065,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityGetFeedsError::Generic { code }), + code => Err(ActivityGetFeedsError::Generic { code }.into()), } } } @@ -1900,19 +2079,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for get_repo_subscription](https://docs.github.com/rest/activity/watching#get-a-repository-subscription) /// /// --- - pub async fn get_repo_subscription_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_repo_subscription_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/subscription", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1924,9 +2103,9 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActivityGetRepoSubscriptionError::Status404), - 403 => Err(ActivityGetRepoSubscriptionError::Status403(github_response.to_json_async().await?)), - code => Err(ActivityGetRepoSubscriptionError::Generic { code }), + 404 => Err(ActivityGetRepoSubscriptionError::Status404.into()), + 403 => Err(ActivityGetRepoSubscriptionError::Status403(github_response.to_json_async().await?).into()), + code => Err(ActivityGetRepoSubscriptionError::Generic { code }.into()), } } } @@ -1941,7 +2120,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_subscription(&self, owner: &str, repo: &str) -> Result { + pub fn get_repo_subscription(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/subscription", super::GITHUB_BASE_API_URL, owner, repo); @@ -1953,7 +2132,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1965,9 +2144,9 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActivityGetRepoSubscriptionError::Status404), - 403 => Err(ActivityGetRepoSubscriptionError::Status403(github_response.to_json()?)), - code => Err(ActivityGetRepoSubscriptionError::Generic { code }), + 404 => Err(ActivityGetRepoSubscriptionError::Status404.into()), + 403 => Err(ActivityGetRepoSubscriptionError::Status403(github_response.to_json()?).into()), + code => Err(ActivityGetRepoSubscriptionError::Generic { code }.into()), } } } @@ -1981,19 +2160,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for get_thread](https://docs.github.com/rest/activity/notifications#get-a-thread) /// /// --- - pub async fn get_thread_async(&self, thread_id: i32) -> Result { + pub async fn get_thread_async(&self, thread_id: i32) -> Result { let request_uri = format!("{}/notifications/threads/{}", super::GITHUB_BASE_API_URL, thread_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2005,10 +2184,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ActivityGetThreadError::Status304), - 403 => Err(ActivityGetThreadError::Status403(github_response.to_json_async().await?)), - 401 => Err(ActivityGetThreadError::Status401(github_response.to_json_async().await?)), - code => Err(ActivityGetThreadError::Generic { code }), + 304 => Err(ActivityGetThreadError::Status304.into()), + 403 => Err(ActivityGetThreadError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ActivityGetThreadError::Status401(github_response.to_json_async().await?).into()), + code => Err(ActivityGetThreadError::Generic { code }.into()), } } } @@ -2023,7 +2202,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_thread(&self, thread_id: i32) -> Result { + pub fn get_thread(&self, thread_id: i32) -> Result { let request_uri = format!("{}/notifications/threads/{}", super::GITHUB_BASE_API_URL, thread_id); @@ -2035,7 +2214,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2047,10 +2226,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ActivityGetThreadError::Status304), - 403 => Err(ActivityGetThreadError::Status403(github_response.to_json()?)), - 401 => Err(ActivityGetThreadError::Status401(github_response.to_json()?)), - code => Err(ActivityGetThreadError::Generic { code }), + 304 => Err(ActivityGetThreadError::Status304.into()), + 403 => Err(ActivityGetThreadError::Status403(github_response.to_json()?).into()), + 401 => Err(ActivityGetThreadError::Status401(github_response.to_json()?).into()), + code => Err(ActivityGetThreadError::Generic { code }.into()), } } } @@ -2066,19 +2245,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for get_thread_subscription_for_authenticated_user](https://docs.github.com/rest/activity/notifications#get-a-thread-subscription-for-the-authenticated-user) /// /// --- - pub async fn get_thread_subscription_for_authenticated_user_async(&self, thread_id: i32) -> Result { + pub async fn get_thread_subscription_for_authenticated_user_async(&self, thread_id: i32) -> Result { let request_uri = format!("{}/notifications/threads/{}/subscription", super::GITHUB_BASE_API_URL, thread_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2090,10 +2269,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status304), - 403 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Generic { code }), + 304 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2110,7 +2289,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_thread_subscription_for_authenticated_user(&self, thread_id: i32) -> Result { + pub fn get_thread_subscription_for_authenticated_user(&self, thread_id: i32) -> Result { let request_uri = format!("{}/notifications/threads/{}/subscription", super::GITHUB_BASE_API_URL, thread_id); @@ -2122,7 +2301,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2134,10 +2313,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status304), - 403 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Generic { code }), + 304 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(ActivityGetThreadSubscriptionForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2154,7 +2333,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_events_for_authenticated_user](https://docs.github.com/rest/activity/events#list-events-for-the-authenticated-user) /// /// --- - pub async fn list_events_for_authenticated_user_async(&self, username: &str, query_params: Option>) -> Result, ActivityListEventsForAuthenticatedUserError> { + pub async fn list_events_for_authenticated_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/events", super::GITHUB_BASE_API_URL, username); @@ -2165,12 +2344,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2182,7 +2361,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityListEventsForAuthenticatedUserError::Generic { code }), + code => Err(ActivityListEventsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2200,7 +2379,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_events_for_authenticated_user(&self, username: &str, query_params: Option>) -> Result, ActivityListEventsForAuthenticatedUserError> { + pub fn list_events_for_authenticated_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/events", super::GITHUB_BASE_API_URL, username); @@ -2217,7 +2396,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2229,7 +2408,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityListEventsForAuthenticatedUserError::Generic { code }), + code => Err(ActivityListEventsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2243,7 +2422,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_notifications_for_authenticated_user](https://docs.github.com/rest/activity/notifications#list-notifications-for-the-authenticated-user) /// /// --- - pub async fn list_notifications_for_authenticated_user_async(&self, query_params: Option>) -> Result, ActivityListNotificationsForAuthenticatedUserError> { + pub async fn list_notifications_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/notifications", super::GITHUB_BASE_API_URL); @@ -2254,12 +2433,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2271,11 +2450,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ActivityListNotificationsForAuthenticatedUserError::Status304), - 403 => Err(ActivityListNotificationsForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(ActivityListNotificationsForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 422 => Err(ActivityListNotificationsForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - code => Err(ActivityListNotificationsForAuthenticatedUserError::Generic { code }), + 304 => Err(ActivityListNotificationsForAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityListNotificationsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ActivityListNotificationsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 422 => Err(ActivityListNotificationsForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(ActivityListNotificationsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2290,7 +2469,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_notifications_for_authenticated_user(&self, query_params: Option>) -> Result, ActivityListNotificationsForAuthenticatedUserError> { + pub fn list_notifications_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/notifications", super::GITHUB_BASE_API_URL); @@ -2307,7 +2486,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2319,11 +2498,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ActivityListNotificationsForAuthenticatedUserError::Status304), - 403 => Err(ActivityListNotificationsForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(ActivityListNotificationsForAuthenticatedUserError::Status401(github_response.to_json()?)), - 422 => Err(ActivityListNotificationsForAuthenticatedUserError::Status422(github_response.to_json()?)), - code => Err(ActivityListNotificationsForAuthenticatedUserError::Generic { code }), + 304 => Err(ActivityListNotificationsForAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityListNotificationsForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(ActivityListNotificationsForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 422 => Err(ActivityListNotificationsForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + code => Err(ActivityListNotificationsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2340,7 +2519,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_org_events_for_authenticated_user](https://docs.github.com/rest/activity/events#list-organization-events-for-the-authenticated-user) /// /// --- - pub async fn list_org_events_for_authenticated_user_async(&self, username: &str, org: &str, query_params: Option>) -> Result, ActivityListOrgEventsForAuthenticatedUserError> { + pub async fn list_org_events_for_authenticated_user_async(&self, username: &str, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/events/orgs/{}", super::GITHUB_BASE_API_URL, username, org); @@ -2351,12 +2530,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2368,7 +2547,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityListOrgEventsForAuthenticatedUserError::Generic { code }), + code => Err(ActivityListOrgEventsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2386,7 +2565,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_org_events_for_authenticated_user(&self, username: &str, org: &str, query_params: Option>) -> Result, ActivityListOrgEventsForAuthenticatedUserError> { + pub fn list_org_events_for_authenticated_user(&self, username: &str, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/events/orgs/{}", super::GITHUB_BASE_API_URL, username, org); @@ -2403,7 +2582,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2415,7 +2594,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityListOrgEventsForAuthenticatedUserError::Generic { code }), + code => Err(ActivityListOrgEventsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2430,7 +2609,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_public_events](https://docs.github.com/rest/activity/events#list-public-events) /// /// --- - pub async fn list_public_events_async(&self, query_params: Option>) -> Result, ActivityListPublicEventsError> { + pub async fn list_public_events_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/events", super::GITHUB_BASE_API_URL); @@ -2441,12 +2620,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2458,10 +2637,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ActivityListPublicEventsError::Status304), - 403 => Err(ActivityListPublicEventsError::Status403(github_response.to_json_async().await?)), - 503 => Err(ActivityListPublicEventsError::Status503(github_response.to_json_async().await?)), - code => Err(ActivityListPublicEventsError::Generic { code }), + 304 => Err(ActivityListPublicEventsError::Status304.into()), + 403 => Err(ActivityListPublicEventsError::Status403(github_response.to_json_async().await?).into()), + 503 => Err(ActivityListPublicEventsError::Status503(github_response.to_json_async().await?).into()), + code => Err(ActivityListPublicEventsError::Generic { code }.into()), } } } @@ -2477,7 +2656,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_public_events(&self, query_params: Option>) -> Result, ActivityListPublicEventsError> { + pub fn list_public_events(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/events", super::GITHUB_BASE_API_URL); @@ -2494,7 +2673,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2506,10 +2685,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ActivityListPublicEventsError::Status304), - 403 => Err(ActivityListPublicEventsError::Status403(github_response.to_json()?)), - 503 => Err(ActivityListPublicEventsError::Status503(github_response.to_json()?)), - code => Err(ActivityListPublicEventsError::Generic { code }), + 304 => Err(ActivityListPublicEventsError::Status304.into()), + 403 => Err(ActivityListPublicEventsError::Status403(github_response.to_json()?).into()), + 503 => Err(ActivityListPublicEventsError::Status503(github_response.to_json()?).into()), + code => Err(ActivityListPublicEventsError::Generic { code }.into()), } } } @@ -2524,7 +2703,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_public_events_for_repo_network](https://docs.github.com/rest/activity/events#list-public-events-for-a-network-of-repositories) /// /// --- - pub async fn list_public_events_for_repo_network_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ActivityListPublicEventsForRepoNetworkError> { + pub async fn list_public_events_for_repo_network_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/networks/{}/{}/events", super::GITHUB_BASE_API_URL, owner, repo); @@ -2535,12 +2714,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2552,11 +2731,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActivityListPublicEventsForRepoNetworkError::Status404(github_response.to_json_async().await?)), - 403 => Err(ActivityListPublicEventsForRepoNetworkError::Status403(github_response.to_json_async().await?)), - 304 => Err(ActivityListPublicEventsForRepoNetworkError::Status304), - 301 => Err(ActivityListPublicEventsForRepoNetworkError::Status301(github_response.to_json_async().await?)), - code => Err(ActivityListPublicEventsForRepoNetworkError::Generic { code }), + 404 => Err(ActivityListPublicEventsForRepoNetworkError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(ActivityListPublicEventsForRepoNetworkError::Status403(github_response.to_json_async().await?).into()), + 304 => Err(ActivityListPublicEventsForRepoNetworkError::Status304.into()), + 301 => Err(ActivityListPublicEventsForRepoNetworkError::Status301(github_response.to_json_async().await?).into()), + code => Err(ActivityListPublicEventsForRepoNetworkError::Generic { code }.into()), } } } @@ -2572,7 +2751,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_public_events_for_repo_network(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ActivityListPublicEventsForRepoNetworkError> { + pub fn list_public_events_for_repo_network(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/networks/{}/{}/events", super::GITHUB_BASE_API_URL, owner, repo); @@ -2589,7 +2768,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2601,11 +2780,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActivityListPublicEventsForRepoNetworkError::Status404(github_response.to_json()?)), - 403 => Err(ActivityListPublicEventsForRepoNetworkError::Status403(github_response.to_json()?)), - 304 => Err(ActivityListPublicEventsForRepoNetworkError::Status304), - 301 => Err(ActivityListPublicEventsForRepoNetworkError::Status301(github_response.to_json()?)), - code => Err(ActivityListPublicEventsForRepoNetworkError::Generic { code }), + 404 => Err(ActivityListPublicEventsForRepoNetworkError::Status404(github_response.to_json()?).into()), + 403 => Err(ActivityListPublicEventsForRepoNetworkError::Status403(github_response.to_json()?).into()), + 304 => Err(ActivityListPublicEventsForRepoNetworkError::Status304.into()), + 301 => Err(ActivityListPublicEventsForRepoNetworkError::Status301(github_response.to_json()?).into()), + code => Err(ActivityListPublicEventsForRepoNetworkError::Generic { code }.into()), } } } @@ -2620,7 +2799,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_public_events_for_user](https://docs.github.com/rest/activity/events#list-public-events-for-a-user) /// /// --- - pub async fn list_public_events_for_user_async(&self, username: &str, query_params: Option>) -> Result, ActivityListPublicEventsForUserError> { + pub async fn list_public_events_for_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/events/public", super::GITHUB_BASE_API_URL, username); @@ -2631,12 +2810,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2648,7 +2827,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityListPublicEventsForUserError::Generic { code }), + code => Err(ActivityListPublicEventsForUserError::Generic { code }.into()), } } } @@ -2664,7 +2843,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_public_events_for_user(&self, username: &str, query_params: Option>) -> Result, ActivityListPublicEventsForUserError> { + pub fn list_public_events_for_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/events/public", super::GITHUB_BASE_API_URL, username); @@ -2681,7 +2860,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2693,7 +2872,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityListPublicEventsForUserError::Generic { code }), + code => Err(ActivityListPublicEventsForUserError::Generic { code }.into()), } } } @@ -2708,7 +2887,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_public_org_events](https://docs.github.com/rest/activity/events#list-public-organization-events) /// /// --- - pub async fn list_public_org_events_async(&self, org: &str, query_params: Option>) -> Result, ActivityListPublicOrgEventsError> { + pub async fn list_public_org_events_async(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/events", super::GITHUB_BASE_API_URL, org); @@ -2719,12 +2898,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2736,7 +2915,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityListPublicOrgEventsError::Generic { code }), + code => Err(ActivityListPublicOrgEventsError::Generic { code }.into()), } } } @@ -2752,7 +2931,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_public_org_events(&self, org: &str, query_params: Option>) -> Result, ActivityListPublicOrgEventsError> { + pub fn list_public_org_events(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/events", super::GITHUB_BASE_API_URL, org); @@ -2769,7 +2948,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2781,7 +2960,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityListPublicOrgEventsError::Generic { code }), + code => Err(ActivityListPublicOrgEventsError::Generic { code }.into()), } } } @@ -2799,7 +2978,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_received_events_for_user](https://docs.github.com/rest/activity/events#list-events-received-by-the-authenticated-user) /// /// --- - pub async fn list_received_events_for_user_async(&self, username: &str, query_params: Option>) -> Result, ActivityListReceivedEventsForUserError> { + pub async fn list_received_events_for_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/received_events", super::GITHUB_BASE_API_URL, username); @@ -2810,12 +2989,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2827,7 +3006,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityListReceivedEventsForUserError::Generic { code }), + code => Err(ActivityListReceivedEventsForUserError::Generic { code }.into()), } } } @@ -2846,7 +3025,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_received_events_for_user(&self, username: &str, query_params: Option>) -> Result, ActivityListReceivedEventsForUserError> { + pub fn list_received_events_for_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/received_events", super::GITHUB_BASE_API_URL, username); @@ -2863,7 +3042,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2875,7 +3054,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityListReceivedEventsForUserError::Generic { code }), + code => Err(ActivityListReceivedEventsForUserError::Generic { code }.into()), } } } @@ -2890,7 +3069,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_received_public_events_for_user](https://docs.github.com/rest/activity/events#list-public-events-received-by-a-user) /// /// --- - pub async fn list_received_public_events_for_user_async(&self, username: &str, query_params: Option>) -> Result, ActivityListReceivedPublicEventsForUserError> { + pub async fn list_received_public_events_for_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/received_events/public", super::GITHUB_BASE_API_URL, username); @@ -2901,12 +3080,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2918,7 +3097,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityListReceivedPublicEventsForUserError::Generic { code }), + code => Err(ActivityListReceivedPublicEventsForUserError::Generic { code }.into()), } } } @@ -2934,7 +3113,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_received_public_events_for_user(&self, username: &str, query_params: Option>) -> Result, ActivityListReceivedPublicEventsForUserError> { + pub fn list_received_public_events_for_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/received_events/public", super::GITHUB_BASE_API_URL, username); @@ -2951,7 +3130,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2963,7 +3142,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityListReceivedPublicEventsForUserError::Generic { code }), + code => Err(ActivityListReceivedPublicEventsForUserError::Generic { code }.into()), } } } @@ -2978,7 +3157,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_repo_events](https://docs.github.com/rest/activity/events#list-repository-events) /// /// --- - pub async fn list_repo_events_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ActivityListRepoEventsError> { + pub async fn list_repo_events_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/events", super::GITHUB_BASE_API_URL, owner, repo); @@ -2989,12 +3168,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3006,7 +3185,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityListRepoEventsError::Generic { code }), + code => Err(ActivityListRepoEventsError::Generic { code }.into()), } } } @@ -3022,7 +3201,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repo_events(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ActivityListRepoEventsError> { + pub fn list_repo_events(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/events", super::GITHUB_BASE_API_URL, owner, repo); @@ -3039,7 +3218,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3051,7 +3230,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityListRepoEventsError::Generic { code }), + code => Err(ActivityListRepoEventsError::Generic { code }.into()), } } } @@ -3065,7 +3244,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_repo_notifications_for_authenticated_user](https://docs.github.com/rest/activity/notifications#list-repository-notifications-for-the-authenticated-user) /// /// --- - pub async fn list_repo_notifications_for_authenticated_user_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ActivityListRepoNotificationsForAuthenticatedUserError> { + pub async fn list_repo_notifications_for_authenticated_user_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/notifications", super::GITHUB_BASE_API_URL, owner, repo); @@ -3076,12 +3255,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3093,7 +3272,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityListRepoNotificationsForAuthenticatedUserError::Generic { code }), + code => Err(ActivityListRepoNotificationsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3108,7 +3287,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repo_notifications_for_authenticated_user(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ActivityListRepoNotificationsForAuthenticatedUserError> { + pub fn list_repo_notifications_for_authenticated_user(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/notifications", super::GITHUB_BASE_API_URL, owner, repo); @@ -3125,7 +3304,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3137,7 +3316,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityListRepoNotificationsForAuthenticatedUserError::Generic { code }), + code => Err(ActivityListRepoNotificationsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3155,7 +3334,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_repos_starred_by_authenticated_user](https://docs.github.com/rest/activity/starring#list-repositories-starred-by-the-authenticated-user) /// /// --- - pub async fn list_repos_starred_by_authenticated_user_async(&self, query_params: Option>>) -> Result, ActivityListReposStarredByAuthenticatedUserError> { + pub async fn list_repos_starred_by_authenticated_user_async(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/starred", super::GITHUB_BASE_API_URL); @@ -3166,12 +3345,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3183,10 +3362,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ActivityListReposStarredByAuthenticatedUserError::Status304), - 403 => Err(ActivityListReposStarredByAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(ActivityListReposStarredByAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(ActivityListReposStarredByAuthenticatedUserError::Generic { code }), + 304 => Err(ActivityListReposStarredByAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityListReposStarredByAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ActivityListReposStarredByAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(ActivityListReposStarredByAuthenticatedUserError::Generic { code }.into()), } } } @@ -3205,7 +3384,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repos_starred_by_authenticated_user(&self, query_params: Option>>) -> Result, ActivityListReposStarredByAuthenticatedUserError> { + pub fn list_repos_starred_by_authenticated_user(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/starred", super::GITHUB_BASE_API_URL); @@ -3222,7 +3401,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3234,10 +3413,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ActivityListReposStarredByAuthenticatedUserError::Status304), - 403 => Err(ActivityListReposStarredByAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(ActivityListReposStarredByAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(ActivityListReposStarredByAuthenticatedUserError::Generic { code }), + 304 => Err(ActivityListReposStarredByAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityListReposStarredByAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(ActivityListReposStarredByAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(ActivityListReposStarredByAuthenticatedUserError::Generic { code }.into()), } } } @@ -3255,7 +3434,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_repos_starred_by_user](https://docs.github.com/rest/activity/starring#list-repositories-starred-by-a-user) /// /// --- - pub async fn list_repos_starred_by_user_async(&self, username: &str, query_params: Option>>) -> Result { + pub async fn list_repos_starred_by_user_async(&self, username: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/users/{}/starred", super::GITHUB_BASE_API_URL, username); @@ -3266,12 +3445,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3283,7 +3462,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityListReposStarredByUserError::Generic { code }), + code => Err(ActivityListReposStarredByUserError::Generic { code }.into()), } } } @@ -3302,7 +3481,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repos_starred_by_user(&self, username: &str, query_params: Option>>) -> Result { + pub fn list_repos_starred_by_user(&self, username: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/users/{}/starred", super::GITHUB_BASE_API_URL, username); @@ -3319,7 +3498,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3331,7 +3510,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityListReposStarredByUserError::Generic { code }), + code => Err(ActivityListReposStarredByUserError::Generic { code }.into()), } } } @@ -3345,7 +3524,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_repos_watched_by_user](https://docs.github.com/rest/activity/watching#list-repositories-watched-by-a-user) /// /// --- - pub async fn list_repos_watched_by_user_async(&self, username: &str, query_params: Option>) -> Result, ActivityListReposWatchedByUserError> { + pub async fn list_repos_watched_by_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/subscriptions", super::GITHUB_BASE_API_URL, username); @@ -3356,12 +3535,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3373,7 +3552,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityListReposWatchedByUserError::Generic { code }), + code => Err(ActivityListReposWatchedByUserError::Generic { code }.into()), } } } @@ -3388,7 +3567,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repos_watched_by_user(&self, username: &str, query_params: Option>) -> Result, ActivityListReposWatchedByUserError> { + pub fn list_repos_watched_by_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/subscriptions", super::GITHUB_BASE_API_URL, username); @@ -3405,7 +3584,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3417,7 +3596,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityListReposWatchedByUserError::Generic { code }), + code => Err(ActivityListReposWatchedByUserError::Generic { code }.into()), } } } @@ -3435,7 +3614,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_stargazers_for_repo](https://docs.github.com/rest/activity/starring#list-stargazers) /// /// --- - pub async fn list_stargazers_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub async fn list_stargazers_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/stargazers", super::GITHUB_BASE_API_URL, owner, repo); @@ -3446,12 +3625,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3463,8 +3642,8 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ActivityListStargazersForRepoError::Status422(github_response.to_json_async().await?)), - code => Err(ActivityListStargazersForRepoError::Generic { code }), + 422 => Err(ActivityListStargazersForRepoError::Status422(github_response.to_json_async().await?).into()), + code => Err(ActivityListStargazersForRepoError::Generic { code }.into()), } } } @@ -3483,7 +3662,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_stargazers_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub fn list_stargazers_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/stargazers", super::GITHUB_BASE_API_URL, owner, repo); @@ -3500,7 +3679,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3512,8 +3691,8 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ActivityListStargazersForRepoError::Status422(github_response.to_json()?)), - code => Err(ActivityListStargazersForRepoError::Generic { code }), + 422 => Err(ActivityListStargazersForRepoError::Status422(github_response.to_json()?).into()), + code => Err(ActivityListStargazersForRepoError::Generic { code }.into()), } } } @@ -3527,7 +3706,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_watched_repos_for_authenticated_user](https://docs.github.com/rest/activity/watching#list-repositories-watched-by-the-authenticated-user) /// /// --- - pub async fn list_watched_repos_for_authenticated_user_async(&self, query_params: Option>) -> Result, ActivityListWatchedReposForAuthenticatedUserError> { + pub async fn list_watched_repos_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/subscriptions", super::GITHUB_BASE_API_URL); @@ -3538,12 +3717,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3555,10 +3734,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status304), - 403 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(ActivityListWatchedReposForAuthenticatedUserError::Generic { code }), + 304 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(ActivityListWatchedReposForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3573,7 +3752,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_watched_repos_for_authenticated_user(&self, query_params: Option>) -> Result, ActivityListWatchedReposForAuthenticatedUserError> { + pub fn list_watched_repos_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/subscriptions", super::GITHUB_BASE_API_URL); @@ -3590,7 +3769,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3602,10 +3781,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status304), - 403 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(ActivityListWatchedReposForAuthenticatedUserError::Generic { code }), + 304 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(ActivityListWatchedReposForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(ActivityListWatchedReposForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3619,7 +3798,7 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for list_watchers_for_repo](https://docs.github.com/rest/activity/watching#list-watchers) /// /// --- - pub async fn list_watchers_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ActivityListWatchersForRepoError> { + pub async fn list_watchers_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/subscribers", super::GITHUB_BASE_API_URL, owner, repo); @@ -3630,12 +3809,12 @@ impl<'api, C: Client> Activity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3647,7 +3826,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityListWatchersForRepoError::Generic { code }), + code => Err(ActivityListWatchersForRepoError::Generic { code }.into()), } } } @@ -3662,7 +3841,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_watchers_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ActivityListWatchersForRepoError> { + pub fn list_watchers_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/subscribers", super::GITHUB_BASE_API_URL, owner, repo); @@ -3679,7 +3858,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3691,7 +3870,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityListWatchersForRepoError::Generic { code }), + code => Err(ActivityListWatchersForRepoError::Generic { code }.into()), } } } @@ -3705,19 +3884,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for mark_notifications_as_read](https://docs.github.com/rest/activity/notifications#mark-notifications-as-read) /// /// --- - pub async fn mark_notifications_as_read_async(&self, body: PutActivityMarkNotificationsAsRead) -> Result { + pub async fn mark_notifications_as_read_async(&self, body: PutActivityMarkNotificationsAsRead) -> Result { let request_uri = format!("{}/notifications", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PutActivityMarkNotificationsAsRead::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3729,11 +3908,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 205 => Err(ActivityMarkNotificationsAsReadError::Status205), - 304 => Err(ActivityMarkNotificationsAsReadError::Status304), - 403 => Err(ActivityMarkNotificationsAsReadError::Status403(github_response.to_json_async().await?)), - 401 => Err(ActivityMarkNotificationsAsReadError::Status401(github_response.to_json_async().await?)), - code => Err(ActivityMarkNotificationsAsReadError::Generic { code }), + 205 => Err(ActivityMarkNotificationsAsReadError::Status205.into()), + 304 => Err(ActivityMarkNotificationsAsReadError::Status304.into()), + 403 => Err(ActivityMarkNotificationsAsReadError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ActivityMarkNotificationsAsReadError::Status401(github_response.to_json_async().await?).into()), + code => Err(ActivityMarkNotificationsAsReadError::Generic { code }.into()), } } } @@ -3748,19 +3927,19 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn mark_notifications_as_read(&self, body: PutActivityMarkNotificationsAsRead) -> Result { + pub fn mark_notifications_as_read(&self, body: PutActivityMarkNotificationsAsRead) -> Result { let request_uri = format!("{}/notifications", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PutActivityMarkNotificationsAsRead::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3772,11 +3951,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 205 => Err(ActivityMarkNotificationsAsReadError::Status205), - 304 => Err(ActivityMarkNotificationsAsReadError::Status304), - 403 => Err(ActivityMarkNotificationsAsReadError::Status403(github_response.to_json()?)), - 401 => Err(ActivityMarkNotificationsAsReadError::Status401(github_response.to_json()?)), - code => Err(ActivityMarkNotificationsAsReadError::Generic { code }), + 205 => Err(ActivityMarkNotificationsAsReadError::Status205.into()), + 304 => Err(ActivityMarkNotificationsAsReadError::Status304.into()), + 403 => Err(ActivityMarkNotificationsAsReadError::Status403(github_response.to_json()?).into()), + 401 => Err(ActivityMarkNotificationsAsReadError::Status401(github_response.to_json()?).into()), + code => Err(ActivityMarkNotificationsAsReadError::Generic { code }.into()), } } } @@ -3790,19 +3969,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for mark_repo_notifications_as_read](https://docs.github.com/rest/activity/notifications#mark-repository-notifications-as-read) /// /// --- - pub async fn mark_repo_notifications_as_read_async(&self, owner: &str, repo: &str, body: PutActivityMarkRepoNotificationsAsRead) -> Result { + pub async fn mark_repo_notifications_as_read_async(&self, owner: &str, repo: &str, body: PutActivityMarkRepoNotificationsAsRead) -> Result { let request_uri = format!("{}/repos/{}/{}/notifications", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutActivityMarkRepoNotificationsAsRead::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3814,8 +3993,8 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 205 => Err(ActivityMarkRepoNotificationsAsReadError::Status205), - code => Err(ActivityMarkRepoNotificationsAsReadError::Generic { code }), + 205 => Err(ActivityMarkRepoNotificationsAsReadError::Status205.into()), + code => Err(ActivityMarkRepoNotificationsAsReadError::Generic { code }.into()), } } } @@ -3830,19 +4009,19 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn mark_repo_notifications_as_read(&self, owner: &str, repo: &str, body: PutActivityMarkRepoNotificationsAsRead) -> Result { + pub fn mark_repo_notifications_as_read(&self, owner: &str, repo: &str, body: PutActivityMarkRepoNotificationsAsRead) -> Result { let request_uri = format!("{}/repos/{}/{}/notifications", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutActivityMarkRepoNotificationsAsRead::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3854,8 +4033,8 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 205 => Err(ActivityMarkRepoNotificationsAsReadError::Status205), - code => Err(ActivityMarkRepoNotificationsAsReadError::Generic { code }), + 205 => Err(ActivityMarkRepoNotificationsAsReadError::Status205.into()), + code => Err(ActivityMarkRepoNotificationsAsReadError::Generic { code }.into()), } } } @@ -3869,19 +4048,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for mark_thread_as_done](https://docs.github.com/rest/activity/notifications#mark-a-thread-as-done) /// /// --- - pub async fn mark_thread_as_done_async(&self, thread_id: i32) -> Result<(), ActivityMarkThreadAsDoneError> { + pub async fn mark_thread_as_done_async(&self, thread_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/notifications/threads/{}", super::GITHUB_BASE_API_URL, thread_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3893,7 +4072,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivityMarkThreadAsDoneError::Generic { code }), + code => Err(ActivityMarkThreadAsDoneError::Generic { code }.into()), } } } @@ -3908,7 +4087,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn mark_thread_as_done(&self, thread_id: i32) -> Result<(), ActivityMarkThreadAsDoneError> { + pub fn mark_thread_as_done(&self, thread_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/notifications/threads/{}", super::GITHUB_BASE_API_URL, thread_id); @@ -3920,7 +4099,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3932,7 +4111,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivityMarkThreadAsDoneError::Generic { code }), + code => Err(ActivityMarkThreadAsDoneError::Generic { code }.into()), } } } @@ -3946,19 +4125,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for mark_thread_as_read](https://docs.github.com/rest/activity/notifications#mark-a-thread-as-read) /// /// --- - pub async fn mark_thread_as_read_async(&self, thread_id: i32) -> Result<(), ActivityMarkThreadAsReadError> { + pub async fn mark_thread_as_read_async(&self, thread_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/notifications/threads/{}", super::GITHUB_BASE_API_URL, thread_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3970,9 +4149,9 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ActivityMarkThreadAsReadError::Status304), - 403 => Err(ActivityMarkThreadAsReadError::Status403(github_response.to_json_async().await?)), - code => Err(ActivityMarkThreadAsReadError::Generic { code }), + 304 => Err(ActivityMarkThreadAsReadError::Status304.into()), + 403 => Err(ActivityMarkThreadAsReadError::Status403(github_response.to_json_async().await?).into()), + code => Err(ActivityMarkThreadAsReadError::Generic { code }.into()), } } } @@ -3987,7 +4166,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn mark_thread_as_read(&self, thread_id: i32) -> Result<(), ActivityMarkThreadAsReadError> { + pub fn mark_thread_as_read(&self, thread_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/notifications/threads/{}", super::GITHUB_BASE_API_URL, thread_id); @@ -3999,7 +4178,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4011,9 +4190,9 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ActivityMarkThreadAsReadError::Status304), - 403 => Err(ActivityMarkThreadAsReadError::Status403(github_response.to_json()?)), - code => Err(ActivityMarkThreadAsReadError::Generic { code }), + 304 => Err(ActivityMarkThreadAsReadError::Status304.into()), + 403 => Err(ActivityMarkThreadAsReadError::Status403(github_response.to_json()?).into()), + code => Err(ActivityMarkThreadAsReadError::Generic { code }.into()), } } } @@ -4027,19 +4206,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for set_repo_subscription](https://docs.github.com/rest/activity/watching#set-a-repository-subscription) /// /// --- - pub async fn set_repo_subscription_async(&self, owner: &str, repo: &str, body: PutActivitySetRepoSubscription) -> Result { + pub async fn set_repo_subscription_async(&self, owner: &str, repo: &str, body: PutActivitySetRepoSubscription) -> Result { let request_uri = format!("{}/repos/{}/{}/subscription", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutActivitySetRepoSubscription::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4051,7 +4230,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ActivitySetRepoSubscriptionError::Generic { code }), + code => Err(ActivitySetRepoSubscriptionError::Generic { code }.into()), } } } @@ -4066,19 +4245,19 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_repo_subscription(&self, owner: &str, repo: &str, body: PutActivitySetRepoSubscription) -> Result { + pub fn set_repo_subscription(&self, owner: &str, repo: &str, body: PutActivitySetRepoSubscription) -> Result { let request_uri = format!("{}/repos/{}/{}/subscription", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutActivitySetRepoSubscription::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4090,7 +4269,7 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ActivitySetRepoSubscriptionError::Generic { code }), + code => Err(ActivitySetRepoSubscriptionError::Generic { code }.into()), } } } @@ -4108,19 +4287,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for set_thread_subscription](https://docs.github.com/rest/activity/notifications#set-a-thread-subscription) /// /// --- - pub async fn set_thread_subscription_async(&self, thread_id: i32, body: PutActivitySetThreadSubscription) -> Result { + pub async fn set_thread_subscription_async(&self, thread_id: i32, body: PutActivitySetThreadSubscription) -> Result { let request_uri = format!("{}/notifications/threads/{}/subscription", super::GITHUB_BASE_API_URL, thread_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutActivitySetThreadSubscription::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4132,10 +4311,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ActivitySetThreadSubscriptionError::Status304), - 403 => Err(ActivitySetThreadSubscriptionError::Status403(github_response.to_json_async().await?)), - 401 => Err(ActivitySetThreadSubscriptionError::Status401(github_response.to_json_async().await?)), - code => Err(ActivitySetThreadSubscriptionError::Generic { code }), + 304 => Err(ActivitySetThreadSubscriptionError::Status304.into()), + 403 => Err(ActivitySetThreadSubscriptionError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ActivitySetThreadSubscriptionError::Status401(github_response.to_json_async().await?).into()), + code => Err(ActivitySetThreadSubscriptionError::Generic { code }.into()), } } } @@ -4154,19 +4333,19 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_thread_subscription(&self, thread_id: i32, body: PutActivitySetThreadSubscription) -> Result { + pub fn set_thread_subscription(&self, thread_id: i32, body: PutActivitySetThreadSubscription) -> Result { let request_uri = format!("{}/notifications/threads/{}/subscription", super::GITHUB_BASE_API_URL, thread_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutActivitySetThreadSubscription::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4178,10 +4357,10 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ActivitySetThreadSubscriptionError::Status304), - 403 => Err(ActivitySetThreadSubscriptionError::Status403(github_response.to_json()?)), - 401 => Err(ActivitySetThreadSubscriptionError::Status401(github_response.to_json()?)), - code => Err(ActivitySetThreadSubscriptionError::Generic { code }), + 304 => Err(ActivitySetThreadSubscriptionError::Status304.into()), + 403 => Err(ActivitySetThreadSubscriptionError::Status403(github_response.to_json()?).into()), + 401 => Err(ActivitySetThreadSubscriptionError::Status401(github_response.to_json()?).into()), + code => Err(ActivitySetThreadSubscriptionError::Generic { code }.into()), } } } @@ -4195,19 +4374,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for star_repo_for_authenticated_user](https://docs.github.com/rest/activity/starring#star-a-repository-for-the-authenticated-user) /// /// --- - pub async fn star_repo_for_authenticated_user_async(&self, owner: &str, repo: &str) -> Result<(), ActivityStarRepoForAuthenticatedUserError> { + pub async fn star_repo_for_authenticated_user_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/starred/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4219,11 +4398,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ActivityStarRepoForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(ActivityStarRepoForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 401 => Err(ActivityStarRepoForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 304 => Err(ActivityStarRepoForAuthenticatedUserError::Status304), - code => Err(ActivityStarRepoForAuthenticatedUserError::Generic { code }), + 403 => Err(ActivityStarRepoForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ActivityStarRepoForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 401 => Err(ActivityStarRepoForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 304 => Err(ActivityStarRepoForAuthenticatedUserError::Status304.into()), + code => Err(ActivityStarRepoForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4238,7 +4417,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn star_repo_for_authenticated_user(&self, owner: &str, repo: &str) -> Result<(), ActivityStarRepoForAuthenticatedUserError> { + pub fn star_repo_for_authenticated_user(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/starred/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); @@ -4250,7 +4429,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4262,11 +4441,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ActivityStarRepoForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(ActivityStarRepoForAuthenticatedUserError::Status404(github_response.to_json()?)), - 401 => Err(ActivityStarRepoForAuthenticatedUserError::Status401(github_response.to_json()?)), - 304 => Err(ActivityStarRepoForAuthenticatedUserError::Status304), - code => Err(ActivityStarRepoForAuthenticatedUserError::Generic { code }), + 403 => Err(ActivityStarRepoForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(ActivityStarRepoForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 401 => Err(ActivityStarRepoForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 304 => Err(ActivityStarRepoForAuthenticatedUserError::Status304.into()), + code => Err(ActivityStarRepoForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4280,19 +4459,19 @@ impl<'api, C: Client> Activity<'api, C> { /// [GitHub API docs for unstar_repo_for_authenticated_user](https://docs.github.com/rest/activity/starring#unstar-a-repository-for-the-authenticated-user) /// /// --- - pub async fn unstar_repo_for_authenticated_user_async(&self, owner: &str, repo: &str) -> Result<(), ActivityUnstarRepoForAuthenticatedUserError> { + pub async fn unstar_repo_for_authenticated_user_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/starred/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4304,11 +4483,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 401 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 304 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status304), - 403 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - code => Err(ActivityUnstarRepoForAuthenticatedUserError::Generic { code }), + 404 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 401 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 304 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + code => Err(ActivityUnstarRepoForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4323,7 +4502,7 @@ impl<'api, C: Client> Activity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn unstar_repo_for_authenticated_user(&self, owner: &str, repo: &str) -> Result<(), ActivityUnstarRepoForAuthenticatedUserError> { + pub fn unstar_repo_for_authenticated_user(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/starred/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); @@ -4335,7 +4514,7 @@ impl<'api, C: Client> Activity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4347,11 +4526,11 @@ impl<'api, C: Client> Activity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status404(github_response.to_json()?)), - 401 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status401(github_response.to_json()?)), - 304 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status304), - 403 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status403(github_response.to_json()?)), - code => Err(ActivityUnstarRepoForAuthenticatedUserError::Generic { code }), + 404 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 401 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 304 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status304.into()), + 403 => Err(ActivityUnstarRepoForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + code => Err(ActivityUnstarRepoForAuthenticatedUserError::Generic { code }.into()), } } } diff --git a/src/endpoints/apps.rs b/src/endpoints/apps.rs index bb4fc6b..4794dda 100644 --- a/src/endpoints/apps.rs +++ b/src/endpoints/apps.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Apps<'api, C: Client> { +pub struct Apps<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Apps { +pub fn new(client: &C) -> Apps where AdapterError: From<::Err> { Apps { client } } /// Errors for the [Add a repository to an app installation](Apps::add_repo_to_installation_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsAddRepoToInstallationForAuthenticatedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Not modified")] @@ -53,19 +43,26 @@ pub enum AppsAddRepoToInstallationForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsAddRepoToInstallationForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + AppsAddRepoToInstallationForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + AppsAddRepoToInstallationForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + AppsAddRepoToInstallationForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + AppsAddRepoToInstallationForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check a token](Apps::check_token_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsCheckTokenError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -74,19 +71,25 @@ pub enum AppsCheckTokenError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsCheckTokenError) -> Self { + let (description, status_code) = match err { + AppsCheckTokenError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + AppsCheckTokenError::Status404(_) => (String::from("Resource not found"), 404), + AppsCheckTokenError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a GitHub App from a manifest](Apps::create_from_manifest_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsCreateFromManifestError { - #[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, or the endpoint has been spammed.")] @@ -95,19 +98,25 @@ pub enum AppsCreateFromManifestError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsCreateFromManifestError) -> Self { + let (description, status_code) = match err { + AppsCreateFromManifestError::Status404(_) => (String::from("Resource not found"), 404), + AppsCreateFromManifestError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + AppsCreateFromManifestError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an installation access token for an app](Apps::create_installation_access_token_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsCreateInstallationAccessTokenError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Requires authentication")] @@ -120,93 +129,120 @@ pub enum AppsCreateInstallationAccessTokenError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsCreateInstallationAccessTokenError) -> Self { + let (description, status_code) = match err { + AppsCreateInstallationAccessTokenError::Status403(_) => (String::from("Forbidden"), 403), + AppsCreateInstallationAccessTokenError::Status401(_) => (String::from("Requires authentication"), 401), + AppsCreateInstallationAccessTokenError::Status404(_) => (String::from("Resource not found"), 404), + AppsCreateInstallationAccessTokenError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + AppsCreateInstallationAccessTokenError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an app authorization](Apps::delete_authorization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsDeleteAuthorizationError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsDeleteAuthorizationError) -> Self { + let (description, status_code) = match err { + AppsDeleteAuthorizationError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + AppsDeleteAuthorizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an installation for the authenticated app](Apps::delete_installation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsDeleteInstallationError { - #[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 }, } +impl From for AdapterError { + fn from(err: AppsDeleteInstallationError) -> Self { + let (description, status_code) = match err { + AppsDeleteInstallationError::Status404(_) => (String::from("Resource not found"), 404), + AppsDeleteInstallationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an app token](Apps::delete_token_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsDeleteTokenError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsDeleteTokenError) -> Self { + let (description, status_code) = match err { + AppsDeleteTokenError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + AppsDeleteTokenError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the authenticated app](Apps::get_authenticated_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsGetAuthenticatedError { - #[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 }, } +impl From for AdapterError { + fn from(err: AppsGetAuthenticatedError) -> Self { + let (description, status_code) = match err { + AppsGetAuthenticatedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an app](Apps::get_by_slug_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsGetBySlugError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -215,55 +251,70 @@ pub enum AppsGetBySlugError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsGetBySlugError) -> Self { + let (description, status_code) = match err { + AppsGetBySlugError::Status403(_) => (String::from("Forbidden"), 403), + AppsGetBySlugError::Status404(_) => (String::from("Resource not found"), 404), + AppsGetBySlugError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an installation for the authenticated app](Apps::get_installation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsGetInstallationError { - #[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 }, } +impl From for AdapterError { + fn from(err: AppsGetInstallationError) -> Self { + let (description, status_code) = match err { + AppsGetInstallationError::Status404(_) => (String::from("Resource not found"), 404), + AppsGetInstallationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization installation for the authenticated app](Apps::get_org_installation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsGetOrgInstallationError { - #[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 }, } +impl From for AdapterError { + fn from(err: AppsGetOrgInstallationError) -> Self { + let (description, status_code) = match err { + AppsGetOrgInstallationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository installation for the authenticated app](Apps::get_repo_installation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsGetRepoInstallationError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Moved permanently")] Status301(BasicError), #[error("Resource not found")] @@ -272,19 +323,25 @@ pub enum AppsGetRepoInstallationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsGetRepoInstallationError) -> Self { + let (description, status_code) = match err { + AppsGetRepoInstallationError::Status301(_) => (String::from("Moved permanently"), 301), + AppsGetRepoInstallationError::Status404(_) => (String::from("Resource not found"), 404), + AppsGetRepoInstallationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a subscription plan for an account](Apps::get_subscription_plan_for_account_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsGetSubscriptionPlanForAccountError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found when the account has not purchased the listing")] Status404(BasicError), #[error("Requires authentication")] @@ -293,19 +350,25 @@ pub enum AppsGetSubscriptionPlanForAccountError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsGetSubscriptionPlanForAccountError) -> Self { + let (description, status_code) = match err { + AppsGetSubscriptionPlanForAccountError::Status404(_) => (String::from("Not Found when the account has not purchased the listing"), 404), + AppsGetSubscriptionPlanForAccountError::Status401(_) => (String::from("Requires authentication"), 401), + AppsGetSubscriptionPlanForAccountError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a subscription plan for an account (stubbed)](Apps::get_subscription_plan_for_account_stubbed_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsGetSubscriptionPlanForAccountStubbedError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found when the account has not purchased the listing")] Status404, #[error("Requires authentication")] @@ -314,53 +377,67 @@ pub enum AppsGetSubscriptionPlanForAccountStubbedError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsGetSubscriptionPlanForAccountStubbedError) -> Self { + let (description, status_code) = match err { + AppsGetSubscriptionPlanForAccountStubbedError::Status404 => (String::from("Not Found when the account has not purchased the listing"), 404), + AppsGetSubscriptionPlanForAccountStubbedError::Status401(_) => (String::from("Requires authentication"), 401), + AppsGetSubscriptionPlanForAccountStubbedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a user installation for the authenticated app](Apps::get_user_installation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsGetUserInstallationError { - #[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 }, } +impl From for AdapterError { + fn from(err: AppsGetUserInstallationError) -> Self { + let (description, status_code) = match err { + AppsGetUserInstallationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a webhook configuration for an app](Apps::get_webhook_config_for_app_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsGetWebhookConfigForAppError { - #[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 }, } +impl From for AdapterError { + fn from(err: AppsGetWebhookConfigForAppError) -> Self { + let (description, status_code) = match err { + AppsGetWebhookConfigForAppError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a delivery for an app webhook](Apps::get_webhook_delivery_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsGetWebhookDeliveryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -369,19 +446,25 @@ pub enum AppsGetWebhookDeliveryError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsGetWebhookDeliveryError) -> Self { + let (description, status_code) = match err { + AppsGetWebhookDeliveryError::Status400(_) => (String::from("Bad Request"), 400), + AppsGetWebhookDeliveryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + AppsGetWebhookDeliveryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List accounts for a plan](Apps::list_accounts_for_plan_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListAccountsForPlanError { - #[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, or the endpoint has been spammed.")] @@ -392,38 +475,50 @@ pub enum AppsListAccountsForPlanError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsListAccountsForPlanError) -> Self { + let (description, status_code) = match err { + AppsListAccountsForPlanError::Status404(_) => (String::from("Resource not found"), 404), + AppsListAccountsForPlanError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + AppsListAccountsForPlanError::Status401(_) => (String::from("Requires authentication"), 401), + AppsListAccountsForPlanError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List accounts for a plan (stubbed)](Apps::list_accounts_for_plan_stubbed_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListAccountsForPlanStubbedError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsListAccountsForPlanStubbedError) -> Self { + let (description, status_code) = match err { + AppsListAccountsForPlanStubbedError::Status401(_) => (String::from("Requires authentication"), 401), + AppsListAccountsForPlanStubbedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories accessible to the user access token](Apps::list_installation_repos_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListInstallationReposForAuthenticatedUserError { - #[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("Forbidden")] @@ -434,19 +529,26 @@ pub enum AppsListInstallationReposForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsListInstallationReposForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + AppsListInstallationReposForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + AppsListInstallationReposForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + AppsListInstallationReposForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + AppsListInstallationReposForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List installation requests for the authenticated app](Apps::list_installation_requests_for_authenticated_app_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListInstallationRequestsForAuthenticatedAppError { - #[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("Requires authentication")] @@ -455,36 +557,46 @@ pub enum AppsListInstallationRequestsForAuthenticatedAppError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsListInstallationRequestsForAuthenticatedAppError) -> Self { + let (description, status_code) = match err { + AppsListInstallationRequestsForAuthenticatedAppError::Status304 => (String::from("Not modified"), 304), + AppsListInstallationRequestsForAuthenticatedAppError::Status401(_) => (String::from("Requires authentication"), 401), + AppsListInstallationRequestsForAuthenticatedAppError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List installations for the authenticated app](Apps::list_installations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListInstallationsError { - #[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 }, } +impl From for AdapterError { + fn from(err: AppsListInstallationsError) -> Self { + let (description, status_code) = match err { + AppsListInstallationsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List app installations accessible to the user access token](Apps::list_installations_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListInstallationsForAuthenticatedUserError { - #[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("Forbidden")] @@ -495,19 +607,26 @@ pub enum AppsListInstallationsForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsListInstallationsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + AppsListInstallationsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + AppsListInstallationsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + AppsListInstallationsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + AppsListInstallationsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List plans](Apps::list_plans_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListPlansError { - #[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("Requires authentication")] @@ -516,38 +635,49 @@ pub enum AppsListPlansError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsListPlansError) -> Self { + let (description, status_code) = match err { + AppsListPlansError::Status404(_) => (String::from("Resource not found"), 404), + AppsListPlansError::Status401(_) => (String::from("Requires authentication"), 401), + AppsListPlansError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List plans (stubbed)](Apps::list_plans_stubbed_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListPlansStubbedError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsListPlansStubbedError) -> Self { + let (description, status_code) = match err { + AppsListPlansStubbedError::Status401(_) => (String::from("Requires authentication"), 401), + AppsListPlansStubbedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories accessible to the app installation](Apps::list_repos_accessible_to_installation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListReposAccessibleToInstallationError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Not modified")] @@ -558,19 +688,26 @@ pub enum AppsListReposAccessibleToInstallationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsListReposAccessibleToInstallationError) -> Self { + let (description, status_code) = match err { + AppsListReposAccessibleToInstallationError::Status403(_) => (String::from("Forbidden"), 403), + AppsListReposAccessibleToInstallationError::Status304 => (String::from("Not modified"), 304), + AppsListReposAccessibleToInstallationError::Status401(_) => (String::from("Requires authentication"), 401), + AppsListReposAccessibleToInstallationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List subscriptions for the authenticated user](Apps::list_subscriptions_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListSubscriptionsForAuthenticatedUserError { - #[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("Requires authentication")] @@ -581,19 +718,26 @@ pub enum AppsListSubscriptionsForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsListSubscriptionsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + AppsListSubscriptionsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + AppsListSubscriptionsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + AppsListSubscriptionsForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + AppsListSubscriptionsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List subscriptions for the authenticated user (stubbed)](Apps::list_subscriptions_for_authenticated_user_stubbed_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListSubscriptionsForAuthenticatedUserStubbedError { - #[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("Requires authentication")] @@ -602,19 +746,25 @@ pub enum AppsListSubscriptionsForAuthenticatedUserStubbedError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsListSubscriptionsForAuthenticatedUserStubbedError) -> Self { + let (description, status_code) = match err { + AppsListSubscriptionsForAuthenticatedUserStubbedError::Status304 => (String::from("Not modified"), 304), + AppsListSubscriptionsForAuthenticatedUserStubbedError::Status401(_) => (String::from("Requires authentication"), 401), + AppsListSubscriptionsForAuthenticatedUserStubbedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List deliveries for an app webhook](Apps::list_webhook_deliveries_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsListWebhookDeliveriesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -623,19 +773,25 @@ pub enum AppsListWebhookDeliveriesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsListWebhookDeliveriesError) -> Self { + let (description, status_code) = match err { + AppsListWebhookDeliveriesError::Status400(_) => (String::from("Bad Request"), 400), + AppsListWebhookDeliveriesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + AppsListWebhookDeliveriesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Redeliver a delivery for an app webhook](Apps::redeliver_webhook_delivery_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsRedeliverWebhookDeliveryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -644,19 +800,25 @@ pub enum AppsRedeliverWebhookDeliveryError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsRedeliverWebhookDeliveryError) -> Self { + let (description, status_code) = match err { + AppsRedeliverWebhookDeliveryError::Status400(_) => (String::from("Bad Request"), 400), + AppsRedeliverWebhookDeliveryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + AppsRedeliverWebhookDeliveryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove a repository from an app installation](Apps::remove_repo_from_installation_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsRemoveRepoFromInstallationForAuthenticatedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Not modified")] @@ -669,55 +831,72 @@ pub enum AppsRemoveRepoFromInstallationForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsRemoveRepoFromInstallationForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status422 => (String::from("Returned when the application is installed on `all` repositories in the organization, or if this request would remove the last repository that the application has access to in the organization."), 422), + AppsRemoveRepoFromInstallationForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Reset a token](Apps::reset_token_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsResetTokenError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsResetTokenError) -> Self { + let (description, status_code) = match err { + AppsResetTokenError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + AppsResetTokenError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Revoke an installation access token](Apps::revoke_installation_access_token_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsRevokeInstallationAccessTokenError { - #[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 }, } +impl From for AdapterError { + fn from(err: AppsRevokeInstallationAccessTokenError) -> Self { + let (description, status_code) = match err { + AppsRevokeInstallationAccessTokenError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a scoped access token](Apps::scope_token_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsScopeTokenError { - #[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")] @@ -730,61 +909,93 @@ pub enum AppsScopeTokenError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: AppsScopeTokenError) -> Self { + let (description, status_code) = match err { + AppsScopeTokenError::Status401(_) => (String::from("Requires authentication"), 401), + AppsScopeTokenError::Status403(_) => (String::from("Forbidden"), 403), + AppsScopeTokenError::Status404(_) => (String::from("Resource not found"), 404), + AppsScopeTokenError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + AppsScopeTokenError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Suspend an app installation](Apps::suspend_installation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsSuspendInstallationError { - #[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 }, } +impl From for AdapterError { + fn from(err: AppsSuspendInstallationError) -> Self { + let (description, status_code) = match err { + AppsSuspendInstallationError::Status404(_) => (String::from("Resource not found"), 404), + AppsSuspendInstallationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Unsuspend an app installation](Apps::unsuspend_installation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsUnsuspendInstallationError { - #[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 }, } +impl From for AdapterError { + fn from(err: AppsUnsuspendInstallationError) -> Self { + let (description, status_code) = match err { + AppsUnsuspendInstallationError::Status404(_) => (String::from("Resource not found"), 404), + AppsUnsuspendInstallationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a webhook configuration for an app](Apps::update_webhook_config_for_app_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum AppsUpdateWebhookConfigForAppError { - #[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 }, } +impl From for AdapterError { + fn from(err: AppsUpdateWebhookConfigForAppError) -> Self { + let (description, status_code) = match err { + AppsUpdateWebhookConfigForAppError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List accounts for a plan](Apps::list_accounts_for_plan_async()) endpoint. #[derive(Default, Serialize)] @@ -1355,7 +1566,7 @@ impl<'req> AppsListWebhookDeliveriesParams<'req> { } -impl<'api, C: Client> Apps<'api, C> { +impl<'api, C: Client> Apps<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Add a repository to an app installation @@ -1367,19 +1578,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for add_repo_to_installation_for_authenticated_user](https://docs.github.com/rest/apps/installations#add-a-repository-to-an-app-installation) /// /// --- - pub async fn add_repo_to_installation_for_authenticated_user_async(&self, installation_id: i32, repository_id: i32) -> Result<(), AppsAddRepoToInstallationForAuthenticatedUserError> { + pub async fn add_repo_to_installation_for_authenticated_user_async(&self, installation_id: i32, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/installations/{}/repositories/{}", super::GITHUB_BASE_API_URL, installation_id, repository_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1391,10 +1602,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 304 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status304), - 404 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Generic { code }), + 403 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 304 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status304.into()), + 404 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1411,7 +1622,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_repo_to_installation_for_authenticated_user(&self, installation_id: i32, repository_id: i32) -> Result<(), AppsAddRepoToInstallationForAuthenticatedUserError> { + pub fn add_repo_to_installation_for_authenticated_user(&self, installation_id: i32, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/installations/{}/repositories/{}", super::GITHUB_BASE_API_URL, installation_id, repository_id); @@ -1423,7 +1634,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1435,10 +1646,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status403(github_response.to_json()?)), - 304 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status304), - 404 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Generic { code }), + 403 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 304 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status304.into()), + 404 => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(AppsAddRepoToInstallationForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1452,19 +1663,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for check_token](https://docs.github.com/rest/apps/oauth-applications#check-a-token) /// /// --- - pub async fn check_token_async(&self, client_id: &str, body: PostAppsCheckToken) -> Result { + pub async fn check_token_async(&self, client_id: &str, body: PostAppsCheckToken) -> Result { let request_uri = format!("{}/applications/{}/token", super::GITHUB_BASE_API_URL, client_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostAppsCheckToken::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1476,9 +1687,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(AppsCheckTokenError::Status422(github_response.to_json_async().await?)), - 404 => Err(AppsCheckTokenError::Status404(github_response.to_json_async().await?)), - code => Err(AppsCheckTokenError::Generic { code }), + 422 => Err(AppsCheckTokenError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(AppsCheckTokenError::Status404(github_response.to_json_async().await?).into()), + code => Err(AppsCheckTokenError::Generic { code }.into()), } } } @@ -1493,19 +1704,19 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_token(&self, client_id: &str, body: PostAppsCheckToken) -> Result { + pub fn check_token(&self, client_id: &str, body: PostAppsCheckToken) -> Result { let request_uri = format!("{}/applications/{}/token", super::GITHUB_BASE_API_URL, client_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostAppsCheckToken::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1517,9 +1728,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(AppsCheckTokenError::Status422(github_response.to_json()?)), - 404 => Err(AppsCheckTokenError::Status404(github_response.to_json()?)), - code => Err(AppsCheckTokenError::Generic { code }), + 422 => Err(AppsCheckTokenError::Status422(github_response.to_json()?).into()), + 404 => Err(AppsCheckTokenError::Status404(github_response.to_json()?).into()), + code => Err(AppsCheckTokenError::Generic { code }.into()), } } } @@ -1533,19 +1744,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for create_from_manifest](https://docs.github.com/rest/apps/apps#create-a-github-app-from-a-manifest) /// /// --- - pub async fn create_from_manifest_async(&self, code: &str) -> Result { + pub async fn create_from_manifest_async(&self, code: &str) -> Result { let request_uri = format!("{}/app-manifests/{}/conversions", super::GITHUB_BASE_API_URL, code); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1557,9 +1768,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(AppsCreateFromManifestError::Status404(github_response.to_json_async().await?)), - 422 => Err(AppsCreateFromManifestError::Status422(github_response.to_json_async().await?)), - code => Err(AppsCreateFromManifestError::Generic { code }), + 404 => Err(AppsCreateFromManifestError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(AppsCreateFromManifestError::Status422(github_response.to_json_async().await?).into()), + code => Err(AppsCreateFromManifestError::Generic { code }.into()), } } } @@ -1574,7 +1785,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_from_manifest(&self, code: &str) -> Result { + pub fn create_from_manifest(&self, code: &str) -> Result { let request_uri = format!("{}/app-manifests/{}/conversions", super::GITHUB_BASE_API_URL, code); @@ -1586,7 +1797,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1598,9 +1809,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(AppsCreateFromManifestError::Status404(github_response.to_json()?)), - 422 => Err(AppsCreateFromManifestError::Status422(github_response.to_json()?)), - code => Err(AppsCreateFromManifestError::Generic { code }), + 404 => Err(AppsCreateFromManifestError::Status404(github_response.to_json()?).into()), + 422 => Err(AppsCreateFromManifestError::Status422(github_response.to_json()?).into()), + code => Err(AppsCreateFromManifestError::Generic { code }.into()), } } } @@ -1622,19 +1833,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for create_installation_access_token](https://docs.github.com/rest/apps/apps#create-an-installation-access-token-for-an-app) /// /// --- - pub async fn create_installation_access_token_async(&self, installation_id: i32, body: PostAppsCreateInstallationAccessToken) -> Result { + pub async fn create_installation_access_token_async(&self, installation_id: i32, body: PostAppsCreateInstallationAccessToken) -> Result { let request_uri = format!("{}/app/installations/{}/access_tokens", super::GITHUB_BASE_API_URL, installation_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostAppsCreateInstallationAccessToken::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1646,11 +1857,11 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(AppsCreateInstallationAccessTokenError::Status403(github_response.to_json_async().await?)), - 401 => Err(AppsCreateInstallationAccessTokenError::Status401(github_response.to_json_async().await?)), - 404 => Err(AppsCreateInstallationAccessTokenError::Status404(github_response.to_json_async().await?)), - 422 => Err(AppsCreateInstallationAccessTokenError::Status422(github_response.to_json_async().await?)), - code => Err(AppsCreateInstallationAccessTokenError::Generic { code }), + 403 => Err(AppsCreateInstallationAccessTokenError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(AppsCreateInstallationAccessTokenError::Status401(github_response.to_json_async().await?).into()), + 404 => Err(AppsCreateInstallationAccessTokenError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(AppsCreateInstallationAccessTokenError::Status422(github_response.to_json_async().await?).into()), + code => Err(AppsCreateInstallationAccessTokenError::Generic { code }.into()), } } } @@ -1673,19 +1884,19 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_installation_access_token(&self, installation_id: i32, body: PostAppsCreateInstallationAccessToken) -> Result { + pub fn create_installation_access_token(&self, installation_id: i32, body: PostAppsCreateInstallationAccessToken) -> Result { let request_uri = format!("{}/app/installations/{}/access_tokens", super::GITHUB_BASE_API_URL, installation_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostAppsCreateInstallationAccessToken::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1697,11 +1908,11 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(AppsCreateInstallationAccessTokenError::Status403(github_response.to_json()?)), - 401 => Err(AppsCreateInstallationAccessTokenError::Status401(github_response.to_json()?)), - 404 => Err(AppsCreateInstallationAccessTokenError::Status404(github_response.to_json()?)), - 422 => Err(AppsCreateInstallationAccessTokenError::Status422(github_response.to_json()?)), - code => Err(AppsCreateInstallationAccessTokenError::Generic { code }), + 403 => Err(AppsCreateInstallationAccessTokenError::Status403(github_response.to_json()?).into()), + 401 => Err(AppsCreateInstallationAccessTokenError::Status401(github_response.to_json()?).into()), + 404 => Err(AppsCreateInstallationAccessTokenError::Status404(github_response.to_json()?).into()), + 422 => Err(AppsCreateInstallationAccessTokenError::Status422(github_response.to_json()?).into()), + code => Err(AppsCreateInstallationAccessTokenError::Generic { code }.into()), } } } @@ -1716,19 +1927,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for delete_authorization](https://docs.github.com/rest/apps/oauth-applications#delete-an-app-authorization) /// /// --- - pub async fn delete_authorization_async(&self, client_id: &str, body: DeleteAppsDeleteAuthorization) -> Result<(), AppsDeleteAuthorizationError> { + pub async fn delete_authorization_async(&self, client_id: &str, body: DeleteAppsDeleteAuthorization) -> Result<(), AdapterError> { let request_uri = format!("{}/applications/{}/grant", super::GITHUB_BASE_API_URL, client_id); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteAppsDeleteAuthorization::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1740,8 +1951,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(AppsDeleteAuthorizationError::Status422(github_response.to_json_async().await?)), - code => Err(AppsDeleteAuthorizationError::Generic { code }), + 422 => Err(AppsDeleteAuthorizationError::Status422(github_response.to_json_async().await?).into()), + code => Err(AppsDeleteAuthorizationError::Generic { code }.into()), } } } @@ -1757,19 +1968,19 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_authorization(&self, client_id: &str, body: DeleteAppsDeleteAuthorization) -> Result<(), AppsDeleteAuthorizationError> { + pub fn delete_authorization(&self, client_id: &str, body: DeleteAppsDeleteAuthorization) -> Result<(), AdapterError> { let request_uri = format!("{}/applications/{}/grant", super::GITHUB_BASE_API_URL, client_id); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteAppsDeleteAuthorization::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1781,8 +1992,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(AppsDeleteAuthorizationError::Status422(github_response.to_json()?)), - code => Err(AppsDeleteAuthorizationError::Generic { code }), + 422 => Err(AppsDeleteAuthorizationError::Status422(github_response.to_json()?).into()), + code => Err(AppsDeleteAuthorizationError::Generic { code }.into()), } } } @@ -1798,19 +2009,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for delete_installation](https://docs.github.com/rest/apps/apps#delete-an-installation-for-the-authenticated-app) /// /// --- - pub async fn delete_installation_async(&self, installation_id: i32) -> Result<(), AppsDeleteInstallationError> { + pub async fn delete_installation_async(&self, installation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/app/installations/{}", super::GITHUB_BASE_API_URL, installation_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1822,8 +2033,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(AppsDeleteInstallationError::Status404(github_response.to_json_async().await?)), - code => Err(AppsDeleteInstallationError::Generic { code }), + 404 => Err(AppsDeleteInstallationError::Status404(github_response.to_json_async().await?).into()), + code => Err(AppsDeleteInstallationError::Generic { code }.into()), } } } @@ -1840,7 +2051,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_installation(&self, installation_id: i32) -> Result<(), AppsDeleteInstallationError> { + pub fn delete_installation(&self, installation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/app/installations/{}", super::GITHUB_BASE_API_URL, installation_id); @@ -1852,7 +2063,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1864,8 +2075,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(AppsDeleteInstallationError::Status404(github_response.to_json()?)), - code => Err(AppsDeleteInstallationError::Generic { code }), + 404 => Err(AppsDeleteInstallationError::Status404(github_response.to_json()?).into()), + code => Err(AppsDeleteInstallationError::Generic { code }.into()), } } } @@ -1879,19 +2090,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for delete_token](https://docs.github.com/rest/apps/oauth-applications#delete-an-app-token) /// /// --- - pub async fn delete_token_async(&self, client_id: &str, body: DeleteAppsDeleteToken) -> Result<(), AppsDeleteTokenError> { + pub async fn delete_token_async(&self, client_id: &str, body: DeleteAppsDeleteToken) -> Result<(), AdapterError> { let request_uri = format!("{}/applications/{}/token", super::GITHUB_BASE_API_URL, client_id); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteAppsDeleteToken::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1903,8 +2114,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(AppsDeleteTokenError::Status422(github_response.to_json_async().await?)), - code => Err(AppsDeleteTokenError::Generic { code }), + 422 => Err(AppsDeleteTokenError::Status422(github_response.to_json_async().await?).into()), + code => Err(AppsDeleteTokenError::Generic { code }.into()), } } } @@ -1919,19 +2130,19 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_token(&self, client_id: &str, body: DeleteAppsDeleteToken) -> Result<(), AppsDeleteTokenError> { + pub fn delete_token(&self, client_id: &str, body: DeleteAppsDeleteToken) -> Result<(), AdapterError> { let request_uri = format!("{}/applications/{}/token", super::GITHUB_BASE_API_URL, client_id); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteAppsDeleteToken::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1943,8 +2154,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(AppsDeleteTokenError::Status422(github_response.to_json()?)), - code => Err(AppsDeleteTokenError::Generic { code }), + 422 => Err(AppsDeleteTokenError::Status422(github_response.to_json()?).into()), + code => Err(AppsDeleteTokenError::Generic { code }.into()), } } } @@ -1960,19 +2171,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for get_authenticated](https://docs.github.com/rest/apps/apps#get-the-authenticated-app) /// /// --- - pub async fn get_authenticated_async(&self) -> Result { + pub async fn get_authenticated_async(&self) -> Result { let request_uri = format!("{}/app", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1984,7 +2195,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(AppsGetAuthenticatedError::Generic { code }), + code => Err(AppsGetAuthenticatedError::Generic { code }.into()), } } } @@ -2001,7 +2212,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_authenticated(&self) -> Result { + pub fn get_authenticated(&self) -> Result { let request_uri = format!("{}/app", super::GITHUB_BASE_API_URL); @@ -2013,7 +2224,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2025,7 +2236,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(AppsGetAuthenticatedError::Generic { code }), + code => Err(AppsGetAuthenticatedError::Generic { code }.into()), } } } @@ -2040,19 +2251,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for get_by_slug](https://docs.github.com/rest/apps/apps#get-an-app) /// /// --- - pub async fn get_by_slug_async(&self, app_slug: &str) -> Result { + pub async fn get_by_slug_async(&self, app_slug: &str) -> Result { let request_uri = format!("{}/apps/{}", super::GITHUB_BASE_API_URL, app_slug); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2064,9 +2275,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(AppsGetBySlugError::Status403(github_response.to_json_async().await?)), - 404 => Err(AppsGetBySlugError::Status404(github_response.to_json_async().await?)), - code => Err(AppsGetBySlugError::Generic { code }), + 403 => Err(AppsGetBySlugError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(AppsGetBySlugError::Status404(github_response.to_json_async().await?).into()), + code => Err(AppsGetBySlugError::Generic { code }.into()), } } } @@ -2082,7 +2293,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_by_slug(&self, app_slug: &str) -> Result { + pub fn get_by_slug(&self, app_slug: &str) -> Result { let request_uri = format!("{}/apps/{}", super::GITHUB_BASE_API_URL, app_slug); @@ -2094,7 +2305,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2106,9 +2317,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(AppsGetBySlugError::Status403(github_response.to_json()?)), - 404 => Err(AppsGetBySlugError::Status404(github_response.to_json()?)), - code => Err(AppsGetBySlugError::Generic { code }), + 403 => Err(AppsGetBySlugError::Status403(github_response.to_json()?).into()), + 404 => Err(AppsGetBySlugError::Status404(github_response.to_json()?).into()), + code => Err(AppsGetBySlugError::Generic { code }.into()), } } } @@ -2124,19 +2335,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for get_installation](https://docs.github.com/rest/apps/apps#get-an-installation-for-the-authenticated-app) /// /// --- - pub async fn get_installation_async(&self, installation_id: i32) -> Result { + pub async fn get_installation_async(&self, installation_id: i32) -> Result { let request_uri = format!("{}/app/installations/{}", super::GITHUB_BASE_API_URL, installation_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2148,8 +2359,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(AppsGetInstallationError::Status404(github_response.to_json_async().await?)), - code => Err(AppsGetInstallationError::Generic { code }), + 404 => Err(AppsGetInstallationError::Status404(github_response.to_json_async().await?).into()), + code => Err(AppsGetInstallationError::Generic { code }.into()), } } } @@ -2166,7 +2377,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_installation(&self, installation_id: i32) -> Result { + pub fn get_installation(&self, installation_id: i32) -> Result { let request_uri = format!("{}/app/installations/{}", super::GITHUB_BASE_API_URL, installation_id); @@ -2178,7 +2389,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2190,8 +2401,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(AppsGetInstallationError::Status404(github_response.to_json()?)), - code => Err(AppsGetInstallationError::Generic { code }), + 404 => Err(AppsGetInstallationError::Status404(github_response.to_json()?).into()), + code => Err(AppsGetInstallationError::Generic { code }.into()), } } } @@ -2207,19 +2418,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for get_org_installation](https://docs.github.com/rest/apps/apps#get-an-organization-installation-for-the-authenticated-app) /// /// --- - pub async fn get_org_installation_async(&self, org: &str) -> Result { + pub async fn get_org_installation_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/installation", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2231,7 +2442,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(AppsGetOrgInstallationError::Generic { code }), + code => Err(AppsGetOrgInstallationError::Generic { code }.into()), } } } @@ -2248,7 +2459,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_installation(&self, org: &str) -> Result { + pub fn get_org_installation(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/installation", super::GITHUB_BASE_API_URL, org); @@ -2260,7 +2471,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2272,7 +2483,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(AppsGetOrgInstallationError::Generic { code }), + code => Err(AppsGetOrgInstallationError::Generic { code }.into()), } } } @@ -2288,19 +2499,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for get_repo_installation](https://docs.github.com/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app) /// /// --- - pub async fn get_repo_installation_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_repo_installation_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/installation", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2312,9 +2523,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 301 => Err(AppsGetRepoInstallationError::Status301(github_response.to_json_async().await?)), - 404 => Err(AppsGetRepoInstallationError::Status404(github_response.to_json_async().await?)), - code => Err(AppsGetRepoInstallationError::Generic { code }), + 301 => Err(AppsGetRepoInstallationError::Status301(github_response.to_json_async().await?).into()), + 404 => Err(AppsGetRepoInstallationError::Status404(github_response.to_json_async().await?).into()), + code => Err(AppsGetRepoInstallationError::Generic { code }.into()), } } } @@ -2331,7 +2542,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_installation(&self, owner: &str, repo: &str) -> Result { + pub fn get_repo_installation(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/installation", super::GITHUB_BASE_API_URL, owner, repo); @@ -2343,7 +2554,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2355,9 +2566,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 301 => Err(AppsGetRepoInstallationError::Status301(github_response.to_json()?)), - 404 => Err(AppsGetRepoInstallationError::Status404(github_response.to_json()?)), - code => Err(AppsGetRepoInstallationError::Generic { code }), + 301 => Err(AppsGetRepoInstallationError::Status301(github_response.to_json()?).into()), + 404 => Err(AppsGetRepoInstallationError::Status404(github_response.to_json()?).into()), + code => Err(AppsGetRepoInstallationError::Generic { code }.into()), } } } @@ -2373,19 +2584,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for get_subscription_plan_for_account](https://docs.github.com/rest/apps/marketplace#get-a-subscription-plan-for-an-account) /// /// --- - pub async fn get_subscription_plan_for_account_async(&self, account_id: i32) -> Result { + pub async fn get_subscription_plan_for_account_async(&self, account_id: i32) -> Result { let request_uri = format!("{}/marketplace_listing/accounts/{}", super::GITHUB_BASE_API_URL, account_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2397,9 +2608,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(AppsGetSubscriptionPlanForAccountError::Status404(github_response.to_json_async().await?)), - 401 => Err(AppsGetSubscriptionPlanForAccountError::Status401(github_response.to_json_async().await?)), - code => Err(AppsGetSubscriptionPlanForAccountError::Generic { code }), + 404 => Err(AppsGetSubscriptionPlanForAccountError::Status404(github_response.to_json_async().await?).into()), + 401 => Err(AppsGetSubscriptionPlanForAccountError::Status401(github_response.to_json_async().await?).into()), + code => Err(AppsGetSubscriptionPlanForAccountError::Generic { code }.into()), } } } @@ -2416,7 +2627,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_subscription_plan_for_account(&self, account_id: i32) -> Result { + pub fn get_subscription_plan_for_account(&self, account_id: i32) -> Result { let request_uri = format!("{}/marketplace_listing/accounts/{}", super::GITHUB_BASE_API_URL, account_id); @@ -2428,7 +2639,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2440,9 +2651,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(AppsGetSubscriptionPlanForAccountError::Status404(github_response.to_json()?)), - 401 => Err(AppsGetSubscriptionPlanForAccountError::Status401(github_response.to_json()?)), - code => Err(AppsGetSubscriptionPlanForAccountError::Generic { code }), + 404 => Err(AppsGetSubscriptionPlanForAccountError::Status404(github_response.to_json()?).into()), + 401 => Err(AppsGetSubscriptionPlanForAccountError::Status401(github_response.to_json()?).into()), + code => Err(AppsGetSubscriptionPlanForAccountError::Generic { code }.into()), } } } @@ -2458,19 +2669,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for get_subscription_plan_for_account_stubbed](https://docs.github.com/rest/apps/marketplace#get-a-subscription-plan-for-an-account-stubbed) /// /// --- - pub async fn get_subscription_plan_for_account_stubbed_async(&self, account_id: i32) -> Result { + pub async fn get_subscription_plan_for_account_stubbed_async(&self, account_id: i32) -> Result { let request_uri = format!("{}/marketplace_listing/stubbed/accounts/{}", super::GITHUB_BASE_API_URL, account_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2482,9 +2693,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(AppsGetSubscriptionPlanForAccountStubbedError::Status404), - 401 => Err(AppsGetSubscriptionPlanForAccountStubbedError::Status401(github_response.to_json_async().await?)), - code => Err(AppsGetSubscriptionPlanForAccountStubbedError::Generic { code }), + 404 => Err(AppsGetSubscriptionPlanForAccountStubbedError::Status404.into()), + 401 => Err(AppsGetSubscriptionPlanForAccountStubbedError::Status401(github_response.to_json_async().await?).into()), + code => Err(AppsGetSubscriptionPlanForAccountStubbedError::Generic { code }.into()), } } } @@ -2501,7 +2712,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_subscription_plan_for_account_stubbed(&self, account_id: i32) -> Result { + pub fn get_subscription_plan_for_account_stubbed(&self, account_id: i32) -> Result { let request_uri = format!("{}/marketplace_listing/stubbed/accounts/{}", super::GITHUB_BASE_API_URL, account_id); @@ -2513,7 +2724,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2525,9 +2736,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(AppsGetSubscriptionPlanForAccountStubbedError::Status404), - 401 => Err(AppsGetSubscriptionPlanForAccountStubbedError::Status401(github_response.to_json()?)), - code => Err(AppsGetSubscriptionPlanForAccountStubbedError::Generic { code }), + 404 => Err(AppsGetSubscriptionPlanForAccountStubbedError::Status404.into()), + 401 => Err(AppsGetSubscriptionPlanForAccountStubbedError::Status401(github_response.to_json()?).into()), + code => Err(AppsGetSubscriptionPlanForAccountStubbedError::Generic { code }.into()), } } } @@ -2543,19 +2754,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for get_user_installation](https://docs.github.com/rest/apps/apps#get-a-user-installation-for-the-authenticated-app) /// /// --- - pub async fn get_user_installation_async(&self, username: &str) -> Result { + pub async fn get_user_installation_async(&self, username: &str) -> Result { let request_uri = format!("{}/users/{}/installation", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2567,7 +2778,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(AppsGetUserInstallationError::Generic { code }), + code => Err(AppsGetUserInstallationError::Generic { code }.into()), } } } @@ -2584,7 +2795,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_user_installation(&self, username: &str) -> Result { + pub fn get_user_installation(&self, username: &str) -> Result { let request_uri = format!("{}/users/{}/installation", super::GITHUB_BASE_API_URL, username); @@ -2596,7 +2807,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2608,7 +2819,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(AppsGetUserInstallationError::Generic { code }), + code => Err(AppsGetUserInstallationError::Generic { code }.into()), } } } @@ -2624,19 +2835,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for get_webhook_config_for_app](https://docs.github.com/rest/apps/webhooks#get-a-webhook-configuration-for-an-app) /// /// --- - pub async fn get_webhook_config_for_app_async(&self) -> Result { + pub async fn get_webhook_config_for_app_async(&self) -> Result { let request_uri = format!("{}/app/hook/config", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2648,7 +2859,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(AppsGetWebhookConfigForAppError::Generic { code }), + code => Err(AppsGetWebhookConfigForAppError::Generic { code }.into()), } } } @@ -2665,7 +2876,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_webhook_config_for_app(&self) -> Result { + pub fn get_webhook_config_for_app(&self) -> Result { let request_uri = format!("{}/app/hook/config", super::GITHUB_BASE_API_URL); @@ -2677,7 +2888,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2689,7 +2900,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(AppsGetWebhookConfigForAppError::Generic { code }), + code => Err(AppsGetWebhookConfigForAppError::Generic { code }.into()), } } } @@ -2705,19 +2916,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for get_webhook_delivery](https://docs.github.com/rest/apps/webhooks#get-a-delivery-for-an-app-webhook) /// /// --- - pub async fn get_webhook_delivery_async(&self, delivery_id: i32) -> Result { + pub async fn get_webhook_delivery_async(&self, delivery_id: i32) -> Result { let request_uri = format!("{}/app/hook/deliveries/{}", super::GITHUB_BASE_API_URL, delivery_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2729,9 +2940,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(AppsGetWebhookDeliveryError::Status400(github_response.to_json_async().await?)), - 422 => Err(AppsGetWebhookDeliveryError::Status422(github_response.to_json_async().await?)), - code => Err(AppsGetWebhookDeliveryError::Generic { code }), + 400 => Err(AppsGetWebhookDeliveryError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(AppsGetWebhookDeliveryError::Status422(github_response.to_json_async().await?).into()), + code => Err(AppsGetWebhookDeliveryError::Generic { code }.into()), } } } @@ -2748,7 +2959,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_webhook_delivery(&self, delivery_id: i32) -> Result { + pub fn get_webhook_delivery(&self, delivery_id: i32) -> Result { let request_uri = format!("{}/app/hook/deliveries/{}", super::GITHUB_BASE_API_URL, delivery_id); @@ -2760,7 +2971,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2772,9 +2983,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(AppsGetWebhookDeliveryError::Status400(github_response.to_json()?)), - 422 => Err(AppsGetWebhookDeliveryError::Status422(github_response.to_json()?)), - code => Err(AppsGetWebhookDeliveryError::Generic { code }), + 400 => Err(AppsGetWebhookDeliveryError::Status400(github_response.to_json()?).into()), + 422 => Err(AppsGetWebhookDeliveryError::Status422(github_response.to_json()?).into()), + code => Err(AppsGetWebhookDeliveryError::Generic { code }.into()), } } } @@ -2790,7 +3001,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_accounts_for_plan](https://docs.github.com/rest/apps/marketplace#list-accounts-for-a-plan) /// /// --- - pub async fn list_accounts_for_plan_async(&self, plan_id: i32, query_params: Option>>) -> Result, AppsListAccountsForPlanError> { + pub async fn list_accounts_for_plan_async(&self, plan_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/marketplace_listing/plans/{}/accounts", super::GITHUB_BASE_API_URL, plan_id); @@ -2801,12 +3012,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2818,10 +3029,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(AppsListAccountsForPlanError::Status404(github_response.to_json_async().await?)), - 422 => Err(AppsListAccountsForPlanError::Status422(github_response.to_json_async().await?)), - 401 => Err(AppsListAccountsForPlanError::Status401(github_response.to_json_async().await?)), - code => Err(AppsListAccountsForPlanError::Generic { code }), + 404 => Err(AppsListAccountsForPlanError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(AppsListAccountsForPlanError::Status422(github_response.to_json_async().await?).into()), + 401 => Err(AppsListAccountsForPlanError::Status401(github_response.to_json_async().await?).into()), + code => Err(AppsListAccountsForPlanError::Generic { code }.into()), } } } @@ -2838,7 +3049,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_accounts_for_plan(&self, plan_id: i32, query_params: Option>>) -> Result, AppsListAccountsForPlanError> { + pub fn list_accounts_for_plan(&self, plan_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/marketplace_listing/plans/{}/accounts", super::GITHUB_BASE_API_URL, plan_id); @@ -2855,7 +3066,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2867,10 +3078,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(AppsListAccountsForPlanError::Status404(github_response.to_json()?)), - 422 => Err(AppsListAccountsForPlanError::Status422(github_response.to_json()?)), - 401 => Err(AppsListAccountsForPlanError::Status401(github_response.to_json()?)), - code => Err(AppsListAccountsForPlanError::Generic { code }), + 404 => Err(AppsListAccountsForPlanError::Status404(github_response.to_json()?).into()), + 422 => Err(AppsListAccountsForPlanError::Status422(github_response.to_json()?).into()), + 401 => Err(AppsListAccountsForPlanError::Status401(github_response.to_json()?).into()), + code => Err(AppsListAccountsForPlanError::Generic { code }.into()), } } } @@ -2886,7 +3097,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_accounts_for_plan_stubbed](https://docs.github.com/rest/apps/marketplace#list-accounts-for-a-plan-stubbed) /// /// --- - pub async fn list_accounts_for_plan_stubbed_async(&self, plan_id: i32, query_params: Option>>) -> Result, AppsListAccountsForPlanStubbedError> { + pub async fn list_accounts_for_plan_stubbed_async(&self, plan_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/marketplace_listing/stubbed/plans/{}/accounts", super::GITHUB_BASE_API_URL, plan_id); @@ -2897,12 +3108,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2914,8 +3125,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(AppsListAccountsForPlanStubbedError::Status401(github_response.to_json_async().await?)), - code => Err(AppsListAccountsForPlanStubbedError::Generic { code }), + 401 => Err(AppsListAccountsForPlanStubbedError::Status401(github_response.to_json_async().await?).into()), + code => Err(AppsListAccountsForPlanStubbedError::Generic { code }.into()), } } } @@ -2932,7 +3143,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_accounts_for_plan_stubbed(&self, plan_id: i32, query_params: Option>>) -> Result, AppsListAccountsForPlanStubbedError> { + pub fn list_accounts_for_plan_stubbed(&self, plan_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/marketplace_listing/stubbed/plans/{}/accounts", super::GITHUB_BASE_API_URL, plan_id); @@ -2949,7 +3160,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2961,8 +3172,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(AppsListAccountsForPlanStubbedError::Status401(github_response.to_json()?)), - code => Err(AppsListAccountsForPlanStubbedError::Generic { code }), + 401 => Err(AppsListAccountsForPlanStubbedError::Status401(github_response.to_json()?).into()), + code => Err(AppsListAccountsForPlanStubbedError::Generic { code }.into()), } } } @@ -2980,7 +3191,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_installation_repos_for_authenticated_user](https://docs.github.com/rest/apps/installations#list-repositories-accessible-to-the-user-access-token) /// /// --- - pub async fn list_installation_repos_for_authenticated_user_async(&self, installation_id: i32, query_params: Option>) -> Result { + 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); @@ -2991,12 +3202,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3008,10 +3219,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(AppsListInstallationReposForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(AppsListInstallationReposForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 304 => Err(AppsListInstallationReposForAuthenticatedUserError::Status304), - code => Err(AppsListInstallationReposForAuthenticatedUserError::Generic { code }), + 404 => Err(AppsListInstallationReposForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(AppsListInstallationReposForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 304 => Err(AppsListInstallationReposForAuthenticatedUserError::Status304.into()), + code => Err(AppsListInstallationReposForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3030,7 +3241,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_installation_repos_for_authenticated_user(&self, installation_id: i32, query_params: Option>) -> Result { + 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); @@ -3047,7 +3258,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3059,10 +3270,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(AppsListInstallationReposForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(AppsListInstallationReposForAuthenticatedUserError::Status403(github_response.to_json()?)), - 304 => Err(AppsListInstallationReposForAuthenticatedUserError::Status304), - code => Err(AppsListInstallationReposForAuthenticatedUserError::Generic { code }), + 404 => Err(AppsListInstallationReposForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(AppsListInstallationReposForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 304 => Err(AppsListInstallationReposForAuthenticatedUserError::Status304.into()), + code => Err(AppsListInstallationReposForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3076,7 +3287,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_installation_requests_for_authenticated_app](https://docs.github.com/rest/apps/apps#list-installation-requests-for-the-authenticated-app) /// /// --- - pub async fn list_installation_requests_for_authenticated_app_async(&self, query_params: Option>) -> Result, AppsListInstallationRequestsForAuthenticatedAppError> { + pub async fn list_installation_requests_for_authenticated_app_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/app/installation-requests", super::GITHUB_BASE_API_URL); @@ -3087,12 +3298,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3104,9 +3315,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(AppsListInstallationRequestsForAuthenticatedAppError::Status304), - 401 => Err(AppsListInstallationRequestsForAuthenticatedAppError::Status401(github_response.to_json_async().await?)), - code => Err(AppsListInstallationRequestsForAuthenticatedAppError::Generic { code }), + 304 => Err(AppsListInstallationRequestsForAuthenticatedAppError::Status304.into()), + 401 => Err(AppsListInstallationRequestsForAuthenticatedAppError::Status401(github_response.to_json_async().await?).into()), + code => Err(AppsListInstallationRequestsForAuthenticatedAppError::Generic { code }.into()), } } } @@ -3121,7 +3332,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_installation_requests_for_authenticated_app(&self, query_params: Option>) -> Result, AppsListInstallationRequestsForAuthenticatedAppError> { + pub fn list_installation_requests_for_authenticated_app(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/app/installation-requests", super::GITHUB_BASE_API_URL); @@ -3138,7 +3349,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3150,9 +3361,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(AppsListInstallationRequestsForAuthenticatedAppError::Status304), - 401 => Err(AppsListInstallationRequestsForAuthenticatedAppError::Status401(github_response.to_json()?)), - code => Err(AppsListInstallationRequestsForAuthenticatedAppError::Generic { code }), + 304 => Err(AppsListInstallationRequestsForAuthenticatedAppError::Status304.into()), + 401 => Err(AppsListInstallationRequestsForAuthenticatedAppError::Status401(github_response.to_json()?).into()), + code => Err(AppsListInstallationRequestsForAuthenticatedAppError::Generic { code }.into()), } } } @@ -3168,7 +3379,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_installations](https://docs.github.com/rest/apps/apps#list-installations-for-the-authenticated-app) /// /// --- - pub async fn list_installations_async(&self, query_params: Option>>) -> Result, AppsListInstallationsError> { + pub async fn list_installations_async(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/app/installations", super::GITHUB_BASE_API_URL); @@ -3179,12 +3390,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3196,7 +3407,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(AppsListInstallationsError::Generic { code }), + code => Err(AppsListInstallationsError::Generic { code }.into()), } } } @@ -3213,7 +3424,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_installations(&self, query_params: Option>>) -> Result, AppsListInstallationsError> { + pub fn list_installations(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/app/installations", super::GITHUB_BASE_API_URL); @@ -3230,7 +3441,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3242,7 +3453,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(AppsListInstallationsError::Generic { code }), + code => Err(AppsListInstallationsError::Generic { code }.into()), } } } @@ -3260,7 +3471,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_installations_for_authenticated_user](https://docs.github.com/rest/apps/installations#list-app-installations-accessible-to-the-user-access-token) /// /// --- - pub async fn list_installations_for_authenticated_user_async(&self, query_params: Option>) -> Result { + pub async fn list_installations_for_authenticated_user_async(&self, query_params: Option>) -> Result { let mut request_uri = format!("{}/user/installations", super::GITHUB_BASE_API_URL); @@ -3271,12 +3482,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3288,10 +3499,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(AppsListInstallationsForAuthenticatedUserError::Status304), - 403 => Err(AppsListInstallationsForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(AppsListInstallationsForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(AppsListInstallationsForAuthenticatedUserError::Generic { code }), + 304 => Err(AppsListInstallationsForAuthenticatedUserError::Status304.into()), + 403 => Err(AppsListInstallationsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(AppsListInstallationsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(AppsListInstallationsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3310,7 +3521,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_installations_for_authenticated_user(&self, query_params: Option>) -> Result { + pub fn list_installations_for_authenticated_user(&self, query_params: Option>) -> Result { let mut request_uri = format!("{}/user/installations", super::GITHUB_BASE_API_URL); @@ -3327,7 +3538,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3339,10 +3550,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(AppsListInstallationsForAuthenticatedUserError::Status304), - 403 => Err(AppsListInstallationsForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(AppsListInstallationsForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(AppsListInstallationsForAuthenticatedUserError::Generic { code }), + 304 => Err(AppsListInstallationsForAuthenticatedUserError::Status304.into()), + 403 => Err(AppsListInstallationsForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(AppsListInstallationsForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(AppsListInstallationsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3358,7 +3569,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_plans](https://docs.github.com/rest/apps/marketplace#list-plans) /// /// --- - pub async fn list_plans_async(&self, query_params: Option>) -> Result, AppsListPlansError> { + pub async fn list_plans_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/marketplace_listing/plans", super::GITHUB_BASE_API_URL); @@ -3369,12 +3580,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3386,9 +3597,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(AppsListPlansError::Status404(github_response.to_json_async().await?)), - 401 => Err(AppsListPlansError::Status401(github_response.to_json_async().await?)), - code => Err(AppsListPlansError::Generic { code }), + 404 => Err(AppsListPlansError::Status404(github_response.to_json_async().await?).into()), + 401 => Err(AppsListPlansError::Status401(github_response.to_json_async().await?).into()), + code => Err(AppsListPlansError::Generic { code }.into()), } } } @@ -3405,7 +3616,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_plans(&self, query_params: Option>) -> Result, AppsListPlansError> { + pub fn list_plans(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/marketplace_listing/plans", super::GITHUB_BASE_API_URL); @@ -3422,7 +3633,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3434,9 +3645,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(AppsListPlansError::Status404(github_response.to_json()?)), - 401 => Err(AppsListPlansError::Status401(github_response.to_json()?)), - code => Err(AppsListPlansError::Generic { code }), + 404 => Err(AppsListPlansError::Status404(github_response.to_json()?).into()), + 401 => Err(AppsListPlansError::Status401(github_response.to_json()?).into()), + code => Err(AppsListPlansError::Generic { code }.into()), } } } @@ -3452,7 +3663,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_plans_stubbed](https://docs.github.com/rest/apps/marketplace#list-plans-stubbed) /// /// --- - pub async fn list_plans_stubbed_async(&self, query_params: Option>) -> Result, AppsListPlansStubbedError> { + pub async fn list_plans_stubbed_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/marketplace_listing/stubbed/plans", super::GITHUB_BASE_API_URL); @@ -3463,12 +3674,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3480,8 +3691,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(AppsListPlansStubbedError::Status401(github_response.to_json_async().await?)), - code => Err(AppsListPlansStubbedError::Generic { code }), + 401 => Err(AppsListPlansStubbedError::Status401(github_response.to_json_async().await?).into()), + code => Err(AppsListPlansStubbedError::Generic { code }.into()), } } } @@ -3498,7 +3709,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_plans_stubbed(&self, query_params: Option>) -> Result, AppsListPlansStubbedError> { + pub fn list_plans_stubbed(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/marketplace_listing/stubbed/plans", super::GITHUB_BASE_API_URL); @@ -3515,7 +3726,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3527,8 +3738,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(AppsListPlansStubbedError::Status401(github_response.to_json()?)), - code => Err(AppsListPlansStubbedError::Generic { code }), + 401 => Err(AppsListPlansStubbedError::Status401(github_response.to_json()?).into()), + code => Err(AppsListPlansStubbedError::Generic { code }.into()), } } } @@ -3542,7 +3753,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_repos_accessible_to_installation](https://docs.github.com/rest/apps/installations#list-repositories-accessible-to-the-app-installation) /// /// --- - pub async fn list_repos_accessible_to_installation_async(&self, query_params: Option>) -> Result { + 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); @@ -3553,12 +3764,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3570,10 +3781,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(AppsListReposAccessibleToInstallationError::Status403(github_response.to_json_async().await?)), - 304 => Err(AppsListReposAccessibleToInstallationError::Status304), - 401 => Err(AppsListReposAccessibleToInstallationError::Status401(github_response.to_json_async().await?)), - code => Err(AppsListReposAccessibleToInstallationError::Generic { code }), + 403 => Err(AppsListReposAccessibleToInstallationError::Status403(github_response.to_json_async().await?).into()), + 304 => Err(AppsListReposAccessibleToInstallationError::Status304.into()), + 401 => Err(AppsListReposAccessibleToInstallationError::Status401(github_response.to_json_async().await?).into()), + code => Err(AppsListReposAccessibleToInstallationError::Generic { code }.into()), } } } @@ -3588,7 +3799,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repos_accessible_to_installation(&self, query_params: Option>) -> Result { + pub fn list_repos_accessible_to_installation(&self, query_params: Option>) -> Result { let mut request_uri = format!("{}/installation/repositories", super::GITHUB_BASE_API_URL); @@ -3605,7 +3816,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3617,10 +3828,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(AppsListReposAccessibleToInstallationError::Status403(github_response.to_json()?)), - 304 => Err(AppsListReposAccessibleToInstallationError::Status304), - 401 => Err(AppsListReposAccessibleToInstallationError::Status401(github_response.to_json()?)), - code => Err(AppsListReposAccessibleToInstallationError::Generic { code }), + 403 => Err(AppsListReposAccessibleToInstallationError::Status403(github_response.to_json()?).into()), + 304 => Err(AppsListReposAccessibleToInstallationError::Status304.into()), + 401 => Err(AppsListReposAccessibleToInstallationError::Status401(github_response.to_json()?).into()), + code => Err(AppsListReposAccessibleToInstallationError::Generic { code }.into()), } } } @@ -3634,7 +3845,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_subscriptions_for_authenticated_user](https://docs.github.com/rest/apps/marketplace#list-subscriptions-for-the-authenticated-user) /// /// --- - pub async fn list_subscriptions_for_authenticated_user_async(&self, query_params: Option>) -> Result, AppsListSubscriptionsForAuthenticatedUserError> { + pub async fn list_subscriptions_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/marketplace_purchases", super::GITHUB_BASE_API_URL); @@ -3645,12 +3856,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3662,10 +3873,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status304), - 401 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 404 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(AppsListSubscriptionsForAuthenticatedUserError::Generic { code }), + 304 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status304.into()), + 401 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 404 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(AppsListSubscriptionsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3680,7 +3891,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_subscriptions_for_authenticated_user(&self, query_params: Option>) -> Result, AppsListSubscriptionsForAuthenticatedUserError> { + pub fn list_subscriptions_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/marketplace_purchases", super::GITHUB_BASE_API_URL); @@ -3697,7 +3908,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3709,10 +3920,10 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status304), - 401 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status401(github_response.to_json()?)), - 404 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(AppsListSubscriptionsForAuthenticatedUserError::Generic { code }), + 304 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status304.into()), + 401 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 404 => Err(AppsListSubscriptionsForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(AppsListSubscriptionsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3726,7 +3937,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_subscriptions_for_authenticated_user_stubbed](https://docs.github.com/rest/apps/marketplace#list-subscriptions-for-the-authenticated-user-stubbed) /// /// --- - pub async fn list_subscriptions_for_authenticated_user_stubbed_async(&self, query_params: Option>) -> Result, AppsListSubscriptionsForAuthenticatedUserStubbedError> { + pub async fn list_subscriptions_for_authenticated_user_stubbed_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/marketplace_purchases/stubbed", super::GITHUB_BASE_API_URL); @@ -3737,12 +3948,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3754,9 +3965,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Status304), - 401 => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Status401(github_response.to_json_async().await?)), - code => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Generic { code }), + 304 => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Status304.into()), + 401 => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Status401(github_response.to_json_async().await?).into()), + code => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Generic { code }.into()), } } } @@ -3771,7 +3982,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_subscriptions_for_authenticated_user_stubbed(&self, query_params: Option>) -> Result, AppsListSubscriptionsForAuthenticatedUserStubbedError> { + pub fn list_subscriptions_for_authenticated_user_stubbed(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/marketplace_purchases/stubbed", super::GITHUB_BASE_API_URL); @@ -3788,7 +3999,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3800,9 +4011,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Status304), - 401 => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Status401(github_response.to_json()?)), - code => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Generic { code }), + 304 => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Status304.into()), + 401 => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Status401(github_response.to_json()?).into()), + code => Err(AppsListSubscriptionsForAuthenticatedUserStubbedError::Generic { code }.into()), } } } @@ -3818,7 +4029,7 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for list_webhook_deliveries](https://docs.github.com/rest/apps/webhooks#list-deliveries-for-an-app-webhook) /// /// --- - pub async fn list_webhook_deliveries_async(&self, query_params: Option>>) -> Result, AppsListWebhookDeliveriesError> { + pub async fn list_webhook_deliveries_async(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/app/hook/deliveries", super::GITHUB_BASE_API_URL); @@ -3829,12 +4040,12 @@ impl<'api, C: Client> Apps<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3846,9 +4057,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(AppsListWebhookDeliveriesError::Status400(github_response.to_json_async().await?)), - 422 => Err(AppsListWebhookDeliveriesError::Status422(github_response.to_json_async().await?)), - code => Err(AppsListWebhookDeliveriesError::Generic { code }), + 400 => Err(AppsListWebhookDeliveriesError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(AppsListWebhookDeliveriesError::Status422(github_response.to_json_async().await?).into()), + code => Err(AppsListWebhookDeliveriesError::Generic { code }.into()), } } } @@ -3865,7 +4076,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_webhook_deliveries(&self, query_params: Option>>) -> Result, AppsListWebhookDeliveriesError> { + pub fn list_webhook_deliveries(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/app/hook/deliveries", super::GITHUB_BASE_API_URL); @@ -3882,7 +4093,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3894,9 +4105,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(AppsListWebhookDeliveriesError::Status400(github_response.to_json()?)), - 422 => Err(AppsListWebhookDeliveriesError::Status422(github_response.to_json()?)), - code => Err(AppsListWebhookDeliveriesError::Generic { code }), + 400 => Err(AppsListWebhookDeliveriesError::Status400(github_response.to_json()?).into()), + 422 => Err(AppsListWebhookDeliveriesError::Status422(github_response.to_json()?).into()), + code => Err(AppsListWebhookDeliveriesError::Generic { code }.into()), } } } @@ -3912,19 +4123,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for redeliver_webhook_delivery](https://docs.github.com/rest/apps/webhooks#redeliver-a-delivery-for-an-app-webhook) /// /// --- - pub async fn redeliver_webhook_delivery_async(&self, delivery_id: i32) -> Result, AppsRedeliverWebhookDeliveryError> { + pub async fn redeliver_webhook_delivery_async(&self, delivery_id: i32) -> Result, AdapterError> { let request_uri = format!("{}/app/hook/deliveries/{}/attempts", super::GITHUB_BASE_API_URL, delivery_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3936,9 +4147,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(AppsRedeliverWebhookDeliveryError::Status400(github_response.to_json_async().await?)), - 422 => Err(AppsRedeliverWebhookDeliveryError::Status422(github_response.to_json_async().await?)), - code => Err(AppsRedeliverWebhookDeliveryError::Generic { code }), + 400 => Err(AppsRedeliverWebhookDeliveryError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(AppsRedeliverWebhookDeliveryError::Status422(github_response.to_json_async().await?).into()), + code => Err(AppsRedeliverWebhookDeliveryError::Generic { code }.into()), } } } @@ -3955,7 +4166,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn redeliver_webhook_delivery(&self, delivery_id: i32) -> Result, AppsRedeliverWebhookDeliveryError> { + pub fn redeliver_webhook_delivery(&self, delivery_id: i32) -> Result, AdapterError> { let request_uri = format!("{}/app/hook/deliveries/{}/attempts", super::GITHUB_BASE_API_URL, delivery_id); @@ -3967,7 +4178,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3979,9 +4190,9 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(AppsRedeliverWebhookDeliveryError::Status400(github_response.to_json()?)), - 422 => Err(AppsRedeliverWebhookDeliveryError::Status422(github_response.to_json()?)), - code => Err(AppsRedeliverWebhookDeliveryError::Generic { code }), + 400 => Err(AppsRedeliverWebhookDeliveryError::Status400(github_response.to_json()?).into()), + 422 => Err(AppsRedeliverWebhookDeliveryError::Status422(github_response.to_json()?).into()), + code => Err(AppsRedeliverWebhookDeliveryError::Generic { code }.into()), } } } @@ -3997,19 +4208,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for remove_repo_from_installation_for_authenticated_user](https://docs.github.com/rest/apps/installations#remove-a-repository-from-an-app-installation) /// /// --- - pub async fn remove_repo_from_installation_for_authenticated_user_async(&self, installation_id: i32, repository_id: i32) -> Result<(), AppsRemoveRepoFromInstallationForAuthenticatedUserError> { + pub async fn remove_repo_from_installation_for_authenticated_user_async(&self, installation_id: i32, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/installations/{}/repositories/{}", super::GITHUB_BASE_API_URL, installation_id, repository_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4021,11 +4232,11 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 304 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status304), - 404 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 422 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status422), - code => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Generic { code }), + 403 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 304 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status304.into()), + 404 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status422.into()), + code => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4042,7 +4253,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_repo_from_installation_for_authenticated_user(&self, installation_id: i32, repository_id: i32) -> Result<(), AppsRemoveRepoFromInstallationForAuthenticatedUserError> { + pub fn remove_repo_from_installation_for_authenticated_user(&self, installation_id: i32, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/installations/{}/repositories/{}", super::GITHUB_BASE_API_URL, installation_id, repository_id); @@ -4054,7 +4265,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4066,11 +4277,11 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status403(github_response.to_json()?)), - 304 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status304), - 404 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status404(github_response.to_json()?)), - 422 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status422), - code => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Generic { code }), + 403 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 304 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status304.into()), + 404 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 422 => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Status422.into()), + code => Err(AppsRemoveRepoFromInstallationForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4084,19 +4295,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for reset_token](https://docs.github.com/rest/apps/oauth-applications#reset-a-token) /// /// --- - pub async fn reset_token_async(&self, client_id: &str, body: PatchAppsResetToken) -> Result { + pub async fn reset_token_async(&self, client_id: &str, body: PatchAppsResetToken) -> Result { let request_uri = format!("{}/applications/{}/token", super::GITHUB_BASE_API_URL, client_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchAppsResetToken::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4108,8 +4319,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(AppsResetTokenError::Status422(github_response.to_json_async().await?)), - code => Err(AppsResetTokenError::Generic { code }), + 422 => Err(AppsResetTokenError::Status422(github_response.to_json_async().await?).into()), + code => Err(AppsResetTokenError::Generic { code }.into()), } } } @@ -4124,19 +4335,19 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn reset_token(&self, client_id: &str, body: PatchAppsResetToken) -> Result { + pub fn reset_token(&self, client_id: &str, body: PatchAppsResetToken) -> Result { let request_uri = format!("{}/applications/{}/token", super::GITHUB_BASE_API_URL, client_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchAppsResetToken::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4148,8 +4359,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(AppsResetTokenError::Status422(github_response.to_json()?)), - code => Err(AppsResetTokenError::Generic { code }), + 422 => Err(AppsResetTokenError::Status422(github_response.to_json()?).into()), + code => Err(AppsResetTokenError::Generic { code }.into()), } } } @@ -4165,19 +4376,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for revoke_installation_access_token](https://docs.github.com/rest/apps/installations#revoke-an-installation-access-token) /// /// --- - pub async fn revoke_installation_access_token_async(&self) -> Result<(), AppsRevokeInstallationAccessTokenError> { + pub async fn revoke_installation_access_token_async(&self) -> Result<(), AdapterError> { let request_uri = format!("{}/installation/token", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4189,7 +4400,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(AppsRevokeInstallationAccessTokenError::Generic { code }), + code => Err(AppsRevokeInstallationAccessTokenError::Generic { code }.into()), } } } @@ -4206,7 +4417,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn revoke_installation_access_token(&self) -> Result<(), AppsRevokeInstallationAccessTokenError> { + pub fn revoke_installation_access_token(&self) -> Result<(), AdapterError> { let request_uri = format!("{}/installation/token", super::GITHUB_BASE_API_URL); @@ -4218,7 +4429,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4230,7 +4441,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(AppsRevokeInstallationAccessTokenError::Generic { code }), + code => Err(AppsRevokeInstallationAccessTokenError::Generic { code }.into()), } } } @@ -4248,19 +4459,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for scope_token](https://docs.github.com/rest/apps/apps#create-a-scoped-access-token) /// /// --- - pub async fn scope_token_async(&self, client_id: &str, body: PostAppsScopeToken) -> Result { + pub async fn scope_token_async(&self, client_id: &str, body: PostAppsScopeToken) -> Result { let request_uri = format!("{}/applications/{}/token/scoped", super::GITHUB_BASE_API_URL, client_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostAppsScopeToken::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4272,11 +4483,11 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(AppsScopeTokenError::Status401(github_response.to_json_async().await?)), - 403 => Err(AppsScopeTokenError::Status403(github_response.to_json_async().await?)), - 404 => Err(AppsScopeTokenError::Status404(github_response.to_json_async().await?)), - 422 => Err(AppsScopeTokenError::Status422(github_response.to_json_async().await?)), - code => Err(AppsScopeTokenError::Generic { code }), + 401 => Err(AppsScopeTokenError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(AppsScopeTokenError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(AppsScopeTokenError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(AppsScopeTokenError::Status422(github_response.to_json_async().await?).into()), + code => Err(AppsScopeTokenError::Generic { code }.into()), } } } @@ -4295,19 +4506,19 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn scope_token(&self, client_id: &str, body: PostAppsScopeToken) -> Result { + pub fn scope_token(&self, client_id: &str, body: PostAppsScopeToken) -> Result { let request_uri = format!("{}/applications/{}/token/scoped", super::GITHUB_BASE_API_URL, client_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostAppsScopeToken::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4319,11 +4530,11 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(AppsScopeTokenError::Status401(github_response.to_json()?)), - 403 => Err(AppsScopeTokenError::Status403(github_response.to_json()?)), - 404 => Err(AppsScopeTokenError::Status404(github_response.to_json()?)), - 422 => Err(AppsScopeTokenError::Status422(github_response.to_json()?)), - code => Err(AppsScopeTokenError::Generic { code }), + 401 => Err(AppsScopeTokenError::Status401(github_response.to_json()?).into()), + 403 => Err(AppsScopeTokenError::Status403(github_response.to_json()?).into()), + 404 => Err(AppsScopeTokenError::Status404(github_response.to_json()?).into()), + 422 => Err(AppsScopeTokenError::Status422(github_response.to_json()?).into()), + code => Err(AppsScopeTokenError::Generic { code }.into()), } } } @@ -4339,19 +4550,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for suspend_installation](https://docs.github.com/rest/apps/apps#suspend-an-app-installation) /// /// --- - pub async fn suspend_installation_async(&self, installation_id: i32) -> Result<(), AppsSuspendInstallationError> { + pub async fn suspend_installation_async(&self, installation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/app/installations/{}/suspended", super::GITHUB_BASE_API_URL, installation_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4363,8 +4574,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(AppsSuspendInstallationError::Status404(github_response.to_json_async().await?)), - code => Err(AppsSuspendInstallationError::Generic { code }), + 404 => Err(AppsSuspendInstallationError::Status404(github_response.to_json_async().await?).into()), + code => Err(AppsSuspendInstallationError::Generic { code }.into()), } } } @@ -4381,7 +4592,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn suspend_installation(&self, installation_id: i32) -> Result<(), AppsSuspendInstallationError> { + pub fn suspend_installation(&self, installation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/app/installations/{}/suspended", super::GITHUB_BASE_API_URL, installation_id); @@ -4393,7 +4604,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4405,8 +4616,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(AppsSuspendInstallationError::Status404(github_response.to_json()?)), - code => Err(AppsSuspendInstallationError::Generic { code }), + 404 => Err(AppsSuspendInstallationError::Status404(github_response.to_json()?).into()), + code => Err(AppsSuspendInstallationError::Generic { code }.into()), } } } @@ -4422,19 +4633,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for unsuspend_installation](https://docs.github.com/rest/apps/apps#unsuspend-an-app-installation) /// /// --- - pub async fn unsuspend_installation_async(&self, installation_id: i32) -> Result<(), AppsUnsuspendInstallationError> { + pub async fn unsuspend_installation_async(&self, installation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/app/installations/{}/suspended", super::GITHUB_BASE_API_URL, installation_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4446,8 +4657,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(AppsUnsuspendInstallationError::Status404(github_response.to_json_async().await?)), - code => Err(AppsUnsuspendInstallationError::Generic { code }), + 404 => Err(AppsUnsuspendInstallationError::Status404(github_response.to_json_async().await?).into()), + code => Err(AppsUnsuspendInstallationError::Generic { code }.into()), } } } @@ -4464,7 +4675,7 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn unsuspend_installation(&self, installation_id: i32) -> Result<(), AppsUnsuspendInstallationError> { + pub fn unsuspend_installation(&self, installation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/app/installations/{}/suspended", super::GITHUB_BASE_API_URL, installation_id); @@ -4476,7 +4687,7 @@ impl<'api, C: Client> Apps<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4488,8 +4699,8 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(AppsUnsuspendInstallationError::Status404(github_response.to_json()?)), - code => Err(AppsUnsuspendInstallationError::Generic { code }), + 404 => Err(AppsUnsuspendInstallationError::Status404(github_response.to_json()?).into()), + code => Err(AppsUnsuspendInstallationError::Generic { code }.into()), } } } @@ -4505,19 +4716,19 @@ impl<'api, C: Client> Apps<'api, C> { /// [GitHub API docs for update_webhook_config_for_app](https://docs.github.com/rest/apps/webhooks#update-a-webhook-configuration-for-an-app) /// /// --- - pub async fn update_webhook_config_for_app_async(&self, body: PatchAppsUpdateWebhookConfigForApp) -> Result { + pub async fn update_webhook_config_for_app_async(&self, body: PatchAppsUpdateWebhookConfigForApp) -> Result { let request_uri = format!("{}/app/hook/config", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PatchAppsUpdateWebhookConfigForApp::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4529,7 +4740,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(AppsUpdateWebhookConfigForAppError::Generic { code }), + code => Err(AppsUpdateWebhookConfigForAppError::Generic { code }.into()), } } } @@ -4546,19 +4757,19 @@ impl<'api, C: Client> Apps<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_webhook_config_for_app(&self, body: PatchAppsUpdateWebhookConfigForApp) -> Result { + pub fn update_webhook_config_for_app(&self, body: PatchAppsUpdateWebhookConfigForApp) -> Result { let request_uri = format!("{}/app/hook/config", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PatchAppsUpdateWebhookConfigForApp::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4570,7 +4781,7 @@ impl<'api, C: Client> Apps<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(AppsUpdateWebhookConfigForAppError::Generic { code }), + code => Err(AppsUpdateWebhookConfigForAppError::Generic { code }.into()), } } } diff --git a/src/endpoints/billing.rs b/src/endpoints/billing.rs index 08d4811..0a8b5e1 100644 --- a/src/endpoints/billing.rs +++ b/src/endpoints/billing.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,119 +22,143 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Billing<'api, C: Client> { +pub struct Billing<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Billing { +pub fn new(client: &C) -> Billing where AdapterError: From<::Err> { Billing { client } } /// Errors for the [Get GitHub Actions billing for an organization](Billing::get_github_actions_billing_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum BillingGetGithubActionsBillingOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: BillingGetGithubActionsBillingOrgError) -> Self { + let (description, status_code) = match err { + BillingGetGithubActionsBillingOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get GitHub Actions billing for a user](Billing::get_github_actions_billing_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum BillingGetGithubActionsBillingUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: BillingGetGithubActionsBillingUserError) -> Self { + let (description, status_code) = match err { + BillingGetGithubActionsBillingUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get GitHub Packages billing for an organization](Billing::get_github_packages_billing_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum BillingGetGithubPackagesBillingOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: BillingGetGithubPackagesBillingOrgError) -> Self { + let (description, status_code) = match err { + BillingGetGithubPackagesBillingOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get GitHub Packages billing for a user](Billing::get_github_packages_billing_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum BillingGetGithubPackagesBillingUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: BillingGetGithubPackagesBillingUserError) -> Self { + let (description, status_code) = match err { + BillingGetGithubPackagesBillingUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get shared storage billing for an organization](Billing::get_shared_storage_billing_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum BillingGetSharedStorageBillingOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: BillingGetSharedStorageBillingOrgError) -> Self { + let (description, status_code) = match err { + BillingGetSharedStorageBillingOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get shared storage billing for a user](Billing::get_shared_storage_billing_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum BillingGetSharedStorageBillingUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: BillingGetSharedStorageBillingUserError) -> Self { + let (description, status_code) = match err { + BillingGetSharedStorageBillingUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} -impl<'api, C: Client> Billing<'api, C> { + +impl<'api, C: Client> Billing<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Get GitHub Actions billing for an organization @@ -148,19 +172,19 @@ impl<'api, C: Client> Billing<'api, C> { /// [GitHub API docs for get_github_actions_billing_org](https://docs.github.com/rest/billing/billing#get-github-actions-billing-for-an-organization) /// /// --- - pub async fn get_github_actions_billing_org_async(&self, org: &str) -> Result { + pub async fn get_github_actions_billing_org_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/settings/billing/actions", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -172,7 +196,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(BillingGetGithubActionsBillingOrgError::Generic { code }), + code => Err(BillingGetGithubActionsBillingOrgError::Generic { code }.into()), } } } @@ -191,7 +215,7 @@ impl<'api, C: Client> Billing<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_github_actions_billing_org(&self, org: &str) -> Result { + pub fn get_github_actions_billing_org(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/settings/billing/actions", super::GITHUB_BASE_API_URL, org); @@ -203,7 +227,7 @@ impl<'api, C: Client> Billing<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -215,7 +239,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(BillingGetGithubActionsBillingOrgError::Generic { code }), + code => Err(BillingGetGithubActionsBillingOrgError::Generic { code }.into()), } } } @@ -233,19 +257,19 @@ impl<'api, C: Client> Billing<'api, C> { /// [GitHub API docs for get_github_actions_billing_user](https://docs.github.com/rest/billing/billing#get-github-actions-billing-for-a-user) /// /// --- - pub async fn get_github_actions_billing_user_async(&self, username: &str) -> Result { + pub async fn get_github_actions_billing_user_async(&self, username: &str) -> Result { let request_uri = format!("{}/users/{}/settings/billing/actions", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -257,7 +281,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(BillingGetGithubActionsBillingUserError::Generic { code }), + code => Err(BillingGetGithubActionsBillingUserError::Generic { code }.into()), } } } @@ -276,7 +300,7 @@ impl<'api, C: Client> Billing<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_github_actions_billing_user(&self, username: &str) -> Result { + pub fn get_github_actions_billing_user(&self, username: &str) -> Result { let request_uri = format!("{}/users/{}/settings/billing/actions", super::GITHUB_BASE_API_URL, username); @@ -288,7 +312,7 @@ impl<'api, C: Client> Billing<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -300,7 +324,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(BillingGetGithubActionsBillingUserError::Generic { code }), + code => Err(BillingGetGithubActionsBillingUserError::Generic { code }.into()), } } } @@ -318,19 +342,19 @@ impl<'api, C: Client> Billing<'api, C> { /// [GitHub API docs for get_github_packages_billing_org](https://docs.github.com/rest/billing/billing#get-github-packages-billing-for-an-organization) /// /// --- - pub async fn get_github_packages_billing_org_async(&self, org: &str) -> Result { + pub async fn get_github_packages_billing_org_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/settings/billing/packages", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -342,7 +366,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(BillingGetGithubPackagesBillingOrgError::Generic { code }), + code => Err(BillingGetGithubPackagesBillingOrgError::Generic { code }.into()), } } } @@ -361,7 +385,7 @@ impl<'api, C: Client> Billing<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_github_packages_billing_org(&self, org: &str) -> Result { + pub fn get_github_packages_billing_org(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/settings/billing/packages", super::GITHUB_BASE_API_URL, org); @@ -373,7 +397,7 @@ impl<'api, C: Client> Billing<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -385,7 +409,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(BillingGetGithubPackagesBillingOrgError::Generic { code }), + code => Err(BillingGetGithubPackagesBillingOrgError::Generic { code }.into()), } } } @@ -403,19 +427,19 @@ impl<'api, C: Client> Billing<'api, C> { /// [GitHub API docs for get_github_packages_billing_user](https://docs.github.com/rest/billing/billing#get-github-packages-billing-for-a-user) /// /// --- - pub async fn get_github_packages_billing_user_async(&self, username: &str) -> Result { + pub async fn get_github_packages_billing_user_async(&self, username: &str) -> Result { let request_uri = format!("{}/users/{}/settings/billing/packages", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -427,7 +451,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(BillingGetGithubPackagesBillingUserError::Generic { code }), + code => Err(BillingGetGithubPackagesBillingUserError::Generic { code }.into()), } } } @@ -446,7 +470,7 @@ impl<'api, C: Client> Billing<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_github_packages_billing_user(&self, username: &str) -> Result { + pub fn get_github_packages_billing_user(&self, username: &str) -> Result { let request_uri = format!("{}/users/{}/settings/billing/packages", super::GITHUB_BASE_API_URL, username); @@ -458,7 +482,7 @@ impl<'api, C: Client> Billing<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -470,7 +494,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(BillingGetGithubPackagesBillingUserError::Generic { code }), + code => Err(BillingGetGithubPackagesBillingUserError::Generic { code }.into()), } } } @@ -488,19 +512,19 @@ impl<'api, C: Client> Billing<'api, C> { /// [GitHub API docs for get_shared_storage_billing_org](https://docs.github.com/rest/billing/billing#get-shared-storage-billing-for-an-organization) /// /// --- - pub async fn get_shared_storage_billing_org_async(&self, org: &str) -> Result { + pub async fn get_shared_storage_billing_org_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/settings/billing/shared-storage", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -512,7 +536,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(BillingGetSharedStorageBillingOrgError::Generic { code }), + code => Err(BillingGetSharedStorageBillingOrgError::Generic { code }.into()), } } } @@ -531,7 +555,7 @@ impl<'api, C: Client> Billing<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_shared_storage_billing_org(&self, org: &str) -> Result { + pub fn get_shared_storage_billing_org(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/settings/billing/shared-storage", super::GITHUB_BASE_API_URL, org); @@ -543,7 +567,7 @@ impl<'api, C: Client> Billing<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -555,7 +579,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(BillingGetSharedStorageBillingOrgError::Generic { code }), + code => Err(BillingGetSharedStorageBillingOrgError::Generic { code }.into()), } } } @@ -573,19 +597,19 @@ impl<'api, C: Client> Billing<'api, C> { /// [GitHub API docs for get_shared_storage_billing_user](https://docs.github.com/rest/billing/billing#get-shared-storage-billing-for-a-user) /// /// --- - pub async fn get_shared_storage_billing_user_async(&self, username: &str) -> Result { + pub async fn get_shared_storage_billing_user_async(&self, username: &str) -> Result { let request_uri = format!("{}/users/{}/settings/billing/shared-storage", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -597,7 +621,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(BillingGetSharedStorageBillingUserError::Generic { code }), + code => Err(BillingGetSharedStorageBillingUserError::Generic { code }.into()), } } } @@ -616,7 +640,7 @@ impl<'api, C: Client> Billing<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_shared_storage_billing_user(&self, username: &str) -> Result { + pub fn get_shared_storage_billing_user(&self, username: &str) -> Result { let request_uri = format!("{}/users/{}/settings/billing/shared-storage", super::GITHUB_BASE_API_URL, username); @@ -628,7 +652,7 @@ impl<'api, C: Client> Billing<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -640,7 +664,7 @@ impl<'api, C: Client> Billing<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(BillingGetSharedStorageBillingUserError::Generic { code }), + code => Err(BillingGetSharedStorageBillingUserError::Generic { code }.into()), } } } diff --git a/src/endpoints/checks.rs b/src/endpoints/checks.rs index dafafa7..a328b37 100644 --- a/src/endpoints/checks.rs +++ b/src/endpoints/checks.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,165 +22,188 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Checks<'api, C: Client> { +pub struct Checks<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Checks { +pub fn new(client: &C) -> Checks where AdapterError: From<::Err> { Checks { client } } /// Errors for the [Create a check run](Checks::create_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksCreateError { - #[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 }, } +impl From for AdapterError { + fn from(err: ChecksCreateError) -> Self { + let (description, status_code) = match err { + ChecksCreateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a check suite](Checks::create_suite_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksCreateSuiteError { - #[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 suite was created")] Status201(CheckSuite), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ChecksCreateSuiteError) -> Self { + let (description, status_code) = match err { + ChecksCreateSuiteError::Status201(_) => (String::from("Response when the suite was created"), 201), + ChecksCreateSuiteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a check run](Checks::get_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksGetError { - #[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 }, } +impl From for AdapterError { + fn from(err: ChecksGetError) -> Self { + let (description, status_code) = match err { + ChecksGetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a check suite](Checks::get_suite_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksGetSuiteError { - #[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 }, } +impl From for AdapterError { + fn from(err: ChecksGetSuiteError) -> Self { + let (description, status_code) = match err { + ChecksGetSuiteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List check run annotations](Checks::list_annotations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksListAnnotationsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ChecksListAnnotationsError) -> Self { + let (description, status_code) = match err { + ChecksListAnnotationsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List check runs for a Git reference](Checks::list_for_ref_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksListForRefError { - #[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 }, } +impl From for AdapterError { + fn from(err: ChecksListForRefError) -> Self { + let (description, status_code) = match err { + ChecksListForRefError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List check runs in a check suite](Checks::list_for_suite_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksListForSuiteError { - #[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 }, } +impl From for AdapterError { + fn from(err: ChecksListForSuiteError) -> Self { + let (description, status_code) = match err { + ChecksListForSuiteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List check suites for a Git reference](Checks::list_suites_for_ref_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksListSuitesForRefError { - #[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 }, } +impl From for AdapterError { + fn from(err: ChecksListSuitesForRefError) -> Self { + let (description, status_code) = match err { + ChecksListSuitesForRefError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Rerequest a check run](Checks::rerequest_run_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksRerequestRunError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden if the check run is not rerequestable or doesn't belong to the authenticated GitHub App")] Status403(BasicError), #[error("Validation error if the check run is not rerequestable")] @@ -191,57 +214,86 @@ pub enum ChecksRerequestRunError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ChecksRerequestRunError) -> Self { + let (description, status_code) = match err { + ChecksRerequestRunError::Status403(_) => (String::from("Forbidden if the check run is not rerequestable or doesn't belong to the authenticated GitHub App"), 403), + ChecksRerequestRunError::Status422(_) => (String::from("Validation error if the check run is not rerequestable"), 422), + ChecksRerequestRunError::Status404(_) => (String::from("Resource not found"), 404), + ChecksRerequestRunError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Rerequest a check suite](Checks::rerequest_suite_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksRerequestSuiteError { - #[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 }, } +impl From for AdapterError { + fn from(err: ChecksRerequestSuiteError) -> Self { + let (description, status_code) = match err { + ChecksRerequestSuiteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update repository preferences for check suites](Checks::set_suites_preferences_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksSetSuitesPreferencesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ChecksSetSuitesPreferencesError) -> Self { + let (description, status_code) = match err { + ChecksSetSuitesPreferencesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a check run](Checks::update_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ChecksUpdateError { - #[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 }, } +impl From for AdapterError { + fn from(err: ChecksUpdateError) -> Self { + let (description, status_code) = match err { + ChecksUpdateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List check run annotations](Checks::list_annotations_async()) endpoint. #[derive(Default, Serialize)] @@ -541,7 +593,7 @@ impl<'enc> From<&'enc PerPage> for ChecksListSuitesForRefParams<'enc> { } } -impl<'api, C: Client> Checks<'api, C> { +impl<'api, C: Client> Checks<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Create a check run @@ -558,19 +610,19 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for create](https://docs.github.com/rest/checks/runs#create-a-check-run) /// /// --- - pub async fn create_async(&self, owner: &str, repo: &str, body: PostChecksCreate) -> Result { + pub async fn create_async(&self, owner: &str, repo: &str, body: PostChecksCreate) -> Result { let request_uri = format!("{}/repos/{}/{}/check-runs", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostChecksCreate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -582,7 +634,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ChecksCreateError::Generic { code }), + code => Err(ChecksCreateError::Generic { code }.into()), } } } @@ -604,19 +656,19 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create(&self, owner: &str, repo: &str, body: PostChecksCreate) -> Result { + pub fn create(&self, owner: &str, repo: &str, body: PostChecksCreate) -> Result { let request_uri = format!("{}/repos/{}/{}/check-runs", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostChecksCreate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -628,7 +680,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ChecksCreateError::Generic { code }), + code => Err(ChecksCreateError::Generic { code }.into()), } } } @@ -647,19 +699,19 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for create_suite](https://docs.github.com/rest/checks/suites#create-a-check-suite) /// /// --- - pub async fn create_suite_async(&self, owner: &str, repo: &str, body: PostChecksCreateSuite) -> Result { + pub async fn create_suite_async(&self, owner: &str, repo: &str, body: PostChecksCreateSuite) -> Result { let request_uri = format!("{}/repos/{}/{}/check-suites", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostChecksCreateSuite::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -671,8 +723,8 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(ChecksCreateSuiteError::Status201(github_response.to_json_async().await?)), - code => Err(ChecksCreateSuiteError::Generic { code }), + 201 => Err(ChecksCreateSuiteError::Status201(github_response.to_json_async().await?).into()), + code => Err(ChecksCreateSuiteError::Generic { code }.into()), } } } @@ -692,19 +744,19 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_suite(&self, owner: &str, repo: &str, body: PostChecksCreateSuite) -> Result { + pub fn create_suite(&self, owner: &str, repo: &str, body: PostChecksCreateSuite) -> Result { let request_uri = format!("{}/repos/{}/{}/check-suites", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostChecksCreateSuite::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -716,8 +768,8 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(ChecksCreateSuiteError::Status201(github_response.to_json()?)), - code => Err(ChecksCreateSuiteError::Generic { code }), + 201 => Err(ChecksCreateSuiteError::Status201(github_response.to_json()?).into()), + code => Err(ChecksCreateSuiteError::Generic { code }.into()), } } } @@ -736,19 +788,19 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for get](https://docs.github.com/rest/checks/runs#get-a-check-run) /// /// --- - pub async fn get_async(&self, owner: &str, repo: &str, check_run_id: i32) -> Result { + pub async fn get_async(&self, owner: &str, repo: &str, check_run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/check-runs/{}", super::GITHUB_BASE_API_URL, owner, repo, check_run_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -760,7 +812,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ChecksGetError::Generic { code }), + code => Err(ChecksGetError::Generic { code }.into()), } } } @@ -780,7 +832,7 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get(&self, owner: &str, repo: &str, check_run_id: i32) -> Result { + pub fn get(&self, owner: &str, repo: &str, check_run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/check-runs/{}", super::GITHUB_BASE_API_URL, owner, repo, check_run_id); @@ -792,7 +844,7 @@ impl<'api, C: Client> Checks<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -804,7 +856,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ChecksGetError::Generic { code }), + code => Err(ChecksGetError::Generic { code }.into()), } } } @@ -823,19 +875,19 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for get_suite](https://docs.github.com/rest/checks/suites#get-a-check-suite) /// /// --- - pub async fn get_suite_async(&self, owner: &str, repo: &str, check_suite_id: i32) -> Result { + pub async fn get_suite_async(&self, owner: &str, repo: &str, check_suite_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/check-suites/{}", super::GITHUB_BASE_API_URL, owner, repo, check_suite_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -847,7 +899,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ChecksGetSuiteError::Generic { code }), + code => Err(ChecksGetSuiteError::Generic { code }.into()), } } } @@ -867,7 +919,7 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_suite(&self, owner: &str, repo: &str, check_suite_id: i32) -> Result { + pub fn get_suite(&self, owner: &str, repo: &str, check_suite_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/check-suites/{}", super::GITHUB_BASE_API_URL, owner, repo, check_suite_id); @@ -879,7 +931,7 @@ impl<'api, C: Client> Checks<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -891,7 +943,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ChecksGetSuiteError::Generic { code }), + code => Err(ChecksGetSuiteError::Generic { code }.into()), } } } @@ -907,7 +959,7 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for list_annotations](https://docs.github.com/rest/checks/runs#list-check-run-annotations) /// /// --- - pub async fn list_annotations_async(&self, owner: &str, repo: &str, check_run_id: i32, query_params: Option>) -> Result, ChecksListAnnotationsError> { + pub async fn list_annotations_async(&self, owner: &str, repo: &str, check_run_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/check-runs/{}/annotations", super::GITHUB_BASE_API_URL, owner, repo, check_run_id); @@ -918,12 +970,12 @@ impl<'api, C: Client> Checks<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -935,7 +987,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ChecksListAnnotationsError::Generic { code }), + code => Err(ChecksListAnnotationsError::Generic { code }.into()), } } } @@ -952,7 +1004,7 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_annotations(&self, owner: &str, repo: &str, check_run_id: i32, query_params: Option>) -> Result, ChecksListAnnotationsError> { + pub fn list_annotations(&self, owner: &str, repo: &str, check_run_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/check-runs/{}/annotations", super::GITHUB_BASE_API_URL, owner, repo, check_run_id); @@ -969,7 +1021,7 @@ impl<'api, C: Client> Checks<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -981,7 +1033,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ChecksListAnnotationsError::Generic { code }), + code => Err(ChecksListAnnotationsError::Generic { code }.into()), } } } @@ -1002,7 +1054,7 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for list_for_ref](https://docs.github.com/rest/checks/runs#list-check-runs-for-a-git-reference) /// /// --- - pub async fn list_for_ref_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>>) -> Result { + pub async fn list_for_ref_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/check-runs", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -1013,12 +1065,12 @@ impl<'api, C: Client> Checks<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1030,7 +1082,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ChecksListForRefError::Generic { code }), + code => Err(ChecksListForRefError::Generic { code }.into()), } } } @@ -1052,7 +1104,7 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_ref(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>>) -> Result { + pub fn list_for_ref(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/check-runs", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -1069,7 +1121,7 @@ impl<'api, C: Client> Checks<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1081,7 +1133,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ChecksListForRefError::Generic { code }), + code => Err(ChecksListForRefError::Generic { code }.into()), } } } @@ -1100,7 +1152,7 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for list_for_suite](https://docs.github.com/rest/checks/runs#list-check-runs-in-a-check-suite) /// /// --- - pub async fn list_for_suite_async(&self, owner: &str, repo: &str, check_suite_id: i32, query_params: Option>>) -> Result { + pub async fn list_for_suite_async(&self, owner: &str, repo: &str, check_suite_id: i32, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/check-suites/{}/check-runs", super::GITHUB_BASE_API_URL, owner, repo, check_suite_id); @@ -1111,12 +1163,12 @@ impl<'api, C: Client> Checks<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1128,7 +1180,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ChecksListForSuiteError::Generic { code }), + code => Err(ChecksListForSuiteError::Generic { code }.into()), } } } @@ -1148,7 +1200,7 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_suite(&self, owner: &str, repo: &str, check_suite_id: i32, query_params: Option>>) -> Result { + pub fn list_for_suite(&self, owner: &str, repo: &str, check_suite_id: i32, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/check-suites/{}/check-runs", super::GITHUB_BASE_API_URL, owner, repo, check_suite_id); @@ -1165,7 +1217,7 @@ impl<'api, C: Client> Checks<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1177,7 +1229,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ChecksListForSuiteError::Generic { code }), + code => Err(ChecksListForSuiteError::Generic { code }.into()), } } } @@ -1196,7 +1248,7 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for list_suites_for_ref](https://docs.github.com/rest/checks/suites#list-check-suites-for-a-git-reference) /// /// --- - pub async fn list_suites_for_ref_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>>) -> Result { + pub async fn list_suites_for_ref_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/check-suites", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -1207,12 +1259,12 @@ impl<'api, C: Client> Checks<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1224,7 +1276,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ChecksListSuitesForRefError::Generic { code }), + code => Err(ChecksListSuitesForRefError::Generic { code }.into()), } } } @@ -1244,7 +1296,7 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_suites_for_ref(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>>) -> Result { + pub fn list_suites_for_ref(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/check-suites", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -1261,7 +1313,7 @@ impl<'api, C: Client> Checks<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1273,7 +1325,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ChecksListSuitesForRefError::Generic { code }), + code => Err(ChecksListSuitesForRefError::Generic { code }.into()), } } } @@ -1291,19 +1343,19 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for rerequest_run](https://docs.github.com/rest/checks/runs#rerequest-a-check-run) /// /// --- - pub async fn rerequest_run_async(&self, owner: &str, repo: &str, check_run_id: i32) -> Result { + pub async fn rerequest_run_async(&self, owner: &str, repo: &str, check_run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/check-runs/{}/rerequest", super::GITHUB_BASE_API_URL, owner, repo, check_run_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1315,10 +1367,10 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ChecksRerequestRunError::Status403(github_response.to_json_async().await?)), - 422 => Err(ChecksRerequestRunError::Status422(github_response.to_json_async().await?)), - 404 => Err(ChecksRerequestRunError::Status404(github_response.to_json_async().await?)), - code => Err(ChecksRerequestRunError::Generic { code }), + 403 => Err(ChecksRerequestRunError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(ChecksRerequestRunError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(ChecksRerequestRunError::Status404(github_response.to_json_async().await?).into()), + code => Err(ChecksRerequestRunError::Generic { code }.into()), } } } @@ -1337,7 +1389,7 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn rerequest_run(&self, owner: &str, repo: &str, check_run_id: i32) -> Result { + pub fn rerequest_run(&self, owner: &str, repo: &str, check_run_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/check-runs/{}/rerequest", super::GITHUB_BASE_API_URL, owner, repo, check_run_id); @@ -1349,7 +1401,7 @@ impl<'api, C: Client> Checks<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1361,10 +1413,10 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ChecksRerequestRunError::Status403(github_response.to_json()?)), - 422 => Err(ChecksRerequestRunError::Status422(github_response.to_json()?)), - 404 => Err(ChecksRerequestRunError::Status404(github_response.to_json()?)), - code => Err(ChecksRerequestRunError::Generic { code }), + 403 => Err(ChecksRerequestRunError::Status403(github_response.to_json()?).into()), + 422 => Err(ChecksRerequestRunError::Status422(github_response.to_json()?).into()), + 404 => Err(ChecksRerequestRunError::Status404(github_response.to_json()?).into()), + code => Err(ChecksRerequestRunError::Generic { code }.into()), } } } @@ -1380,19 +1432,19 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for rerequest_suite](https://docs.github.com/rest/checks/suites#rerequest-a-check-suite) /// /// --- - pub async fn rerequest_suite_async(&self, owner: &str, repo: &str, check_suite_id: i32) -> Result { + pub async fn rerequest_suite_async(&self, owner: &str, repo: &str, check_suite_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/check-suites/{}/rerequest", super::GITHUB_BASE_API_URL, owner, repo, check_suite_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1404,7 +1456,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ChecksRerequestSuiteError::Generic { code }), + code => Err(ChecksRerequestSuiteError::Generic { code }.into()), } } } @@ -1421,7 +1473,7 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn rerequest_suite(&self, owner: &str, repo: &str, check_suite_id: i32) -> Result { + pub fn rerequest_suite(&self, owner: &str, repo: &str, check_suite_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/check-suites/{}/rerequest", super::GITHUB_BASE_API_URL, owner, repo, check_suite_id); @@ -1433,7 +1485,7 @@ impl<'api, C: Client> Checks<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1445,7 +1497,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ChecksRerequestSuiteError::Generic { code }), + code => Err(ChecksRerequestSuiteError::Generic { code }.into()), } } } @@ -1460,19 +1512,19 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for set_suites_preferences](https://docs.github.com/rest/checks/suites#update-repository-preferences-for-check-suites) /// /// --- - pub async fn set_suites_preferences_async(&self, owner: &str, repo: &str, body: PatchChecksSetSuitesPreferences) -> Result { + pub async fn set_suites_preferences_async(&self, owner: &str, repo: &str, body: PatchChecksSetSuitesPreferences) -> Result { let request_uri = format!("{}/repos/{}/{}/check-suites/preferences", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchChecksSetSuitesPreferences::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1484,7 +1536,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ChecksSetSuitesPreferencesError::Generic { code }), + code => Err(ChecksSetSuitesPreferencesError::Generic { code }.into()), } } } @@ -1500,19 +1552,19 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_suites_preferences(&self, owner: &str, repo: &str, body: PatchChecksSetSuitesPreferences) -> Result { + pub fn set_suites_preferences(&self, owner: &str, repo: &str, body: PatchChecksSetSuitesPreferences) -> Result { let request_uri = format!("{}/repos/{}/{}/check-suites/preferences", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchChecksSetSuitesPreferences::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1524,7 +1576,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ChecksSetSuitesPreferencesError::Generic { code }), + code => Err(ChecksSetSuitesPreferencesError::Generic { code }.into()), } } } @@ -1543,19 +1595,19 @@ impl<'api, C: Client> Checks<'api, C> { /// [GitHub API docs for update](https://docs.github.com/rest/checks/runs#update-a-check-run) /// /// --- - pub async fn update_async(&self, owner: &str, repo: &str, check_run_id: i32, body: PatchChecksUpdate) -> Result { + pub async fn update_async(&self, owner: &str, repo: &str, check_run_id: i32, body: PatchChecksUpdate) -> Result { let request_uri = format!("{}/repos/{}/{}/check-runs/{}", super::GITHUB_BASE_API_URL, owner, repo, check_run_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchChecksUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1567,7 +1619,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ChecksUpdateError::Generic { code }), + code => Err(ChecksUpdateError::Generic { code }.into()), } } } @@ -1587,19 +1639,19 @@ impl<'api, C: Client> Checks<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update(&self, owner: &str, repo: &str, check_run_id: i32, body: PatchChecksUpdate) -> Result { + pub fn update(&self, owner: &str, repo: &str, check_run_id: i32, body: PatchChecksUpdate) -> Result { let request_uri = format!("{}/repos/{}/{}/check-runs/{}", super::GITHUB_BASE_API_URL, owner, repo, check_run_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchChecksUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1611,7 +1663,7 @@ impl<'api, C: Client> Checks<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ChecksUpdateError::Generic { code }), + code => Err(ChecksUpdateError::Generic { code }.into()), } } } diff --git a/src/endpoints/classroom.rs b/src/endpoints/classroom.rs index 9f6baee..2ee6a82 100644 --- a/src/endpoints/classroom.rs +++ b/src/endpoints/classroom.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,122 +22,149 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Classroom<'api, C: Client> { +pub struct Classroom<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Classroom { +pub fn new(client: &C) -> Classroom where AdapterError: From<::Err> { Classroom { client } } /// Errors for the [Get a classroom](Classroom::get_a_classroom_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ClassroomGetAClassroomError { - #[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 }, } +impl From for AdapterError { + fn from(err: ClassroomGetAClassroomError) -> Self { + let (description, status_code) = match err { + ClassroomGetAClassroomError::Status404(_) => (String::from("Resource not found"), 404), + ClassroomGetAClassroomError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an assignment](Classroom::get_an_assignment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ClassroomGetAnAssignmentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ClassroomGetAnAssignmentError) -> Self { + let (description, status_code) = match err { + ClassroomGetAnAssignmentError::Status404(_) => (String::from("Resource not found"), 404), + ClassroomGetAnAssignmentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get assignment grades](Classroom::get_assignment_grades_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ClassroomGetAssignmentGradesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ClassroomGetAssignmentGradesError) -> Self { + let (description, status_code) = match err { + ClassroomGetAssignmentGradesError::Status404(_) => (String::from("Resource not found"), 404), + ClassroomGetAssignmentGradesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List accepted assignments for an assignment](Classroom::list_accepted_assignments_for_an_assignment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ClassroomListAcceptedAssignmentsForAnAssignmentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ClassroomListAcceptedAssignmentsForAnAssignmentError) -> Self { + let (description, status_code) = match err { + ClassroomListAcceptedAssignmentsForAnAssignmentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List assignments for a classroom](Classroom::list_assignments_for_a_classroom_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ClassroomListAssignmentsForAClassroomError { - #[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 }, } +impl From for AdapterError { + fn from(err: ClassroomListAssignmentsForAClassroomError) -> Self { + let (description, status_code) = match err { + ClassroomListAssignmentsForAClassroomError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List classrooms](Classroom::list_classrooms_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ClassroomListClassroomsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ClassroomListClassroomsError) -> Self { + let (description, status_code) = match err { + ClassroomListClassroomsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List accepted assignments for an assignment](Classroom::list_accepted_assignments_for_an_assignment_async()) endpoint. #[derive(Default, Serialize)] @@ -260,7 +287,7 @@ impl<'enc> From<&'enc PerPage> for ClassroomListClassroomsParams { } } -impl<'api, C: Client> Classroom<'api, C> { +impl<'api, C: Client> Classroom<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Get a classroom @@ -270,19 +297,19 @@ impl<'api, C: Client> Classroom<'api, C> { /// [GitHub API docs for get_a_classroom](https://docs.github.com/rest/classroom/classroom#get-a-classroom) /// /// --- - pub async fn get_a_classroom_async(&self, classroom_id: i32) -> Result { + pub async fn get_a_classroom_async(&self, classroom_id: i32) -> Result { let request_uri = format!("{}/classrooms/{}", super::GITHUB_BASE_API_URL, classroom_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -294,8 +321,8 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ClassroomGetAClassroomError::Status404(github_response.to_json_async().await?)), - code => Err(ClassroomGetAClassroomError::Generic { code }), + 404 => Err(ClassroomGetAClassroomError::Status404(github_response.to_json_async().await?).into()), + code => Err(ClassroomGetAClassroomError::Generic { code }.into()), } } } @@ -310,7 +337,7 @@ impl<'api, C: Client> Classroom<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_a_classroom(&self, classroom_id: i32) -> Result { + pub fn get_a_classroom(&self, classroom_id: i32) -> Result { let request_uri = format!("{}/classrooms/{}", super::GITHUB_BASE_API_URL, classroom_id); @@ -322,7 +349,7 @@ impl<'api, C: Client> Classroom<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -334,8 +361,8 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ClassroomGetAClassroomError::Status404(github_response.to_json()?)), - code => Err(ClassroomGetAClassroomError::Generic { code }), + 404 => Err(ClassroomGetAClassroomError::Status404(github_response.to_json()?).into()), + code => Err(ClassroomGetAClassroomError::Generic { code }.into()), } } } @@ -349,19 +376,19 @@ impl<'api, C: Client> Classroom<'api, C> { /// [GitHub API docs for get_an_assignment](https://docs.github.com/rest/classroom/classroom#get-an-assignment) /// /// --- - pub async fn get_an_assignment_async(&self, assignment_id: i32) -> Result { + pub async fn get_an_assignment_async(&self, assignment_id: i32) -> Result { let request_uri = format!("{}/assignments/{}", super::GITHUB_BASE_API_URL, assignment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -373,8 +400,8 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ClassroomGetAnAssignmentError::Status404(github_response.to_json_async().await?)), - code => Err(ClassroomGetAnAssignmentError::Generic { code }), + 404 => Err(ClassroomGetAnAssignmentError::Status404(github_response.to_json_async().await?).into()), + code => Err(ClassroomGetAnAssignmentError::Generic { code }.into()), } } } @@ -389,7 +416,7 @@ impl<'api, C: Client> Classroom<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_an_assignment(&self, assignment_id: i32) -> Result { + pub fn get_an_assignment(&self, assignment_id: i32) -> Result { let request_uri = format!("{}/assignments/{}", super::GITHUB_BASE_API_URL, assignment_id); @@ -401,7 +428,7 @@ impl<'api, C: Client> Classroom<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -413,8 +440,8 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ClassroomGetAnAssignmentError::Status404(github_response.to_json()?)), - code => Err(ClassroomGetAnAssignmentError::Generic { code }), + 404 => Err(ClassroomGetAnAssignmentError::Status404(github_response.to_json()?).into()), + code => Err(ClassroomGetAnAssignmentError::Generic { code }.into()), } } } @@ -428,19 +455,19 @@ impl<'api, C: Client> Classroom<'api, C> { /// [GitHub API docs for get_assignment_grades](https://docs.github.com/rest/classroom/classroom#get-assignment-grades) /// /// --- - pub async fn get_assignment_grades_async(&self, assignment_id: i32) -> Result, ClassroomGetAssignmentGradesError> { + pub async fn get_assignment_grades_async(&self, assignment_id: i32) -> Result, AdapterError> { let request_uri = format!("{}/assignments/{}/grades", super::GITHUB_BASE_API_URL, assignment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -452,8 +479,8 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ClassroomGetAssignmentGradesError::Status404(github_response.to_json_async().await?)), - code => Err(ClassroomGetAssignmentGradesError::Generic { code }), + 404 => Err(ClassroomGetAssignmentGradesError::Status404(github_response.to_json_async().await?).into()), + code => Err(ClassroomGetAssignmentGradesError::Generic { code }.into()), } } } @@ -468,7 +495,7 @@ impl<'api, C: Client> Classroom<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_assignment_grades(&self, assignment_id: i32) -> Result, ClassroomGetAssignmentGradesError> { + pub fn get_assignment_grades(&self, assignment_id: i32) -> Result, AdapterError> { let request_uri = format!("{}/assignments/{}/grades", super::GITHUB_BASE_API_URL, assignment_id); @@ -480,7 +507,7 @@ impl<'api, C: Client> Classroom<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -492,8 +519,8 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ClassroomGetAssignmentGradesError::Status404(github_response.to_json()?)), - code => Err(ClassroomGetAssignmentGradesError::Generic { code }), + 404 => Err(ClassroomGetAssignmentGradesError::Status404(github_response.to_json()?).into()), + code => Err(ClassroomGetAssignmentGradesError::Generic { code }.into()), } } } @@ -507,7 +534,7 @@ impl<'api, C: Client> Classroom<'api, C> { /// [GitHub API docs for list_accepted_assignments_for_an_assignment](https://docs.github.com/rest/classroom/classroom#list-accepted-assignments-for-an-assignment) /// /// --- - pub async fn list_accepted_assignments_for_an_assignment_async(&self, assignment_id: i32, query_params: Option>) -> Result, ClassroomListAcceptedAssignmentsForAnAssignmentError> { + pub async fn list_accepted_assignments_for_an_assignment_async(&self, assignment_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/assignments/{}/accepted_assignments", super::GITHUB_BASE_API_URL, assignment_id); @@ -518,12 +545,12 @@ impl<'api, C: Client> Classroom<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -535,7 +562,7 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ClassroomListAcceptedAssignmentsForAnAssignmentError::Generic { code }), + code => Err(ClassroomListAcceptedAssignmentsForAnAssignmentError::Generic { code }.into()), } } } @@ -550,7 +577,7 @@ impl<'api, C: Client> Classroom<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_accepted_assignments_for_an_assignment(&self, assignment_id: i32, query_params: Option>) -> Result, ClassroomListAcceptedAssignmentsForAnAssignmentError> { + pub fn list_accepted_assignments_for_an_assignment(&self, assignment_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/assignments/{}/accepted_assignments", super::GITHUB_BASE_API_URL, assignment_id); @@ -567,7 +594,7 @@ impl<'api, C: Client> Classroom<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -579,7 +606,7 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ClassroomListAcceptedAssignmentsForAnAssignmentError::Generic { code }), + code => Err(ClassroomListAcceptedAssignmentsForAnAssignmentError::Generic { code }.into()), } } } @@ -593,7 +620,7 @@ impl<'api, C: Client> Classroom<'api, C> { /// [GitHub API docs for list_assignments_for_a_classroom](https://docs.github.com/rest/classroom/classroom#list-assignments-for-a-classroom) /// /// --- - pub async fn list_assignments_for_a_classroom_async(&self, classroom_id: i32, query_params: Option>) -> Result, ClassroomListAssignmentsForAClassroomError> { + pub async fn list_assignments_for_a_classroom_async(&self, classroom_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/classrooms/{}/assignments", super::GITHUB_BASE_API_URL, classroom_id); @@ -604,12 +631,12 @@ impl<'api, C: Client> Classroom<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -621,7 +648,7 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ClassroomListAssignmentsForAClassroomError::Generic { code }), + code => Err(ClassroomListAssignmentsForAClassroomError::Generic { code }.into()), } } } @@ -636,7 +663,7 @@ impl<'api, C: Client> Classroom<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_assignments_for_a_classroom(&self, classroom_id: i32, query_params: Option>) -> Result, ClassroomListAssignmentsForAClassroomError> { + pub fn list_assignments_for_a_classroom(&self, classroom_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/classrooms/{}/assignments", super::GITHUB_BASE_API_URL, classroom_id); @@ -653,7 +680,7 @@ impl<'api, C: Client> Classroom<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -665,7 +692,7 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ClassroomListAssignmentsForAClassroomError::Generic { code }), + code => Err(ClassroomListAssignmentsForAClassroomError::Generic { code }.into()), } } } @@ -679,7 +706,7 @@ impl<'api, C: Client> Classroom<'api, C> { /// [GitHub API docs for list_classrooms](https://docs.github.com/rest/classroom/classroom#list-classrooms) /// /// --- - pub async fn list_classrooms_async(&self, query_params: Option>) -> Result, ClassroomListClassroomsError> { + pub async fn list_classrooms_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/classrooms", super::GITHUB_BASE_API_URL); @@ -690,12 +717,12 @@ impl<'api, C: Client> Classroom<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -707,7 +734,7 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ClassroomListClassroomsError::Generic { code }), + code => Err(ClassroomListClassroomsError::Generic { code }.into()), } } } @@ -722,7 +749,7 @@ impl<'api, C: Client> Classroom<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_classrooms(&self, query_params: Option>) -> Result, ClassroomListClassroomsError> { + pub fn list_classrooms(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/classrooms", super::GITHUB_BASE_API_URL); @@ -739,7 +766,7 @@ impl<'api, C: Client> Classroom<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -751,7 +778,7 @@ impl<'api, C: Client> Classroom<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ClassroomListClassroomsError::Generic { code }), + code => Err(ClassroomListClassroomsError::Generic { code }.into()), } } } diff --git a/src/endpoints/code_scanning.rs b/src/endpoints/code_scanning.rs index 111976f..ef1f0ae 100644 --- a/src/endpoints/code_scanning.rs +++ b/src/endpoints/code_scanning.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct CodeScanning<'api, C: Client> { +pub struct CodeScanning<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> CodeScanning { +pub fn new(client: &C) -> CodeScanning where AdapterError: From<::Err> { CodeScanning { client } } /// Errors for the [Create a CodeQL variant analysis](CodeScanning::create_variant_analysis_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningCreateVariantAnalysisError { - #[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("Unable to process variant analysis submission")] @@ -53,19 +43,26 @@ pub enum CodeScanningCreateVariantAnalysisError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningCreateVariantAnalysisError) -> Self { + let (description, status_code) = match err { + CodeScanningCreateVariantAnalysisError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningCreateVariantAnalysisError::Status422(_) => (String::from("Unable to process variant analysis submission"), 422), + CodeScanningCreateVariantAnalysisError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningCreateVariantAnalysisError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a code scanning analysis from a repository](CodeScanning::delete_analysis_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningDeleteAnalysisError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository")] @@ -78,19 +75,27 @@ pub enum CodeScanningDeleteAnalysisError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningDeleteAnalysisError) -> Self { + let (description, status_code) = match err { + CodeScanningDeleteAnalysisError::Status400(_) => (String::from("Bad Request"), 400), + CodeScanningDeleteAnalysisError::Status403(_) => (String::from("Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningDeleteAnalysisError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningDeleteAnalysisError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningDeleteAnalysisError::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 { - #[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("Response if GitHub Advanced Security is not enabled for this repository")] @@ -103,19 +108,27 @@ pub enum CodeScanningGetAlertError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningGetAlertError) -> Self { + let (description, status_code) = match err { + CodeScanningGetAlertError::Status304 => (String::from("Not modified"), 304), + CodeScanningGetAlertError::Status403(_) => (String::from("Response if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningGetAlertError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningGetAlertError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningGetAlertError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a code scanning analysis for a repository](CodeScanning::get_analysis_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningGetAnalysisError { - #[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("Resource not found")] @@ -126,19 +139,26 @@ pub enum CodeScanningGetAnalysisError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningGetAnalysisError) -> Self { + let (description, status_code) = match err { + CodeScanningGetAnalysisError::Status403(_) => (String::from("Response if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningGetAnalysisError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningGetAnalysisError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningGetAnalysisError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a CodeQL database for a repository](CodeScanning::get_codeql_database_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningGetCodeqlDatabaseError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Found")] Status302, #[error("Response if GitHub Advanced Security is not enabled for this repository")] @@ -151,19 +171,27 @@ pub enum CodeScanningGetCodeqlDatabaseError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningGetCodeqlDatabaseError) -> Self { + let (description, status_code) = match err { + CodeScanningGetCodeqlDatabaseError::Status302 => (String::from("Found"), 302), + CodeScanningGetCodeqlDatabaseError::Status403(_) => (String::from("Response if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningGetCodeqlDatabaseError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningGetCodeqlDatabaseError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningGetCodeqlDatabaseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a code scanning default setup configuration](CodeScanning::get_default_setup_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningGetDefaultSetupError { - #[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("Resource not found")] @@ -174,19 +202,26 @@ pub enum CodeScanningGetDefaultSetupError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningGetDefaultSetupError) -> Self { + let (description, status_code) = match err { + CodeScanningGetDefaultSetupError::Status403(_) => (String::from("Response if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningGetDefaultSetupError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningGetDefaultSetupError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningGetDefaultSetupError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get information about a SARIF upload](CodeScanning::get_sarif_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningGetSarifError { - #[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("Not Found if the sarif id does not match any upload")] @@ -197,19 +232,26 @@ pub enum CodeScanningGetSarifError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningGetSarifError) -> Self { + let (description, status_code) = match err { + CodeScanningGetSarifError::Status403(_) => (String::from("Response if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningGetSarifError::Status404 => (String::from("Not Found if the sarif id does not match any upload"), 404), + CodeScanningGetSarifError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningGetSarifError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the summary of a CodeQL variant analysis](CodeScanning::get_variant_analysis_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningGetVariantAnalysisError { - #[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("Service unavailable")] @@ -218,19 +260,25 @@ pub enum CodeScanningGetVariantAnalysisError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningGetVariantAnalysisError) -> Self { + let (description, status_code) = match err { + CodeScanningGetVariantAnalysisError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningGetVariantAnalysisError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningGetVariantAnalysisError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the analysis status of a repository in a CodeQL variant analysis](CodeScanning::get_variant_analysis_repo_task_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningGetVariantAnalysisRepoTaskError { - #[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("Service unavailable")] @@ -239,19 +287,25 @@ pub enum CodeScanningGetVariantAnalysisRepoTaskError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningGetVariantAnalysisRepoTaskError) -> Self { + let (description, status_code) = match err { + CodeScanningGetVariantAnalysisRepoTaskError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningGetVariantAnalysisRepoTaskError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningGetVariantAnalysisRepoTaskError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List instances of a code scanning alert](CodeScanning::list_alert_instances_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningListAlertInstancesError { - #[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("Resource not found")] @@ -262,19 +316,26 @@ pub enum CodeScanningListAlertInstancesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningListAlertInstancesError) -> Self { + let (description, status_code) = match err { + CodeScanningListAlertInstancesError::Status403(_) => (String::from("Response if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningListAlertInstancesError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningListAlertInstancesError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningListAlertInstancesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List code scanning alerts for an organization](CodeScanning::list_alerts_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningListAlertsForOrgError { - #[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("Service unavailable")] @@ -283,19 +344,25 @@ pub enum CodeScanningListAlertsForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningListAlertsForOrgError) -> Self { + let (description, status_code) = match err { + CodeScanningListAlertsForOrgError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningListAlertsForOrgError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningListAlertsForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List code scanning alerts for a repository](CodeScanning::list_alerts_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningListAlertsForRepoError { - #[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("Response if GitHub Advanced Security is not enabled for this repository")] @@ -308,19 +375,27 @@ pub enum CodeScanningListAlertsForRepoError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningListAlertsForRepoError) -> Self { + let (description, status_code) = match err { + CodeScanningListAlertsForRepoError::Status304 => (String::from("Not modified"), 304), + CodeScanningListAlertsForRepoError::Status403(_) => (String::from("Response if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningListAlertsForRepoError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningListAlertsForRepoError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningListAlertsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List CodeQL databases for a repository](CodeScanning::list_codeql_databases_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningListCodeqlDatabasesError { - #[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("Resource not found")] @@ -331,19 +406,26 @@ pub enum CodeScanningListCodeqlDatabasesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningListCodeqlDatabasesError) -> Self { + let (description, status_code) = match err { + CodeScanningListCodeqlDatabasesError::Status403(_) => (String::from("Response if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningListCodeqlDatabasesError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningListCodeqlDatabasesError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningListCodeqlDatabasesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List code scanning analyses for a repository](CodeScanning::list_recent_analyses_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningListRecentAnalysesError { - #[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("Resource not found")] @@ -354,19 +436,26 @@ pub enum CodeScanningListRecentAnalysesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningListRecentAnalysesError) -> Self { + let (description, status_code) = match err { + CodeScanningListRecentAnalysesError::Status403(_) => (String::from("Response if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningListRecentAnalysesError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningListRecentAnalysesError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningListRecentAnalysesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a code scanning alert](CodeScanning::update_alert_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningUpdateAlertError { - #[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 the repository is archived or if GitHub Advanced Security is not enabled for this repository")] Status403(BasicError), #[error("Resource not found")] @@ -377,19 +466,26 @@ pub enum CodeScanningUpdateAlertError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningUpdateAlertError) -> Self { + let (description, status_code) = match err { + CodeScanningUpdateAlertError::Status403(_) => (String::from("Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningUpdateAlertError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningUpdateAlertError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningUpdateAlertError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a code scanning default setup configuration](CodeScanning::update_default_setup_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningUpdateDefaultSetupError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status202(CodeScanningDefaultSetupUpdateResponse), #[error("Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository")] @@ -404,19 +500,28 @@ pub enum CodeScanningUpdateDefaultSetupError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningUpdateDefaultSetupError) -> Self { + let (description, status_code) = match err { + CodeScanningUpdateDefaultSetupError::Status202(_) => (String::from("Response"), 202), + CodeScanningUpdateDefaultSetupError::Status403(_) => (String::from("Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningUpdateDefaultSetupError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningUpdateDefaultSetupError::Status409(_) => (String::from("Response if there is already a validation run in progress with a different default setup configuration"), 409), + CodeScanningUpdateDefaultSetupError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningUpdateDefaultSetupError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Upload an analysis as SARIF data](CodeScanning::upload_sarif_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeScanningUploadSarifError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request if the sarif field is invalid")] Status400, #[error("Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository")] @@ -431,6 +536,25 @@ pub enum CodeScanningUploadSarifError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeScanningUploadSarifError) -> Self { + let (description, status_code) = match err { + CodeScanningUploadSarifError::Status400 => (String::from("Bad Request if the sarif field is invalid"), 400), + CodeScanningUploadSarifError::Status403(_) => (String::from("Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository"), 403), + CodeScanningUploadSarifError::Status404(_) => (String::from("Resource not found"), 404), + CodeScanningUploadSarifError::Status413 => (String::from("Payload Too Large if the sarif field is too large"), 413), + CodeScanningUploadSarifError::Status503(_) => (String::from("Service unavailable"), 503), + CodeScanningUploadSarifError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [Delete a code scanning analysis from a repository](CodeScanning::delete_analysis_async()) endpoint. #[derive(Default, Serialize)] @@ -737,6 +861,10 @@ pub struct CodeScanningListAlertsForRepoParams<'req> { pr: Option, /// The direction to sort the results by. direction: Option<&'req str>, + /// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + before: Option<&'req str>, + /// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + after: Option<&'req str>, /// The property by which to sort the results. sort: Option<&'req str>, /// If specified, only code scanning alerts with this state will be returned. @@ -760,6 +888,8 @@ impl<'req> CodeScanningListAlertsForRepoParams<'req> { git_ref: self.git_ref, pr: self.pr, direction: self.direction, + before: self.before, + after: self.after, sort: self.sort, state: self.state, severity: self.severity, @@ -776,6 +906,8 @@ impl<'req> CodeScanningListAlertsForRepoParams<'req> { git_ref: self.git_ref, pr: self.pr, direction: self.direction, + before: self.before, + after: self.after, sort: self.sort, state: self.state, severity: self.severity, @@ -792,6 +924,8 @@ impl<'req> CodeScanningListAlertsForRepoParams<'req> { git_ref: self.git_ref, pr: self.pr, direction: self.direction, + before: self.before, + after: self.after, sort: self.sort, state: self.state, severity: self.severity, @@ -808,6 +942,8 @@ impl<'req> CodeScanningListAlertsForRepoParams<'req> { git_ref: self.git_ref, pr: self.pr, direction: self.direction, + before: self.before, + after: self.after, sort: self.sort, state: self.state, severity: self.severity, @@ -824,6 +960,8 @@ impl<'req> CodeScanningListAlertsForRepoParams<'req> { git_ref: Some(git_ref), pr: self.pr, direction: self.direction, + before: self.before, + after: self.after, sort: self.sort, state: self.state, severity: self.severity, @@ -840,6 +978,8 @@ impl<'req> CodeScanningListAlertsForRepoParams<'req> { git_ref: self.git_ref, pr: Some(pr), direction: self.direction, + before: self.before, + after: self.after, sort: self.sort, state: self.state, severity: self.severity, @@ -856,6 +996,44 @@ impl<'req> CodeScanningListAlertsForRepoParams<'req> { git_ref: self.git_ref, pr: self.pr, direction: Some(direction), + before: self.before, + after: self.after, + sort: self.sort, + state: self.state, + severity: self.severity, + } + } + + /// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results before this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + pub fn before(self, before: &'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, + pr: self.pr, + direction: self.direction, + before: Some(before), + after: self.after, + sort: self.sort, + state: self.state, + severity: self.severity, + } + } + + /// A cursor, as given in the [Link header](https://docs.github.com/rest/guides/using-pagination-in-the-rest-api#using-link-headers). If specified, the query only searches for results after this cursor. For more information, see \"[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api).\" + pub fn after(self, after: &'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, + pr: self.pr, + direction: self.direction, + before: self.before, + after: Some(after), sort: self.sort, state: self.state, severity: self.severity, @@ -872,6 +1050,8 @@ impl<'req> CodeScanningListAlertsForRepoParams<'req> { git_ref: self.git_ref, pr: self.pr, direction: self.direction, + before: self.before, + after: self.after, sort: Some(sort), state: self.state, severity: self.severity, @@ -888,6 +1068,8 @@ impl<'req> CodeScanningListAlertsForRepoParams<'req> { git_ref: self.git_ref, pr: self.pr, direction: self.direction, + before: self.before, + after: self.after, sort: self.sort, state: Some(state), severity: self.severity, @@ -904,6 +1086,8 @@ impl<'req> CodeScanningListAlertsForRepoParams<'req> { git_ref: self.git_ref, pr: self.pr, direction: self.direction, + before: self.before, + after: self.after, sort: self.sort, state: self.state, severity: Some(severity), @@ -1094,7 +1278,7 @@ impl<'enc> From<&'enc PerPage> for CodeScanningListRecentAnalysesParams<'enc> { } } -impl<'api, C: Client> CodeScanning<'api, C> { +impl<'api, C: Client> CodeScanning<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Create a CodeQL variant analysis @@ -1111,19 +1295,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for create_variant_analysis](https://docs.github.com/rest/code-scanning/code-scanning#create-a-codeql-variant-analysis) /// /// --- - pub async fn create_variant_analysis_async(&self, owner: &str, repo: &str, body: PostCodeScanningCreateVariantAnalysis) -> Result { + pub async fn create_variant_analysis_async(&self, owner: &str, repo: &str, body: PostCodeScanningCreateVariantAnalysis) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/codeql/variant-analyses", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodeScanningCreateVariantAnalysis::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1135,10 +1319,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(CodeScanningCreateVariantAnalysisError::Status404(github_response.to_json_async().await?)), - 422 => Err(CodeScanningCreateVariantAnalysisError::Status422(github_response.to_json_async().await?)), - 503 => Err(CodeScanningCreateVariantAnalysisError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningCreateVariantAnalysisError::Generic { code }), + 404 => Err(CodeScanningCreateVariantAnalysisError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CodeScanningCreateVariantAnalysisError::Status422(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningCreateVariantAnalysisError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningCreateVariantAnalysisError::Generic { code }.into()), } } } @@ -1160,19 +1344,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_variant_analysis(&self, owner: &str, repo: &str, body: PostCodeScanningCreateVariantAnalysis) -> Result { + pub fn create_variant_analysis(&self, owner: &str, repo: &str, body: PostCodeScanningCreateVariantAnalysis) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/codeql/variant-analyses", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodeScanningCreateVariantAnalysis::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1184,10 +1368,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(CodeScanningCreateVariantAnalysisError::Status404(github_response.to_json()?)), - 422 => Err(CodeScanningCreateVariantAnalysisError::Status422(github_response.to_json()?)), - 503 => Err(CodeScanningCreateVariantAnalysisError::Status503(github_response.to_json()?)), - code => Err(CodeScanningCreateVariantAnalysisError::Generic { code }), + 404 => Err(CodeScanningCreateVariantAnalysisError::Status404(github_response.to_json()?).into()), + 422 => Err(CodeScanningCreateVariantAnalysisError::Status422(github_response.to_json()?).into()), + 503 => Err(CodeScanningCreateVariantAnalysisError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningCreateVariantAnalysisError::Generic { code }.into()), } } } @@ -1264,7 +1448,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for delete_analysis](https://docs.github.com/rest/code-scanning/code-scanning#delete-a-code-scanning-analysis-from-a-repository) /// /// --- - pub async fn delete_analysis_async(&self, owner: &str, repo: &str, analysis_id: i32, query_params: Option>>) -> Result { + pub async fn delete_analysis_async(&self, owner: &str, repo: &str, analysis_id: i32, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/code-scanning/analyses/{}", super::GITHUB_BASE_API_URL, owner, repo, analysis_id); @@ -1275,12 +1459,12 @@ impl<'api, C: Client> CodeScanning<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1292,11 +1476,11 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(CodeScanningDeleteAnalysisError::Status400(github_response.to_json_async().await?)), - 403 => Err(CodeScanningDeleteAnalysisError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningDeleteAnalysisError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningDeleteAnalysisError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningDeleteAnalysisError::Generic { code }), + 400 => Err(CodeScanningDeleteAnalysisError::Status400(github_response.to_json_async().await?).into()), + 403 => Err(CodeScanningDeleteAnalysisError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningDeleteAnalysisError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningDeleteAnalysisError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningDeleteAnalysisError::Generic { code }.into()), } } } @@ -1374,7 +1558,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_analysis(&self, owner: &str, repo: &str, analysis_id: i32, query_params: Option>>) -> Result { + pub fn delete_analysis(&self, owner: &str, repo: &str, analysis_id: i32, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/code-scanning/analyses/{}", super::GITHUB_BASE_API_URL, owner, repo, analysis_id); @@ -1391,7 +1575,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1403,11 +1587,11 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(CodeScanningDeleteAnalysisError::Status400(github_response.to_json()?)), - 403 => Err(CodeScanningDeleteAnalysisError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningDeleteAnalysisError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningDeleteAnalysisError::Status503(github_response.to_json()?)), - code => Err(CodeScanningDeleteAnalysisError::Generic { code }), + 400 => Err(CodeScanningDeleteAnalysisError::Status400(github_response.to_json()?).into()), + 403 => Err(CodeScanningDeleteAnalysisError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningDeleteAnalysisError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningDeleteAnalysisError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningDeleteAnalysisError::Generic { code }.into()), } } } @@ -1423,19 +1607,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for get_alert](https://docs.github.com/rest/code-scanning/code-scanning#get-a-code-scanning-alert) /// /// --- - pub async fn get_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { + pub async fn get_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1447,11 +1631,11 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodeScanningGetAlertError::Status304), - 403 => Err(CodeScanningGetAlertError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningGetAlertError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningGetAlertError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningGetAlertError::Generic { code }), + 304 => Err(CodeScanningGetAlertError::Status304.into()), + 403 => Err(CodeScanningGetAlertError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningGetAlertError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningGetAlertError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningGetAlertError::Generic { code }.into()), } } } @@ -1468,7 +1652,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { + pub fn get_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); @@ -1480,7 +1664,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1492,11 +1676,11 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodeScanningGetAlertError::Status304), - 403 => Err(CodeScanningGetAlertError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningGetAlertError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningGetAlertError::Status503(github_response.to_json()?)), - code => Err(CodeScanningGetAlertError::Generic { code }), + 304 => Err(CodeScanningGetAlertError::Status304.into()), + 403 => Err(CodeScanningGetAlertError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningGetAlertError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningGetAlertError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningGetAlertError::Generic { code }.into()), } } } @@ -1526,19 +1710,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for get_analysis](https://docs.github.com/rest/code-scanning/code-scanning#get-a-code-scanning-analysis-for-a-repository) /// /// --- - pub async fn get_analysis_async(&self, owner: &str, repo: &str, analysis_id: i32) -> Result { + pub async fn get_analysis_async(&self, owner: &str, repo: &str, analysis_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/analyses/{}", super::GITHUB_BASE_API_URL, owner, repo, analysis_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1550,10 +1734,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(CodeScanningGetAnalysisError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningGetAnalysisError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningGetAnalysisError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningGetAnalysisError::Generic { code }), + 403 => Err(CodeScanningGetAnalysisError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningGetAnalysisError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningGetAnalysisError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningGetAnalysisError::Generic { code }.into()), } } } @@ -1584,7 +1768,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_analysis(&self, owner: &str, repo: &str, analysis_id: i32) -> Result { + pub fn get_analysis(&self, owner: &str, repo: &str, analysis_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/analyses/{}", super::GITHUB_BASE_API_URL, owner, repo, analysis_id); @@ -1596,7 +1780,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1608,10 +1792,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(CodeScanningGetAnalysisError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningGetAnalysisError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningGetAnalysisError::Status503(github_response.to_json()?)), - code => Err(CodeScanningGetAnalysisError::Generic { code }), + 403 => Err(CodeScanningGetAnalysisError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningGetAnalysisError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningGetAnalysisError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningGetAnalysisError::Generic { code }.into()), } } } @@ -1633,19 +1817,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for get_codeql_database](https://docs.github.com/rest/code-scanning/code-scanning#get-a-codeql-database-for-a-repository) /// /// --- - pub async fn get_codeql_database_async(&self, owner: &str, repo: &str, language: &str) -> Result { + pub async fn get_codeql_database_async(&self, owner: &str, repo: &str, language: &str) -> Result { 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, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1657,11 +1841,11 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 302 => Err(CodeScanningGetCodeqlDatabaseError::Status302), - 403 => Err(CodeScanningGetCodeqlDatabaseError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningGetCodeqlDatabaseError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningGetCodeqlDatabaseError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningGetCodeqlDatabaseError::Generic { code }), + 302 => Err(CodeScanningGetCodeqlDatabaseError::Status302.into()), + 403 => Err(CodeScanningGetCodeqlDatabaseError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningGetCodeqlDatabaseError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningGetCodeqlDatabaseError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningGetCodeqlDatabaseError::Generic { code }.into()), } } } @@ -1684,7 +1868,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_codeql_database(&self, owner: &str, repo: &str, language: &str) -> Result { + pub fn get_codeql_database(&self, owner: &str, repo: &str, language: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/codeql/databases/{}", super::GITHUB_BASE_API_URL, owner, repo, language); @@ -1696,7 +1880,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1708,11 +1892,11 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 302 => Err(CodeScanningGetCodeqlDatabaseError::Status302), - 403 => Err(CodeScanningGetCodeqlDatabaseError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningGetCodeqlDatabaseError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningGetCodeqlDatabaseError::Status503(github_response.to_json()?)), - code => Err(CodeScanningGetCodeqlDatabaseError::Generic { code }), + 302 => Err(CodeScanningGetCodeqlDatabaseError::Status302.into()), + 403 => Err(CodeScanningGetCodeqlDatabaseError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningGetCodeqlDatabaseError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningGetCodeqlDatabaseError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningGetCodeqlDatabaseError::Generic { code }.into()), } } } @@ -1728,19 +1912,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for get_default_setup](https://docs.github.com/rest/code-scanning/code-scanning#get-a-code-scanning-default-setup-configuration) /// /// --- - pub async fn get_default_setup_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_default_setup_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/default-setup", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1752,10 +1936,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(CodeScanningGetDefaultSetupError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningGetDefaultSetupError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningGetDefaultSetupError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningGetDefaultSetupError::Generic { code }), + 403 => Err(CodeScanningGetDefaultSetupError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningGetDefaultSetupError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningGetDefaultSetupError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningGetDefaultSetupError::Generic { code }.into()), } } } @@ -1772,7 +1956,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_default_setup(&self, owner: &str, repo: &str) -> Result { + pub fn get_default_setup(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/default-setup", super::GITHUB_BASE_API_URL, owner, repo); @@ -1784,7 +1968,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1796,10 +1980,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(CodeScanningGetDefaultSetupError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningGetDefaultSetupError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningGetDefaultSetupError::Status503(github_response.to_json()?)), - code => Err(CodeScanningGetDefaultSetupError::Generic { code }), + 403 => Err(CodeScanningGetDefaultSetupError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningGetDefaultSetupError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningGetDefaultSetupError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningGetDefaultSetupError::Generic { code }.into()), } } } @@ -1814,19 +1998,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for get_sarif](https://docs.github.com/rest/code-scanning/code-scanning#get-information-about-a-sarif-upload) /// /// --- - pub async fn get_sarif_async(&self, owner: &str, repo: &str, sarif_id: &str) -> Result { + pub async fn get_sarif_async(&self, owner: &str, repo: &str, sarif_id: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/sarifs/{}", super::GITHUB_BASE_API_URL, owner, repo, sarif_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1838,10 +2022,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(CodeScanningGetSarifError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningGetSarifError::Status404), - 503 => Err(CodeScanningGetSarifError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningGetSarifError::Generic { code }), + 403 => Err(CodeScanningGetSarifError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningGetSarifError::Status404.into()), + 503 => Err(CodeScanningGetSarifError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningGetSarifError::Generic { code }.into()), } } } @@ -1857,7 +2041,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_sarif(&self, owner: &str, repo: &str, sarif_id: &str) -> Result { + pub fn get_sarif(&self, owner: &str, repo: &str, sarif_id: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/sarifs/{}", super::GITHUB_BASE_API_URL, owner, repo, sarif_id); @@ -1869,7 +2053,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1881,10 +2065,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(CodeScanningGetSarifError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningGetSarifError::Status404), - 503 => Err(CodeScanningGetSarifError::Status503(github_response.to_json()?)), - code => Err(CodeScanningGetSarifError::Generic { code }), + 403 => Err(CodeScanningGetSarifError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningGetSarifError::Status404.into()), + 503 => Err(CodeScanningGetSarifError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningGetSarifError::Generic { code }.into()), } } } @@ -1900,19 +2084,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for get_variant_analysis](https://docs.github.com/rest/code-scanning/code-scanning#get-the-summary-of-a-codeql-variant-analysis) /// /// --- - pub async fn get_variant_analysis_async(&self, owner: &str, repo: &str, codeql_variant_analysis_id: i32) -> Result { + pub async fn get_variant_analysis_async(&self, owner: &str, repo: &str, codeql_variant_analysis_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/codeql/variant-analyses/{}", super::GITHUB_BASE_API_URL, owner, repo, codeql_variant_analysis_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1924,9 +2108,9 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(CodeScanningGetVariantAnalysisError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningGetVariantAnalysisError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningGetVariantAnalysisError::Generic { code }), + 404 => Err(CodeScanningGetVariantAnalysisError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningGetVariantAnalysisError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningGetVariantAnalysisError::Generic { code }.into()), } } } @@ -1943,7 +2127,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_variant_analysis(&self, owner: &str, repo: &str, codeql_variant_analysis_id: i32) -> Result { + pub fn get_variant_analysis(&self, owner: &str, repo: &str, codeql_variant_analysis_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/codeql/variant-analyses/{}", super::GITHUB_BASE_API_URL, owner, repo, codeql_variant_analysis_id); @@ -1955,7 +2139,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1967,9 +2151,9 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(CodeScanningGetVariantAnalysisError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningGetVariantAnalysisError::Status503(github_response.to_json()?)), - code => Err(CodeScanningGetVariantAnalysisError::Generic { code }), + 404 => Err(CodeScanningGetVariantAnalysisError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningGetVariantAnalysisError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningGetVariantAnalysisError::Generic { code }.into()), } } } @@ -1985,19 +2169,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for get_variant_analysis_repo_task](https://docs.github.com/rest/code-scanning/code-scanning#get-the-analysis-status-of-a-repository-in-a-codeql-variant-analysis) /// /// --- - pub async fn get_variant_analysis_repo_task_async(&self, owner: &str, repo: &str, codeql_variant_analysis_id: i32, repo_owner: &str, repo_name: &str) -> Result { + pub async fn get_variant_analysis_repo_task_async(&self, owner: &str, repo: &str, codeql_variant_analysis_id: i32, repo_owner: &str, repo_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/codeql/variant-analyses/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo, codeql_variant_analysis_id, repo_owner, repo_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2009,9 +2193,9 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(CodeScanningGetVariantAnalysisRepoTaskError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningGetVariantAnalysisRepoTaskError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningGetVariantAnalysisRepoTaskError::Generic { code }), + 404 => Err(CodeScanningGetVariantAnalysisRepoTaskError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningGetVariantAnalysisRepoTaskError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningGetVariantAnalysisRepoTaskError::Generic { code }.into()), } } } @@ -2028,7 +2212,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_variant_analysis_repo_task(&self, owner: &str, repo: &str, codeql_variant_analysis_id: i32, repo_owner: &str, repo_name: &str) -> Result { + pub fn get_variant_analysis_repo_task(&self, owner: &str, repo: &str, codeql_variant_analysis_id: i32, repo_owner: &str, repo_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/codeql/variant-analyses/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo, codeql_variant_analysis_id, repo_owner, repo_name); @@ -2040,7 +2224,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2052,9 +2236,9 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(CodeScanningGetVariantAnalysisRepoTaskError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningGetVariantAnalysisRepoTaskError::Status503(github_response.to_json()?)), - code => Err(CodeScanningGetVariantAnalysisRepoTaskError::Generic { code }), + 404 => Err(CodeScanningGetVariantAnalysisRepoTaskError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningGetVariantAnalysisRepoTaskError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningGetVariantAnalysisRepoTaskError::Generic { code }.into()), } } } @@ -2070,7 +2254,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for list_alert_instances](https://docs.github.com/rest/code-scanning/code-scanning#list-instances-of-a-code-scanning-alert) /// /// --- - pub async fn list_alert_instances_async(&self, owner: &str, repo: &str, alert_number: AlertNumber, query_params: Option>) -> Result, CodeScanningListAlertInstancesError> { + pub async fn list_alert_instances_async(&self, owner: &str, repo: &str, alert_number: AlertNumber, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/code-scanning/alerts/{}/instances", super::GITHUB_BASE_API_URL, owner, repo, alert_number); @@ -2081,12 +2265,12 @@ impl<'api, C: Client> CodeScanning<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2098,10 +2282,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(CodeScanningListAlertInstancesError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningListAlertInstancesError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningListAlertInstancesError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningListAlertInstancesError::Generic { code }), + 403 => Err(CodeScanningListAlertInstancesError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningListAlertInstancesError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningListAlertInstancesError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningListAlertInstancesError::Generic { code }.into()), } } } @@ -2118,7 +2302,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_alert_instances(&self, owner: &str, repo: &str, alert_number: AlertNumber, query_params: Option>) -> Result, CodeScanningListAlertInstancesError> { + pub fn list_alert_instances(&self, owner: &str, repo: &str, alert_number: AlertNumber, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/code-scanning/alerts/{}/instances", super::GITHUB_BASE_API_URL, owner, repo, alert_number); @@ -2135,7 +2319,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2147,10 +2331,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(CodeScanningListAlertInstancesError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningListAlertInstancesError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningListAlertInstancesError::Status503(github_response.to_json()?)), - code => Err(CodeScanningListAlertInstancesError::Generic { code }), + 403 => Err(CodeScanningListAlertInstancesError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningListAlertInstancesError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningListAlertInstancesError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningListAlertInstancesError::Generic { code }.into()), } } } @@ -2168,7 +2352,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for list_alerts_for_org](https://docs.github.com/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-an-organization) /// /// --- - pub async fn list_alerts_for_org_async(&self, org: &str, query_params: Option>>) -> Result, CodeScanningListAlertsForOrgError> { + pub async fn list_alerts_for_org_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/code-scanning/alerts", super::GITHUB_BASE_API_URL, org); @@ -2179,12 +2363,12 @@ impl<'api, C: Client> CodeScanning<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2196,9 +2380,9 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(CodeScanningListAlertsForOrgError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningListAlertsForOrgError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningListAlertsForOrgError::Generic { code }), + 404 => Err(CodeScanningListAlertsForOrgError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningListAlertsForOrgError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningListAlertsForOrgError::Generic { code }.into()), } } } @@ -2217,7 +2401,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_alerts_for_org(&self, org: &str, query_params: Option>>) -> Result, CodeScanningListAlertsForOrgError> { + pub fn list_alerts_for_org(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/code-scanning/alerts", super::GITHUB_BASE_API_URL, org); @@ -2234,7 +2418,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2246,9 +2430,9 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(CodeScanningListAlertsForOrgError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningListAlertsForOrgError::Status503(github_response.to_json()?)), - code => Err(CodeScanningListAlertsForOrgError::Generic { code }), + 404 => Err(CodeScanningListAlertsForOrgError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningListAlertsForOrgError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningListAlertsForOrgError::Generic { code }.into()), } } } @@ -2268,7 +2452,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for list_alerts_for_repo](https://docs.github.com/rest/code-scanning/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, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/code-scanning/alerts", super::GITHUB_BASE_API_URL, owner, repo); @@ -2279,12 +2463,12 @@ impl<'api, C: Client> CodeScanning<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2296,11 +2480,11 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodeScanningListAlertsForRepoError::Status304), - 403 => Err(CodeScanningListAlertsForRepoError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningListAlertsForRepoError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningListAlertsForRepoError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningListAlertsForRepoError::Generic { code }), + 304 => Err(CodeScanningListAlertsForRepoError::Status304.into()), + 403 => Err(CodeScanningListAlertsForRepoError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningListAlertsForRepoError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningListAlertsForRepoError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningListAlertsForRepoError::Generic { code }.into()), } } } @@ -2321,7 +2505,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[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, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/code-scanning/alerts", super::GITHUB_BASE_API_URL, owner, repo); @@ -2338,7 +2522,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2350,11 +2534,11 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodeScanningListAlertsForRepoError::Status304), - 403 => Err(CodeScanningListAlertsForRepoError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningListAlertsForRepoError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningListAlertsForRepoError::Status503(github_response.to_json()?)), - code => Err(CodeScanningListAlertsForRepoError::Generic { code }), + 304 => Err(CodeScanningListAlertsForRepoError::Status304.into()), + 403 => Err(CodeScanningListAlertsForRepoError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningListAlertsForRepoError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningListAlertsForRepoError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningListAlertsForRepoError::Generic { code }.into()), } } } @@ -2370,19 +2554,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for list_codeql_databases](https://docs.github.com/rest/code-scanning/code-scanning#list-codeql-databases-for-a-repository) /// /// --- - pub async fn list_codeql_databases_async(&self, owner: &str, repo: &str) -> Result, CodeScanningListCodeqlDatabasesError> { + pub async fn list_codeql_databases_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/code-scanning/codeql/databases", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2394,10 +2578,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(CodeScanningListCodeqlDatabasesError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningListCodeqlDatabasesError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningListCodeqlDatabasesError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningListCodeqlDatabasesError::Generic { code }), + 403 => Err(CodeScanningListCodeqlDatabasesError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningListCodeqlDatabasesError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningListCodeqlDatabasesError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningListCodeqlDatabasesError::Generic { code }.into()), } } } @@ -2414,7 +2598,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_codeql_databases(&self, owner: &str, repo: &str) -> Result, CodeScanningListCodeqlDatabasesError> { + pub fn list_codeql_databases(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/code-scanning/codeql/databases", super::GITHUB_BASE_API_URL, owner, repo); @@ -2426,7 +2610,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2438,10 +2622,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(CodeScanningListCodeqlDatabasesError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningListCodeqlDatabasesError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningListCodeqlDatabasesError::Status503(github_response.to_json()?)), - code => Err(CodeScanningListCodeqlDatabasesError::Generic { code }), + 403 => Err(CodeScanningListCodeqlDatabasesError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningListCodeqlDatabasesError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningListCodeqlDatabasesError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningListCodeqlDatabasesError::Generic { code }.into()), } } } @@ -2469,7 +2653,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for list_recent_analyses](https://docs.github.com/rest/code-scanning/code-scanning#list-code-scanning-analyses-for-a-repository) /// /// --- - pub async fn list_recent_analyses_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, CodeScanningListRecentAnalysesError> { + pub async fn list_recent_analyses_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/code-scanning/analyses", super::GITHUB_BASE_API_URL, owner, repo); @@ -2480,12 +2664,12 @@ impl<'api, C: Client> CodeScanning<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2497,10 +2681,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(CodeScanningListRecentAnalysesError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningListRecentAnalysesError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningListRecentAnalysesError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningListRecentAnalysesError::Generic { code }), + 403 => Err(CodeScanningListRecentAnalysesError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningListRecentAnalysesError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningListRecentAnalysesError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningListRecentAnalysesError::Generic { code }.into()), } } } @@ -2529,7 +2713,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_recent_analyses(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, CodeScanningListRecentAnalysesError> { + pub fn list_recent_analyses(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/code-scanning/analyses", super::GITHUB_BASE_API_URL, owner, repo); @@ -2546,7 +2730,7 @@ impl<'api, C: Client> CodeScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2558,10 +2742,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(CodeScanningListRecentAnalysesError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningListRecentAnalysesError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningListRecentAnalysesError::Status503(github_response.to_json()?)), - code => Err(CodeScanningListRecentAnalysesError::Generic { code }), + 403 => Err(CodeScanningListRecentAnalysesError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningListRecentAnalysesError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningListRecentAnalysesError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningListRecentAnalysesError::Generic { code }.into()), } } } @@ -2576,19 +2760,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for update_alert](https://docs.github.com/rest/code-scanning/code-scanning#update-a-code-scanning-alert) /// /// --- - pub async fn update_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchCodeScanningUpdateAlert) -> Result { + pub async fn update_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchCodeScanningUpdateAlert) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchCodeScanningUpdateAlert::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2600,10 +2784,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(CodeScanningUpdateAlertError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningUpdateAlertError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodeScanningUpdateAlertError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningUpdateAlertError::Generic { code }), + 403 => Err(CodeScanningUpdateAlertError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningUpdateAlertError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningUpdateAlertError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningUpdateAlertError::Generic { code }.into()), } } } @@ -2619,19 +2803,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchCodeScanningUpdateAlert) -> Result { + pub fn update_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchCodeScanningUpdateAlert) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchCodeScanningUpdateAlert::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2643,10 +2827,10 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(CodeScanningUpdateAlertError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningUpdateAlertError::Status404(github_response.to_json()?)), - 503 => Err(CodeScanningUpdateAlertError::Status503(github_response.to_json()?)), - code => Err(CodeScanningUpdateAlertError::Generic { code }), + 403 => Err(CodeScanningUpdateAlertError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningUpdateAlertError::Status404(github_response.to_json()?).into()), + 503 => Err(CodeScanningUpdateAlertError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningUpdateAlertError::Generic { code }.into()), } } } @@ -2662,19 +2846,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for update_default_setup](https://docs.github.com/rest/code-scanning/code-scanning#update-a-code-scanning-default-setup-configuration) /// /// --- - pub async fn update_default_setup_async(&self, owner: &str, repo: &str, body: PatchCodeScanningUpdateDefaultSetup) -> Result { + pub async fn update_default_setup_async(&self, owner: &str, repo: &str, body: PatchCodeScanningUpdateDefaultSetup) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/default-setup", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchCodeScanningUpdateDefaultSetup::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2686,12 +2870,12 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 202 => Err(CodeScanningUpdateDefaultSetupError::Status202(github_response.to_json_async().await?)), - 403 => Err(CodeScanningUpdateDefaultSetupError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningUpdateDefaultSetupError::Status404(github_response.to_json_async().await?)), - 409 => Err(CodeScanningUpdateDefaultSetupError::Status409(github_response.to_json_async().await?)), - 503 => Err(CodeScanningUpdateDefaultSetupError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningUpdateDefaultSetupError::Generic { code }), + 202 => Err(CodeScanningUpdateDefaultSetupError::Status202(github_response.to_json_async().await?).into()), + 403 => Err(CodeScanningUpdateDefaultSetupError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningUpdateDefaultSetupError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(CodeScanningUpdateDefaultSetupError::Status409(github_response.to_json_async().await?).into()), + 503 => Err(CodeScanningUpdateDefaultSetupError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningUpdateDefaultSetupError::Generic { code }.into()), } } } @@ -2708,19 +2892,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_default_setup(&self, owner: &str, repo: &str, body: PatchCodeScanningUpdateDefaultSetup) -> Result { + pub fn update_default_setup(&self, owner: &str, repo: &str, body: PatchCodeScanningUpdateDefaultSetup) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/default-setup", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchCodeScanningUpdateDefaultSetup::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2732,12 +2916,12 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 202 => Err(CodeScanningUpdateDefaultSetupError::Status202(github_response.to_json()?)), - 403 => Err(CodeScanningUpdateDefaultSetupError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningUpdateDefaultSetupError::Status404(github_response.to_json()?)), - 409 => Err(CodeScanningUpdateDefaultSetupError::Status409(github_response.to_json()?)), - 503 => Err(CodeScanningUpdateDefaultSetupError::Status503(github_response.to_json()?)), - code => Err(CodeScanningUpdateDefaultSetupError::Generic { code }), + 202 => Err(CodeScanningUpdateDefaultSetupError::Status202(github_response.to_json()?).into()), + 403 => Err(CodeScanningUpdateDefaultSetupError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningUpdateDefaultSetupError::Status404(github_response.to_json()?).into()), + 409 => Err(CodeScanningUpdateDefaultSetupError::Status409(github_response.to_json()?).into()), + 503 => Err(CodeScanningUpdateDefaultSetupError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningUpdateDefaultSetupError::Generic { code }.into()), } } } @@ -2784,19 +2968,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// [GitHub API docs for upload_sarif](https://docs.github.com/rest/code-scanning/code-scanning#upload-an-analysis-as-sarif-data) /// /// --- - pub async fn upload_sarif_async(&self, owner: &str, repo: &str, body: PostCodeScanningUploadSarif) -> Result { + pub async fn upload_sarif_async(&self, owner: &str, repo: &str, body: PostCodeScanningUploadSarif) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/sarifs", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodeScanningUploadSarif::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2808,12 +2992,12 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(CodeScanningUploadSarifError::Status400), - 403 => Err(CodeScanningUploadSarifError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeScanningUploadSarifError::Status404(github_response.to_json_async().await?)), - 413 => Err(CodeScanningUploadSarifError::Status413), - 503 => Err(CodeScanningUploadSarifError::Status503(github_response.to_json_async().await?)), - code => Err(CodeScanningUploadSarifError::Generic { code }), + 400 => Err(CodeScanningUploadSarifError::Status400.into()), + 403 => Err(CodeScanningUploadSarifError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeScanningUploadSarifError::Status404(github_response.to_json_async().await?).into()), + 413 => Err(CodeScanningUploadSarifError::Status413.into()), + 503 => Err(CodeScanningUploadSarifError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodeScanningUploadSarifError::Generic { code }.into()), } } } @@ -2861,19 +3045,19 @@ impl<'api, C: Client> CodeScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn upload_sarif(&self, owner: &str, repo: &str, body: PostCodeScanningUploadSarif) -> Result { + pub fn upload_sarif(&self, owner: &str, repo: &str, body: PostCodeScanningUploadSarif) -> Result { let request_uri = format!("{}/repos/{}/{}/code-scanning/sarifs", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodeScanningUploadSarif::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2885,12 +3069,12 @@ impl<'api, C: Client> CodeScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(CodeScanningUploadSarifError::Status400), - 403 => Err(CodeScanningUploadSarifError::Status403(github_response.to_json()?)), - 404 => Err(CodeScanningUploadSarifError::Status404(github_response.to_json()?)), - 413 => Err(CodeScanningUploadSarifError::Status413), - 503 => Err(CodeScanningUploadSarifError::Status503(github_response.to_json()?)), - code => Err(CodeScanningUploadSarifError::Generic { code }), + 400 => Err(CodeScanningUploadSarifError::Status400.into()), + 403 => Err(CodeScanningUploadSarifError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeScanningUploadSarifError::Status404(github_response.to_json()?).into()), + 413 => Err(CodeScanningUploadSarifError::Status413.into()), + 503 => Err(CodeScanningUploadSarifError::Status503(github_response.to_json()?).into()), + code => Err(CodeScanningUploadSarifError::Generic { code }.into()), } } } diff --git a/src/endpoints/code_security.rs b/src/endpoints/code_security.rs index b4e2b78..6a1cc66 100644 --- a/src/endpoints/code_security.rs +++ b/src/endpoints/code_security.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,61 +22,59 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct CodeSecurity<'api, C: Client> { +pub struct CodeSecurity<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> CodeSecurity { +pub fn new(client: &C) -> CodeSecurity where AdapterError: From<::Err> { CodeSecurity { client } } /// Errors for the [Attach a configuration to repositories](CodeSecurity::attach_configuration_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeSecurityAttachConfigurationError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodeSecurityAttachConfigurationError) -> Self { + let (description, status_code) = match err { + CodeSecurityAttachConfigurationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a code security configuration](CodeSecurity::create_configuration_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeSecurityCreateConfigurationError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodeSecurityCreateConfigurationError) -> Self { + let (description, status_code) = match err { + CodeSecurityCreateConfigurationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a code security configuration](CodeSecurity::delete_configuration_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeSecurityDeleteConfigurationError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Forbidden")] @@ -89,19 +87,27 @@ pub enum CodeSecurityDeleteConfigurationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeSecurityDeleteConfigurationError) -> Self { + let (description, status_code) = match err { + CodeSecurityDeleteConfigurationError::Status400(_) => (String::from("Bad Request"), 400), + CodeSecurityDeleteConfigurationError::Status403(_) => (String::from("Forbidden"), 403), + CodeSecurityDeleteConfigurationError::Status404(_) => (String::from("Resource not found"), 404), + CodeSecurityDeleteConfigurationError::Status409(_) => (String::from("Conflict"), 409), + CodeSecurityDeleteConfigurationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Detach configurations from repositories](CodeSecurity::detach_configuration_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeSecurityDetachConfigurationError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Forbidden")] @@ -114,19 +120,27 @@ pub enum CodeSecurityDetachConfigurationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeSecurityDetachConfigurationError) -> Self { + let (description, status_code) = match err { + CodeSecurityDetachConfigurationError::Status400(_) => (String::from("Bad Request"), 400), + CodeSecurityDetachConfigurationError::Status403(_) => (String::from("Forbidden"), 403), + CodeSecurityDetachConfigurationError::Status404(_) => (String::from("Resource not found"), 404), + CodeSecurityDetachConfigurationError::Status409(_) => (String::from("Conflict"), 409), + CodeSecurityDetachConfigurationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a code security configuration](CodeSecurity::get_configuration_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeSecurityGetConfigurationError { - #[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("Forbidden")] @@ -137,19 +151,26 @@ pub enum CodeSecurityGetConfigurationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeSecurityGetConfigurationError) -> Self { + let (description, status_code) = match err { + CodeSecurityGetConfigurationError::Status304 => (String::from("Not modified"), 304), + CodeSecurityGetConfigurationError::Status403(_) => (String::from("Forbidden"), 403), + CodeSecurityGetConfigurationError::Status404(_) => (String::from("Resource not found"), 404), + CodeSecurityGetConfigurationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the code security configuration associated with a repository](CodeSecurity::get_configuration_for_repository_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeSecurityGetConfigurationForRepositoryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("A header with no content is returned.")] Status204, #[error("Not modified")] @@ -162,19 +183,27 @@ pub enum CodeSecurityGetConfigurationForRepositoryError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeSecurityGetConfigurationForRepositoryError) -> Self { + let (description, status_code) = match err { + CodeSecurityGetConfigurationForRepositoryError::Status204 => (String::from("A header with no content is returned."), 204), + CodeSecurityGetConfigurationForRepositoryError::Status304 => (String::from("Not modified"), 304), + CodeSecurityGetConfigurationForRepositoryError::Status403(_) => (String::from("Forbidden"), 403), + CodeSecurityGetConfigurationForRepositoryError::Status404(_) => (String::from("Resource not found"), 404), + CodeSecurityGetConfigurationForRepositoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get code security configurations for an organization](CodeSecurity::get_configurations_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeSecurityGetConfigurationsForOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -183,19 +212,25 @@ pub enum CodeSecurityGetConfigurationsForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeSecurityGetConfigurationsForOrgError) -> Self { + let (description, status_code) = match err { + CodeSecurityGetConfigurationsForOrgError::Status403(_) => (String::from("Forbidden"), 403), + CodeSecurityGetConfigurationsForOrgError::Status404(_) => (String::from("Resource not found"), 404), + CodeSecurityGetConfigurationsForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get default code security configurations](CodeSecurity::get_default_configurations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeSecurityGetDefaultConfigurationsError { - #[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("Forbidden")] @@ -206,19 +241,26 @@ pub enum CodeSecurityGetDefaultConfigurationsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeSecurityGetDefaultConfigurationsError) -> Self { + let (description, status_code) = match err { + CodeSecurityGetDefaultConfigurationsError::Status304 => (String::from("Not modified"), 304), + CodeSecurityGetDefaultConfigurationsError::Status403(_) => (String::from("Forbidden"), 403), + CodeSecurityGetDefaultConfigurationsError::Status404(_) => (String::from("Resource not found"), 404), + CodeSecurityGetDefaultConfigurationsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get repositories associated with a code security configuration](CodeSecurity::get_repositories_for_configuration_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeSecurityGetRepositoriesForConfigurationError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -227,19 +269,25 @@ pub enum CodeSecurityGetRepositoriesForConfigurationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeSecurityGetRepositoriesForConfigurationError) -> Self { + let (description, status_code) = match err { + CodeSecurityGetRepositoriesForConfigurationError::Status403(_) => (String::from("Forbidden"), 403), + CodeSecurityGetRepositoriesForConfigurationError::Status404(_) => (String::from("Resource not found"), 404), + CodeSecurityGetRepositoriesForConfigurationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set a code security configuration as a default for an organization](CodeSecurity::set_configuration_as_default_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeSecuritySetConfigurationAsDefaultError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -248,25 +296,46 @@ pub enum CodeSecuritySetConfigurationAsDefaultError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeSecuritySetConfigurationAsDefaultError) -> Self { + let (description, status_code) = match err { + CodeSecuritySetConfigurationAsDefaultError::Status403(_) => (String::from("Forbidden"), 403), + CodeSecuritySetConfigurationAsDefaultError::Status404(_) => (String::from("Resource not found"), 404), + CodeSecuritySetConfigurationAsDefaultError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a code security configuration](CodeSecurity::update_configuration_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodeSecurityUpdateConfigurationError { - #[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 no new updates are made")] Status204, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodeSecurityUpdateConfigurationError) -> Self { + let (description, status_code) = match err { + CodeSecurityUpdateConfigurationError::Status204 => (String::from("Response when no new updates are made"), 204), + CodeSecurityUpdateConfigurationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [Get code security configurations for an organization](CodeSecurity::get_configurations_for_org_async()) endpoint. #[derive(Default, Serialize)] @@ -387,7 +456,7 @@ impl<'req> CodeSecurityGetRepositoriesForConfigurationParams<'req> { } -impl<'api, C: Client> CodeSecurity<'api, C> { +impl<'api, C: Client> CodeSecurity<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Attach a configuration to repositories @@ -403,19 +472,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// [GitHub API docs for attach_configuration](https://docs.github.com/rest/code-security/configurations#attach-a-configuration-to-repositories) /// /// --- - pub async fn attach_configuration_async(&self, org: &str, configuration_id: i32, body: PostCodeSecurityAttachConfiguration) -> Result, CodeSecurityAttachConfigurationError> { + pub async fn attach_configuration_async(&self, org: &str, configuration_id: i32, body: PostCodeSecurityAttachConfiguration) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/code-security/configurations/{}/attach", super::GITHUB_BASE_API_URL, org, configuration_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodeSecurityAttachConfiguration::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -427,7 +496,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodeSecurityAttachConfigurationError::Generic { code }), + code => Err(CodeSecurityAttachConfigurationError::Generic { code }.into()), } } } @@ -448,19 +517,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn attach_configuration(&self, org: &str, configuration_id: i32, body: PostCodeSecurityAttachConfiguration) -> Result, CodeSecurityAttachConfigurationError> { + pub fn attach_configuration(&self, org: &str, configuration_id: i32, body: PostCodeSecurityAttachConfiguration) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/code-security/configurations/{}/attach", super::GITHUB_BASE_API_URL, org, configuration_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodeSecurityAttachConfiguration::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -472,7 +541,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodeSecurityAttachConfigurationError::Generic { code }), + code => Err(CodeSecurityAttachConfigurationError::Generic { code }.into()), } } } @@ -490,19 +559,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// [GitHub API docs for create_configuration](https://docs.github.com/rest/code-security/configurations#create-a-code-security-configuration) /// /// --- - pub async fn create_configuration_async(&self, org: &str, body: PostCodeSecurityCreateConfiguration) -> Result { + pub async fn create_configuration_async(&self, org: &str, body: PostCodeSecurityCreateConfiguration) -> Result { let request_uri = format!("{}/orgs/{}/code-security/configurations", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodeSecurityCreateConfiguration::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -514,7 +583,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodeSecurityCreateConfigurationError::Generic { code }), + code => Err(CodeSecurityCreateConfigurationError::Generic { code }.into()), } } } @@ -533,19 +602,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_configuration(&self, org: &str, body: PostCodeSecurityCreateConfiguration) -> Result { + pub fn create_configuration(&self, org: &str, body: PostCodeSecurityCreateConfiguration) -> Result { let request_uri = format!("{}/orgs/{}/code-security/configurations", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodeSecurityCreateConfiguration::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -557,7 +626,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodeSecurityCreateConfigurationError::Generic { code }), + code => Err(CodeSecurityCreateConfigurationError::Generic { code }.into()), } } } @@ -577,19 +646,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// [GitHub API docs for delete_configuration](https://docs.github.com/rest/code-security/configurations#delete-a-code-security-configuration) /// /// --- - pub async fn delete_configuration_async(&self, org: &str, configuration_id: i32) -> Result<(), CodeSecurityDeleteConfigurationError> { + pub async fn delete_configuration_async(&self, org: &str, configuration_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/code-security/configurations/{}", super::GITHUB_BASE_API_URL, org, configuration_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -601,11 +670,11 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(CodeSecurityDeleteConfigurationError::Status400(github_response.to_json_async().await?)), - 403 => Err(CodeSecurityDeleteConfigurationError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeSecurityDeleteConfigurationError::Status404(github_response.to_json_async().await?)), - 409 => Err(CodeSecurityDeleteConfigurationError::Status409(github_response.to_json_async().await?)), - code => Err(CodeSecurityDeleteConfigurationError::Generic { code }), + 400 => Err(CodeSecurityDeleteConfigurationError::Status400(github_response.to_json_async().await?).into()), + 403 => Err(CodeSecurityDeleteConfigurationError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeSecurityDeleteConfigurationError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(CodeSecurityDeleteConfigurationError::Status409(github_response.to_json_async().await?).into()), + code => Err(CodeSecurityDeleteConfigurationError::Generic { code }.into()), } } } @@ -626,7 +695,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_configuration(&self, org: &str, configuration_id: i32) -> Result<(), CodeSecurityDeleteConfigurationError> { + pub fn delete_configuration(&self, org: &str, configuration_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/code-security/configurations/{}", super::GITHUB_BASE_API_URL, org, configuration_id); @@ -638,7 +707,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -650,11 +719,11 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(CodeSecurityDeleteConfigurationError::Status400(github_response.to_json()?)), - 403 => Err(CodeSecurityDeleteConfigurationError::Status403(github_response.to_json()?)), - 404 => Err(CodeSecurityDeleteConfigurationError::Status404(github_response.to_json()?)), - 409 => Err(CodeSecurityDeleteConfigurationError::Status409(github_response.to_json()?)), - code => Err(CodeSecurityDeleteConfigurationError::Generic { code }), + 400 => Err(CodeSecurityDeleteConfigurationError::Status400(github_response.to_json()?).into()), + 403 => Err(CodeSecurityDeleteConfigurationError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeSecurityDeleteConfigurationError::Status404(github_response.to_json()?).into()), + 409 => Err(CodeSecurityDeleteConfigurationError::Status409(github_response.to_json()?).into()), + code => Err(CodeSecurityDeleteConfigurationError::Generic { code }.into()), } } } @@ -673,19 +742,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// [GitHub API docs for detach_configuration](https://docs.github.com/rest/code-security/configurations#detach-configurations-from-repositories) /// /// --- - pub async fn detach_configuration_async(&self, org: &str, body: DeleteCodeSecurityDetachConfiguration) -> Result<(), CodeSecurityDetachConfigurationError> { + pub async fn detach_configuration_async(&self, org: &str, body: DeleteCodeSecurityDetachConfiguration) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/code-security/configurations/detach", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteCodeSecurityDetachConfiguration::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -697,11 +766,11 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(CodeSecurityDetachConfigurationError::Status400(github_response.to_json_async().await?)), - 403 => Err(CodeSecurityDetachConfigurationError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeSecurityDetachConfigurationError::Status404(github_response.to_json_async().await?)), - 409 => Err(CodeSecurityDetachConfigurationError::Status409(github_response.to_json_async().await?)), - code => Err(CodeSecurityDetachConfigurationError::Generic { code }), + 400 => Err(CodeSecurityDetachConfigurationError::Status400(github_response.to_json_async().await?).into()), + 403 => Err(CodeSecurityDetachConfigurationError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeSecurityDetachConfigurationError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(CodeSecurityDetachConfigurationError::Status409(github_response.to_json_async().await?).into()), + code => Err(CodeSecurityDetachConfigurationError::Generic { code }.into()), } } } @@ -721,19 +790,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn detach_configuration(&self, org: &str, body: DeleteCodeSecurityDetachConfiguration) -> Result<(), CodeSecurityDetachConfigurationError> { + pub fn detach_configuration(&self, org: &str, body: DeleteCodeSecurityDetachConfiguration) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/code-security/configurations/detach", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteCodeSecurityDetachConfiguration::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -745,11 +814,11 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(CodeSecurityDetachConfigurationError::Status400(github_response.to_json()?)), - 403 => Err(CodeSecurityDetachConfigurationError::Status403(github_response.to_json()?)), - 404 => Err(CodeSecurityDetachConfigurationError::Status404(github_response.to_json()?)), - 409 => Err(CodeSecurityDetachConfigurationError::Status409(github_response.to_json()?)), - code => Err(CodeSecurityDetachConfigurationError::Generic { code }), + 400 => Err(CodeSecurityDetachConfigurationError::Status400(github_response.to_json()?).into()), + 403 => Err(CodeSecurityDetachConfigurationError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeSecurityDetachConfigurationError::Status404(github_response.to_json()?).into()), + 409 => Err(CodeSecurityDetachConfigurationError::Status409(github_response.to_json()?).into()), + code => Err(CodeSecurityDetachConfigurationError::Generic { code }.into()), } } } @@ -767,19 +836,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// [GitHub API docs for get_configuration](https://docs.github.com/rest/code-security/configurations#get-a-code-security-configuration) /// /// --- - pub async fn get_configuration_async(&self, org: &str, configuration_id: i32) -> Result { + pub async fn get_configuration_async(&self, org: &str, configuration_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/code-security/configurations/{}", super::GITHUB_BASE_API_URL, org, configuration_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -791,10 +860,10 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodeSecurityGetConfigurationError::Status304), - 403 => Err(CodeSecurityGetConfigurationError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeSecurityGetConfigurationError::Status404(github_response.to_json_async().await?)), - code => Err(CodeSecurityGetConfigurationError::Generic { code }), + 304 => Err(CodeSecurityGetConfigurationError::Status304.into()), + 403 => Err(CodeSecurityGetConfigurationError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeSecurityGetConfigurationError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodeSecurityGetConfigurationError::Generic { code }.into()), } } } @@ -813,7 +882,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_configuration(&self, org: &str, configuration_id: i32) -> Result { + pub fn get_configuration(&self, org: &str, configuration_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/code-security/configurations/{}", super::GITHUB_BASE_API_URL, org, configuration_id); @@ -825,7 +894,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -837,10 +906,10 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodeSecurityGetConfigurationError::Status304), - 403 => Err(CodeSecurityGetConfigurationError::Status403(github_response.to_json()?)), - 404 => Err(CodeSecurityGetConfigurationError::Status404(github_response.to_json()?)), - code => Err(CodeSecurityGetConfigurationError::Generic { code }), + 304 => Err(CodeSecurityGetConfigurationError::Status304.into()), + 403 => Err(CodeSecurityGetConfigurationError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeSecurityGetConfigurationError::Status404(github_response.to_json()?).into()), + code => Err(CodeSecurityGetConfigurationError::Generic { code }.into()), } } } @@ -858,19 +927,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// [GitHub API docs for get_configuration_for_repository](https://docs.github.com/rest/code-security/configurations#get-the-code-security-configuration-associated-with-a-repository) /// /// --- - pub async fn get_configuration_for_repository_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_configuration_for_repository_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/code-security-configuration", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -882,11 +951,11 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(CodeSecurityGetConfigurationForRepositoryError::Status204), - 304 => Err(CodeSecurityGetConfigurationForRepositoryError::Status304), - 403 => Err(CodeSecurityGetConfigurationForRepositoryError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeSecurityGetConfigurationForRepositoryError::Status404(github_response.to_json_async().await?)), - code => Err(CodeSecurityGetConfigurationForRepositoryError::Generic { code }), + 204 => Err(CodeSecurityGetConfigurationForRepositoryError::Status204.into()), + 304 => Err(CodeSecurityGetConfigurationForRepositoryError::Status304.into()), + 403 => Err(CodeSecurityGetConfigurationForRepositoryError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeSecurityGetConfigurationForRepositoryError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodeSecurityGetConfigurationForRepositoryError::Generic { code }.into()), } } } @@ -905,7 +974,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_configuration_for_repository(&self, owner: &str, repo: &str) -> Result { + pub fn get_configuration_for_repository(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/code-security-configuration", super::GITHUB_BASE_API_URL, owner, repo); @@ -917,7 +986,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -929,11 +998,11 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(CodeSecurityGetConfigurationForRepositoryError::Status204), - 304 => Err(CodeSecurityGetConfigurationForRepositoryError::Status304), - 403 => Err(CodeSecurityGetConfigurationForRepositoryError::Status403(github_response.to_json()?)), - 404 => Err(CodeSecurityGetConfigurationForRepositoryError::Status404(github_response.to_json()?)), - code => Err(CodeSecurityGetConfigurationForRepositoryError::Generic { code }), + 204 => Err(CodeSecurityGetConfigurationForRepositoryError::Status204.into()), + 304 => Err(CodeSecurityGetConfigurationForRepositoryError::Status304.into()), + 403 => Err(CodeSecurityGetConfigurationForRepositoryError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeSecurityGetConfigurationForRepositoryError::Status404(github_response.to_json()?).into()), + code => Err(CodeSecurityGetConfigurationForRepositoryError::Generic { code }.into()), } } } @@ -951,7 +1020,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// [GitHub API docs for get_configurations_for_org](https://docs.github.com/rest/code-security/configurations#get-code-security-configurations-for-an-organization) /// /// --- - pub async fn get_configurations_for_org_async(&self, org: &str, query_params: Option>>) -> Result, CodeSecurityGetConfigurationsForOrgError> { + pub async fn get_configurations_for_org_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/code-security/configurations", super::GITHUB_BASE_API_URL, org); @@ -962,12 +1031,12 @@ impl<'api, C: Client> CodeSecurity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -979,9 +1048,9 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(CodeSecurityGetConfigurationsForOrgError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeSecurityGetConfigurationsForOrgError::Status404(github_response.to_json_async().await?)), - code => Err(CodeSecurityGetConfigurationsForOrgError::Generic { code }), + 403 => Err(CodeSecurityGetConfigurationsForOrgError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeSecurityGetConfigurationsForOrgError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodeSecurityGetConfigurationsForOrgError::Generic { code }.into()), } } } @@ -1000,7 +1069,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_configurations_for_org(&self, org: &str, query_params: Option>>) -> Result, CodeSecurityGetConfigurationsForOrgError> { + pub fn get_configurations_for_org(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/code-security/configurations", super::GITHUB_BASE_API_URL, org); @@ -1017,7 +1086,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1029,9 +1098,9 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(CodeSecurityGetConfigurationsForOrgError::Status403(github_response.to_json()?)), - 404 => Err(CodeSecurityGetConfigurationsForOrgError::Status404(github_response.to_json()?)), - code => Err(CodeSecurityGetConfigurationsForOrgError::Generic { code }), + 403 => Err(CodeSecurityGetConfigurationsForOrgError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeSecurityGetConfigurationsForOrgError::Status404(github_response.to_json()?).into()), + code => Err(CodeSecurityGetConfigurationsForOrgError::Generic { code }.into()), } } } @@ -1049,19 +1118,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// [GitHub API docs for get_default_configurations](https://docs.github.com/rest/code-security/configurations#get-default-code-security-configurations) /// /// --- - pub async fn get_default_configurations_async(&self, org: &str) -> Result { + pub async fn get_default_configurations_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/code-security/configurations/defaults", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1073,10 +1142,10 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodeSecurityGetDefaultConfigurationsError::Status304), - 403 => Err(CodeSecurityGetDefaultConfigurationsError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeSecurityGetDefaultConfigurationsError::Status404(github_response.to_json_async().await?)), - code => Err(CodeSecurityGetDefaultConfigurationsError::Generic { code }), + 304 => Err(CodeSecurityGetDefaultConfigurationsError::Status304.into()), + 403 => Err(CodeSecurityGetDefaultConfigurationsError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeSecurityGetDefaultConfigurationsError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodeSecurityGetDefaultConfigurationsError::Generic { code }.into()), } } } @@ -1095,7 +1164,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_default_configurations(&self, org: &str) -> Result { + pub fn get_default_configurations(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/code-security/configurations/defaults", super::GITHUB_BASE_API_URL, org); @@ -1107,7 +1176,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1119,10 +1188,10 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodeSecurityGetDefaultConfigurationsError::Status304), - 403 => Err(CodeSecurityGetDefaultConfigurationsError::Status403(github_response.to_json()?)), - 404 => Err(CodeSecurityGetDefaultConfigurationsError::Status404(github_response.to_json()?)), - code => Err(CodeSecurityGetDefaultConfigurationsError::Generic { code }), + 304 => Err(CodeSecurityGetDefaultConfigurationsError::Status304.into()), + 403 => Err(CodeSecurityGetDefaultConfigurationsError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeSecurityGetDefaultConfigurationsError::Status404(github_response.to_json()?).into()), + code => Err(CodeSecurityGetDefaultConfigurationsError::Generic { code }.into()), } } } @@ -1140,7 +1209,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// [GitHub API docs for get_repositories_for_configuration](https://docs.github.com/rest/code-security/configurations#get-repositories-associated-with-a-code-security-configuration) /// /// --- - pub async fn get_repositories_for_configuration_async(&self, org: &str, configuration_id: i32, query_params: Option>>) -> Result, CodeSecurityGetRepositoriesForConfigurationError> { + pub async fn get_repositories_for_configuration_async(&self, org: &str, configuration_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/code-security/configurations/{}/repositories", super::GITHUB_BASE_API_URL, org, configuration_id); @@ -1151,12 +1220,12 @@ impl<'api, C: Client> CodeSecurity<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1168,9 +1237,9 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(CodeSecurityGetRepositoriesForConfigurationError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeSecurityGetRepositoriesForConfigurationError::Status404(github_response.to_json_async().await?)), - code => Err(CodeSecurityGetRepositoriesForConfigurationError::Generic { code }), + 403 => Err(CodeSecurityGetRepositoriesForConfigurationError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeSecurityGetRepositoriesForConfigurationError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodeSecurityGetRepositoriesForConfigurationError::Generic { code }.into()), } } } @@ -1189,7 +1258,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repositories_for_configuration(&self, org: &str, configuration_id: i32, query_params: Option>>) -> Result, CodeSecurityGetRepositoriesForConfigurationError> { + pub fn get_repositories_for_configuration(&self, org: &str, configuration_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/code-security/configurations/{}/repositories", super::GITHUB_BASE_API_URL, org, configuration_id); @@ -1206,7 +1275,7 @@ impl<'api, C: Client> CodeSecurity<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1218,9 +1287,9 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(CodeSecurityGetRepositoriesForConfigurationError::Status403(github_response.to_json()?)), - 404 => Err(CodeSecurityGetRepositoriesForConfigurationError::Status404(github_response.to_json()?)), - code => Err(CodeSecurityGetRepositoriesForConfigurationError::Generic { code }), + 403 => Err(CodeSecurityGetRepositoriesForConfigurationError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeSecurityGetRepositoriesForConfigurationError::Status404(github_response.to_json()?).into()), + code => Err(CodeSecurityGetRepositoriesForConfigurationError::Generic { code }.into()), } } } @@ -1240,19 +1309,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// [GitHub API docs for set_configuration_as_default](https://docs.github.com/rest/code-security/configurations#set-a-code-security-configuration-as-a-default-for-an-organization) /// /// --- - pub async fn set_configuration_as_default_async(&self, org: &str, configuration_id: i32, body: PutCodeSecuritySetConfigurationAsDefault) -> Result { + pub async fn set_configuration_as_default_async(&self, org: &str, configuration_id: i32, body: PutCodeSecuritySetConfigurationAsDefault) -> Result { let request_uri = format!("{}/orgs/{}/code-security/configurations/{}/defaults", super::GITHUB_BASE_API_URL, org, configuration_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutCodeSecuritySetConfigurationAsDefault::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1264,9 +1333,9 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(CodeSecuritySetConfigurationAsDefaultError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodeSecuritySetConfigurationAsDefaultError::Status404(github_response.to_json_async().await?)), - code => Err(CodeSecuritySetConfigurationAsDefaultError::Generic { code }), + 403 => Err(CodeSecuritySetConfigurationAsDefaultError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodeSecuritySetConfigurationAsDefaultError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodeSecuritySetConfigurationAsDefaultError::Generic { code }.into()), } } } @@ -1287,19 +1356,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_configuration_as_default(&self, org: &str, configuration_id: i32, body: PutCodeSecuritySetConfigurationAsDefault) -> Result { + pub fn set_configuration_as_default(&self, org: &str, configuration_id: i32, body: PutCodeSecuritySetConfigurationAsDefault) -> Result { let request_uri = format!("{}/orgs/{}/code-security/configurations/{}/defaults", super::GITHUB_BASE_API_URL, org, configuration_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutCodeSecuritySetConfigurationAsDefault::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1311,9 +1380,9 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(CodeSecuritySetConfigurationAsDefaultError::Status403(github_response.to_json()?)), - 404 => Err(CodeSecuritySetConfigurationAsDefaultError::Status404(github_response.to_json()?)), - code => Err(CodeSecuritySetConfigurationAsDefaultError::Generic { code }), + 403 => Err(CodeSecuritySetConfigurationAsDefaultError::Status403(github_response.to_json()?).into()), + 404 => Err(CodeSecuritySetConfigurationAsDefaultError::Status404(github_response.to_json()?).into()), + code => Err(CodeSecuritySetConfigurationAsDefaultError::Generic { code }.into()), } } } @@ -1331,19 +1400,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// [GitHub API docs for update_configuration](https://docs.github.com/rest/code-security/configurations#update-a-code-security-configuration) /// /// --- - pub async fn update_configuration_async(&self, org: &str, configuration_id: i32, body: PatchCodeSecurityUpdateConfiguration) -> Result { + pub async fn update_configuration_async(&self, org: &str, configuration_id: i32, body: PatchCodeSecurityUpdateConfiguration) -> Result { let request_uri = format!("{}/orgs/{}/code-security/configurations/{}", super::GITHUB_BASE_API_URL, org, configuration_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchCodeSecurityUpdateConfiguration::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1355,8 +1424,8 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(CodeSecurityUpdateConfigurationError::Status204), - code => Err(CodeSecurityUpdateConfigurationError::Generic { code }), + 204 => Err(CodeSecurityUpdateConfigurationError::Status204.into()), + code => Err(CodeSecurityUpdateConfigurationError::Generic { code }.into()), } } } @@ -1375,19 +1444,19 @@ impl<'api, C: Client> CodeSecurity<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_configuration(&self, org: &str, configuration_id: i32, body: PatchCodeSecurityUpdateConfiguration) -> Result { + pub fn update_configuration(&self, org: &str, configuration_id: i32, body: PatchCodeSecurityUpdateConfiguration) -> Result { let request_uri = format!("{}/orgs/{}/code-security/configurations/{}", super::GITHUB_BASE_API_URL, org, configuration_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchCodeSecurityUpdateConfiguration::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1399,8 +1468,8 @@ impl<'api, C: Client> CodeSecurity<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(CodeSecurityUpdateConfigurationError::Status204), - code => Err(CodeSecurityUpdateConfigurationError::Generic { code }), + 204 => Err(CodeSecurityUpdateConfigurationError::Status204.into()), + code => Err(CodeSecurityUpdateConfigurationError::Generic { code }.into()), } } } diff --git a/src/endpoints/codes_of_conduct.rs b/src/endpoints/codes_of_conduct.rs index a179f40..f1f1c4c 100644 --- a/src/endpoints/codes_of_conduct.rs +++ b/src/endpoints/codes_of_conduct.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,46 +22,41 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct CodesOfConduct<'api, C: Client> { +pub struct CodesOfConduct<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> CodesOfConduct { +pub fn new(client: &C) -> CodesOfConduct where AdapterError: From<::Err> { CodesOfConduct { client } } /// Errors for the [Get all codes of conduct](CodesOfConduct::get_all_codes_of_conduct_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodesOfConductGetAllCodesOfConductError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodesOfConductGetAllCodesOfConductError) -> Self { + let (description, status_code) = match err { + CodesOfConductGetAllCodesOfConductError::Status304 => (String::from("Not modified"), 304), + CodesOfConductGetAllCodesOfConductError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a code of conduct](CodesOfConduct::get_conduct_code_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodesOfConductGetConductCodeError { - #[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("Not modified")] @@ -70,9 +65,25 @@ pub enum CodesOfConductGetConductCodeError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodesOfConductGetConductCodeError) -> Self { + let (description, status_code) = match err { + CodesOfConductGetConductCodeError::Status404(_) => (String::from("Resource not found"), 404), + CodesOfConductGetConductCodeError::Status304 => (String::from("Not modified"), 304), + CodesOfConductGetConductCodeError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + -impl<'api, C: Client> CodesOfConduct<'api, C> { +impl<'api, C: Client> CodesOfConduct<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Get all codes of conduct @@ -82,19 +93,19 @@ impl<'api, C: Client> CodesOfConduct<'api, C> { /// [GitHub API docs for get_all_codes_of_conduct](https://docs.github.com/rest/codes-of-conduct/codes-of-conduct#get-all-codes-of-conduct) /// /// --- - pub async fn get_all_codes_of_conduct_async(&self) -> Result, CodesOfConductGetAllCodesOfConductError> { + pub async fn get_all_codes_of_conduct_async(&self) -> Result, AdapterError> { let request_uri = format!("{}/codes_of_conduct", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -106,8 +117,8 @@ impl<'api, C: Client> CodesOfConduct<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodesOfConductGetAllCodesOfConductError::Status304), - code => Err(CodesOfConductGetAllCodesOfConductError::Generic { code }), + 304 => Err(CodesOfConductGetAllCodesOfConductError::Status304.into()), + code => Err(CodesOfConductGetAllCodesOfConductError::Generic { code }.into()), } } } @@ -122,7 +133,7 @@ impl<'api, C: Client> CodesOfConduct<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_codes_of_conduct(&self) -> Result, CodesOfConductGetAllCodesOfConductError> { + pub fn get_all_codes_of_conduct(&self) -> Result, AdapterError> { let request_uri = format!("{}/codes_of_conduct", super::GITHUB_BASE_API_URL); @@ -134,7 +145,7 @@ impl<'api, C: Client> CodesOfConduct<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -146,8 +157,8 @@ impl<'api, C: Client> CodesOfConduct<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodesOfConductGetAllCodesOfConductError::Status304), - code => Err(CodesOfConductGetAllCodesOfConductError::Generic { code }), + 304 => Err(CodesOfConductGetAllCodesOfConductError::Status304.into()), + code => Err(CodesOfConductGetAllCodesOfConductError::Generic { code }.into()), } } } @@ -161,19 +172,19 @@ impl<'api, C: Client> CodesOfConduct<'api, C> { /// [GitHub API docs for get_conduct_code](https://docs.github.com/rest/codes-of-conduct/codes-of-conduct#get-a-code-of-conduct) /// /// --- - pub async fn get_conduct_code_async(&self, key: &str) -> Result { + pub async fn get_conduct_code_async(&self, key: &str) -> Result { let request_uri = format!("{}/codes_of_conduct/{}", super::GITHUB_BASE_API_URL, key); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -185,9 +196,9 @@ impl<'api, C: Client> CodesOfConduct<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(CodesOfConductGetConductCodeError::Status404(github_response.to_json_async().await?)), - 304 => Err(CodesOfConductGetConductCodeError::Status304), - code => Err(CodesOfConductGetConductCodeError::Generic { code }), + 404 => Err(CodesOfConductGetConductCodeError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(CodesOfConductGetConductCodeError::Status304.into()), + code => Err(CodesOfConductGetConductCodeError::Generic { code }.into()), } } } @@ -202,7 +213,7 @@ impl<'api, C: Client> CodesOfConduct<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_conduct_code(&self, key: &str) -> Result { + pub fn get_conduct_code(&self, key: &str) -> Result { let request_uri = format!("{}/codes_of_conduct/{}", super::GITHUB_BASE_API_URL, key); @@ -214,7 +225,7 @@ impl<'api, C: Client> CodesOfConduct<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -226,9 +237,9 @@ impl<'api, C: Client> CodesOfConduct<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(CodesOfConductGetConductCodeError::Status404(github_response.to_json()?)), - 304 => Err(CodesOfConductGetConductCodeError::Status304), - code => Err(CodesOfConductGetConductCodeError::Generic { code }), + 404 => Err(CodesOfConductGetConductCodeError::Status404(github_response.to_json()?).into()), + 304 => Err(CodesOfConductGetConductCodeError::Status304.into()), + code => Err(CodesOfConductGetConductCodeError::Generic { code }.into()), } } } diff --git a/src/endpoints/codespaces.rs b/src/endpoints/codespaces.rs index 9153dfd..afb097c 100644 --- a/src/endpoints/codespaces.rs +++ b/src/endpoints/codespaces.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Codespaces<'api, C: Client> { +pub struct Codespaces<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Codespaces { +pub fn new(client: &C) -> Codespaces where AdapterError: From<::Err> { Codespaces { client } } /// 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")] @@ -55,19 +45,27 @@ pub enum CodespacesAddRepositoryForSecretForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesAddRepositoryForSecretForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesAddRepositoryForSecretForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add selected repository to an organization secret](Codespaces::add_selected_repo_to_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesAddSelectedRepoToOrgSecretError { - #[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("Conflict when visibility type is not set to selected")] @@ -78,19 +76,26 @@ pub enum CodespacesAddSelectedRepoToOrgSecretError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesAddSelectedRepoToOrgSecretError) -> Self { + let (description, status_code) = match err { + CodespacesAddSelectedRepoToOrgSecretError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesAddSelectedRepoToOrgSecretError::Status409 => (String::from("Conflict when visibility type is not set to selected"), 409), + CodespacesAddSelectedRepoToOrgSecretError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + CodespacesAddSelectedRepoToOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check if permissions defined by a devcontainer have been accepted by the authenticated user](Codespaces::check_permissions_for_devcontainer_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesCheckPermissionsForDevcontainerError { - #[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")] @@ -105,19 +110,28 @@ pub enum CodespacesCheckPermissionsForDevcontainerError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesCheckPermissionsForDevcontainerError) -> Self { + let (description, status_code) = match err { + CodespacesCheckPermissionsForDevcontainerError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesCheckPermissionsForDevcontainerError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesCheckPermissionsForDevcontainerError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesCheckPermissionsForDevcontainerError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + CodespacesCheckPermissionsForDevcontainerError::Status503(_) => (String::from("Service unavailable"), 503), + CodespacesCheckPermissionsForDevcontainerError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -132,19 +146,28 @@ pub enum CodespacesCodespaceMachinesForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesCodespaceMachinesForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesCodespaceMachinesForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + CodespacesCodespaceMachinesForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesCodespaceMachinesForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesCodespaceMachinesForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesCodespaceMachinesForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesCodespaceMachinesForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -159,19 +182,28 @@ pub enum CodespacesCreateForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesCreateForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesCreateForAuthenticatedUserError::Status202(_) => (String::from("Response when the codespace creation partially failed but is being retried in the background"), 202), + CodespacesCreateForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesCreateForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesCreateForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesCreateForAuthenticatedUserError::Status503(_) => (String::from("Service unavailable"), 503), + CodespacesCreateForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update an organization secret](Codespaces::create_or_update_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesCreateOrUpdateOrgSecretError { - #[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 updating a secret")] Status204, #[error("Resource not found")] @@ -182,38 +214,50 @@ pub enum CodespacesCreateOrUpdateOrgSecretError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesCreateOrUpdateOrgSecretError) -> Self { + let (description, status_code) = match err { + CodespacesCreateOrUpdateOrgSecretError::Status204 => (String::from("Response when updating a secret"), 204), + CodespacesCreateOrUpdateOrgSecretError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesCreateOrUpdateOrgSecretError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + CodespacesCreateOrUpdateOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update a repository secret](Codespaces::create_or_update_repo_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesCreateOrUpdateRepoSecretError { - #[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 updating a secret")] Status204, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesCreateOrUpdateRepoSecretError) -> Self { + let (description, status_code) = match err { + CodespacesCreateOrUpdateRepoSecretError::Status204 => (String::from("Response when updating a secret"), 204), + CodespacesCreateOrUpdateRepoSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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, or the endpoint has been spammed.")] @@ -224,19 +268,26 @@ pub enum CodespacesCreateOrUpdateSecretForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesCreateOrUpdateSecretForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status204 => (String::from("Response after successfully updating a secret"), 204), + CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -251,19 +302,28 @@ pub enum CodespacesCreateWithPrForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesCreateWithPrForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesCreateWithPrForAuthenticatedUserError::Status202(_) => (String::from("Response when the codespace creation partially failed but is being retried in the background"), 202), + CodespacesCreateWithPrForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesCreateWithPrForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesCreateWithPrForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesCreateWithPrForAuthenticatedUserError::Status503(_) => (String::from("Service unavailable"), 503), + CodespacesCreateWithPrForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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("Bad Request")] @@ -280,19 +340,29 @@ pub enum CodespacesCreateWithRepoForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesCreateWithRepoForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesCreateWithRepoForAuthenticatedUserError::Status202(_) => (String::from("Response when the codespace creation partially failed but is being retried in the background"), 202), + CodespacesCreateWithRepoForAuthenticatedUserError::Status400(_) => (String::from("Bad Request"), 400), + CodespacesCreateWithRepoForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesCreateWithRepoForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesCreateWithRepoForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesCreateWithRepoForAuthenticatedUserError::Status503(_) => (String::from("Service unavailable"), 503), + CodespacesCreateWithRepoForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove users from Codespaces access for an organization](Codespaces::delete_codespaces_access_users_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesDeleteCodespacesAccessUsersError { - #[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("Users are neither members nor collaborators of this organization.")] @@ -307,19 +377,28 @@ pub enum CodespacesDeleteCodespacesAccessUsersError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesDeleteCodespacesAccessUsersError) -> Self { + let (description, status_code) = match err { + CodespacesDeleteCodespacesAccessUsersError::Status304 => (String::from("Not modified"), 304), + CodespacesDeleteCodespacesAccessUsersError::Status400 => (String::from("Users are neither members nor collaborators of this organization."), 400), + CodespacesDeleteCodespacesAccessUsersError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesDeleteCodespacesAccessUsersError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + CodespacesDeleteCodespacesAccessUsersError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesDeleteCodespacesAccessUsersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -334,19 +413,28 @@ pub enum CodespacesDeleteForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesDeleteForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesDeleteForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + CodespacesDeleteForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesDeleteForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesDeleteForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesDeleteForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesDeleteForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a codespace from the organization](Codespaces::delete_from_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesDeleteFromOrganizationError { - #[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")] @@ -361,72 +449,94 @@ pub enum CodespacesDeleteFromOrganizationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesDeleteFromOrganizationError) -> Self { + let (description, status_code) = match err { + CodespacesDeleteFromOrganizationError::Status304 => (String::from("Not modified"), 304), + CodespacesDeleteFromOrganizationError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesDeleteFromOrganizationError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesDeleteFromOrganizationError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesDeleteFromOrganizationError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesDeleteFromOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an organization secret](Codespaces::delete_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesDeleteOrgSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodespacesDeleteOrgSecretError) -> Self { + let (description, status_code) = match err { + CodespacesDeleteOrgSecretError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesDeleteOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a repository secret](Codespaces::delete_repo_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesDeleteRepoSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodespacesDeleteRepoSecretError) -> Self { + let (description, status_code) = match err { + CodespacesDeleteRepoSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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 }, } +impl From for AdapterError { + fn from(err: CodespacesDeleteSecretForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesDeleteSecretForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Export a codespace for the authenticated user](Codespaces::export_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesExportForAuthenticatedUserError { - #[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")] @@ -441,19 +551,28 @@ pub enum CodespacesExportForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesExportForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesExportForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesExportForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesExportForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesExportForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesExportForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + CodespacesExportForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List codespaces for a user in organization](Codespaces::get_codespaces_for_user_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesGetCodespacesForUserInOrgError { - #[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")] @@ -468,38 +587,52 @@ pub enum CodespacesGetCodespacesForUserInOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesGetCodespacesForUserInOrgError) -> Self { + let (description, status_code) = match err { + CodespacesGetCodespacesForUserInOrgError::Status304 => (String::from("Not modified"), 304), + CodespacesGetCodespacesForUserInOrgError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesGetCodespacesForUserInOrgError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesGetCodespacesForUserInOrgError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesGetCodespacesForUserInOrgError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesGetCodespacesForUserInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get details about a codespace export](Codespaces::get_export_details_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesGetExportDetailsForAuthenticatedUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodespacesGetExportDetailsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesGetExportDetailsForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesGetExportDetailsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -514,121 +647,154 @@ pub enum CodespacesGetForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesGetForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesGetForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + CodespacesGetForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesGetForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesGetForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesGetForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesGetForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization public key](Codespaces::get_org_public_key_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesGetOrgPublicKeyError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodespacesGetOrgPublicKeyError) -> Self { + let (description, status_code) = match err { + CodespacesGetOrgPublicKeyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization secret](Codespaces::get_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesGetOrgSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodespacesGetOrgSecretError) -> Self { + let (description, status_code) = match err { + CodespacesGetOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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 }, } +impl From for AdapterError { + fn from(err: CodespacesGetPublicKeyForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesGetPublicKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository public key](Codespaces::get_repo_public_key_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesGetRepoPublicKeyError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodespacesGetRepoPublicKeyError) -> Self { + let (description, status_code) = match err { + CodespacesGetRepoPublicKeyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository secret](Codespaces::get_repo_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesGetRepoSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodespacesGetRepoSecretError) -> Self { + let (description, status_code) = match err { + CodespacesGetRepoSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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 }, } +impl From for AdapterError { + fn from(err: CodespacesGetSecretForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesGetSecretForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List devcontainer configurations in a repository for the authenticated user](Codespaces::list_devcontainers_in_repository_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesListDevcontainersInRepositoryForAuthenticatedUserError { - #[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("Bad Request")] @@ -643,19 +809,28 @@ pub enum CodespacesListDevcontainersInRepositoryForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesListDevcontainersInRepositoryForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status400(_) => (String::from("Bad Request"), 400), + CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -670,19 +845,28 @@ pub enum CodespacesListForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesListForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesListForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + CodespacesListForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesListForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesListForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesListForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesListForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List codespaces for the organization](Codespaces::list_in_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesListInOrganizationError { - #[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")] @@ -697,19 +881,28 @@ pub enum CodespacesListInOrganizationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesListInOrganizationError) -> Self { + let (description, status_code) = match err { + CodespacesListInOrganizationError::Status304 => (String::from("Not modified"), 304), + CodespacesListInOrganizationError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesListInOrganizationError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesListInOrganizationError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesListInOrganizationError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesListInOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -722,53 +915,69 @@ pub enum CodespacesListInRepositoryForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesListInRepositoryForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesListInRepositoryForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesListInRepositoryForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesListInRepositoryForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesListInRepositoryForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesListInRepositoryForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization secrets](Codespaces::list_org_secrets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesListOrgSecretsError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodespacesListOrgSecretsError) -> Self { + let (description, status_code) = match err { + CodespacesListOrgSecretsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository secrets](Codespaces::list_repo_secrets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesListRepoSecretsError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodespacesListRepoSecretsError) -> Self { + let (description, status_code) = match err { + CodespacesListRepoSecretsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -781,55 +990,72 @@ pub enum CodespacesListRepositoriesForSecretForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesListRepositoriesForSecretForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesListRepositoriesForSecretForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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 }, } +impl From for AdapterError { + fn from(err: CodespacesListSecretsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesListSecretsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List selected repositories for an organization secret](Codespaces::list_selected_repos_for_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesListSelectedReposForOrgSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: CodespacesListSelectedReposForOrgSecretError) -> Self { + let (description, status_code) = match err { + CodespacesListSelectedReposForOrgSecretError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesListSelectedReposForOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get default attributes for a codespace](Codespaces::pre_flight_with_repo_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesPreFlightWithRepoForAuthenticatedUserError { - #[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")] @@ -840,19 +1066,26 @@ pub enum CodespacesPreFlightWithRepoForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesPreFlightWithRepoForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesPreFlightWithRepoForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesPreFlightWithRepoForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesPreFlightWithRepoForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesPreFlightWithRepoForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a repository from an unpublished codespace](Codespaces::publish_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesPublishForAuthenticatedUserError { - #[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")] @@ -865,19 +1098,27 @@ pub enum CodespacesPublishForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesPublishForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesPublishForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesPublishForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesPublishForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesPublishForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + CodespacesPublishForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -890,19 +1131,27 @@ pub enum CodespacesRemoveRepositoryForSecretForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesRemoveRepositoryForSecretForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove selected repository from an organization secret](Codespaces::remove_selected_repo_from_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesRemoveSelectedRepoFromOrgSecretError { - #[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("Conflict when visibility type not set to selected")] @@ -913,19 +1162,26 @@ pub enum CodespacesRemoveSelectedRepoFromOrgSecretError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesRemoveSelectedRepoFromOrgSecretError) -> Self { + let (description, status_code) = match err { + CodespacesRemoveSelectedRepoFromOrgSecretError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesRemoveSelectedRepoFromOrgSecretError::Status409 => (String::from("Conflict when visibility type not set to selected"), 409), + CodespacesRemoveSelectedRepoFromOrgSecretError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + CodespacesRemoveSelectedRepoFromOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -940,19 +1196,28 @@ pub enum CodespacesRepoMachinesForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesRepoMachinesForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesRepoMachinesForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + CodespacesRepoMachinesForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesRepoMachinesForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesRepoMachinesForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesRepoMachinesForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesRepoMachinesForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Manage access control for organization codespaces](Codespaces::set_codespaces_access_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesSetCodespacesAccessError { - #[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("Users are neither members nor collaborators of this organization.")] @@ -967,19 +1232,28 @@ pub enum CodespacesSetCodespacesAccessError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesSetCodespacesAccessError) -> Self { + let (description, status_code) = match err { + CodespacesSetCodespacesAccessError::Status304 => (String::from("Not modified"), 304), + CodespacesSetCodespacesAccessError::Status400 => (String::from("Users are neither members nor collaborators of this organization."), 400), + CodespacesSetCodespacesAccessError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesSetCodespacesAccessError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + CodespacesSetCodespacesAccessError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesSetCodespacesAccessError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add users to Codespaces access for an organization](Codespaces::set_codespaces_access_users_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesSetCodespacesAccessUsersError { - #[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("Users are neither members nor collaborators of this organization.")] @@ -994,19 +1268,28 @@ pub enum CodespacesSetCodespacesAccessUsersError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesSetCodespacesAccessUsersError) -> Self { + let (description, status_code) = match err { + CodespacesSetCodespacesAccessUsersError::Status304 => (String::from("Not modified"), 304), + CodespacesSetCodespacesAccessUsersError::Status400 => (String::from("Users are neither members nor collaborators of this organization."), 400), + CodespacesSetCodespacesAccessUsersError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesSetCodespacesAccessUsersError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + CodespacesSetCodespacesAccessUsersError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesSetCodespacesAccessUsersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -1019,19 +1302,27 @@ pub enum CodespacesSetRepositoriesForSecretForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesSetRepositoriesForSecretForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set selected repositories for an organization secret](Codespaces::set_selected_repos_for_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesSetSelectedReposForOrgSecretError { - #[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("Conflict when visibility type not set to selected")] @@ -1040,19 +1331,25 @@ pub enum CodespacesSetSelectedReposForOrgSecretError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesSetSelectedReposForOrgSecretError) -> Self { + let (description, status_code) = match err { + CodespacesSetSelectedReposForOrgSecretError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesSetSelectedReposForOrgSecretError::Status409 => (String::from("Conflict when visibility type not set to selected"), 409), + CodespacesSetSelectedReposForOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -1073,19 +1370,31 @@ pub enum CodespacesStartForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesStartForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesStartForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + CodespacesStartForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesStartForAuthenticatedUserError::Status400(_) => (String::from("Bad Request"), 400), + CodespacesStartForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesStartForAuthenticatedUserError::Status402(_) => (String::from("Payment required"), 402), + CodespacesStartForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesStartForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesStartForAuthenticatedUserError::Status409(_) => (String::from("Conflict"), 409), + CodespacesStartForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -1098,19 +1407,27 @@ pub enum CodespacesStopForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesStopForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesStopForAuthenticatedUserError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesStopForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesStopForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesStopForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesStopForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Stop a codespace for an organization user](Codespaces::stop_in_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CodespacesStopInOrganizationError { - #[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")] @@ -1125,19 +1442,28 @@ pub enum CodespacesStopInOrganizationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesStopInOrganizationError) -> Self { + let (description, status_code) = match err { + CodespacesStopInOrganizationError::Status304 => (String::from("Not modified"), 304), + CodespacesStopInOrganizationError::Status500(_) => (String::from("Internal Error"), 500), + CodespacesStopInOrganizationError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesStopInOrganizationError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesStopInOrganizationError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesStopInOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -1148,6 +1474,23 @@ pub enum CodespacesUpdateForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CodespacesUpdateForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + CodespacesUpdateForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + CodespacesUpdateForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + CodespacesUpdateForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + CodespacesUpdateForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [Check if permissions defined by a devcontainer have been accepted by the authenticated user](Codespaces::check_permissions_for_devcontainer_async()) endpoint. #[derive(Default, Serialize)] @@ -1629,7 +1972,7 @@ impl<'req> CodespacesRepoMachinesForAuthenticatedUserParams<'req> { } -impl<'api, C: Client> Codespaces<'api, C> { +impl<'api, C: Client> Codespaces<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Add a selected repository to a user secret @@ -1643,19 +1986,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for add_repository_for_secret_for_authenticated_user](https://docs.github.com/rest/codespaces/secrets#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> { + pub async fn add_repository_for_secret_for_authenticated_user_async(&self, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { 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, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1667,11 +2010,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 500 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - code => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + code => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1690,7 +2033,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_repository_for_secret_for_authenticated_user(&self, secret_name: &str, repository_id: i32) -> Result<(), CodespacesAddRepositoryForSecretForAuthenticatedUserError> { + pub fn add_repository_for_secret_for_authenticated_user(&self, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/codespaces/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, secret_name, repository_id); @@ -1702,7 +2045,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1714,11 +2057,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status404(github_response.to_json()?)), - 500 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status500(github_response.to_json()?)), - code => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 500 => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + code => Err(CodespacesAddRepositoryForSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1733,19 +2076,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for add_selected_repo_to_org_secret](https://docs.github.com/rest/codespaces/organization-secrets#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<(), CodespacesAddSelectedRepoToOrgSecretError> { + pub async fn add_selected_repo_to_org_secret_async(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1757,10 +2100,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status404(github_response.to_json_async().await?)), - 409 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status409), - 422 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status422(github_response.to_json_async().await?)), - code => Err(CodespacesAddSelectedRepoToOrgSecretError::Generic { code }), + 404 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status409.into()), + 422 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status422(github_response.to_json_async().await?).into()), + code => Err(CodespacesAddSelectedRepoToOrgSecretError::Generic { code }.into()), } } } @@ -1776,7 +2119,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_selected_repo_to_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), CodespacesAddSelectedRepoToOrgSecretError> { + pub fn add_selected_repo_to_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); @@ -1788,7 +2131,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1800,10 +2143,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status404(github_response.to_json()?)), - 409 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status409), - 422 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status422(github_response.to_json()?)), - code => Err(CodespacesAddSelectedRepoToOrgSecretError::Generic { code }), + 404 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status404(github_response.to_json()?).into()), + 409 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status409.into()), + 422 => Err(CodespacesAddSelectedRepoToOrgSecretError::Status422(github_response.to_json()?).into()), + code => Err(CodespacesAddSelectedRepoToOrgSecretError::Generic { code }.into()), } } } @@ -1819,7 +2162,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for check_permissions_for_devcontainer](https://docs.github.com/rest/codespaces/codespaces#check-if-permissions-defined-by-a-devcontainer-have-been-accepted-by-the-authenticated-user) /// /// --- - pub async fn check_permissions_for_devcontainer_async(&self, owner: &str, repo: &str, query_params: impl Into>) -> Result { + pub async fn check_permissions_for_devcontainer_async(&self, owner: &str, repo: &str, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codespaces/permissions_check", super::GITHUB_BASE_API_URL, owner, repo); @@ -1828,12 +2171,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1845,12 +2188,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(CodespacesCheckPermissionsForDevcontainerError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesCheckPermissionsForDevcontainerError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesCheckPermissionsForDevcontainerError::Status404(github_response.to_json_async().await?)), - 422 => Err(CodespacesCheckPermissionsForDevcontainerError::Status422(github_response.to_json_async().await?)), - 503 => Err(CodespacesCheckPermissionsForDevcontainerError::Status503(github_response.to_json_async().await?)), - code => Err(CodespacesCheckPermissionsForDevcontainerError::Generic { code }), + 401 => Err(CodespacesCheckPermissionsForDevcontainerError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesCheckPermissionsForDevcontainerError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesCheckPermissionsForDevcontainerError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CodespacesCheckPermissionsForDevcontainerError::Status422(github_response.to_json_async().await?).into()), + 503 => Err(CodespacesCheckPermissionsForDevcontainerError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodespacesCheckPermissionsForDevcontainerError::Generic { code }.into()), } } } @@ -1867,7 +2210,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_permissions_for_devcontainer(&self, owner: &str, repo: &str, query_params: impl Into>) -> Result { + pub fn check_permissions_for_devcontainer(&self, owner: &str, repo: &str, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codespaces/permissions_check", super::GITHUB_BASE_API_URL, owner, repo); @@ -1882,7 +2225,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1894,12 +2237,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(CodespacesCheckPermissionsForDevcontainerError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesCheckPermissionsForDevcontainerError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesCheckPermissionsForDevcontainerError::Status404(github_response.to_json()?)), - 422 => Err(CodespacesCheckPermissionsForDevcontainerError::Status422(github_response.to_json()?)), - 503 => Err(CodespacesCheckPermissionsForDevcontainerError::Status503(github_response.to_json()?)), - code => Err(CodespacesCheckPermissionsForDevcontainerError::Generic { code }), + 401 => Err(CodespacesCheckPermissionsForDevcontainerError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesCheckPermissionsForDevcontainerError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesCheckPermissionsForDevcontainerError::Status404(github_response.to_json()?).into()), + 422 => Err(CodespacesCheckPermissionsForDevcontainerError::Status422(github_response.to_json()?).into()), + 503 => Err(CodespacesCheckPermissionsForDevcontainerError::Status503(github_response.to_json()?).into()), + code => Err(CodespacesCheckPermissionsForDevcontainerError::Generic { code }.into()), } } } @@ -1915,19 +2258,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for codespace_machines_for_authenticated_user](https://docs.github.com/rest/codespaces/machines#list-machine-types-for-a-codespace) /// /// --- - pub async fn codespace_machines_for_authenticated_user_async(&self, codespace_name: &str) -> Result { + 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, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1939,12 +2282,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status304), - 500 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1961,7 +2304,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn codespace_machines_for_authenticated_user(&self, codespace_name: &str) -> Result { + 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); @@ -1973,7 +2316,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1985,12 +2328,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status304), - 500 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesCodespaceMachinesForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2008,19 +2351,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for create_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#create-a-codespace-for-the-authenticated-user) /// /// --- - pub async fn create_for_authenticated_user_async(&self, body: PostCodespacesCreateForAuthenticatedUser) -> Result { + 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)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2032,12 +2375,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 202 => Err(CodespacesCreateForAuthenticatedUserError::Status202(github_response.to_json_async().await?)), - 401 => Err(CodespacesCreateForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesCreateForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesCreateForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodespacesCreateForAuthenticatedUserError::Status503(github_response.to_json_async().await?)), - code => Err(CodespacesCreateForAuthenticatedUserError::Generic { code }), + 202 => Err(CodespacesCreateForAuthenticatedUserError::Status202(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesCreateForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesCreateForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesCreateForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodespacesCreateForAuthenticatedUserError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodespacesCreateForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2056,19 +2399,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_authenticated_user(&self, body: PostCodespacesCreateForAuthenticatedUser) -> Result { + 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)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2080,12 +2423,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 202 => Err(CodespacesCreateForAuthenticatedUserError::Status202(github_response.to_json()?)), - 401 => Err(CodespacesCreateForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesCreateForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesCreateForAuthenticatedUserError::Status404(github_response.to_json()?)), - 503 => Err(CodespacesCreateForAuthenticatedUserError::Status503(github_response.to_json()?)), - code => Err(CodespacesCreateForAuthenticatedUserError::Generic { code }), + 202 => Err(CodespacesCreateForAuthenticatedUserError::Status202(github_response.to_json()?).into()), + 401 => Err(CodespacesCreateForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesCreateForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesCreateForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 503 => Err(CodespacesCreateForAuthenticatedUserError::Status503(github_response.to_json()?).into()), + code => Err(CodespacesCreateForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2102,19 +2445,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for create_or_update_org_secret](https://docs.github.com/rest/codespaces/organization-secrets#create-or-update-an-organization-secret) /// /// --- - pub async fn create_or_update_org_secret_async(&self, org: &str, secret_name: &str, body: PutCodespacesCreateOrUpdateOrgSecret) -> Result { + pub async fn create_or_update_org_secret_async(&self, org: &str, secret_name: &str, body: PutCodespacesCreateOrUpdateOrgSecret) -> Result { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutCodespacesCreateOrUpdateOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2126,10 +2469,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(CodespacesCreateOrUpdateOrgSecretError::Status204), - 404 => Err(CodespacesCreateOrUpdateOrgSecretError::Status404(github_response.to_json_async().await?)), - 422 => Err(CodespacesCreateOrUpdateOrgSecretError::Status422(github_response.to_json_async().await?)), - code => Err(CodespacesCreateOrUpdateOrgSecretError::Generic { code }), + 204 => Err(CodespacesCreateOrUpdateOrgSecretError::Status204.into()), + 404 => Err(CodespacesCreateOrUpdateOrgSecretError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CodespacesCreateOrUpdateOrgSecretError::Status422(github_response.to_json_async().await?).into()), + code => Err(CodespacesCreateOrUpdateOrgSecretError::Generic { code }.into()), } } } @@ -2147,19 +2490,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_org_secret(&self, org: &str, secret_name: &str, body: PutCodespacesCreateOrUpdateOrgSecret) -> Result { + pub fn create_or_update_org_secret(&self, org: &str, secret_name: &str, body: PutCodespacesCreateOrUpdateOrgSecret) -> Result { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutCodespacesCreateOrUpdateOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2171,10 +2514,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(CodespacesCreateOrUpdateOrgSecretError::Status204), - 404 => Err(CodespacesCreateOrUpdateOrgSecretError::Status404(github_response.to_json()?)), - 422 => Err(CodespacesCreateOrUpdateOrgSecretError::Status422(github_response.to_json()?)), - code => Err(CodespacesCreateOrUpdateOrgSecretError::Generic { code }), + 204 => Err(CodespacesCreateOrUpdateOrgSecretError::Status204.into()), + 404 => Err(CodespacesCreateOrUpdateOrgSecretError::Status404(github_response.to_json()?).into()), + 422 => Err(CodespacesCreateOrUpdateOrgSecretError::Status422(github_response.to_json()?).into()), + code => Err(CodespacesCreateOrUpdateOrgSecretError::Generic { code }.into()), } } } @@ -2191,19 +2534,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for create_or_update_repo_secret](https://docs.github.com/rest/codespaces/repository-secrets#create-or-update-a-repository-secret) /// /// --- - pub async fn create_or_update_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str, body: PutCodespacesCreateOrUpdateRepoSecret) -> Result { + pub async fn create_or_update_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str, body: PutCodespacesCreateOrUpdateRepoSecret) -> Result { let request_uri = format!("{}/repos/{}/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutCodespacesCreateOrUpdateRepoSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2215,8 +2558,8 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(CodespacesCreateOrUpdateRepoSecretError::Status204), - code => Err(CodespacesCreateOrUpdateRepoSecretError::Generic { code }), + 204 => Err(CodespacesCreateOrUpdateRepoSecretError::Status204.into()), + code => Err(CodespacesCreateOrUpdateRepoSecretError::Generic { code }.into()), } } } @@ -2234,19 +2577,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_repo_secret(&self, owner: &str, repo: &str, secret_name: &str, body: PutCodespacesCreateOrUpdateRepoSecret) -> Result { + pub fn create_or_update_repo_secret(&self, owner: &str, repo: &str, secret_name: &str, body: PutCodespacesCreateOrUpdateRepoSecret) -> Result { let request_uri = format!("{}/repos/{}/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutCodespacesCreateOrUpdateRepoSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2258,8 +2601,8 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(CodespacesCreateOrUpdateRepoSecretError::Status204), - code => Err(CodespacesCreateOrUpdateRepoSecretError::Generic { code }), + 204 => Err(CodespacesCreateOrUpdateRepoSecretError::Status204.into()), + code => Err(CodespacesCreateOrUpdateRepoSecretError::Generic { code }.into()), } } } @@ -2278,19 +2621,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for create_or_update_secret_for_authenticated_user](https://docs.github.com/rest/codespaces/secrets#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 { + pub async fn create_or_update_secret_for_authenticated_user_async(&self, secret_name: &str, body: PutCodespacesCreateOrUpdateSecretForAuthenticatedUser) -> Result { 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)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2302,10 +2645,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status204), - 422 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - 404 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Generic { code }), + 204 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status204.into()), + 422 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2325,19 +2668,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_secret_for_authenticated_user(&self, secret_name: &str, body: PutCodespacesCreateOrUpdateSecretForAuthenticatedUser) -> Result { + pub fn create_or_update_secret_for_authenticated_user(&self, secret_name: &str, body: PutCodespacesCreateOrUpdateSecretForAuthenticatedUser) -> Result { 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)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2349,10 +2692,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status204), - 422 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status422(github_response.to_json()?)), - 404 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Generic { code }), + 204 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status204.into()), + 422 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + 404 => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesCreateOrUpdateSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2368,19 +2711,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for create_with_pr_for_authenticated_user](https://docs.github.com/rest/codespaces/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 { + 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)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2392,12 +2735,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 202 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status202(github_response.to_json_async().await?)), - 401 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status503(github_response.to_json_async().await?)), - code => Err(CodespacesCreateWithPrForAuthenticatedUserError::Generic { code }), + 202 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status202(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodespacesCreateWithPrForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2414,19 +2757,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_with_pr_for_authenticated_user(&self, owner: &str, repo: &str, pull_number: i32, body: PostCodespacesCreateWithPrForAuthenticatedUser) -> Result { + 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)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2438,12 +2781,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 202 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status202(github_response.to_json()?)), - 401 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status404(github_response.to_json()?)), - 503 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status503(github_response.to_json()?)), - code => Err(CodespacesCreateWithPrForAuthenticatedUserError::Generic { code }), + 202 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status202(github_response.to_json()?).into()), + 401 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 503 => Err(CodespacesCreateWithPrForAuthenticatedUserError::Status503(github_response.to_json()?).into()), + code => Err(CodespacesCreateWithPrForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2459,19 +2802,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for create_with_repo_for_authenticated_user](https://docs.github.com/rest/codespaces/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 { + 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)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2483,13 +2826,13 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 202 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status202(github_response.to_json_async().await?)), - 400 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status400(github_response.to_json_async().await?)), - 401 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 503 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status503(github_response.to_json_async().await?)), - code => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Generic { code }), + 202 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status202(github_response.to_json_async().await?).into()), + 400 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status400(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status503(github_response.to_json_async().await?).into()), + code => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2506,19 +2849,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_with_repo_for_authenticated_user(&self, owner: &str, repo: &str, body: PostCodespacesCreateWithRepoForAuthenticatedUser) -> Result { + 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)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2530,13 +2873,13 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 202 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status202(github_response.to_json()?)), - 400 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status400(github_response.to_json()?)), - 401 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status404(github_response.to_json()?)), - 503 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status503(github_response.to_json()?)), - code => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Generic { code }), + 202 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status202(github_response.to_json()?).into()), + 400 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status400(github_response.to_json()?).into()), + 401 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 503 => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Status503(github_response.to_json()?).into()), + code => Err(CodespacesCreateWithRepoForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2555,19 +2898,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for delete_codespaces_access_users](https://docs.github.com/rest/codespaces/organizations#remove-users-from-codespaces-access-for-an-organization) /// /// --- - pub async fn delete_codespaces_access_users_async(&self, org: &str, body: DeleteCodespacesDeleteCodespacesAccessUsers) -> Result<(), CodespacesDeleteCodespacesAccessUsersError> { + pub async fn delete_codespaces_access_users_async(&self, org: &str, body: DeleteCodespacesDeleteCodespacesAccessUsers) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/access/selected_users", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteCodespacesDeleteCodespacesAccessUsers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2579,12 +2922,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesDeleteCodespacesAccessUsersError::Status304), - 400 => Err(CodespacesDeleteCodespacesAccessUsersError::Status400), - 404 => Err(CodespacesDeleteCodespacesAccessUsersError::Status404(github_response.to_json_async().await?)), - 422 => Err(CodespacesDeleteCodespacesAccessUsersError::Status422(github_response.to_json_async().await?)), - 500 => Err(CodespacesDeleteCodespacesAccessUsersError::Status500(github_response.to_json_async().await?)), - code => Err(CodespacesDeleteCodespacesAccessUsersError::Generic { code }), + 304 => Err(CodespacesDeleteCodespacesAccessUsersError::Status304.into()), + 400 => Err(CodespacesDeleteCodespacesAccessUsersError::Status400.into()), + 404 => Err(CodespacesDeleteCodespacesAccessUsersError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CodespacesDeleteCodespacesAccessUsersError::Status422(github_response.to_json_async().await?).into()), + 500 => Err(CodespacesDeleteCodespacesAccessUsersError::Status500(github_response.to_json_async().await?).into()), + code => Err(CodespacesDeleteCodespacesAccessUsersError::Generic { code }.into()), } } } @@ -2604,19 +2947,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_codespaces_access_users(&self, org: &str, body: DeleteCodespacesDeleteCodespacesAccessUsers) -> Result<(), CodespacesDeleteCodespacesAccessUsersError> { + pub fn delete_codespaces_access_users(&self, org: &str, body: DeleteCodespacesDeleteCodespacesAccessUsers) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/access/selected_users", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteCodespacesDeleteCodespacesAccessUsers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2628,12 +2971,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesDeleteCodespacesAccessUsersError::Status304), - 400 => Err(CodespacesDeleteCodespacesAccessUsersError::Status400), - 404 => Err(CodespacesDeleteCodespacesAccessUsersError::Status404(github_response.to_json()?)), - 422 => Err(CodespacesDeleteCodespacesAccessUsersError::Status422(github_response.to_json()?)), - 500 => Err(CodespacesDeleteCodespacesAccessUsersError::Status500(github_response.to_json()?)), - code => Err(CodespacesDeleteCodespacesAccessUsersError::Generic { code }), + 304 => Err(CodespacesDeleteCodespacesAccessUsersError::Status304.into()), + 400 => Err(CodespacesDeleteCodespacesAccessUsersError::Status400.into()), + 404 => Err(CodespacesDeleteCodespacesAccessUsersError::Status404(github_response.to_json()?).into()), + 422 => Err(CodespacesDeleteCodespacesAccessUsersError::Status422(github_response.to_json()?).into()), + 500 => Err(CodespacesDeleteCodespacesAccessUsersError::Status500(github_response.to_json()?).into()), + code => Err(CodespacesDeleteCodespacesAccessUsersError::Generic { code }.into()), } } } @@ -2649,19 +2992,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for delete_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#delete-a-codespace-for-the-authenticated-user) /// /// --- - pub async fn delete_for_authenticated_user_async(&self, codespace_name: &str) -> Result, CodespacesDeleteForAuthenticatedUserError> { + pub async fn delete_for_authenticated_user_async(&self, codespace_name: &str) -> Result, AdapterError> { let request_uri = format!("{}/user/codespaces/{}", super::GITHUB_BASE_API_URL, codespace_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2673,12 +3016,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesDeleteForAuthenticatedUserError::Status304), - 500 => Err(CodespacesDeleteForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesDeleteForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesDeleteForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesDeleteForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesDeleteForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesDeleteForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesDeleteForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesDeleteForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesDeleteForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesDeleteForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesDeleteForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2695,7 +3038,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_for_authenticated_user(&self, codespace_name: &str) -> Result, CodespacesDeleteForAuthenticatedUserError> { + pub fn delete_for_authenticated_user(&self, codespace_name: &str) -> Result, AdapterError> { let request_uri = format!("{}/user/codespaces/{}", super::GITHUB_BASE_API_URL, codespace_name); @@ -2707,7 +3050,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2719,12 +3062,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesDeleteForAuthenticatedUserError::Status304), - 500 => Err(CodespacesDeleteForAuthenticatedUserError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesDeleteForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesDeleteForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesDeleteForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesDeleteForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesDeleteForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesDeleteForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesDeleteForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesDeleteForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesDeleteForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesDeleteForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2740,19 +3083,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for delete_from_organization](https://docs.github.com/rest/codespaces/organizations#delete-a-codespace-from-the-organization) /// /// --- - pub async fn delete_from_organization_async(&self, org: &str, username: &str, codespace_name: &str) -> Result, CodespacesDeleteFromOrganizationError> { + pub async fn delete_from_organization_async(&self, org: &str, username: &str, codespace_name: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/members/{}/codespaces/{}", super::GITHUB_BASE_API_URL, org, username, codespace_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2764,12 +3107,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesDeleteFromOrganizationError::Status304), - 500 => Err(CodespacesDeleteFromOrganizationError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesDeleteFromOrganizationError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesDeleteFromOrganizationError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesDeleteFromOrganizationError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesDeleteFromOrganizationError::Generic { code }), + 304 => Err(CodespacesDeleteFromOrganizationError::Status304.into()), + 500 => Err(CodespacesDeleteFromOrganizationError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesDeleteFromOrganizationError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesDeleteFromOrganizationError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesDeleteFromOrganizationError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesDeleteFromOrganizationError::Generic { code }.into()), } } } @@ -2786,7 +3129,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_from_organization(&self, org: &str, username: &str, codespace_name: &str) -> Result, CodespacesDeleteFromOrganizationError> { + pub fn delete_from_organization(&self, org: &str, username: &str, codespace_name: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/members/{}/codespaces/{}", super::GITHUB_BASE_API_URL, org, username, codespace_name); @@ -2798,7 +3141,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2810,12 +3153,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesDeleteFromOrganizationError::Status304), - 500 => Err(CodespacesDeleteFromOrganizationError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesDeleteFromOrganizationError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesDeleteFromOrganizationError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesDeleteFromOrganizationError::Status404(github_response.to_json()?)), - code => Err(CodespacesDeleteFromOrganizationError::Generic { code }), + 304 => Err(CodespacesDeleteFromOrganizationError::Status304.into()), + 500 => Err(CodespacesDeleteFromOrganizationError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesDeleteFromOrganizationError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesDeleteFromOrganizationError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesDeleteFromOrganizationError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesDeleteFromOrganizationError::Generic { code }.into()), } } } @@ -2831,19 +3174,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for delete_org_secret](https://docs.github.com/rest/codespaces/organization-secrets#delete-an-organization-secret) /// /// --- - pub async fn delete_org_secret_async(&self, org: &str, secret_name: &str) -> Result<(), CodespacesDeleteOrgSecretError> { + pub async fn delete_org_secret_async(&self, org: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2855,8 +3198,8 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(CodespacesDeleteOrgSecretError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesDeleteOrgSecretError::Generic { code }), + 404 => Err(CodespacesDeleteOrgSecretError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesDeleteOrgSecretError::Generic { code }.into()), } } } @@ -2873,7 +3216,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_org_secret(&self, org: &str, secret_name: &str) -> Result<(), CodespacesDeleteOrgSecretError> { + pub fn delete_org_secret(&self, org: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); @@ -2885,7 +3228,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2897,8 +3240,8 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(CodespacesDeleteOrgSecretError::Status404(github_response.to_json()?)), - code => Err(CodespacesDeleteOrgSecretError::Generic { code }), + 404 => Err(CodespacesDeleteOrgSecretError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesDeleteOrgSecretError::Generic { code }.into()), } } } @@ -2914,19 +3257,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for delete_repo_secret](https://docs.github.com/rest/codespaces/repository-secrets#delete-a-repository-secret) /// /// --- - pub async fn delete_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), CodespacesDeleteRepoSecretError> { + pub async fn delete_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2938,7 +3281,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodespacesDeleteRepoSecretError::Generic { code }), + code => Err(CodespacesDeleteRepoSecretError::Generic { code }.into()), } } } @@ -2955,7 +3298,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), CodespacesDeleteRepoSecretError> { + pub fn delete_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); @@ -2967,7 +3310,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2979,7 +3322,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodespacesDeleteRepoSecretError::Generic { code }), + code => Err(CodespacesDeleteRepoSecretError::Generic { code }.into()), } } } @@ -2997,19 +3340,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for delete_secret_for_authenticated_user](https://docs.github.com/rest/codespaces/secrets#delete-a-secret-for-the-authenticated-user) /// /// --- - pub async fn delete_secret_for_authenticated_user_async(&self, secret_name: &str) -> Result<(), CodespacesDeleteSecretForAuthenticatedUserError> { + pub async fn delete_secret_for_authenticated_user_async(&self, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3021,7 +3364,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodespacesDeleteSecretForAuthenticatedUserError::Generic { code }), + code => Err(CodespacesDeleteSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3040,7 +3383,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_secret_for_authenticated_user(&self, secret_name: &str) -> Result<(), CodespacesDeleteSecretForAuthenticatedUserError> { + pub fn delete_secret_for_authenticated_user(&self, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, secret_name); @@ -3052,7 +3395,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3064,7 +3407,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodespacesDeleteSecretForAuthenticatedUserError::Generic { code }), + code => Err(CodespacesDeleteSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3082,19 +3425,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for export_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#export-a-codespace-for-the-authenticated-user) /// /// --- - pub async fn export_for_authenticated_user_async(&self, codespace_name: &str) -> Result { + pub async fn export_for_authenticated_user_async(&self, codespace_name: &str) -> Result { let request_uri = format!("{}/user/codespaces/{}/exports", super::GITHUB_BASE_API_URL, codespace_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3106,12 +3449,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CodespacesExportForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesExportForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesExportForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesExportForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 422 => Err(CodespacesExportForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - code => Err(CodespacesExportForAuthenticatedUserError::Generic { code }), + 500 => Err(CodespacesExportForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesExportForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesExportForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesExportForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CodespacesExportForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(CodespacesExportForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3130,7 +3473,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn export_for_authenticated_user(&self, codespace_name: &str) -> Result { + pub fn export_for_authenticated_user(&self, codespace_name: &str) -> Result { let request_uri = format!("{}/user/codespaces/{}/exports", super::GITHUB_BASE_API_URL, codespace_name); @@ -3142,7 +3485,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3154,12 +3497,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CodespacesExportForAuthenticatedUserError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesExportForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesExportForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesExportForAuthenticatedUserError::Status404(github_response.to_json()?)), - 422 => Err(CodespacesExportForAuthenticatedUserError::Status422(github_response.to_json()?)), - code => Err(CodespacesExportForAuthenticatedUserError::Generic { code }), + 500 => Err(CodespacesExportForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesExportForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesExportForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesExportForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 422 => Err(CodespacesExportForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + code => Err(CodespacesExportForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3175,7 +3518,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for get_codespaces_for_user_in_org](https://docs.github.com/rest/codespaces/organizations#list-codespaces-for-a-user-in-organization) /// /// --- - pub async fn get_codespaces_for_user_in_org_async(&self, org: &str, username: &str, query_params: Option>) -> Result { + pub async fn get_codespaces_for_user_in_org_async(&self, org: &str, username: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/members/{}/codespaces", super::GITHUB_BASE_API_URL, org, username); @@ -3186,12 +3529,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3203,12 +3546,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesGetCodespacesForUserInOrgError::Status304), - 500 => Err(CodespacesGetCodespacesForUserInOrgError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesGetCodespacesForUserInOrgError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesGetCodespacesForUserInOrgError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesGetCodespacesForUserInOrgError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesGetCodespacesForUserInOrgError::Generic { code }), + 304 => Err(CodespacesGetCodespacesForUserInOrgError::Status304.into()), + 500 => Err(CodespacesGetCodespacesForUserInOrgError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesGetCodespacesForUserInOrgError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesGetCodespacesForUserInOrgError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesGetCodespacesForUserInOrgError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesGetCodespacesForUserInOrgError::Generic { code }.into()), } } } @@ -3225,7 +3568,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_codespaces_for_user_in_org(&self, org: &str, username: &str, query_params: Option>) -> Result { + pub fn get_codespaces_for_user_in_org(&self, org: &str, username: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/members/{}/codespaces", super::GITHUB_BASE_API_URL, org, username); @@ -3242,7 +3585,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3254,12 +3597,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesGetCodespacesForUserInOrgError::Status304), - 500 => Err(CodespacesGetCodespacesForUserInOrgError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesGetCodespacesForUserInOrgError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesGetCodespacesForUserInOrgError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesGetCodespacesForUserInOrgError::Status404(github_response.to_json()?)), - code => Err(CodespacesGetCodespacesForUserInOrgError::Generic { code }), + 304 => Err(CodespacesGetCodespacesForUserInOrgError::Status304.into()), + 500 => Err(CodespacesGetCodespacesForUserInOrgError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesGetCodespacesForUserInOrgError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesGetCodespacesForUserInOrgError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesGetCodespacesForUserInOrgError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesGetCodespacesForUserInOrgError::Generic { code }.into()), } } } @@ -3275,19 +3618,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for get_export_details_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#get-details-about-a-codespace-export) /// /// --- - pub async fn get_export_details_for_authenticated_user_async(&self, codespace_name: &str, export_id: &str) -> Result { + pub async fn get_export_details_for_authenticated_user_async(&self, codespace_name: &str, export_id: &str) -> Result { let request_uri = format!("{}/user/codespaces/{}/exports/{}", super::GITHUB_BASE_API_URL, codespace_name, export_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3299,8 +3642,8 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(CodespacesGetExportDetailsForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesGetExportDetailsForAuthenticatedUserError::Generic { code }), + 404 => Err(CodespacesGetExportDetailsForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesGetExportDetailsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3317,7 +3660,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_export_details_for_authenticated_user(&self, codespace_name: &str, export_id: &str) -> Result { + pub fn get_export_details_for_authenticated_user(&self, codespace_name: &str, export_id: &str) -> Result { let request_uri = format!("{}/user/codespaces/{}/exports/{}", super::GITHUB_BASE_API_URL, codespace_name, export_id); @@ -3329,7 +3672,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3341,8 +3684,8 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(CodespacesGetExportDetailsForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesGetExportDetailsForAuthenticatedUserError::Generic { code }), + 404 => Err(CodespacesGetExportDetailsForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesGetExportDetailsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3358,19 +3701,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for get_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#get-a-codespace-for-the-authenticated-user) /// /// --- - pub async fn get_for_authenticated_user_async(&self, codespace_name: &str) -> Result { + 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, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3382,12 +3725,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesGetForAuthenticatedUserError::Status304), - 500 => Err(CodespacesGetForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesGetForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesGetForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesGetForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesGetForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesGetForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesGetForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesGetForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesGetForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesGetForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesGetForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3404,7 +3747,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_for_authenticated_user(&self, codespace_name: &str) -> Result { + pub fn get_for_authenticated_user(&self, codespace_name: &str) -> Result { let request_uri = format!("{}/user/codespaces/{}", super::GITHUB_BASE_API_URL, codespace_name); @@ -3416,7 +3759,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3428,12 +3771,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesGetForAuthenticatedUserError::Status304), - 500 => Err(CodespacesGetForAuthenticatedUserError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesGetForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesGetForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesGetForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesGetForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesGetForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesGetForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesGetForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesGetForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesGetForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesGetForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3448,19 +3791,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for get_org_public_key](https://docs.github.com/rest/codespaces/organization-secrets#get-an-organization-public-key) /// /// --- - pub async fn get_org_public_key_async(&self, org: &str) -> Result { + pub async fn get_org_public_key_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/codespaces/secrets/public-key", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3472,7 +3815,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodespacesGetOrgPublicKeyError::Generic { code }), + code => Err(CodespacesGetOrgPublicKeyError::Generic { code }.into()), } } } @@ -3488,7 +3831,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_public_key(&self, org: &str) -> Result { + pub fn get_org_public_key(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/codespaces/secrets/public-key", super::GITHUB_BASE_API_URL, org); @@ -3500,7 +3843,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3512,7 +3855,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodespacesGetOrgPublicKeyError::Generic { code }), + code => Err(CodespacesGetOrgPublicKeyError::Generic { code }.into()), } } } @@ -3528,19 +3871,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for get_org_secret](https://docs.github.com/rest/codespaces/organization-secrets#get-an-organization-secret) /// /// --- - pub async fn get_org_secret_async(&self, org: &str, secret_name: &str) -> Result { + pub async fn get_org_secret_async(&self, org: &str, secret_name: &str) -> Result { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3552,7 +3895,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodespacesGetOrgSecretError::Generic { code }), + code => Err(CodespacesGetOrgSecretError::Generic { code }.into()), } } } @@ -3569,7 +3912,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_secret(&self, org: &str, secret_name: &str) -> Result { + pub fn get_org_secret(&self, org: &str, secret_name: &str) -> Result { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); @@ -3581,7 +3924,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3593,7 +3936,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodespacesGetOrgSecretError::Generic { code }), + code => Err(CodespacesGetOrgSecretError::Generic { code }.into()), } } } @@ -3611,19 +3954,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for get_public_key_for_authenticated_user](https://docs.github.com/rest/codespaces/secrets#get-public-key-for-the-authenticated-user) /// /// --- - pub async fn get_public_key_for_authenticated_user_async(&self) -> Result { + 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, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3635,7 +3978,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodespacesGetPublicKeyForAuthenticatedUserError::Generic { code }), + code => Err(CodespacesGetPublicKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3654,7 +3997,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_public_key_for_authenticated_user(&self) -> Result { + pub fn get_public_key_for_authenticated_user(&self) -> Result { let request_uri = format!("{}/user/codespaces/secrets/public-key", super::GITHUB_BASE_API_URL); @@ -3666,7 +4009,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3678,7 +4021,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodespacesGetPublicKeyForAuthenticatedUserError::Generic { code }), + code => Err(CodespacesGetPublicKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3695,19 +4038,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for get_repo_public_key](https://docs.github.com/rest/codespaces/repository-secrets#get-a-repository-public-key) /// /// --- - pub async fn get_repo_public_key_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_repo_public_key_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/codespaces/secrets/public-key", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3719,7 +4062,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodespacesGetRepoPublicKeyError::Generic { code }), + code => Err(CodespacesGetRepoPublicKeyError::Generic { code }.into()), } } } @@ -3737,7 +4080,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_public_key(&self, owner: &str, repo: &str) -> Result { + pub fn get_repo_public_key(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/codespaces/secrets/public-key", super::GITHUB_BASE_API_URL, owner, repo); @@ -3749,7 +4092,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3761,7 +4104,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodespacesGetRepoPublicKeyError::Generic { code }), + code => Err(CodespacesGetRepoPublicKeyError::Generic { code }.into()), } } } @@ -3777,19 +4120,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for get_repo_secret](https://docs.github.com/rest/codespaces/repository-secrets#get-a-repository-secret) /// /// --- - pub async fn get_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result { + pub async fn get_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3801,7 +4144,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodespacesGetRepoSecretError::Generic { code }), + code => Err(CodespacesGetRepoSecretError::Generic { code }.into()), } } } @@ -3818,7 +4161,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result { + pub fn get_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/codespaces/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); @@ -3830,7 +4173,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3842,7 +4185,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodespacesGetRepoSecretError::Generic { code }), + code => Err(CodespacesGetRepoSecretError::Generic { code }.into()), } } } @@ -3860,19 +4203,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for get_secret_for_authenticated_user](https://docs.github.com/rest/codespaces/secrets#get-a-secret-for-the-authenticated-user) /// /// --- - pub async fn get_secret_for_authenticated_user_async(&self, secret_name: &str) -> Result { + 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, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3884,7 +4227,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodespacesGetSecretForAuthenticatedUserError::Generic { code }), + code => Err(CodespacesGetSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3903,7 +4246,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_secret_for_authenticated_user(&self, secret_name: &str) -> Result { + 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); @@ -3915,7 +4258,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3927,7 +4270,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodespacesGetSecretForAuthenticatedUserError::Generic { code }), + code => Err(CodespacesGetSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3944,7 +4287,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for list_devcontainers_in_repository_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#list-devcontainer-configurations-in-a-repository-for-the-authenticated-user) /// /// --- - pub async fn list_devcontainers_in_repository_for_authenticated_user_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub async fn list_devcontainers_in_repository_for_authenticated_user_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codespaces/devcontainers", super::GITHUB_BASE_API_URL, owner, repo); @@ -3955,12 +4298,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3972,12 +4315,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - 400 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status400(github_response.to_json_async().await?)), - 401 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Generic { code }), + 500 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + 400 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status400(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3995,7 +4338,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_devcontainers_in_repository_for_authenticated_user(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub fn list_devcontainers_in_repository_for_authenticated_user(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codespaces/devcontainers", super::GITHUB_BASE_API_URL, owner, repo); @@ -4012,7 +4355,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4024,12 +4367,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status500(github_response.to_json()?)), - 400 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status400(github_response.to_json()?)), - 401 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Generic { code }), + 500 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + 400 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status400(github_response.to_json()?).into()), + 401 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesListDevcontainersInRepositoryForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4045,7 +4388,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#list-codespaces-for-the-authenticated-user) /// /// --- - pub async fn list_for_authenticated_user_async(&self, query_params: Option>) -> Result { + 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); @@ -4056,12 +4399,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4073,12 +4416,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesListForAuthenticatedUserError::Status304), - 500 => Err(CodespacesListForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesListForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesListForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesListForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesListForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesListForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesListForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesListForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesListForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesListForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4095,7 +4438,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_authenticated_user(&self, query_params: Option>) -> Result { + pub fn list_for_authenticated_user(&self, query_params: Option>) -> Result { let mut request_uri = format!("{}/user/codespaces", super::GITHUB_BASE_API_URL); @@ -4112,7 +4455,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4124,12 +4467,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesListForAuthenticatedUserError::Status304), - 500 => Err(CodespacesListForAuthenticatedUserError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesListForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesListForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesListForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesListForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesListForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesListForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesListForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesListForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesListForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4145,7 +4488,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for list_in_organization](https://docs.github.com/rest/codespaces/organizations#list-codespaces-for-the-organization) /// /// --- - pub async fn list_in_organization_async(&self, org: &str, query_params: Option>) -> Result { + pub async fn list_in_organization_async(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/codespaces", super::GITHUB_BASE_API_URL, org); @@ -4156,12 +4499,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4173,12 +4516,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesListInOrganizationError::Status304), - 500 => Err(CodespacesListInOrganizationError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesListInOrganizationError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesListInOrganizationError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesListInOrganizationError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesListInOrganizationError::Generic { code }), + 304 => Err(CodespacesListInOrganizationError::Status304.into()), + 500 => Err(CodespacesListInOrganizationError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesListInOrganizationError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesListInOrganizationError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesListInOrganizationError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesListInOrganizationError::Generic { code }.into()), } } } @@ -4195,7 +4538,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_in_organization(&self, org: &str, query_params: Option>) -> Result { + pub fn list_in_organization(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/codespaces", super::GITHUB_BASE_API_URL, org); @@ -4212,7 +4555,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4224,12 +4567,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesListInOrganizationError::Status304), - 500 => Err(CodespacesListInOrganizationError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesListInOrganizationError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesListInOrganizationError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesListInOrganizationError::Status404(github_response.to_json()?)), - code => Err(CodespacesListInOrganizationError::Generic { code }), + 304 => Err(CodespacesListInOrganizationError::Status304.into()), + 500 => Err(CodespacesListInOrganizationError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesListInOrganizationError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesListInOrganizationError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesListInOrganizationError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesListInOrganizationError::Generic { code }.into()), } } } @@ -4245,7 +4588,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for list_in_repository_for_authenticated_user](https://docs.github.com/rest/codespaces/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 { + 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); @@ -4256,12 +4599,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4273,11 +4616,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesListInRepositoryForAuthenticatedUserError::Generic { code }), + 500 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesListInRepositoryForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4294,7 +4637,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_in_repository_for_authenticated_user(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + 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); @@ -4311,7 +4654,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4323,11 +4666,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesListInRepositoryForAuthenticatedUserError::Generic { code }), + 500 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesListInRepositoryForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesListInRepositoryForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4344,7 +4687,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for list_org_secrets](https://docs.github.com/rest/codespaces/organization-secrets#list-organization-secrets) /// /// --- - pub async fn list_org_secrets_async(&self, org: &str, query_params: Option>) -> Result { + pub async fn list_org_secrets_async(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/codespaces/secrets", super::GITHUB_BASE_API_URL, org); @@ -4355,12 +4698,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4372,7 +4715,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodespacesListOrgSecretsError::Generic { code }), + code => Err(CodespacesListOrgSecretsError::Generic { code }.into()), } } } @@ -4390,7 +4733,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_org_secrets(&self, org: &str, query_params: Option>) -> Result { + pub fn list_org_secrets(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/codespaces/secrets", super::GITHUB_BASE_API_URL, org); @@ -4407,7 +4750,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4419,7 +4762,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodespacesListOrgSecretsError::Generic { code }), + code => Err(CodespacesListOrgSecretsError::Generic { code }.into()), } } } @@ -4436,7 +4779,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for list_repo_secrets](https://docs.github.com/rest/codespaces/repository-secrets#list-repository-secrets) /// /// --- - pub async fn list_repo_secrets_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub async fn list_repo_secrets_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codespaces/secrets", super::GITHUB_BASE_API_URL, owner, repo); @@ -4447,12 +4790,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4464,7 +4807,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodespacesListRepoSecretsError::Generic { code }), + code => Err(CodespacesListRepoSecretsError::Generic { code }.into()), } } } @@ -4482,7 +4825,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repo_secrets(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub fn list_repo_secrets(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codespaces/secrets", super::GITHUB_BASE_API_URL, owner, repo); @@ -4499,7 +4842,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4511,7 +4854,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodespacesListRepoSecretsError::Generic { code }), + code => Err(CodespacesListRepoSecretsError::Generic { code }.into()), } } } @@ -4529,19 +4872,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for list_repositories_for_secret_for_authenticated_user](https://docs.github.com/rest/codespaces/secrets#list-selected-repositories-for-a-user-secret) /// /// --- - pub async fn list_repositories_for_secret_for_authenticated_user_async(&self, secret_name: &str) -> Result { + 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, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4553,11 +4896,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 500 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - code => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + code => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4576,7 +4919,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repositories_for_secret_for_authenticated_user(&self, secret_name: &str) -> Result { + 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); @@ -4588,7 +4931,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4600,11 +4943,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status404(github_response.to_json()?)), - 500 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status500(github_response.to_json()?)), - code => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 500 => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + code => Err(CodespacesListRepositoriesForSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4623,7 +4966,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for list_secrets_for_authenticated_user](https://docs.github.com/rest/codespaces/secrets#list-secrets-for-the-authenticated-user) /// /// --- - pub async fn list_secrets_for_authenticated_user_async(&self, query_params: Option>) -> Result { + 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); @@ -4634,12 +4977,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4651,7 +4994,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(CodespacesListSecretsForAuthenticatedUserError::Generic { code }), + code => Err(CodespacesListSecretsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4671,7 +5014,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_secrets_for_authenticated_user(&self, query_params: Option>) -> Result { + 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); @@ -4688,7 +5031,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4700,7 +5043,7 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(CodespacesListSecretsForAuthenticatedUserError::Generic { code }), + code => Err(CodespacesListSecretsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4717,7 +5060,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for list_selected_repos_for_org_secret](https://docs.github.com/rest/codespaces/organization-secrets#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/{}/codespaces/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); @@ -4728,12 +5071,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4745,8 +5088,8 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(CodespacesListSelectedReposForOrgSecretError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesListSelectedReposForOrgSecretError::Generic { code }), + 404 => Err(CodespacesListSelectedReposForOrgSecretError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesListSelectedReposForOrgSecretError::Generic { code }.into()), } } } @@ -4764,7 +5107,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[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/{}/codespaces/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); @@ -4781,7 +5124,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4793,8 +5136,8 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(CodespacesListSelectedReposForOrgSecretError::Status404(github_response.to_json()?)), - code => Err(CodespacesListSelectedReposForOrgSecretError::Generic { code }), + 404 => Err(CodespacesListSelectedReposForOrgSecretError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesListSelectedReposForOrgSecretError::Generic { code }.into()), } } } @@ -4810,7 +5153,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for pre_flight_with_repo_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#get-default-attributes-for-a-codespace) /// /// --- - pub async fn pre_flight_with_repo_for_authenticated_user_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub async fn pre_flight_with_repo_for_authenticated_user_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codespaces/new", super::GITHUB_BASE_API_URL, owner, repo); @@ -4821,12 +5164,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4838,10 +5181,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4858,7 +5201,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn pre_flight_with_repo_for_authenticated_user(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub fn pre_flight_with_repo_for_authenticated_user(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codespaces/new", super::GITHUB_BASE_API_URL, owner, repo); @@ -4875,7 +5218,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4887,10 +5230,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesPreFlightWithRepoForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4910,19 +5253,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for publish_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#create-a-repository-from-an-unpublished-codespace) /// /// --- - pub async fn publish_for_authenticated_user_async(&self, codespace_name: &str, body: PostCodespacesPublishForAuthenticatedUser) -> Result { + pub async fn publish_for_authenticated_user_async(&self, codespace_name: &str, body: PostCodespacesPublishForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/codespaces/{}/publish", super::GITHUB_BASE_API_URL, codespace_name); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodespacesPublishForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4934,11 +5277,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(CodespacesPublishForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesPublishForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesPublishForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 422 => Err(CodespacesPublishForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - code => Err(CodespacesPublishForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesPublishForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesPublishForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesPublishForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CodespacesPublishForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(CodespacesPublishForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4959,19 +5302,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn publish_for_authenticated_user(&self, codespace_name: &str, body: PostCodespacesPublishForAuthenticatedUser) -> Result { + pub fn publish_for_authenticated_user(&self, codespace_name: &str, body: PostCodespacesPublishForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/codespaces/{}/publish", super::GITHUB_BASE_API_URL, codespace_name); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodespacesPublishForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4983,11 +5326,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(CodespacesPublishForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesPublishForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesPublishForAuthenticatedUserError::Status404(github_response.to_json()?)), - 422 => Err(CodespacesPublishForAuthenticatedUserError::Status422(github_response.to_json()?)), - code => Err(CodespacesPublishForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesPublishForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesPublishForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesPublishForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 422 => Err(CodespacesPublishForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + code => Err(CodespacesPublishForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5005,19 +5348,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for remove_repository_for_secret_for_authenticated_user](https://docs.github.com/rest/codespaces/secrets#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> { + pub async fn remove_repository_for_secret_for_authenticated_user_async(&self, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { 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, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5029,11 +5372,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 500 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - code => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + code => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5052,7 +5395,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_repository_for_secret_for_authenticated_user(&self, secret_name: &str, repository_id: i32) -> Result<(), CodespacesRemoveRepositoryForSecretForAuthenticatedUserError> { + pub fn remove_repository_for_secret_for_authenticated_user(&self, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/codespaces/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, secret_name, repository_id); @@ -5064,7 +5407,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5076,11 +5419,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status404(github_response.to_json()?)), - 500 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status500(github_response.to_json()?)), - code => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 500 => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + code => Err(CodespacesRemoveRepositoryForSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5098,19 +5441,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for remove_selected_repo_from_org_secret](https://docs.github.com/rest/codespaces/organization-secrets#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<(), CodespacesRemoveSelectedRepoFromOrgSecretError> { + pub async fn remove_selected_repo_from_org_secret_async(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5122,10 +5465,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status404(github_response.to_json_async().await?)), - 409 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status409), - 422 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status422(github_response.to_json_async().await?)), - code => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Generic { code }), + 404 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status409.into()), + 422 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status422(github_response.to_json_async().await?).into()), + code => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Generic { code }.into()), } } } @@ -5144,7 +5487,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_selected_repo_from_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), CodespacesRemoveSelectedRepoFromOrgSecretError> { + pub fn remove_selected_repo_from_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); @@ -5156,7 +5499,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5168,10 +5511,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status404(github_response.to_json()?)), - 409 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status409), - 422 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status422(github_response.to_json()?)), - code => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Generic { code }), + 404 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status404(github_response.to_json()?).into()), + 409 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status409.into()), + 422 => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Status422(github_response.to_json()?).into()), + code => Err(CodespacesRemoveSelectedRepoFromOrgSecretError::Generic { code }.into()), } } } @@ -5187,7 +5530,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for repo_machines_for_authenticated_user](https://docs.github.com/rest/codespaces/machines#list-available-machine-types-for-a-repository) /// /// --- - pub async fn repo_machines_for_authenticated_user_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub async fn repo_machines_for_authenticated_user_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codespaces/machines", super::GITHUB_BASE_API_URL, owner, repo); @@ -5198,12 +5541,12 @@ impl<'api, C: Client> Codespaces<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5215,12 +5558,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status304), - 500 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesRepoMachinesForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesRepoMachinesForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5237,7 +5580,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn repo_machines_for_authenticated_user(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub fn repo_machines_for_authenticated_user(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codespaces/machines", super::GITHUB_BASE_API_URL, owner, repo); @@ -5254,7 +5597,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5266,12 +5609,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status304), - 500 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesRepoMachinesForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesRepoMachinesForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesRepoMachinesForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5286,19 +5629,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for set_codespaces_access](https://docs.github.com/rest/codespaces/organizations#manage-access-control-for-organization-codespaces) /// /// --- - pub async fn set_codespaces_access_async(&self, org: &str, body: PutCodespacesSetCodespacesAccess) -> Result<(), CodespacesSetCodespacesAccessError> { + pub async fn set_codespaces_access_async(&self, org: &str, body: PutCodespacesSetCodespacesAccess) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/access", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutCodespacesSetCodespacesAccess::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5310,12 +5653,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesSetCodespacesAccessError::Status304), - 400 => Err(CodespacesSetCodespacesAccessError::Status400), - 404 => Err(CodespacesSetCodespacesAccessError::Status404(github_response.to_json_async().await?)), - 422 => Err(CodespacesSetCodespacesAccessError::Status422(github_response.to_json_async().await?)), - 500 => Err(CodespacesSetCodespacesAccessError::Status500(github_response.to_json_async().await?)), - code => Err(CodespacesSetCodespacesAccessError::Generic { code }), + 304 => Err(CodespacesSetCodespacesAccessError::Status304.into()), + 400 => Err(CodespacesSetCodespacesAccessError::Status400.into()), + 404 => Err(CodespacesSetCodespacesAccessError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CodespacesSetCodespacesAccessError::Status422(github_response.to_json_async().await?).into()), + 500 => Err(CodespacesSetCodespacesAccessError::Status500(github_response.to_json_async().await?).into()), + code => Err(CodespacesSetCodespacesAccessError::Generic { code }.into()), } } } @@ -5331,19 +5674,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_codespaces_access(&self, org: &str, body: PutCodespacesSetCodespacesAccess) -> Result<(), CodespacesSetCodespacesAccessError> { + pub fn set_codespaces_access(&self, org: &str, body: PutCodespacesSetCodespacesAccess) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/access", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutCodespacesSetCodespacesAccess::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5355,12 +5698,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesSetCodespacesAccessError::Status304), - 400 => Err(CodespacesSetCodespacesAccessError::Status400), - 404 => Err(CodespacesSetCodespacesAccessError::Status404(github_response.to_json()?)), - 422 => Err(CodespacesSetCodespacesAccessError::Status422(github_response.to_json()?)), - 500 => Err(CodespacesSetCodespacesAccessError::Status500(github_response.to_json()?)), - code => Err(CodespacesSetCodespacesAccessError::Generic { code }), + 304 => Err(CodespacesSetCodespacesAccessError::Status304.into()), + 400 => Err(CodespacesSetCodespacesAccessError::Status400.into()), + 404 => Err(CodespacesSetCodespacesAccessError::Status404(github_response.to_json()?).into()), + 422 => Err(CodespacesSetCodespacesAccessError::Status422(github_response.to_json()?).into()), + 500 => Err(CodespacesSetCodespacesAccessError::Status500(github_response.to_json()?).into()), + code => Err(CodespacesSetCodespacesAccessError::Generic { code }.into()), } } } @@ -5379,19 +5722,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for set_codespaces_access_users](https://docs.github.com/rest/codespaces/organizations#add-users-to-codespaces-access-for-an-organization) /// /// --- - pub async fn set_codespaces_access_users_async(&self, org: &str, body: PostCodespacesSetCodespacesAccessUsers) -> Result<(), CodespacesSetCodespacesAccessUsersError> { + pub async fn set_codespaces_access_users_async(&self, org: &str, body: PostCodespacesSetCodespacesAccessUsers) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/access/selected_users", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodespacesSetCodespacesAccessUsers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5403,12 +5746,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesSetCodespacesAccessUsersError::Status304), - 400 => Err(CodespacesSetCodespacesAccessUsersError::Status400), - 404 => Err(CodespacesSetCodespacesAccessUsersError::Status404(github_response.to_json_async().await?)), - 422 => Err(CodespacesSetCodespacesAccessUsersError::Status422(github_response.to_json_async().await?)), - 500 => Err(CodespacesSetCodespacesAccessUsersError::Status500(github_response.to_json_async().await?)), - code => Err(CodespacesSetCodespacesAccessUsersError::Generic { code }), + 304 => Err(CodespacesSetCodespacesAccessUsersError::Status304.into()), + 400 => Err(CodespacesSetCodespacesAccessUsersError::Status400.into()), + 404 => Err(CodespacesSetCodespacesAccessUsersError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CodespacesSetCodespacesAccessUsersError::Status422(github_response.to_json_async().await?).into()), + 500 => Err(CodespacesSetCodespacesAccessUsersError::Status500(github_response.to_json_async().await?).into()), + code => Err(CodespacesSetCodespacesAccessUsersError::Generic { code }.into()), } } } @@ -5428,19 +5771,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_codespaces_access_users(&self, org: &str, body: PostCodespacesSetCodespacesAccessUsers) -> Result<(), CodespacesSetCodespacesAccessUsersError> { + pub fn set_codespaces_access_users(&self, org: &str, body: PostCodespacesSetCodespacesAccessUsers) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/access/selected_users", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostCodespacesSetCodespacesAccessUsers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5452,12 +5795,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesSetCodespacesAccessUsersError::Status304), - 400 => Err(CodespacesSetCodespacesAccessUsersError::Status400), - 404 => Err(CodespacesSetCodespacesAccessUsersError::Status404(github_response.to_json()?)), - 422 => Err(CodespacesSetCodespacesAccessUsersError::Status422(github_response.to_json()?)), - 500 => Err(CodespacesSetCodespacesAccessUsersError::Status500(github_response.to_json()?)), - code => Err(CodespacesSetCodespacesAccessUsersError::Generic { code }), + 304 => Err(CodespacesSetCodespacesAccessUsersError::Status304.into()), + 400 => Err(CodespacesSetCodespacesAccessUsersError::Status400.into()), + 404 => Err(CodespacesSetCodespacesAccessUsersError::Status404(github_response.to_json()?).into()), + 422 => Err(CodespacesSetCodespacesAccessUsersError::Status422(github_response.to_json()?).into()), + 500 => Err(CodespacesSetCodespacesAccessUsersError::Status500(github_response.to_json()?).into()), + code => Err(CodespacesSetCodespacesAccessUsersError::Generic { code }.into()), } } } @@ -5475,19 +5818,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for set_repositories_for_secret_for_authenticated_user](https://docs.github.com/rest/codespaces/secrets#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> { + pub async fn set_repositories_for_secret_for_authenticated_user_async(&self, secret_name: &str, body: PutCodespacesSetRepositoriesForSecretForAuthenticatedUser) -> Result<(), AdapterError> { 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)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5499,11 +5842,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 500 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - code => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + code => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5522,19 +5865,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_repositories_for_secret_for_authenticated_user(&self, secret_name: &str, body: PutCodespacesSetRepositoriesForSecretForAuthenticatedUser) -> Result<(), CodespacesSetRepositoriesForSecretForAuthenticatedUserError> { + pub fn set_repositories_for_secret_for_authenticated_user(&self, secret_name: &str, body: PutCodespacesSetRepositoriesForSecretForAuthenticatedUser) -> Result<(), AdapterError> { 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)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5546,11 +5889,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status404(github_response.to_json()?)), - 500 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status500(github_response.to_json()?)), - code => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 500 => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + code => Err(CodespacesSetRepositoriesForSecretForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5568,19 +5911,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for set_selected_repos_for_org_secret](https://docs.github.com/rest/codespaces/organization-secrets#set-selected-repositories-for-an-organization-secret) /// /// --- - pub async fn set_selected_repos_for_org_secret_async(&self, org: &str, secret_name: &str, body: PutCodespacesSetSelectedReposForOrgSecret) -> Result<(), CodespacesSetSelectedReposForOrgSecretError> { + pub async fn set_selected_repos_for_org_secret_async(&self, org: &str, secret_name: &str, body: PutCodespacesSetSelectedReposForOrgSecret) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutCodespacesSetSelectedReposForOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5592,9 +5935,9 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(CodespacesSetSelectedReposForOrgSecretError::Status404(github_response.to_json_async().await?)), - 409 => Err(CodespacesSetSelectedReposForOrgSecretError::Status409), - code => Err(CodespacesSetSelectedReposForOrgSecretError::Generic { code }), + 404 => Err(CodespacesSetSelectedReposForOrgSecretError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(CodespacesSetSelectedReposForOrgSecretError::Status409.into()), + code => Err(CodespacesSetSelectedReposForOrgSecretError::Generic { code }.into()), } } } @@ -5613,19 +5956,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_selected_repos_for_org_secret(&self, org: &str, secret_name: &str, body: PutCodespacesSetSelectedReposForOrgSecret) -> Result<(), CodespacesSetSelectedReposForOrgSecretError> { + pub fn set_selected_repos_for_org_secret(&self, org: &str, secret_name: &str, body: PutCodespacesSetSelectedReposForOrgSecret) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/codespaces/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutCodespacesSetSelectedReposForOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5637,9 +5980,9 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(CodespacesSetSelectedReposForOrgSecretError::Status404(github_response.to_json()?)), - 409 => Err(CodespacesSetSelectedReposForOrgSecretError::Status409), - code => Err(CodespacesSetSelectedReposForOrgSecretError::Generic { code }), + 404 => Err(CodespacesSetSelectedReposForOrgSecretError::Status404(github_response.to_json()?).into()), + 409 => Err(CodespacesSetSelectedReposForOrgSecretError::Status409.into()), + code => Err(CodespacesSetSelectedReposForOrgSecretError::Generic { code }.into()), } } } @@ -5655,19 +5998,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for start_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#start-a-codespace-for-the-authenticated-user) /// /// --- - pub async fn start_for_authenticated_user_async(&self, codespace_name: &str) -> Result { + 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, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5679,15 +6022,15 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesStartForAuthenticatedUserError::Status304), - 500 => Err(CodespacesStartForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - 400 => Err(CodespacesStartForAuthenticatedUserError::Status400(github_response.to_json_async().await?)), - 401 => Err(CodespacesStartForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 402 => Err(CodespacesStartForAuthenticatedUserError::Status402(github_response.to_json_async().await?)), - 403 => Err(CodespacesStartForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesStartForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 409 => Err(CodespacesStartForAuthenticatedUserError::Status409(github_response.to_json_async().await?)), - code => Err(CodespacesStartForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesStartForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesStartForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + 400 => Err(CodespacesStartForAuthenticatedUserError::Status400(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesStartForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 402 => Err(CodespacesStartForAuthenticatedUserError::Status402(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesStartForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesStartForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(CodespacesStartForAuthenticatedUserError::Status409(github_response.to_json_async().await?).into()), + code => Err(CodespacesStartForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5704,7 +6047,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn start_for_authenticated_user(&self, codespace_name: &str) -> Result { + 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); @@ -5716,7 +6059,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5728,15 +6071,15 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesStartForAuthenticatedUserError::Status304), - 500 => Err(CodespacesStartForAuthenticatedUserError::Status500(github_response.to_json()?)), - 400 => Err(CodespacesStartForAuthenticatedUserError::Status400(github_response.to_json()?)), - 401 => Err(CodespacesStartForAuthenticatedUserError::Status401(github_response.to_json()?)), - 402 => Err(CodespacesStartForAuthenticatedUserError::Status402(github_response.to_json()?)), - 403 => Err(CodespacesStartForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesStartForAuthenticatedUserError::Status404(github_response.to_json()?)), - 409 => Err(CodespacesStartForAuthenticatedUserError::Status409(github_response.to_json()?)), - code => Err(CodespacesStartForAuthenticatedUserError::Generic { code }), + 304 => Err(CodespacesStartForAuthenticatedUserError::Status304.into()), + 500 => Err(CodespacesStartForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + 400 => Err(CodespacesStartForAuthenticatedUserError::Status400(github_response.to_json()?).into()), + 401 => Err(CodespacesStartForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 402 => Err(CodespacesStartForAuthenticatedUserError::Status402(github_response.to_json()?).into()), + 403 => Err(CodespacesStartForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesStartForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 409 => Err(CodespacesStartForAuthenticatedUserError::Status409(github_response.to_json()?).into()), + code => Err(CodespacesStartForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5752,19 +6095,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for stop_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#stop-a-codespace-for-the-authenticated-user) /// /// --- - pub async fn stop_for_authenticated_user_async(&self, codespace_name: &str) -> Result { + 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, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5776,11 +6119,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CodespacesStopForAuthenticatedUserError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesStopForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesStopForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesStopForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesStopForAuthenticatedUserError::Generic { code }), + 500 => Err(CodespacesStopForAuthenticatedUserError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesStopForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesStopForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesStopForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesStopForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5797,7 +6140,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn stop_for_authenticated_user(&self, codespace_name: &str) -> Result { + 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); @@ -5809,7 +6152,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5821,11 +6164,11 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CodespacesStopForAuthenticatedUserError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesStopForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesStopForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesStopForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesStopForAuthenticatedUserError::Generic { code }), + 500 => Err(CodespacesStopForAuthenticatedUserError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesStopForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesStopForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesStopForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesStopForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5841,19 +6184,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for stop_in_organization](https://docs.github.com/rest/codespaces/organizations#stop-a-codespace-for-an-organization-user) /// /// --- - pub async fn stop_in_organization_async(&self, org: &str, username: &str, codespace_name: &str) -> Result { + pub async fn stop_in_organization_async(&self, org: &str, username: &str, codespace_name: &str) -> Result { let request_uri = format!("{}/orgs/{}/members/{}/codespaces/{}/stop", super::GITHUB_BASE_API_URL, org, username, codespace_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5865,12 +6208,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(CodespacesStopInOrganizationError::Status304), - 500 => Err(CodespacesStopInOrganizationError::Status500(github_response.to_json_async().await?)), - 401 => Err(CodespacesStopInOrganizationError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesStopInOrganizationError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesStopInOrganizationError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesStopInOrganizationError::Generic { code }), + 304 => Err(CodespacesStopInOrganizationError::Status304.into()), + 500 => Err(CodespacesStopInOrganizationError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CodespacesStopInOrganizationError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesStopInOrganizationError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesStopInOrganizationError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesStopInOrganizationError::Generic { code }.into()), } } } @@ -5887,7 +6230,7 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn stop_in_organization(&self, org: &str, username: &str, codespace_name: &str) -> Result { + pub fn stop_in_organization(&self, org: &str, username: &str, codespace_name: &str) -> Result { let request_uri = format!("{}/orgs/{}/members/{}/codespaces/{}/stop", super::GITHUB_BASE_API_URL, org, username, codespace_name); @@ -5899,7 +6242,7 @@ impl<'api, C: Client> Codespaces<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5911,12 +6254,12 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(CodespacesStopInOrganizationError::Status304), - 500 => Err(CodespacesStopInOrganizationError::Status500(github_response.to_json()?)), - 401 => Err(CodespacesStopInOrganizationError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesStopInOrganizationError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesStopInOrganizationError::Status404(github_response.to_json()?)), - code => Err(CodespacesStopInOrganizationError::Generic { code }), + 304 => Err(CodespacesStopInOrganizationError::Status304.into()), + 500 => Err(CodespacesStopInOrganizationError::Status500(github_response.to_json()?).into()), + 401 => Err(CodespacesStopInOrganizationError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesStopInOrganizationError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesStopInOrganizationError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesStopInOrganizationError::Generic { code }.into()), } } } @@ -5934,19 +6277,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// [GitHub API docs for update_for_authenticated_user](https://docs.github.com/rest/codespaces/codespaces#update-a-codespace-for-the-authenticated-user) /// /// --- - pub async fn update_for_authenticated_user_async(&self, codespace_name: &str, body: PatchCodespacesUpdateForAuthenticatedUser) -> Result { + 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)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5958,10 +6301,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(CodespacesUpdateForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CodespacesUpdateForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CodespacesUpdateForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(CodespacesUpdateForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesUpdateForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CodespacesUpdateForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CodespacesUpdateForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(CodespacesUpdateForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5980,19 +6323,19 @@ impl<'api, C: Client> Codespaces<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_for_authenticated_user(&self, codespace_name: &str, body: PatchCodespacesUpdateForAuthenticatedUser) -> Result { + 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)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6004,10 +6347,10 @@ impl<'api, C: Client> Codespaces<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(CodespacesUpdateForAuthenticatedUserError::Status401(github_response.to_json()?)), - 403 => Err(CodespacesUpdateForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(CodespacesUpdateForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(CodespacesUpdateForAuthenticatedUserError::Generic { code }), + 401 => Err(CodespacesUpdateForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CodespacesUpdateForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CodespacesUpdateForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(CodespacesUpdateForAuthenticatedUserError::Generic { code }.into()), } } } diff --git a/src/endpoints/copilot.rs b/src/endpoints/copilot.rs index 21353e4..af0bb27 100644 --- a/src/endpoints/copilot.rs +++ b/src/endpoints/copilot.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Copilot<'api, C: Client> { +pub struct Copilot<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Copilot { +pub fn new(client: &C) -> Copilot where AdapterError: From<::Err> { Copilot { client } } /// Errors for the [Add teams to the Copilot subscription for an organization](Copilot::add_copilot_seats_for_teams_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotAddCopilotSeatsForTeamsError { - #[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")] @@ -57,19 +47,28 @@ pub enum CopilotAddCopilotSeatsForTeamsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotAddCopilotSeatsForTeamsError) -> Self { + let (description, status_code) = match err { + CopilotAddCopilotSeatsForTeamsError::Status500(_) => (String::from("Internal Error"), 500), + CopilotAddCopilotSeatsForTeamsError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotAddCopilotSeatsForTeamsError::Status403(_) => (String::from("Forbidden"), 403), + CopilotAddCopilotSeatsForTeamsError::Status404(_) => (String::from("Resource not found"), 404), + CopilotAddCopilotSeatsForTeamsError::Status422 => (String::from("Copilot Business or Enterprise is not enabled for this organization, billing has not been set up for this organization, a public code suggestions policy has not been set for this organization, or the organization's Copilot access setting is set to enable Copilot for all users or is unconfigured."), 422), + CopilotAddCopilotSeatsForTeamsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add users to the Copilot subscription for an organization](Copilot::add_copilot_seats_for_users_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotAddCopilotSeatsForUsersError { - #[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")] @@ -84,19 +83,28 @@ pub enum CopilotAddCopilotSeatsForUsersError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotAddCopilotSeatsForUsersError) -> Self { + let (description, status_code) = match err { + CopilotAddCopilotSeatsForUsersError::Status500(_) => (String::from("Internal Error"), 500), + CopilotAddCopilotSeatsForUsersError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotAddCopilotSeatsForUsersError::Status403(_) => (String::from("Forbidden"), 403), + CopilotAddCopilotSeatsForUsersError::Status404(_) => (String::from("Resource not found"), 404), + CopilotAddCopilotSeatsForUsersError::Status422 => (String::from("Copilot Business or Enterprise is not enabled for this organization, billing has not been set up for this organization, a public code suggestions policy has not been set for this organization, or the organization's Copilot access setting is set to enable Copilot for all users or is unconfigured."), 422), + CopilotAddCopilotSeatsForUsersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove teams from the Copilot subscription for an organization](Copilot::cancel_copilot_seat_assignment_for_teams_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotCancelCopilotSeatAssignmentForTeamsError { - #[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")] @@ -111,19 +119,28 @@ pub enum CopilotCancelCopilotSeatAssignmentForTeamsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotCancelCopilotSeatAssignmentForTeamsError) -> Self { + let (description, status_code) = match err { + CopilotCancelCopilotSeatAssignmentForTeamsError::Status500(_) => (String::from("Internal Error"), 500), + CopilotCancelCopilotSeatAssignmentForTeamsError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotCancelCopilotSeatAssignmentForTeamsError::Status403(_) => (String::from("Forbidden"), 403), + CopilotCancelCopilotSeatAssignmentForTeamsError::Status404(_) => (String::from("Resource not found"), 404), + CopilotCancelCopilotSeatAssignmentForTeamsError::Status422 => (String::from("Copilot Business or Enterprise is not enabled for this organization, billing has not been set up for this organization, a public code suggestions policy has not been set for this organization, or the organization's Copilot access setting is set to enable Copilot for all users or is unconfigured."), 422), + CopilotCancelCopilotSeatAssignmentForTeamsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove users from the Copilot subscription for an organization](Copilot::cancel_copilot_seat_assignment_for_users_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotCancelCopilotSeatAssignmentForUsersError { - #[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")] @@ -138,19 +155,28 @@ pub enum CopilotCancelCopilotSeatAssignmentForUsersError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotCancelCopilotSeatAssignmentForUsersError) -> Self { + let (description, status_code) = match err { + CopilotCancelCopilotSeatAssignmentForUsersError::Status500(_) => (String::from("Internal Error"), 500), + CopilotCancelCopilotSeatAssignmentForUsersError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotCancelCopilotSeatAssignmentForUsersError::Status403(_) => (String::from("Forbidden"), 403), + CopilotCancelCopilotSeatAssignmentForUsersError::Status404(_) => (String::from("Resource not found"), 404), + CopilotCancelCopilotSeatAssignmentForUsersError::Status422 => (String::from("Copilot Business or Enterprise is not enabled for this organization, billing has not been set up for this organization, a public code suggestions policy has not been set for this organization, the seat management setting is set to enable Copilot for all users or is unconfigured, or a user's seat cannot be cancelled because it was assigned to them via a team."), 422), + CopilotCancelCopilotSeatAssignmentForUsersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get Copilot seat information and settings for an organization](Copilot::get_copilot_organization_details_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotGetCopilotOrganizationDetailsError { - #[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")] @@ -165,19 +191,28 @@ pub enum CopilotGetCopilotOrganizationDetailsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotGetCopilotOrganizationDetailsError) -> Self { + let (description, status_code) = match err { + CopilotGetCopilotOrganizationDetailsError::Status500(_) => (String::from("Internal Error"), 500), + CopilotGetCopilotOrganizationDetailsError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotGetCopilotOrganizationDetailsError::Status403(_) => (String::from("Forbidden"), 403), + CopilotGetCopilotOrganizationDetailsError::Status404(_) => (String::from("Resource not found"), 404), + CopilotGetCopilotOrganizationDetailsError::Status422 => (String::from("There is a problem with your account's associated payment method."), 422), + CopilotGetCopilotOrganizationDetailsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get Copilot seat assignment details for a user](Copilot::get_copilot_seat_details_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotGetCopilotSeatDetailsForUserError { - #[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")] @@ -192,19 +227,28 @@ pub enum CopilotGetCopilotSeatDetailsForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotGetCopilotSeatDetailsForUserError) -> Self { + let (description, status_code) = match err { + CopilotGetCopilotSeatDetailsForUserError::Status500(_) => (String::from("Internal Error"), 500), + CopilotGetCopilotSeatDetailsForUserError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotGetCopilotSeatDetailsForUserError::Status403(_) => (String::from("Forbidden"), 403), + CopilotGetCopilotSeatDetailsForUserError::Status404(_) => (String::from("Resource not found"), 404), + CopilotGetCopilotSeatDetailsForUserError::Status422 => (String::from("Copilot Business or Enterprise is not enabled for this organization or the user has a pending organization invitation."), 422), + CopilotGetCopilotSeatDetailsForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List all Copilot seat assignments for an organization](Copilot::list_copilot_seats_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotListCopilotSeatsError { - #[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")] @@ -217,19 +261,27 @@ pub enum CopilotListCopilotSeatsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotListCopilotSeatsError) -> Self { + let (description, status_code) = match err { + CopilotListCopilotSeatsError::Status500(_) => (String::from("Internal Error"), 500), + CopilotListCopilotSeatsError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotListCopilotSeatsError::Status403(_) => (String::from("Forbidden"), 403), + CopilotListCopilotSeatsError::Status404(_) => (String::from("Resource not found"), 404), + CopilotListCopilotSeatsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List all Copilot seat assignments for an enterprise](Copilot::list_copilot_seats_for_enterprise_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotListCopilotSeatsForEnterpriseError { - #[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")] @@ -242,19 +294,27 @@ pub enum CopilotListCopilotSeatsForEnterpriseError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotListCopilotSeatsForEnterpriseError) -> Self { + let (description, status_code) = match err { + CopilotListCopilotSeatsForEnterpriseError::Status500(_) => (String::from("Internal Error"), 500), + CopilotListCopilotSeatsForEnterpriseError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotListCopilotSeatsForEnterpriseError::Status403(_) => (String::from("Forbidden"), 403), + CopilotListCopilotSeatsForEnterpriseError::Status404(_) => (String::from("Resource not found"), 404), + CopilotListCopilotSeatsForEnterpriseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a summary of Copilot usage for enterprise members](Copilot::usage_metrics_for_enterprise_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotUsageMetricsForEnterpriseError { - #[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")] @@ -267,19 +327,27 @@ pub enum CopilotUsageMetricsForEnterpriseError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotUsageMetricsForEnterpriseError) -> Self { + let (description, status_code) = match err { + CopilotUsageMetricsForEnterpriseError::Status500(_) => (String::from("Internal Error"), 500), + CopilotUsageMetricsForEnterpriseError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotUsageMetricsForEnterpriseError::Status403(_) => (String::from("Forbidden"), 403), + CopilotUsageMetricsForEnterpriseError::Status404(_) => (String::from("Resource not found"), 404), + CopilotUsageMetricsForEnterpriseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a summary of Copilot usage for an enterprise team](Copilot::usage_metrics_for_enterprise_team_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotUsageMetricsForEnterpriseTeamError { - #[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")] @@ -292,19 +360,27 @@ pub enum CopilotUsageMetricsForEnterpriseTeamError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotUsageMetricsForEnterpriseTeamError) -> Self { + let (description, status_code) = match err { + CopilotUsageMetricsForEnterpriseTeamError::Status500(_) => (String::from("Internal Error"), 500), + CopilotUsageMetricsForEnterpriseTeamError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotUsageMetricsForEnterpriseTeamError::Status403(_) => (String::from("Forbidden"), 403), + CopilotUsageMetricsForEnterpriseTeamError::Status404(_) => (String::from("Resource not found"), 404), + CopilotUsageMetricsForEnterpriseTeamError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a summary of Copilot usage for organization members](Copilot::usage_metrics_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotUsageMetricsForOrgError { - #[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")] @@ -317,19 +393,27 @@ pub enum CopilotUsageMetricsForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotUsageMetricsForOrgError) -> Self { + let (description, status_code) = match err { + CopilotUsageMetricsForOrgError::Status500(_) => (String::from("Internal Error"), 500), + CopilotUsageMetricsForOrgError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotUsageMetricsForOrgError::Status403(_) => (String::from("Forbidden"), 403), + CopilotUsageMetricsForOrgError::Status404(_) => (String::from("Resource not found"), 404), + CopilotUsageMetricsForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a summary of Copilot usage for a team](Copilot::usage_metrics_for_team_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum CopilotUsageMetricsForTeamError { - #[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")] @@ -342,6 +426,24 @@ pub enum CopilotUsageMetricsForTeamError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: CopilotUsageMetricsForTeamError) -> Self { + let (description, status_code) = match err { + CopilotUsageMetricsForTeamError::Status500(_) => (String::from("Internal Error"), 500), + CopilotUsageMetricsForTeamError::Status401(_) => (String::from("Requires authentication"), 401), + CopilotUsageMetricsForTeamError::Status403(_) => (String::from("Forbidden"), 403), + CopilotUsageMetricsForTeamError::Status404(_) => (String::from("Resource not found"), 404), + CopilotUsageMetricsForTeamError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List all Copilot seat assignments for an organization](Copilot::list_copilot_seats_async()) endpoint. #[derive(Default, Serialize)] @@ -696,7 +798,7 @@ impl<'enc> From<&'enc PerPage> for CopilotUsageMetricsForTeamParams<'enc> { } } -impl<'api, C: Client> Copilot<'api, C> { +impl<'api, C: Client> Copilot<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Add teams to the Copilot subscription for an organization @@ -720,19 +822,19 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for add_copilot_seats_for_teams](https://docs.github.com/rest/copilot/copilot-user-management#add-teams-to-the-copilot-subscription-for-an-organization) /// /// --- - pub async fn add_copilot_seats_for_teams_async(&self, org: &str, body: PostCopilotAddCopilotSeatsForTeams) -> Result { + pub async fn add_copilot_seats_for_teams_async(&self, org: &str, body: PostCopilotAddCopilotSeatsForTeams) -> Result { let request_uri = format!("{}/orgs/{}/copilot/billing/selected_teams", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostCopilotAddCopilotSeatsForTeams::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -744,12 +846,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotAddCopilotSeatsForTeamsError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotAddCopilotSeatsForTeamsError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotAddCopilotSeatsForTeamsError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotAddCopilotSeatsForTeamsError::Status404(github_response.to_json_async().await?)), - 422 => Err(CopilotAddCopilotSeatsForTeamsError::Status422), - code => Err(CopilotAddCopilotSeatsForTeamsError::Generic { code }), + 500 => Err(CopilotAddCopilotSeatsForTeamsError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotAddCopilotSeatsForTeamsError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotAddCopilotSeatsForTeamsError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotAddCopilotSeatsForTeamsError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CopilotAddCopilotSeatsForTeamsError::Status422.into()), + code => Err(CopilotAddCopilotSeatsForTeamsError::Generic { code }.into()), } } } @@ -778,19 +880,19 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_copilot_seats_for_teams(&self, org: &str, body: PostCopilotAddCopilotSeatsForTeams) -> Result { + pub fn add_copilot_seats_for_teams(&self, org: &str, body: PostCopilotAddCopilotSeatsForTeams) -> Result { let request_uri = format!("{}/orgs/{}/copilot/billing/selected_teams", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostCopilotAddCopilotSeatsForTeams::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -802,12 +904,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotAddCopilotSeatsForTeamsError::Status500(github_response.to_json()?)), - 401 => Err(CopilotAddCopilotSeatsForTeamsError::Status401(github_response.to_json()?)), - 403 => Err(CopilotAddCopilotSeatsForTeamsError::Status403(github_response.to_json()?)), - 404 => Err(CopilotAddCopilotSeatsForTeamsError::Status404(github_response.to_json()?)), - 422 => Err(CopilotAddCopilotSeatsForTeamsError::Status422), - code => Err(CopilotAddCopilotSeatsForTeamsError::Generic { code }), + 500 => Err(CopilotAddCopilotSeatsForTeamsError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotAddCopilotSeatsForTeamsError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotAddCopilotSeatsForTeamsError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotAddCopilotSeatsForTeamsError::Status404(github_response.to_json()?).into()), + 422 => Err(CopilotAddCopilotSeatsForTeamsError::Status422.into()), + code => Err(CopilotAddCopilotSeatsForTeamsError::Generic { code }.into()), } } } @@ -835,19 +937,19 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for add_copilot_seats_for_users](https://docs.github.com/rest/copilot/copilot-user-management#add-users-to-the-copilot-subscription-for-an-organization) /// /// --- - pub async fn add_copilot_seats_for_users_async(&self, org: &str, body: PostCopilotAddCopilotSeatsForUsers) -> Result { + pub async fn add_copilot_seats_for_users_async(&self, org: &str, body: PostCopilotAddCopilotSeatsForUsers) -> Result { let request_uri = format!("{}/orgs/{}/copilot/billing/selected_users", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostCopilotAddCopilotSeatsForUsers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -859,12 +961,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotAddCopilotSeatsForUsersError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotAddCopilotSeatsForUsersError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotAddCopilotSeatsForUsersError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotAddCopilotSeatsForUsersError::Status404(github_response.to_json_async().await?)), - 422 => Err(CopilotAddCopilotSeatsForUsersError::Status422), - code => Err(CopilotAddCopilotSeatsForUsersError::Generic { code }), + 500 => Err(CopilotAddCopilotSeatsForUsersError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotAddCopilotSeatsForUsersError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotAddCopilotSeatsForUsersError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotAddCopilotSeatsForUsersError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CopilotAddCopilotSeatsForUsersError::Status422.into()), + code => Err(CopilotAddCopilotSeatsForUsersError::Generic { code }.into()), } } } @@ -893,19 +995,19 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_copilot_seats_for_users(&self, org: &str, body: PostCopilotAddCopilotSeatsForUsers) -> Result { + pub fn add_copilot_seats_for_users(&self, org: &str, body: PostCopilotAddCopilotSeatsForUsers) -> Result { let request_uri = format!("{}/orgs/{}/copilot/billing/selected_users", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostCopilotAddCopilotSeatsForUsers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -917,12 +1019,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotAddCopilotSeatsForUsersError::Status500(github_response.to_json()?)), - 401 => Err(CopilotAddCopilotSeatsForUsersError::Status401(github_response.to_json()?)), - 403 => Err(CopilotAddCopilotSeatsForUsersError::Status403(github_response.to_json()?)), - 404 => Err(CopilotAddCopilotSeatsForUsersError::Status404(github_response.to_json()?)), - 422 => Err(CopilotAddCopilotSeatsForUsersError::Status422), - code => Err(CopilotAddCopilotSeatsForUsersError::Generic { code }), + 500 => Err(CopilotAddCopilotSeatsForUsersError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotAddCopilotSeatsForUsersError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotAddCopilotSeatsForUsersError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotAddCopilotSeatsForUsersError::Status404(github_response.to_json()?).into()), + 422 => Err(CopilotAddCopilotSeatsForUsersError::Status422.into()), + code => Err(CopilotAddCopilotSeatsForUsersError::Generic { code }.into()), } } } @@ -948,19 +1050,19 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for cancel_copilot_seat_assignment_for_teams](https://docs.github.com/rest/copilot/copilot-user-management#remove-teams-from-the-copilot-subscription-for-an-organization) /// /// --- - pub async fn cancel_copilot_seat_assignment_for_teams_async(&self, org: &str, body: DeleteCopilotCancelCopilotSeatAssignmentForTeams) -> Result { + pub async fn cancel_copilot_seat_assignment_for_teams_async(&self, org: &str, body: DeleteCopilotCancelCopilotSeatAssignmentForTeams) -> Result { let request_uri = format!("{}/orgs/{}/copilot/billing/selected_teams", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteCopilotCancelCopilotSeatAssignmentForTeams::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -972,12 +1074,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status404(github_response.to_json_async().await?)), - 422 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status422), - code => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Generic { code }), + 500 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status422.into()), + code => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Generic { code }.into()), } } } @@ -1004,19 +1106,19 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn cancel_copilot_seat_assignment_for_teams(&self, org: &str, body: DeleteCopilotCancelCopilotSeatAssignmentForTeams) -> Result { + pub fn cancel_copilot_seat_assignment_for_teams(&self, org: &str, body: DeleteCopilotCancelCopilotSeatAssignmentForTeams) -> Result { let request_uri = format!("{}/orgs/{}/copilot/billing/selected_teams", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteCopilotCancelCopilotSeatAssignmentForTeams::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1028,12 +1130,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status500(github_response.to_json()?)), - 401 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status401(github_response.to_json()?)), - 403 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status403(github_response.to_json()?)), - 404 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status404(github_response.to_json()?)), - 422 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status422), - code => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Generic { code }), + 500 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status404(github_response.to_json()?).into()), + 422 => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Status422.into()), + code => Err(CopilotCancelCopilotSeatAssignmentForTeamsError::Generic { code }.into()), } } } @@ -1059,19 +1161,19 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for cancel_copilot_seat_assignment_for_users](https://docs.github.com/rest/copilot/copilot-user-management#remove-users-from-the-copilot-subscription-for-an-organization) /// /// --- - pub async fn cancel_copilot_seat_assignment_for_users_async(&self, org: &str, body: DeleteCopilotCancelCopilotSeatAssignmentForUsers) -> Result { + pub async fn cancel_copilot_seat_assignment_for_users_async(&self, org: &str, body: DeleteCopilotCancelCopilotSeatAssignmentForUsers) -> Result { let request_uri = format!("{}/orgs/{}/copilot/billing/selected_users", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteCopilotCancelCopilotSeatAssignmentForUsers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1083,12 +1185,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status404(github_response.to_json_async().await?)), - 422 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status422), - code => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Generic { code }), + 500 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status422.into()), + code => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Generic { code }.into()), } } } @@ -1115,19 +1217,19 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn cancel_copilot_seat_assignment_for_users(&self, org: &str, body: DeleteCopilotCancelCopilotSeatAssignmentForUsers) -> Result { + pub fn cancel_copilot_seat_assignment_for_users(&self, org: &str, body: DeleteCopilotCancelCopilotSeatAssignmentForUsers) -> Result { let request_uri = format!("{}/orgs/{}/copilot/billing/selected_users", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteCopilotCancelCopilotSeatAssignmentForUsers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1139,12 +1241,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status500(github_response.to_json()?)), - 401 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status401(github_response.to_json()?)), - 403 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status403(github_response.to_json()?)), - 404 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status404(github_response.to_json()?)), - 422 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status422), - code => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Generic { code }), + 500 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status404(github_response.to_json()?).into()), + 422 => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Status422.into()), + code => Err(CopilotCancelCopilotSeatAssignmentForUsersError::Generic { code }.into()), } } } @@ -1167,19 +1269,19 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for get_copilot_organization_details](https://docs.github.com/rest/copilot/copilot-user-management#get-copilot-seat-information-and-settings-for-an-organization) /// /// --- - pub async fn get_copilot_organization_details_async(&self, org: &str) -> Result { + pub async fn get_copilot_organization_details_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/copilot/billing", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1191,12 +1293,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotGetCopilotOrganizationDetailsError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotGetCopilotOrganizationDetailsError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotGetCopilotOrganizationDetailsError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotGetCopilotOrganizationDetailsError::Status404(github_response.to_json_async().await?)), - 422 => Err(CopilotGetCopilotOrganizationDetailsError::Status422), - code => Err(CopilotGetCopilotOrganizationDetailsError::Generic { code }), + 500 => Err(CopilotGetCopilotOrganizationDetailsError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotGetCopilotOrganizationDetailsError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotGetCopilotOrganizationDetailsError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotGetCopilotOrganizationDetailsError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CopilotGetCopilotOrganizationDetailsError::Status422.into()), + code => Err(CopilotGetCopilotOrganizationDetailsError::Generic { code }.into()), } } } @@ -1220,7 +1322,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_copilot_organization_details(&self, org: &str) -> Result { + pub fn get_copilot_organization_details(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/copilot/billing", super::GITHUB_BASE_API_URL, org); @@ -1232,7 +1334,7 @@ impl<'api, C: Client> Copilot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1244,12 +1346,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotGetCopilotOrganizationDetailsError::Status500(github_response.to_json()?)), - 401 => Err(CopilotGetCopilotOrganizationDetailsError::Status401(github_response.to_json()?)), - 403 => Err(CopilotGetCopilotOrganizationDetailsError::Status403(github_response.to_json()?)), - 404 => Err(CopilotGetCopilotOrganizationDetailsError::Status404(github_response.to_json()?)), - 422 => Err(CopilotGetCopilotOrganizationDetailsError::Status422), - code => Err(CopilotGetCopilotOrganizationDetailsError::Generic { code }), + 500 => Err(CopilotGetCopilotOrganizationDetailsError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotGetCopilotOrganizationDetailsError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotGetCopilotOrganizationDetailsError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotGetCopilotOrganizationDetailsError::Status404(github_response.to_json()?).into()), + 422 => Err(CopilotGetCopilotOrganizationDetailsError::Status422.into()), + code => Err(CopilotGetCopilotOrganizationDetailsError::Generic { code }.into()), } } } @@ -1270,19 +1372,19 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for get_copilot_seat_details_for_user](https://docs.github.com/rest/copilot/copilot-user-management#get-copilot-seat-assignment-details-for-a-user) /// /// --- - pub async fn get_copilot_seat_details_for_user_async(&self, org: &str, username: &str) -> Result { + pub async fn get_copilot_seat_details_for_user_async(&self, org: &str, username: &str) -> Result { let request_uri = format!("{}/orgs/{}/members/{}/copilot", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1294,12 +1396,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotGetCopilotSeatDetailsForUserError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotGetCopilotSeatDetailsForUserError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotGetCopilotSeatDetailsForUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotGetCopilotSeatDetailsForUserError::Status404(github_response.to_json_async().await?)), - 422 => Err(CopilotGetCopilotSeatDetailsForUserError::Status422), - code => Err(CopilotGetCopilotSeatDetailsForUserError::Generic { code }), + 500 => Err(CopilotGetCopilotSeatDetailsForUserError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotGetCopilotSeatDetailsForUserError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotGetCopilotSeatDetailsForUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotGetCopilotSeatDetailsForUserError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(CopilotGetCopilotSeatDetailsForUserError::Status422.into()), + code => Err(CopilotGetCopilotSeatDetailsForUserError::Generic { code }.into()), } } } @@ -1321,7 +1423,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_copilot_seat_details_for_user(&self, org: &str, username: &str) -> Result { + pub fn get_copilot_seat_details_for_user(&self, org: &str, username: &str) -> Result { let request_uri = format!("{}/orgs/{}/members/{}/copilot", super::GITHUB_BASE_API_URL, org, username); @@ -1333,7 +1435,7 @@ impl<'api, C: Client> Copilot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1345,12 +1447,12 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotGetCopilotSeatDetailsForUserError::Status500(github_response.to_json()?)), - 401 => Err(CopilotGetCopilotSeatDetailsForUserError::Status401(github_response.to_json()?)), - 403 => Err(CopilotGetCopilotSeatDetailsForUserError::Status403(github_response.to_json()?)), - 404 => Err(CopilotGetCopilotSeatDetailsForUserError::Status404(github_response.to_json()?)), - 422 => Err(CopilotGetCopilotSeatDetailsForUserError::Status422), - code => Err(CopilotGetCopilotSeatDetailsForUserError::Generic { code }), + 500 => Err(CopilotGetCopilotSeatDetailsForUserError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotGetCopilotSeatDetailsForUserError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotGetCopilotSeatDetailsForUserError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotGetCopilotSeatDetailsForUserError::Status404(github_response.to_json()?).into()), + 422 => Err(CopilotGetCopilotSeatDetailsForUserError::Status422.into()), + code => Err(CopilotGetCopilotSeatDetailsForUserError::Generic { code }.into()), } } } @@ -1370,7 +1472,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for list_copilot_seats](https://docs.github.com/rest/copilot/copilot-user-management#list-all-copilot-seat-assignments-for-an-organization) /// /// --- - pub async fn list_copilot_seats_async(&self, org: &str, query_params: Option>) -> Result { + pub async fn list_copilot_seats_async(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/copilot/billing/seats", super::GITHUB_BASE_API_URL, org); @@ -1381,12 +1483,12 @@ impl<'api, C: Client> Copilot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1398,11 +1500,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotListCopilotSeatsError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotListCopilotSeatsError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotListCopilotSeatsError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotListCopilotSeatsError::Status404(github_response.to_json_async().await?)), - code => Err(CopilotListCopilotSeatsError::Generic { code }), + 500 => Err(CopilotListCopilotSeatsError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotListCopilotSeatsError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotListCopilotSeatsError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotListCopilotSeatsError::Status404(github_response.to_json_async().await?).into()), + code => Err(CopilotListCopilotSeatsError::Generic { code }.into()), } } } @@ -1423,7 +1525,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_copilot_seats(&self, org: &str, query_params: Option>) -> Result { + pub fn list_copilot_seats(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/copilot/billing/seats", super::GITHUB_BASE_API_URL, org); @@ -1440,7 +1542,7 @@ impl<'api, C: Client> Copilot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1452,11 +1554,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotListCopilotSeatsError::Status500(github_response.to_json()?)), - 401 => Err(CopilotListCopilotSeatsError::Status401(github_response.to_json()?)), - 403 => Err(CopilotListCopilotSeatsError::Status403(github_response.to_json()?)), - 404 => Err(CopilotListCopilotSeatsError::Status404(github_response.to_json()?)), - code => Err(CopilotListCopilotSeatsError::Generic { code }), + 500 => Err(CopilotListCopilotSeatsError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotListCopilotSeatsError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotListCopilotSeatsError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotListCopilotSeatsError::Status404(github_response.to_json()?).into()), + code => Err(CopilotListCopilotSeatsError::Generic { code }.into()), } } } @@ -1481,7 +1583,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for list_copilot_seats_for_enterprise](https://docs.github.com/rest/copilot/copilot-user-management#list-all-copilot-seat-assignments-for-an-enterprise) /// /// --- - pub async fn list_copilot_seats_for_enterprise_async(&self, enterprise: &str, query_params: Option>) -> Result { + pub async fn list_copilot_seats_for_enterprise_async(&self, enterprise: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/enterprises/{}/copilot/billing/seats", super::GITHUB_BASE_API_URL, enterprise); @@ -1492,12 +1594,12 @@ impl<'api, C: Client> Copilot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1509,11 +1611,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotListCopilotSeatsForEnterpriseError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotListCopilotSeatsForEnterpriseError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotListCopilotSeatsForEnterpriseError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotListCopilotSeatsForEnterpriseError::Status404(github_response.to_json_async().await?)), - code => Err(CopilotListCopilotSeatsForEnterpriseError::Generic { code }), + 500 => Err(CopilotListCopilotSeatsForEnterpriseError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotListCopilotSeatsForEnterpriseError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotListCopilotSeatsForEnterpriseError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotListCopilotSeatsForEnterpriseError::Status404(github_response.to_json_async().await?).into()), + code => Err(CopilotListCopilotSeatsForEnterpriseError::Generic { code }.into()), } } } @@ -1539,7 +1641,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_copilot_seats_for_enterprise(&self, enterprise: &str, query_params: Option>) -> Result { + pub fn list_copilot_seats_for_enterprise(&self, enterprise: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/enterprises/{}/copilot/billing/seats", super::GITHUB_BASE_API_URL, enterprise); @@ -1556,7 +1658,7 @@ impl<'api, C: Client> Copilot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1568,11 +1670,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotListCopilotSeatsForEnterpriseError::Status500(github_response.to_json()?)), - 401 => Err(CopilotListCopilotSeatsForEnterpriseError::Status401(github_response.to_json()?)), - 403 => Err(CopilotListCopilotSeatsForEnterpriseError::Status403(github_response.to_json()?)), - 404 => Err(CopilotListCopilotSeatsForEnterpriseError::Status404(github_response.to_json()?)), - code => Err(CopilotListCopilotSeatsForEnterpriseError::Generic { code }), + 500 => Err(CopilotListCopilotSeatsForEnterpriseError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotListCopilotSeatsForEnterpriseError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotListCopilotSeatsForEnterpriseError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotListCopilotSeatsForEnterpriseError::Status404(github_response.to_json()?).into()), + code => Err(CopilotListCopilotSeatsForEnterpriseError::Generic { code }.into()), } } } @@ -1599,7 +1701,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for usage_metrics_for_enterprise](https://docs.github.com/rest/copilot/copilot-usage#get-a-summary-of-copilot-usage-for-enterprise-members) /// /// --- - pub async fn usage_metrics_for_enterprise_async(&self, enterprise: &str, query_params: Option>>) -> Result, CopilotUsageMetricsForEnterpriseError> { + pub async fn usage_metrics_for_enterprise_async(&self, enterprise: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/enterprises/{}/copilot/usage", super::GITHUB_BASE_API_URL, enterprise); @@ -1610,12 +1712,12 @@ impl<'api, C: Client> Copilot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1627,11 +1729,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotUsageMetricsForEnterpriseError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotUsageMetricsForEnterpriseError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotUsageMetricsForEnterpriseError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotUsageMetricsForEnterpriseError::Status404(github_response.to_json_async().await?)), - code => Err(CopilotUsageMetricsForEnterpriseError::Generic { code }), + 500 => Err(CopilotUsageMetricsForEnterpriseError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotUsageMetricsForEnterpriseError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotUsageMetricsForEnterpriseError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotUsageMetricsForEnterpriseError::Status404(github_response.to_json_async().await?).into()), + code => Err(CopilotUsageMetricsForEnterpriseError::Generic { code }.into()), } } } @@ -1659,7 +1761,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn usage_metrics_for_enterprise(&self, enterprise: &str, query_params: Option>>) -> Result, CopilotUsageMetricsForEnterpriseError> { + pub fn usage_metrics_for_enterprise(&self, enterprise: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/enterprises/{}/copilot/usage", super::GITHUB_BASE_API_URL, enterprise); @@ -1676,7 +1778,7 @@ impl<'api, C: Client> Copilot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1688,11 +1790,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotUsageMetricsForEnterpriseError::Status500(github_response.to_json()?)), - 401 => Err(CopilotUsageMetricsForEnterpriseError::Status401(github_response.to_json()?)), - 403 => Err(CopilotUsageMetricsForEnterpriseError::Status403(github_response.to_json()?)), - 404 => Err(CopilotUsageMetricsForEnterpriseError::Status404(github_response.to_json()?)), - code => Err(CopilotUsageMetricsForEnterpriseError::Generic { code }), + 500 => Err(CopilotUsageMetricsForEnterpriseError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotUsageMetricsForEnterpriseError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotUsageMetricsForEnterpriseError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotUsageMetricsForEnterpriseError::Status404(github_response.to_json()?).into()), + code => Err(CopilotUsageMetricsForEnterpriseError::Generic { code }.into()), } } } @@ -1722,7 +1824,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for usage_metrics_for_enterprise_team](https://docs.github.com/rest/copilot/copilot-usage#get-a-summary-of-copilot-usage-for-an-enterprise-team) /// /// --- - pub async fn usage_metrics_for_enterprise_team_async(&self, enterprise: &str, team_slug: &str, query_params: Option>>) -> Result, CopilotUsageMetricsForEnterpriseTeamError> { + pub async fn usage_metrics_for_enterprise_team_async(&self, enterprise: &str, team_slug: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/enterprises/{}/team/{}/copilot/usage", super::GITHUB_BASE_API_URL, enterprise, team_slug); @@ -1733,12 +1835,12 @@ impl<'api, C: Client> Copilot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1750,11 +1852,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status404(github_response.to_json_async().await?)), - code => Err(CopilotUsageMetricsForEnterpriseTeamError::Generic { code }), + 500 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status404(github_response.to_json_async().await?).into()), + code => Err(CopilotUsageMetricsForEnterpriseTeamError::Generic { code }.into()), } } } @@ -1785,7 +1887,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn usage_metrics_for_enterprise_team(&self, enterprise: &str, team_slug: &str, query_params: Option>>) -> Result, CopilotUsageMetricsForEnterpriseTeamError> { + pub fn usage_metrics_for_enterprise_team(&self, enterprise: &str, team_slug: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/enterprises/{}/team/{}/copilot/usage", super::GITHUB_BASE_API_URL, enterprise, team_slug); @@ -1802,7 +1904,7 @@ impl<'api, C: Client> Copilot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1814,11 +1916,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status500(github_response.to_json()?)), - 401 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status401(github_response.to_json()?)), - 403 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status403(github_response.to_json()?)), - 404 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status404(github_response.to_json()?)), - code => Err(CopilotUsageMetricsForEnterpriseTeamError::Generic { code }), + 500 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotUsageMetricsForEnterpriseTeamError::Status404(github_response.to_json()?).into()), + code => Err(CopilotUsageMetricsForEnterpriseTeamError::Generic { code }.into()), } } } @@ -1845,7 +1947,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for usage_metrics_for_org](https://docs.github.com/rest/copilot/copilot-usage#get-a-summary-of-copilot-usage-for-organization-members) /// /// --- - pub async fn usage_metrics_for_org_async(&self, org: &str, query_params: Option>>) -> Result, CopilotUsageMetricsForOrgError> { + pub async fn usage_metrics_for_org_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/copilot/usage", super::GITHUB_BASE_API_URL, org); @@ -1856,12 +1958,12 @@ impl<'api, C: Client> Copilot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1873,11 +1975,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotUsageMetricsForOrgError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotUsageMetricsForOrgError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotUsageMetricsForOrgError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotUsageMetricsForOrgError::Status404(github_response.to_json_async().await?)), - code => Err(CopilotUsageMetricsForOrgError::Generic { code }), + 500 => Err(CopilotUsageMetricsForOrgError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotUsageMetricsForOrgError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotUsageMetricsForOrgError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotUsageMetricsForOrgError::Status404(github_response.to_json_async().await?).into()), + code => Err(CopilotUsageMetricsForOrgError::Generic { code }.into()), } } } @@ -1905,7 +2007,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn usage_metrics_for_org(&self, org: &str, query_params: Option>>) -> Result, CopilotUsageMetricsForOrgError> { + pub fn usage_metrics_for_org(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/copilot/usage", super::GITHUB_BASE_API_URL, org); @@ -1922,7 +2024,7 @@ impl<'api, C: Client> Copilot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1934,11 +2036,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotUsageMetricsForOrgError::Status500(github_response.to_json()?)), - 401 => Err(CopilotUsageMetricsForOrgError::Status401(github_response.to_json()?)), - 403 => Err(CopilotUsageMetricsForOrgError::Status403(github_response.to_json()?)), - 404 => Err(CopilotUsageMetricsForOrgError::Status404(github_response.to_json()?)), - code => Err(CopilotUsageMetricsForOrgError::Generic { code }), + 500 => Err(CopilotUsageMetricsForOrgError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotUsageMetricsForOrgError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotUsageMetricsForOrgError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotUsageMetricsForOrgError::Status404(github_response.to_json()?).into()), + code => Err(CopilotUsageMetricsForOrgError::Generic { code }.into()), } } } @@ -1968,7 +2070,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// [GitHub API docs for usage_metrics_for_team](https://docs.github.com/rest/copilot/copilot-usage#get-a-summary-of-copilot-usage-for-a-team) /// /// --- - pub async fn usage_metrics_for_team_async(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, CopilotUsageMetricsForTeamError> { + pub async fn usage_metrics_for_team_async(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/team/{}/copilot/usage", super::GITHUB_BASE_API_URL, org, team_slug); @@ -1979,12 +2081,12 @@ impl<'api, C: Client> Copilot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1996,11 +2098,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(CopilotUsageMetricsForTeamError::Status500(github_response.to_json_async().await?)), - 401 => Err(CopilotUsageMetricsForTeamError::Status401(github_response.to_json_async().await?)), - 403 => Err(CopilotUsageMetricsForTeamError::Status403(github_response.to_json_async().await?)), - 404 => Err(CopilotUsageMetricsForTeamError::Status404(github_response.to_json_async().await?)), - code => Err(CopilotUsageMetricsForTeamError::Generic { code }), + 500 => Err(CopilotUsageMetricsForTeamError::Status500(github_response.to_json_async().await?).into()), + 401 => Err(CopilotUsageMetricsForTeamError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(CopilotUsageMetricsForTeamError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(CopilotUsageMetricsForTeamError::Status404(github_response.to_json_async().await?).into()), + code => Err(CopilotUsageMetricsForTeamError::Generic { code }.into()), } } } @@ -2031,7 +2133,7 @@ impl<'api, C: Client> Copilot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn usage_metrics_for_team(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, CopilotUsageMetricsForTeamError> { + pub fn usage_metrics_for_team(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/team/{}/copilot/usage", super::GITHUB_BASE_API_URL, org, team_slug); @@ -2048,7 +2150,7 @@ impl<'api, C: Client> Copilot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2060,11 +2162,11 @@ impl<'api, C: Client> Copilot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(CopilotUsageMetricsForTeamError::Status500(github_response.to_json()?)), - 401 => Err(CopilotUsageMetricsForTeamError::Status401(github_response.to_json()?)), - 403 => Err(CopilotUsageMetricsForTeamError::Status403(github_response.to_json()?)), - 404 => Err(CopilotUsageMetricsForTeamError::Status404(github_response.to_json()?)), - code => Err(CopilotUsageMetricsForTeamError::Generic { code }), + 500 => Err(CopilotUsageMetricsForTeamError::Status500(github_response.to_json()?).into()), + 401 => Err(CopilotUsageMetricsForTeamError::Status401(github_response.to_json()?).into()), + 403 => Err(CopilotUsageMetricsForTeamError::Status403(github_response.to_json()?).into()), + 404 => Err(CopilotUsageMetricsForTeamError::Status404(github_response.to_json()?).into()), + code => Err(CopilotUsageMetricsForTeamError::Generic { code }.into()), } } } diff --git a/src/endpoints/dependabot.rs b/src/endpoints/dependabot.rs index 95433c5..45068e8 100644 --- a/src/endpoints/dependabot.rs +++ b/src/endpoints/dependabot.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,118 +22,131 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Dependabot<'api, C: Client> { +pub struct Dependabot<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Dependabot { +pub fn new(client: &C) -> Dependabot where AdapterError: From<::Err> { Dependabot { client } } /// Errors for the [Add selected repository to an organization secret](Dependabot::add_selected_repo_to_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotAddSelectedRepoToOrgSecretError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Conflict when visibility type is not set to selected")] Status409, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: DependabotAddSelectedRepoToOrgSecretError) -> Self { + let (description, status_code) = match err { + DependabotAddSelectedRepoToOrgSecretError::Status409 => (String::from("Conflict when visibility type is not set to selected"), 409), + DependabotAddSelectedRepoToOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update an organization secret](Dependabot::create_or_update_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotCreateOrUpdateOrgSecretError { - #[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 updating a secret")] Status204, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: DependabotCreateOrUpdateOrgSecretError) -> Self { + let (description, status_code) = match err { + DependabotCreateOrUpdateOrgSecretError::Status204 => (String::from("Response when updating a secret"), 204), + DependabotCreateOrUpdateOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update a repository secret](Dependabot::create_or_update_repo_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotCreateOrUpdateRepoSecretError { - #[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 updating a secret")] Status204, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: DependabotCreateOrUpdateRepoSecretError) -> Self { + let (description, status_code) = match err { + DependabotCreateOrUpdateRepoSecretError::Status204 => (String::from("Response when updating a secret"), 204), + DependabotCreateOrUpdateRepoSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an organization secret](Dependabot::delete_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotDeleteOrgSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: DependabotDeleteOrgSecretError) -> Self { + let (description, status_code) = match err { + DependabotDeleteOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a repository secret](Dependabot::delete_repo_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotDeleteRepoSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: DependabotDeleteRepoSecretError) -> Self { + let (description, status_code) = match err { + DependabotDeleteRepoSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a Dependabot alert](Dependabot::get_alert_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotGetAlertError { - #[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("Forbidden")] @@ -144,87 +157,110 @@ pub enum DependabotGetAlertError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: DependabotGetAlertError) -> Self { + let (description, status_code) = match err { + DependabotGetAlertError::Status304 => (String::from("Not modified"), 304), + DependabotGetAlertError::Status403(_) => (String::from("Forbidden"), 403), + DependabotGetAlertError::Status404(_) => (String::from("Resource not found"), 404), + DependabotGetAlertError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization public key](Dependabot::get_org_public_key_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotGetOrgPublicKeyError { - #[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 }, } +impl From for AdapterError { + fn from(err: DependabotGetOrgPublicKeyError) -> Self { + let (description, status_code) = match err { + DependabotGetOrgPublicKeyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization secret](Dependabot::get_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotGetOrgSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: DependabotGetOrgSecretError) -> Self { + let (description, status_code) = match err { + DependabotGetOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository public key](Dependabot::get_repo_public_key_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotGetRepoPublicKeyError { - #[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 }, } +impl From for AdapterError { + fn from(err: DependabotGetRepoPublicKeyError) -> Self { + let (description, status_code) = match err { + DependabotGetRepoPublicKeyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository secret](Dependabot::get_repo_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotGetRepoSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: DependabotGetRepoSecretError) -> Self { + let (description, status_code) = match err { + DependabotGetRepoSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List Dependabot alerts for an enterprise](Dependabot::list_alerts_for_enterprise_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotListAlertsForEnterpriseError { - #[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("Forbidden")] @@ -237,19 +273,27 @@ pub enum DependabotListAlertsForEnterpriseError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: DependabotListAlertsForEnterpriseError) -> Self { + let (description, status_code) = match err { + DependabotListAlertsForEnterpriseError::Status304 => (String::from("Not modified"), 304), + DependabotListAlertsForEnterpriseError::Status403(_) => (String::from("Forbidden"), 403), + DependabotListAlertsForEnterpriseError::Status404(_) => (String::from("Resource not found"), 404), + DependabotListAlertsForEnterpriseError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + DependabotListAlertsForEnterpriseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List Dependabot alerts for an organization](Dependabot::list_alerts_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotListAlertsForOrgError { - #[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("Bad Request")] @@ -264,19 +308,28 @@ pub enum DependabotListAlertsForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: DependabotListAlertsForOrgError) -> Self { + let (description, status_code) = match err { + DependabotListAlertsForOrgError::Status304 => (String::from("Not modified"), 304), + DependabotListAlertsForOrgError::Status400(_) => (String::from("Bad Request"), 400), + DependabotListAlertsForOrgError::Status403(_) => (String::from("Forbidden"), 403), + DependabotListAlertsForOrgError::Status404(_) => (String::from("Resource not found"), 404), + DependabotListAlertsForOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + DependabotListAlertsForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List Dependabot alerts for a repository](Dependabot::list_alerts_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotListAlertsForRepoError { - #[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("Bad Request")] @@ -291,106 +344,136 @@ pub enum DependabotListAlertsForRepoError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: DependabotListAlertsForRepoError) -> Self { + let (description, status_code) = match err { + DependabotListAlertsForRepoError::Status304 => (String::from("Not modified"), 304), + DependabotListAlertsForRepoError::Status400(_) => (String::from("Bad Request"), 400), + DependabotListAlertsForRepoError::Status403(_) => (String::from("Forbidden"), 403), + DependabotListAlertsForRepoError::Status404(_) => (String::from("Resource not found"), 404), + DependabotListAlertsForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + DependabotListAlertsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization secrets](Dependabot::list_org_secrets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotListOrgSecretsError { - #[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 }, } +impl From for AdapterError { + fn from(err: DependabotListOrgSecretsError) -> Self { + let (description, status_code) = match err { + DependabotListOrgSecretsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository secrets](Dependabot::list_repo_secrets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotListRepoSecretsError { - #[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 }, } +impl From for AdapterError { + fn from(err: DependabotListRepoSecretsError) -> Self { + let (description, status_code) = match err { + DependabotListRepoSecretsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List selected repositories for an organization secret](Dependabot::list_selected_repos_for_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotListSelectedReposForOrgSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: DependabotListSelectedReposForOrgSecretError) -> Self { + let (description, status_code) = match err { + DependabotListSelectedReposForOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove selected repository from an organization secret](Dependabot::remove_selected_repo_from_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotRemoveSelectedRepoFromOrgSecretError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Conflict when visibility type not set to selected")] Status409, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: DependabotRemoveSelectedRepoFromOrgSecretError) -> Self { + let (description, status_code) = match err { + DependabotRemoveSelectedRepoFromOrgSecretError::Status409 => (String::from("Conflict when visibility type not set to selected"), 409), + DependabotRemoveSelectedRepoFromOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set selected repositories for an organization secret](Dependabot::set_selected_repos_for_org_secret_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotSetSelectedReposForOrgSecretError { - #[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 }, } +impl From for AdapterError { + fn from(err: DependabotSetSelectedReposForOrgSecretError) -> Self { + let (description, status_code) = match err { + DependabotSetSelectedReposForOrgSecretError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a Dependabot alert](Dependabot::update_alert_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependabotUpdateAlertError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Forbidden")] @@ -405,6 +488,25 @@ pub enum DependabotUpdateAlertError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: DependabotUpdateAlertError) -> Self { + let (description, status_code) = match err { + DependabotUpdateAlertError::Status400(_) => (String::from("Bad Request"), 400), + DependabotUpdateAlertError::Status403(_) => (String::from("Forbidden"), 403), + DependabotUpdateAlertError::Status404(_) => (String::from("Resource not found"), 404), + DependabotUpdateAlertError::Status409(_) => (String::from("Conflict"), 409), + DependabotUpdateAlertError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + DependabotUpdateAlertError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List Dependabot alerts for an enterprise](Dependabot::list_alerts_for_enterprise_async()) endpoint. #[derive(Default, Serialize)] @@ -1357,7 +1459,7 @@ impl<'enc> From<&'enc PerPage> for DependabotListSelectedReposForOrgSecretParams } } -impl<'api, C: Client> Dependabot<'api, C> { +impl<'api, C: Client> Dependabot<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Add selected repository to an organization secret @@ -1371,19 +1473,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for add_selected_repo_to_org_secret](https://docs.github.com/rest/dependabot/secrets#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<(), DependabotAddSelectedRepoToOrgSecretError> { + pub async fn add_selected_repo_to_org_secret_async(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1395,8 +1497,8 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(DependabotAddSelectedRepoToOrgSecretError::Status409), - code => Err(DependabotAddSelectedRepoToOrgSecretError::Generic { code }), + 409 => Err(DependabotAddSelectedRepoToOrgSecretError::Status409.into()), + code => Err(DependabotAddSelectedRepoToOrgSecretError::Generic { code }.into()), } } } @@ -1415,7 +1517,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_selected_repo_to_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), DependabotAddSelectedRepoToOrgSecretError> { + pub fn add_selected_repo_to_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); @@ -1427,7 +1529,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1439,8 +1541,8 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(DependabotAddSelectedRepoToOrgSecretError::Status409), - code => Err(DependabotAddSelectedRepoToOrgSecretError::Generic { code }), + 409 => Err(DependabotAddSelectedRepoToOrgSecretError::Status409.into()), + code => Err(DependabotAddSelectedRepoToOrgSecretError::Generic { code }.into()), } } } @@ -1457,19 +1559,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for create_or_update_org_secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-an-organization-secret) /// /// --- - pub async fn create_or_update_org_secret_async(&self, org: &str, secret_name: &str, body: PutDependabotCreateOrUpdateOrgSecret) -> Result { + pub async fn create_or_update_org_secret_async(&self, org: &str, secret_name: &str, body: PutDependabotCreateOrUpdateOrgSecret) -> Result { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutDependabotCreateOrUpdateOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1481,8 +1583,8 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(DependabotCreateOrUpdateOrgSecretError::Status204), - code => Err(DependabotCreateOrUpdateOrgSecretError::Generic { code }), + 204 => Err(DependabotCreateOrUpdateOrgSecretError::Status204.into()), + code => Err(DependabotCreateOrUpdateOrgSecretError::Generic { code }.into()), } } } @@ -1500,19 +1602,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_org_secret(&self, org: &str, secret_name: &str, body: PutDependabotCreateOrUpdateOrgSecret) -> Result { + pub fn create_or_update_org_secret(&self, org: &str, secret_name: &str, body: PutDependabotCreateOrUpdateOrgSecret) -> Result { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutDependabotCreateOrUpdateOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1524,8 +1626,8 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(DependabotCreateOrUpdateOrgSecretError::Status204), - code => Err(DependabotCreateOrUpdateOrgSecretError::Generic { code }), + 204 => Err(DependabotCreateOrUpdateOrgSecretError::Status204.into()), + code => Err(DependabotCreateOrUpdateOrgSecretError::Generic { code }.into()), } } } @@ -1542,19 +1644,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for create_or_update_repo_secret](https://docs.github.com/rest/dependabot/secrets#create-or-update-a-repository-secret) /// /// --- - pub async fn create_or_update_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str, body: PutDependabotCreateOrUpdateRepoSecret) -> Result { + pub async fn create_or_update_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str, body: PutDependabotCreateOrUpdateRepoSecret) -> Result { let request_uri = format!("{}/repos/{}/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutDependabotCreateOrUpdateRepoSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1566,8 +1668,8 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(DependabotCreateOrUpdateRepoSecretError::Status204), - code => Err(DependabotCreateOrUpdateRepoSecretError::Generic { code }), + 204 => Err(DependabotCreateOrUpdateRepoSecretError::Status204.into()), + code => Err(DependabotCreateOrUpdateRepoSecretError::Generic { code }.into()), } } } @@ -1585,19 +1687,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_repo_secret(&self, owner: &str, repo: &str, secret_name: &str, body: PutDependabotCreateOrUpdateRepoSecret) -> Result { + pub fn create_or_update_repo_secret(&self, owner: &str, repo: &str, secret_name: &str, body: PutDependabotCreateOrUpdateRepoSecret) -> Result { let request_uri = format!("{}/repos/{}/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutDependabotCreateOrUpdateRepoSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1609,8 +1711,8 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(DependabotCreateOrUpdateRepoSecretError::Status204), - code => Err(DependabotCreateOrUpdateRepoSecretError::Generic { code }), + 204 => Err(DependabotCreateOrUpdateRepoSecretError::Status204.into()), + code => Err(DependabotCreateOrUpdateRepoSecretError::Generic { code }.into()), } } } @@ -1626,19 +1728,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for delete_org_secret](https://docs.github.com/rest/dependabot/secrets#delete-an-organization-secret) /// /// --- - pub async fn delete_org_secret_async(&self, org: &str, secret_name: &str) -> Result<(), DependabotDeleteOrgSecretError> { + pub async fn delete_org_secret_async(&self, org: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1650,7 +1752,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(DependabotDeleteOrgSecretError::Generic { code }), + code => Err(DependabotDeleteOrgSecretError::Generic { code }.into()), } } } @@ -1667,7 +1769,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_org_secret(&self, org: &str, secret_name: &str) -> Result<(), DependabotDeleteOrgSecretError> { + pub fn delete_org_secret(&self, org: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); @@ -1679,7 +1781,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1691,7 +1793,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(DependabotDeleteOrgSecretError::Generic { code }), + code => Err(DependabotDeleteOrgSecretError::Generic { code }.into()), } } } @@ -1707,19 +1809,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for delete_repo_secret](https://docs.github.com/rest/dependabot/secrets#delete-a-repository-secret) /// /// --- - pub async fn delete_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), DependabotDeleteRepoSecretError> { + pub async fn delete_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1731,7 +1833,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(DependabotDeleteRepoSecretError::Generic { code }), + code => Err(DependabotDeleteRepoSecretError::Generic { code }.into()), } } } @@ -1748,7 +1850,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), DependabotDeleteRepoSecretError> { + pub fn delete_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); @@ -1760,7 +1862,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1772,7 +1874,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(DependabotDeleteRepoSecretError::Generic { code }), + code => Err(DependabotDeleteRepoSecretError::Generic { code }.into()), } } } @@ -1786,19 +1888,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for get_alert](https://docs.github.com/rest/dependabot/alerts#get-a-dependabot-alert) /// /// --- - pub async fn get_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { + pub async fn get_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { let request_uri = format!("{}/repos/{}/{}/dependabot/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1810,10 +1912,10 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(DependabotGetAlertError::Status304), - 403 => Err(DependabotGetAlertError::Status403(github_response.to_json_async().await?)), - 404 => Err(DependabotGetAlertError::Status404(github_response.to_json_async().await?)), - code => Err(DependabotGetAlertError::Generic { code }), + 304 => Err(DependabotGetAlertError::Status304.into()), + 403 => Err(DependabotGetAlertError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(DependabotGetAlertError::Status404(github_response.to_json_async().await?).into()), + code => Err(DependabotGetAlertError::Generic { code }.into()), } } } @@ -1828,7 +1930,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { + pub fn get_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { let request_uri = format!("{}/repos/{}/{}/dependabot/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); @@ -1840,7 +1942,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1852,10 +1954,10 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(DependabotGetAlertError::Status304), - 403 => Err(DependabotGetAlertError::Status403(github_response.to_json()?)), - 404 => Err(DependabotGetAlertError::Status404(github_response.to_json()?)), - code => Err(DependabotGetAlertError::Generic { code }), + 304 => Err(DependabotGetAlertError::Status304.into()), + 403 => Err(DependabotGetAlertError::Status403(github_response.to_json()?).into()), + 404 => Err(DependabotGetAlertError::Status404(github_response.to_json()?).into()), + code => Err(DependabotGetAlertError::Generic { code }.into()), } } } @@ -1872,19 +1974,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for get_org_public_key](https://docs.github.com/rest/dependabot/secrets#get-an-organization-public-key) /// /// --- - pub async fn get_org_public_key_async(&self, org: &str) -> Result { + pub async fn get_org_public_key_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/dependabot/secrets/public-key", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1896,7 +1998,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(DependabotGetOrgPublicKeyError::Generic { code }), + code => Err(DependabotGetOrgPublicKeyError::Generic { code }.into()), } } } @@ -1914,7 +2016,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_public_key(&self, org: &str) -> Result { + pub fn get_org_public_key(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/dependabot/secrets/public-key", super::GITHUB_BASE_API_URL, org); @@ -1926,7 +2028,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1938,7 +2040,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(DependabotGetOrgPublicKeyError::Generic { code }), + code => Err(DependabotGetOrgPublicKeyError::Generic { code }.into()), } } } @@ -1954,19 +2056,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for get_org_secret](https://docs.github.com/rest/dependabot/secrets#get-an-organization-secret) /// /// --- - pub async fn get_org_secret_async(&self, org: &str, secret_name: &str) -> Result { + pub async fn get_org_secret_async(&self, org: &str, secret_name: &str) -> Result { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1978,7 +2080,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(DependabotGetOrgSecretError::Generic { code }), + code => Err(DependabotGetOrgSecretError::Generic { code }.into()), } } } @@ -1995,7 +2097,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_secret(&self, org: &str, secret_name: &str) -> Result { + pub fn get_org_secret(&self, org: &str, secret_name: &str) -> Result { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, org, secret_name); @@ -2007,7 +2109,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2019,7 +2121,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(DependabotGetOrgSecretError::Generic { code }), + code => Err(DependabotGetOrgSecretError::Generic { code }.into()), } } } @@ -2037,19 +2139,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for get_repo_public_key](https://docs.github.com/rest/dependabot/secrets#get-a-repository-public-key) /// /// --- - pub async fn get_repo_public_key_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_repo_public_key_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/dependabot/secrets/public-key", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2061,7 +2163,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(DependabotGetRepoPublicKeyError::Generic { code }), + code => Err(DependabotGetRepoPublicKeyError::Generic { code }.into()), } } } @@ -2080,7 +2182,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_public_key(&self, owner: &str, repo: &str) -> Result { + pub fn get_repo_public_key(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/dependabot/secrets/public-key", super::GITHUB_BASE_API_URL, owner, repo); @@ -2092,7 +2194,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2104,7 +2206,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(DependabotGetRepoPublicKeyError::Generic { code }), + code => Err(DependabotGetRepoPublicKeyError::Generic { code }.into()), } } } @@ -2120,19 +2222,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for get_repo_secret](https://docs.github.com/rest/dependabot/secrets#get-a-repository-secret) /// /// --- - pub async fn get_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result { + pub async fn get_repo_secret_async(&self, owner: &str, repo: &str, secret_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2144,7 +2246,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(DependabotGetRepoSecretError::Generic { code }), + code => Err(DependabotGetRepoSecretError::Generic { code }.into()), } } } @@ -2161,7 +2263,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result { + pub fn get_repo_secret(&self, owner: &str, repo: &str, secret_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/dependabot/secrets/{}", super::GITHUB_BASE_API_URL, owner, repo, secret_name); @@ -2173,7 +2275,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2185,7 +2287,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(DependabotGetRepoSecretError::Generic { code }), + code => Err(DependabotGetRepoSecretError::Generic { code }.into()), } } } @@ -2205,7 +2307,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for list_alerts_for_enterprise](https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-an-enterprise) /// /// --- - pub async fn list_alerts_for_enterprise_async(&self, enterprise: &str, query_params: Option>>) -> Result, DependabotListAlertsForEnterpriseError> { + pub async fn list_alerts_for_enterprise_async(&self, enterprise: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/enterprises/{}/dependabot/alerts", super::GITHUB_BASE_API_URL, enterprise); @@ -2216,12 +2318,12 @@ impl<'api, C: Client> Dependabot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2233,11 +2335,11 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(DependabotListAlertsForEnterpriseError::Status304), - 403 => Err(DependabotListAlertsForEnterpriseError::Status403(github_response.to_json_async().await?)), - 404 => Err(DependabotListAlertsForEnterpriseError::Status404(github_response.to_json_async().await?)), - 422 => Err(DependabotListAlertsForEnterpriseError::Status422(github_response.to_json_async().await?)), - code => Err(DependabotListAlertsForEnterpriseError::Generic { code }), + 304 => Err(DependabotListAlertsForEnterpriseError::Status304.into()), + 403 => Err(DependabotListAlertsForEnterpriseError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(DependabotListAlertsForEnterpriseError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(DependabotListAlertsForEnterpriseError::Status422(github_response.to_json_async().await?).into()), + code => Err(DependabotListAlertsForEnterpriseError::Generic { code }.into()), } } } @@ -2258,7 +2360,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_alerts_for_enterprise(&self, enterprise: &str, query_params: Option>>) -> Result, DependabotListAlertsForEnterpriseError> { + pub fn list_alerts_for_enterprise(&self, enterprise: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/enterprises/{}/dependabot/alerts", super::GITHUB_BASE_API_URL, enterprise); @@ -2275,7 +2377,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2287,11 +2389,11 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(DependabotListAlertsForEnterpriseError::Status304), - 403 => Err(DependabotListAlertsForEnterpriseError::Status403(github_response.to_json()?)), - 404 => Err(DependabotListAlertsForEnterpriseError::Status404(github_response.to_json()?)), - 422 => Err(DependabotListAlertsForEnterpriseError::Status422(github_response.to_json()?)), - code => Err(DependabotListAlertsForEnterpriseError::Generic { code }), + 304 => Err(DependabotListAlertsForEnterpriseError::Status304.into()), + 403 => Err(DependabotListAlertsForEnterpriseError::Status403(github_response.to_json()?).into()), + 404 => Err(DependabotListAlertsForEnterpriseError::Status404(github_response.to_json()?).into()), + 422 => Err(DependabotListAlertsForEnterpriseError::Status422(github_response.to_json()?).into()), + code => Err(DependabotListAlertsForEnterpriseError::Generic { code }.into()), } } } @@ -2309,7 +2411,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for list_alerts_for_org](https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-an-organization) /// /// --- - pub async fn list_alerts_for_org_async(&self, org: &str, query_params: Option>>) -> Result, DependabotListAlertsForOrgError> { + pub async fn list_alerts_for_org_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/dependabot/alerts", super::GITHUB_BASE_API_URL, org); @@ -2320,12 +2422,12 @@ impl<'api, C: Client> Dependabot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2337,12 +2439,12 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(DependabotListAlertsForOrgError::Status304), - 400 => Err(DependabotListAlertsForOrgError::Status400(github_response.to_json_async().await?)), - 403 => Err(DependabotListAlertsForOrgError::Status403(github_response.to_json_async().await?)), - 404 => Err(DependabotListAlertsForOrgError::Status404(github_response.to_json_async().await?)), - 422 => Err(DependabotListAlertsForOrgError::Status422(github_response.to_json_async().await?)), - code => Err(DependabotListAlertsForOrgError::Generic { code }), + 304 => Err(DependabotListAlertsForOrgError::Status304.into()), + 400 => Err(DependabotListAlertsForOrgError::Status400(github_response.to_json_async().await?).into()), + 403 => Err(DependabotListAlertsForOrgError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(DependabotListAlertsForOrgError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(DependabotListAlertsForOrgError::Status422(github_response.to_json_async().await?).into()), + code => Err(DependabotListAlertsForOrgError::Generic { code }.into()), } } } @@ -2361,7 +2463,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_alerts_for_org(&self, org: &str, query_params: Option>>) -> Result, DependabotListAlertsForOrgError> { + pub fn list_alerts_for_org(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/dependabot/alerts", super::GITHUB_BASE_API_URL, org); @@ -2378,7 +2480,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2390,12 +2492,12 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(DependabotListAlertsForOrgError::Status304), - 400 => Err(DependabotListAlertsForOrgError::Status400(github_response.to_json()?)), - 403 => Err(DependabotListAlertsForOrgError::Status403(github_response.to_json()?)), - 404 => Err(DependabotListAlertsForOrgError::Status404(github_response.to_json()?)), - 422 => Err(DependabotListAlertsForOrgError::Status422(github_response.to_json()?)), - code => Err(DependabotListAlertsForOrgError::Generic { code }), + 304 => Err(DependabotListAlertsForOrgError::Status304.into()), + 400 => Err(DependabotListAlertsForOrgError::Status400(github_response.to_json()?).into()), + 403 => Err(DependabotListAlertsForOrgError::Status403(github_response.to_json()?).into()), + 404 => Err(DependabotListAlertsForOrgError::Status404(github_response.to_json()?).into()), + 422 => Err(DependabotListAlertsForOrgError::Status422(github_response.to_json()?).into()), + code => Err(DependabotListAlertsForOrgError::Generic { code }.into()), } } } @@ -2409,7 +2511,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for list_alerts_for_repo](https://docs.github.com/rest/dependabot/alerts#list-dependabot-alerts-for-a-repository) /// /// --- - pub async fn list_alerts_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, DependabotListAlertsForRepoError> { + pub async fn list_alerts_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/dependabot/alerts", super::GITHUB_BASE_API_URL, owner, repo); @@ -2420,12 +2522,12 @@ impl<'api, C: Client> Dependabot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2437,12 +2539,12 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(DependabotListAlertsForRepoError::Status304), - 400 => Err(DependabotListAlertsForRepoError::Status400(github_response.to_json_async().await?)), - 403 => Err(DependabotListAlertsForRepoError::Status403(github_response.to_json_async().await?)), - 404 => Err(DependabotListAlertsForRepoError::Status404(github_response.to_json_async().await?)), - 422 => Err(DependabotListAlertsForRepoError::Status422(github_response.to_json_async().await?)), - code => Err(DependabotListAlertsForRepoError::Generic { code }), + 304 => Err(DependabotListAlertsForRepoError::Status304.into()), + 400 => Err(DependabotListAlertsForRepoError::Status400(github_response.to_json_async().await?).into()), + 403 => Err(DependabotListAlertsForRepoError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(DependabotListAlertsForRepoError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(DependabotListAlertsForRepoError::Status422(github_response.to_json_async().await?).into()), + code => Err(DependabotListAlertsForRepoError::Generic { code }.into()), } } } @@ -2457,7 +2559,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_alerts_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, DependabotListAlertsForRepoError> { + pub fn list_alerts_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/dependabot/alerts", super::GITHUB_BASE_API_URL, owner, repo); @@ -2474,7 +2576,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2486,12 +2588,12 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(DependabotListAlertsForRepoError::Status304), - 400 => Err(DependabotListAlertsForRepoError::Status400(github_response.to_json()?)), - 403 => Err(DependabotListAlertsForRepoError::Status403(github_response.to_json()?)), - 404 => Err(DependabotListAlertsForRepoError::Status404(github_response.to_json()?)), - 422 => Err(DependabotListAlertsForRepoError::Status422(github_response.to_json()?)), - code => Err(DependabotListAlertsForRepoError::Generic { code }), + 304 => Err(DependabotListAlertsForRepoError::Status304.into()), + 400 => Err(DependabotListAlertsForRepoError::Status400(github_response.to_json()?).into()), + 403 => Err(DependabotListAlertsForRepoError::Status403(github_response.to_json()?).into()), + 404 => Err(DependabotListAlertsForRepoError::Status404(github_response.to_json()?).into()), + 422 => Err(DependabotListAlertsForRepoError::Status422(github_response.to_json()?).into()), + code => Err(DependabotListAlertsForRepoError::Generic { code }.into()), } } } @@ -2508,7 +2610,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for list_org_secrets](https://docs.github.com/rest/dependabot/secrets#list-organization-secrets) /// /// --- - pub async fn list_org_secrets_async(&self, org: &str, query_params: Option>) -> Result { + pub async fn list_org_secrets_async(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/dependabot/secrets", super::GITHUB_BASE_API_URL, org); @@ -2519,12 +2621,12 @@ impl<'api, C: Client> Dependabot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2536,7 +2638,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(DependabotListOrgSecretsError::Generic { code }), + code => Err(DependabotListOrgSecretsError::Generic { code }.into()), } } } @@ -2554,7 +2656,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_org_secrets(&self, org: &str, query_params: Option>) -> Result { + pub fn list_org_secrets(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/dependabot/secrets", super::GITHUB_BASE_API_URL, org); @@ -2571,7 +2673,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2583,7 +2685,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(DependabotListOrgSecretsError::Generic { code }), + code => Err(DependabotListOrgSecretsError::Generic { code }.into()), } } } @@ -2600,7 +2702,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for list_repo_secrets](https://docs.github.com/rest/dependabot/secrets#list-repository-secrets) /// /// --- - pub async fn list_repo_secrets_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub async fn list_repo_secrets_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/dependabot/secrets", super::GITHUB_BASE_API_URL, owner, repo); @@ -2611,12 +2713,12 @@ impl<'api, C: Client> Dependabot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2628,7 +2730,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(DependabotListRepoSecretsError::Generic { code }), + code => Err(DependabotListRepoSecretsError::Generic { code }.into()), } } } @@ -2646,7 +2748,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repo_secrets(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub fn list_repo_secrets(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/dependabot/secrets", super::GITHUB_BASE_API_URL, owner, repo); @@ -2663,7 +2765,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2675,7 +2777,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(DependabotListRepoSecretsError::Generic { code }), + code => Err(DependabotListRepoSecretsError::Generic { code }.into()), } } } @@ -2692,7 +2794,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for list_selected_repos_for_org_secret](https://docs.github.com/rest/dependabot/secrets#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/{}/dependabot/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); @@ -2703,12 +2805,12 @@ impl<'api, C: Client> Dependabot<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2720,7 +2822,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(DependabotListSelectedReposForOrgSecretError::Generic { code }), + code => Err(DependabotListSelectedReposForOrgSecretError::Generic { code }.into()), } } } @@ -2738,7 +2840,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[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/{}/dependabot/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); @@ -2755,7 +2857,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2767,7 +2869,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(DependabotListSelectedReposForOrgSecretError::Generic { code }), + code => Err(DependabotListSelectedReposForOrgSecretError::Generic { code }.into()), } } } @@ -2785,19 +2887,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for remove_selected_repo_from_org_secret](https://docs.github.com/rest/dependabot/secrets#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<(), DependabotRemoveSelectedRepoFromOrgSecretError> { + pub async fn remove_selected_repo_from_org_secret_async(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2809,8 +2911,8 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(DependabotRemoveSelectedRepoFromOrgSecretError::Status409), - code => Err(DependabotRemoveSelectedRepoFromOrgSecretError::Generic { code }), + 409 => Err(DependabotRemoveSelectedRepoFromOrgSecretError::Status409.into()), + code => Err(DependabotRemoveSelectedRepoFromOrgSecretError::Generic { code }.into()), } } } @@ -2829,7 +2931,7 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_selected_repo_from_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), DependabotRemoveSelectedRepoFromOrgSecretError> { + pub fn remove_selected_repo_from_org_secret(&self, org: &str, secret_name: &str, repository_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}/repositories/{}", super::GITHUB_BASE_API_URL, org, secret_name, repository_id); @@ -2841,7 +2943,7 @@ impl<'api, C: Client> Dependabot<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2853,8 +2955,8 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(DependabotRemoveSelectedRepoFromOrgSecretError::Status409), - code => Err(DependabotRemoveSelectedRepoFromOrgSecretError::Generic { code }), + 409 => Err(DependabotRemoveSelectedRepoFromOrgSecretError::Status409.into()), + code => Err(DependabotRemoveSelectedRepoFromOrgSecretError::Generic { code }.into()), } } } @@ -2872,19 +2974,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for set_selected_repos_for_org_secret](https://docs.github.com/rest/dependabot/secrets#set-selected-repositories-for-an-organization-secret) /// /// --- - pub async fn set_selected_repos_for_org_secret_async(&self, org: &str, secret_name: &str, body: PutDependabotSetSelectedReposForOrgSecret) -> Result<(), DependabotSetSelectedReposForOrgSecretError> { + pub async fn set_selected_repos_for_org_secret_async(&self, org: &str, secret_name: &str, body: PutDependabotSetSelectedReposForOrgSecret) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutDependabotSetSelectedReposForOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2896,7 +2998,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(DependabotSetSelectedReposForOrgSecretError::Generic { code }), + code => Err(DependabotSetSelectedReposForOrgSecretError::Generic { code }.into()), } } } @@ -2915,19 +3017,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_selected_repos_for_org_secret(&self, org: &str, secret_name: &str, body: PutDependabotSetSelectedReposForOrgSecret) -> Result<(), DependabotSetSelectedReposForOrgSecretError> { + pub fn set_selected_repos_for_org_secret(&self, org: &str, secret_name: &str, body: PutDependabotSetSelectedReposForOrgSecret) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/dependabot/secrets/{}/repositories", super::GITHUB_BASE_API_URL, org, secret_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutDependabotSetSelectedReposForOrgSecret::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2939,7 +3041,7 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(DependabotSetSelectedReposForOrgSecretError::Generic { code }), + code => Err(DependabotSetSelectedReposForOrgSecretError::Generic { code }.into()), } } } @@ -2955,19 +3057,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// [GitHub API docs for update_alert](https://docs.github.com/rest/dependabot/alerts#update-a-dependabot-alert) /// /// --- - pub async fn update_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchDependabotUpdateAlert) -> Result { + pub async fn update_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchDependabotUpdateAlert) -> Result { let request_uri = format!("{}/repos/{}/{}/dependabot/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchDependabotUpdateAlert::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2979,12 +3081,12 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(DependabotUpdateAlertError::Status400(github_response.to_json_async().await?)), - 403 => Err(DependabotUpdateAlertError::Status403(github_response.to_json_async().await?)), - 404 => Err(DependabotUpdateAlertError::Status404(github_response.to_json_async().await?)), - 409 => Err(DependabotUpdateAlertError::Status409(github_response.to_json_async().await?)), - 422 => Err(DependabotUpdateAlertError::Status422(github_response.to_json_async().await?)), - code => Err(DependabotUpdateAlertError::Generic { code }), + 400 => Err(DependabotUpdateAlertError::Status400(github_response.to_json_async().await?).into()), + 403 => Err(DependabotUpdateAlertError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(DependabotUpdateAlertError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(DependabotUpdateAlertError::Status409(github_response.to_json_async().await?).into()), + 422 => Err(DependabotUpdateAlertError::Status422(github_response.to_json_async().await?).into()), + code => Err(DependabotUpdateAlertError::Generic { code }.into()), } } } @@ -3001,19 +3103,19 @@ impl<'api, C: Client> Dependabot<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchDependabotUpdateAlert) -> Result { + pub fn update_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchDependabotUpdateAlert) -> Result { let request_uri = format!("{}/repos/{}/{}/dependabot/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchDependabotUpdateAlert::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3025,12 +3127,12 @@ impl<'api, C: Client> Dependabot<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(DependabotUpdateAlertError::Status400(github_response.to_json()?)), - 403 => Err(DependabotUpdateAlertError::Status403(github_response.to_json()?)), - 404 => Err(DependabotUpdateAlertError::Status404(github_response.to_json()?)), - 409 => Err(DependabotUpdateAlertError::Status409(github_response.to_json()?)), - 422 => Err(DependabotUpdateAlertError::Status422(github_response.to_json()?)), - code => Err(DependabotUpdateAlertError::Generic { code }), + 400 => Err(DependabotUpdateAlertError::Status400(github_response.to_json()?).into()), + 403 => Err(DependabotUpdateAlertError::Status403(github_response.to_json()?).into()), + 404 => Err(DependabotUpdateAlertError::Status404(github_response.to_json()?).into()), + 409 => Err(DependabotUpdateAlertError::Status409(github_response.to_json()?).into()), + 422 => Err(DependabotUpdateAlertError::Status422(github_response.to_json()?).into()), + code => Err(DependabotUpdateAlertError::Generic { code }.into()), } } } diff --git a/src/endpoints/dependency_graph.rs b/src/endpoints/dependency_graph.rs index 190d039..6a4c251 100644 --- a/src/endpoints/dependency_graph.rs +++ b/src/endpoints/dependency_graph.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,44 +22,38 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct DependencyGraph<'api, C: Client> { +pub struct DependencyGraph<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> DependencyGraph { +pub fn new(client: &C) -> DependencyGraph where AdapterError: From<::Err> { DependencyGraph { client } } /// Errors for the [Create a snapshot of dependencies for a repository](DependencyGraph::create_repository_snapshot_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependencyGraphCreateRepositorySnapshotError { - #[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 }, } +impl From for AdapterError { + fn from(err: DependencyGraphCreateRepositorySnapshotError) -> Self { + let (description, status_code) = match err { + DependencyGraphCreateRepositorySnapshotError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a diff of the dependencies between commits](DependencyGraph::diff_range_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependencyGraphDiffRangeError { - #[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("Response if GitHub Advanced Security is not enabled for this repository")] @@ -68,19 +62,25 @@ pub enum DependencyGraphDiffRangeError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: DependencyGraphDiffRangeError) -> Self { + let (description, status_code) = match err { + DependencyGraphDiffRangeError::Status404(_) => (String::from("Resource not found"), 404), + DependencyGraphDiffRangeError::Status403(_) => (String::from("Response if GitHub Advanced Security is not enabled for this repository"), 403), + DependencyGraphDiffRangeError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Export a software bill of materials (SBOM) for a repository.](DependencyGraph::export_sbom_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum DependencyGraphExportSbomError { - #[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("Forbidden")] @@ -89,6 +89,22 @@ pub enum DependencyGraphExportSbomError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: DependencyGraphExportSbomError) -> Self { + let (description, status_code) = match err { + DependencyGraphExportSbomError::Status404(_) => (String::from("Resource not found"), 404), + DependencyGraphExportSbomError::Status403(_) => (String::from("Forbidden"), 403), + DependencyGraphExportSbomError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [Get a diff of the dependencies between commits](DependencyGraph::diff_range_async()) endpoint. #[derive(Default, Serialize)] @@ -111,7 +127,7 @@ impl<'req> DependencyGraphDiffRangeParams<'req> { } -impl<'api, C: Client> DependencyGraph<'api, C> { +impl<'api, C: Client> DependencyGraph<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Create a snapshot of dependencies for a repository @@ -125,19 +141,19 @@ impl<'api, C: Client> DependencyGraph<'api, C> { /// [GitHub API docs for create_repository_snapshot](https://docs.github.com/rest/dependency-graph/dependency-submission#create-a-snapshot-of-dependencies-for-a-repository) /// /// --- - pub async fn create_repository_snapshot_async(&self, owner: &str, repo: &str, body: PostDependencyGraphCreateRepositorySnapshot) -> Result { + pub async fn create_repository_snapshot_async(&self, owner: &str, repo: &str, body: PostDependencyGraphCreateRepositorySnapshot) -> Result { let request_uri = format!("{}/repos/{}/{}/dependency-graph/snapshots", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostDependencyGraphCreateRepositorySnapshot::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -149,7 +165,7 @@ impl<'api, C: Client> DependencyGraph<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(DependencyGraphCreateRepositorySnapshotError::Generic { code }), + code => Err(DependencyGraphCreateRepositorySnapshotError::Generic { code }.into()), } } } @@ -168,19 +184,19 @@ impl<'api, C: Client> DependencyGraph<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_repository_snapshot(&self, owner: &str, repo: &str, body: PostDependencyGraphCreateRepositorySnapshot) -> Result { + pub fn create_repository_snapshot(&self, owner: &str, repo: &str, body: PostDependencyGraphCreateRepositorySnapshot) -> Result { let request_uri = format!("{}/repos/{}/{}/dependency-graph/snapshots", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostDependencyGraphCreateRepositorySnapshot::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -192,7 +208,7 @@ impl<'api, C: Client> DependencyGraph<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(DependencyGraphCreateRepositorySnapshotError::Generic { code }), + code => Err(DependencyGraphCreateRepositorySnapshotError::Generic { code }.into()), } } } @@ -206,7 +222,7 @@ impl<'api, C: Client> DependencyGraph<'api, C> { /// [GitHub API docs for diff_range](https://docs.github.com/rest/dependency-graph/dependency-review#get-a-diff-of-the-dependencies-between-commits) /// /// --- - pub async fn diff_range_async(&self, owner: &str, repo: &str, basehead: &str, query_params: Option>>) -> Result { + pub async fn diff_range_async(&self, owner: &str, repo: &str, basehead: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/dependency-graph/compare/{}", super::GITHUB_BASE_API_URL, owner, repo, basehead); @@ -217,12 +233,12 @@ impl<'api, C: Client> DependencyGraph<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -234,9 +250,9 @@ impl<'api, C: Client> DependencyGraph<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(DependencyGraphDiffRangeError::Status404(github_response.to_json_async().await?)), - 403 => Err(DependencyGraphDiffRangeError::Status403(github_response.to_json_async().await?)), - code => Err(DependencyGraphDiffRangeError::Generic { code }), + 404 => Err(DependencyGraphDiffRangeError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(DependencyGraphDiffRangeError::Status403(github_response.to_json_async().await?).into()), + code => Err(DependencyGraphDiffRangeError::Generic { code }.into()), } } } @@ -251,7 +267,7 @@ impl<'api, C: Client> DependencyGraph<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn diff_range(&self, owner: &str, repo: &str, basehead: &str, query_params: Option>>) -> Result { + pub fn diff_range(&self, owner: &str, repo: &str, basehead: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/dependency-graph/compare/{}", super::GITHUB_BASE_API_URL, owner, repo, basehead); @@ -268,7 +284,7 @@ impl<'api, C: Client> DependencyGraph<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -280,9 +296,9 @@ impl<'api, C: Client> DependencyGraph<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(DependencyGraphDiffRangeError::Status404(github_response.to_json()?)), - 403 => Err(DependencyGraphDiffRangeError::Status403(github_response.to_json()?)), - code => Err(DependencyGraphDiffRangeError::Generic { code }), + 404 => Err(DependencyGraphDiffRangeError::Status404(github_response.to_json()?).into()), + 403 => Err(DependencyGraphDiffRangeError::Status403(github_response.to_json()?).into()), + code => Err(DependencyGraphDiffRangeError::Generic { code }.into()), } } } @@ -296,19 +312,19 @@ impl<'api, C: Client> DependencyGraph<'api, C> { /// [GitHub API docs for export_sbom](https://docs.github.com/rest/dependency-graph/sboms#export-a-software-bill-of-materials-sbom-for-a-repository) /// /// --- - pub async fn export_sbom_async(&self, owner: &str, repo: &str) -> Result { + pub async fn export_sbom_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/dependency-graph/sbom", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -320,9 +336,9 @@ impl<'api, C: Client> DependencyGraph<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(DependencyGraphExportSbomError::Status404(github_response.to_json_async().await?)), - 403 => Err(DependencyGraphExportSbomError::Status403(github_response.to_json_async().await?)), - code => Err(DependencyGraphExportSbomError::Generic { code }), + 404 => Err(DependencyGraphExportSbomError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(DependencyGraphExportSbomError::Status403(github_response.to_json_async().await?).into()), + code => Err(DependencyGraphExportSbomError::Generic { code }.into()), } } } @@ -337,7 +353,7 @@ impl<'api, C: Client> DependencyGraph<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn export_sbom(&self, owner: &str, repo: &str) -> Result { + pub fn export_sbom(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/dependency-graph/sbom", super::GITHUB_BASE_API_URL, owner, repo); @@ -349,7 +365,7 @@ impl<'api, C: Client> DependencyGraph<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -361,9 +377,9 @@ impl<'api, C: Client> DependencyGraph<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(DependencyGraphExportSbomError::Status404(github_response.to_json()?)), - 403 => Err(DependencyGraphExportSbomError::Status403(github_response.to_json()?)), - code => Err(DependencyGraphExportSbomError::Generic { code }), + 404 => Err(DependencyGraphExportSbomError::Status404(github_response.to_json()?).into()), + 403 => Err(DependencyGraphExportSbomError::Status403(github_response.to_json()?).into()), + code => Err(DependencyGraphExportSbomError::Generic { code }.into()), } } } diff --git a/src/endpoints/emojis.rs b/src/endpoints/emojis.rs index d7c06be..a8c6103 100644 --- a/src/endpoints/emojis.rs +++ b/src/endpoints/emojis.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,36 +22,41 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Emojis<'api, C: Client> { +pub struct Emojis<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Emojis { +pub fn new(client: &C) -> Emojis where AdapterError: From<::Err> { Emojis { client } } /// Errors for the [Get emojis](Emojis::get_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum EmojisGetError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: EmojisGetError) -> Self { + let (description, status_code) = match err { + EmojisGetError::Status304 => (String::from("Not modified"), 304), + EmojisGetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + -impl<'api, C: Client> Emojis<'api, C> { +impl<'api, C: Client> Emojis<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Get emojis @@ -61,19 +66,19 @@ impl<'api, C: Client> Emojis<'api, C> { /// [GitHub API docs for get](https://docs.github.com/rest/emojis/emojis#get-emojis) /// /// --- - pub async fn get_async(&self) -> Result, EmojisGetError> { + pub async fn get_async(&self) -> Result, AdapterError> { let request_uri = format!("{}/emojis", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -85,8 +90,8 @@ impl<'api, C: Client> Emojis<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(EmojisGetError::Status304), - code => Err(EmojisGetError::Generic { code }), + 304 => Err(EmojisGetError::Status304.into()), + code => Err(EmojisGetError::Generic { code }.into()), } } } @@ -101,7 +106,7 @@ impl<'api, C: Client> Emojis<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get(&self) -> Result, EmojisGetError> { + pub fn get(&self) -> Result, AdapterError> { let request_uri = format!("{}/emojis", super::GITHUB_BASE_API_URL); @@ -113,7 +118,7 @@ impl<'api, C: Client> Emojis<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -125,8 +130,8 @@ impl<'api, C: Client> Emojis<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(EmojisGetError::Status304), - code => Err(EmojisGetError::Generic { code }), + 304 => Err(EmojisGetError::Status304.into()), + code => Err(EmojisGetError::Generic { code }.into()), } } } diff --git a/src/endpoints/gists.rs b/src/endpoints/gists.rs index 805b1f4..8bf5353 100644 --- a/src/endpoints/gists.rs +++ b/src/endpoints/gists.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Gists<'api, C: Client> { +pub struct Gists<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Gists { +pub fn new(client: &C) -> Gists where AdapterError: From<::Err> { Gists { client } } /// Errors for the [Check if a gist is starred](Gists::check_is_starred_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsCheckIsStarredError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if gist is not starred")] Status404(HashMap), #[error("Not modified")] @@ -53,19 +43,26 @@ pub enum GistsCheckIsStarredError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsCheckIsStarredError) -> Self { + let (description, status_code) = match err { + GistsCheckIsStarredError::Status404(_) => (String::from("Not Found if gist is not starred"), 404), + GistsCheckIsStarredError::Status304 => (String::from("Not modified"), 304), + GistsCheckIsStarredError::Status403(_) => (String::from("Forbidden"), 403), + GistsCheckIsStarredError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a gist](Gists::create_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsCreateError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -78,19 +75,27 @@ pub enum GistsCreateError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsCreateError) -> Self { + let (description, status_code) = match err { + GistsCreateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GistsCreateError::Status304 => (String::from("Not modified"), 304), + GistsCreateError::Status404(_) => (String::from("Resource not found"), 404), + GistsCreateError::Status403(_) => (String::from("Forbidden"), 403), + GistsCreateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a gist comment](Gists::create_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsCreateCommentError { - #[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("Resource not found")] @@ -101,19 +106,26 @@ pub enum GistsCreateCommentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsCreateCommentError) -> Self { + let (description, status_code) = match err { + GistsCreateCommentError::Status304 => (String::from("Not modified"), 304), + GistsCreateCommentError::Status404(_) => (String::from("Resource not found"), 404), + GistsCreateCommentError::Status403(_) => (String::from("Forbidden"), 403), + GistsCreateCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a gist](Gists::delete_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsDeleteError { - #[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("Not modified")] @@ -124,19 +136,26 @@ pub enum GistsDeleteError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsDeleteError) -> Self { + let (description, status_code) = match err { + GistsDeleteError::Status404(_) => (String::from("Resource not found"), 404), + GistsDeleteError::Status304 => (String::from("Not modified"), 304), + GistsDeleteError::Status403(_) => (String::from("Forbidden"), 403), + GistsDeleteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a gist comment](Gists::delete_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsDeleteCommentError { - #[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("Resource not found")] @@ -147,19 +166,26 @@ pub enum GistsDeleteCommentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsDeleteCommentError) -> Self { + let (description, status_code) = match err { + GistsDeleteCommentError::Status304 => (String::from("Not modified"), 304), + GistsDeleteCommentError::Status404(_) => (String::from("Resource not found"), 404), + GistsDeleteCommentError::Status403(_) => (String::from("Forbidden"), 403), + GistsDeleteCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Fork a gist](Gists::fork_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsForkError { - #[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, or the endpoint has been spammed.")] @@ -172,19 +198,27 @@ pub enum GistsForkError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsForkError) -> Self { + let (description, status_code) = match err { + GistsForkError::Status404(_) => (String::from("Resource not found"), 404), + GistsForkError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GistsForkError::Status304 => (String::from("Not modified"), 304), + GistsForkError::Status403(_) => (String::from("Forbidden"), 403), + GistsForkError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a gist](Gists::get_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsGetError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden Gist")] Status403(GetGistsGetCommentResponse403), #[error("Resource not found")] @@ -195,19 +229,26 @@ pub enum GistsGetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsGetError) -> Self { + let (description, status_code) = match err { + GistsGetError::Status403(_) => (String::from("Forbidden Gist"), 403), + GistsGetError::Status404(_) => (String::from("Resource not found"), 404), + GistsGetError::Status304 => (String::from("Not modified"), 304), + GistsGetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a gist comment](Gists::get_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsGetCommentError { - #[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("Resource not found")] @@ -218,19 +259,26 @@ pub enum GistsGetCommentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsGetCommentError) -> Self { + let (description, status_code) = match err { + GistsGetCommentError::Status304 => (String::from("Not modified"), 304), + GistsGetCommentError::Status404(_) => (String::from("Resource not found"), 404), + GistsGetCommentError::Status403(_) => (String::from("Forbidden Gist"), 403), + GistsGetCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a gist revision](Gists::get_revision_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsGetRevisionError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -241,19 +289,26 @@ pub enum GistsGetRevisionError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsGetRevisionError) -> Self { + let (description, status_code) = match err { + GistsGetRevisionError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GistsGetRevisionError::Status404(_) => (String::from("Resource not found"), 404), + GistsGetRevisionError::Status403(_) => (String::from("Forbidden"), 403), + GistsGetRevisionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List gists for the authenticated user](Gists::list_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsListError { - #[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("Forbidden")] @@ -262,19 +317,25 @@ pub enum GistsListError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsListError) -> Self { + let (description, status_code) = match err { + GistsListError::Status304 => (String::from("Not modified"), 304), + GistsListError::Status403(_) => (String::from("Forbidden"), 403), + GistsListError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List gist comments](Gists::list_comments_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsListCommentsError { - #[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("Resource not found")] @@ -285,19 +346,26 @@ pub enum GistsListCommentsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsListCommentsError) -> Self { + let (description, status_code) = match err { + GistsListCommentsError::Status304 => (String::from("Not modified"), 304), + GistsListCommentsError::Status404(_) => (String::from("Resource not found"), 404), + GistsListCommentsError::Status403(_) => (String::from("Forbidden"), 403), + GistsListCommentsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List gist commits](Gists::list_commits_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsListCommitsError { - #[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("Not modified")] @@ -308,38 +376,50 @@ pub enum GistsListCommitsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsListCommitsError) -> Self { + let (description, status_code) = match err { + GistsListCommitsError::Status404(_) => (String::from("Resource not found"), 404), + GistsListCommitsError::Status304 => (String::from("Not modified"), 304), + GistsListCommitsError::Status403(_) => (String::from("Forbidden"), 403), + GistsListCommitsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List gists for a user](Gists::list_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsListForUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsListForUserError) -> Self { + let (description, status_code) = match err { + GistsListForUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GistsListForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List gist forks](Gists::list_forks_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsListForksError { - #[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("Not modified")] @@ -350,19 +430,26 @@ pub enum GistsListForksError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsListForksError) -> Self { + let (description, status_code) = match err { + GistsListForksError::Status404(_) => (String::from("Resource not found"), 404), + GistsListForksError::Status304 => (String::from("Not modified"), 304), + GistsListForksError::Status403(_) => (String::from("Forbidden"), 403), + GistsListForksError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List public gists](Gists::list_public_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsListPublicError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -373,19 +460,26 @@ pub enum GistsListPublicError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsListPublicError) -> Self { + let (description, status_code) = match err { + GistsListPublicError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GistsListPublicError::Status304 => (String::from("Not modified"), 304), + GistsListPublicError::Status403(_) => (String::from("Forbidden"), 403), + GistsListPublicError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List starred gists](Gists::list_starred_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsListStarredError { - #[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("Not modified")] @@ -396,19 +490,26 @@ pub enum GistsListStarredError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsListStarredError) -> Self { + let (description, status_code) = match err { + GistsListStarredError::Status401(_) => (String::from("Requires authentication"), 401), + GistsListStarredError::Status304 => (String::from("Not modified"), 304), + GistsListStarredError::Status403(_) => (String::from("Forbidden"), 403), + GistsListStarredError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Star a gist](Gists::star_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsStarError { - #[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("Not modified")] @@ -419,19 +520,26 @@ pub enum GistsStarError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsStarError) -> Self { + let (description, status_code) = match err { + GistsStarError::Status404(_) => (String::from("Resource not found"), 404), + GistsStarError::Status304 => (String::from("Not modified"), 304), + GistsStarError::Status403(_) => (String::from("Forbidden"), 403), + GistsStarError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Unstar a gist](Gists::unstar_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsUnstarError { - #[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("Resource not found")] @@ -442,19 +550,26 @@ pub enum GistsUnstarError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsUnstarError) -> Self { + let (description, status_code) = match err { + GistsUnstarError::Status304 => (String::from("Not modified"), 304), + GistsUnstarError::Status404(_) => (String::from("Resource not found"), 404), + GistsUnstarError::Status403(_) => (String::from("Forbidden"), 403), + GistsUnstarError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a gist](Gists::update_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsUpdateError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -463,25 +578,46 @@ pub enum GistsUpdateError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GistsUpdateError) -> Self { + let (description, status_code) = match err { + GistsUpdateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GistsUpdateError::Status404(_) => (String::from("Resource not found"), 404), + GistsUpdateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a gist comment](Gists::update_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GistsUpdateCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: GistsUpdateCommentError) -> Self { + let (description, status_code) = match err { + GistsUpdateCommentError::Status404(_) => (String::from("Resource not found"), 404), + GistsUpdateCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List gists for the authenticated user](Gists::list_async()) endpoint. #[derive(Default, Serialize)] @@ -816,7 +952,7 @@ impl<'enc> From<&'enc PerPage> for GistsListStarredParams { } } -impl<'api, C: Client> Gists<'api, C> { +impl<'api, C: Client> Gists<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Check if a gist is starred @@ -824,19 +960,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for check_is_starred](https://docs.github.com/rest/gists/gists#check-if-a-gist-is-starred) /// /// --- - pub async fn check_is_starred_async(&self, gist_id: &str) -> Result<(), GistsCheckIsStarredError> { + pub async fn check_is_starred_async(&self, gist_id: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/gists/{}/star", super::GITHUB_BASE_API_URL, gist_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -848,10 +984,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GistsCheckIsStarredError::Status404(github_response.to_json_async().await?)), - 304 => Err(GistsCheckIsStarredError::Status304), - 403 => Err(GistsCheckIsStarredError::Status403(github_response.to_json_async().await?)), - code => Err(GistsCheckIsStarredError::Generic { code }), + 404 => Err(GistsCheckIsStarredError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(GistsCheckIsStarredError::Status304.into()), + 403 => Err(GistsCheckIsStarredError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsCheckIsStarredError::Generic { code }.into()), } } } @@ -864,7 +1000,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_is_starred(&self, gist_id: &str) -> Result<(), GistsCheckIsStarredError> { + pub fn check_is_starred(&self, gist_id: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/gists/{}/star", super::GITHUB_BASE_API_URL, gist_id); @@ -876,7 +1012,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -888,10 +1024,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GistsCheckIsStarredError::Status404(github_response.to_json()?)), - 304 => Err(GistsCheckIsStarredError::Status304), - 403 => Err(GistsCheckIsStarredError::Status403(github_response.to_json()?)), - code => Err(GistsCheckIsStarredError::Generic { code }), + 404 => Err(GistsCheckIsStarredError::Status404(github_response.to_json()?).into()), + 304 => Err(GistsCheckIsStarredError::Status304.into()), + 403 => Err(GistsCheckIsStarredError::Status403(github_response.to_json()?).into()), + code => Err(GistsCheckIsStarredError::Generic { code }.into()), } } } @@ -908,19 +1044,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for create](https://docs.github.com/rest/gists/gists#create-a-gist) /// /// --- - pub async fn create_async(&self, body: PostGistsCreate) -> Result { + pub async fn create_async(&self, body: PostGistsCreate) -> Result { let request_uri = format!("{}/gists", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostGistsCreate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -932,11 +1068,11 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GistsCreateError::Status422(github_response.to_json_async().await?)), - 304 => Err(GistsCreateError::Status304), - 404 => Err(GistsCreateError::Status404(github_response.to_json_async().await?)), - 403 => Err(GistsCreateError::Status403(github_response.to_json_async().await?)), - code => Err(GistsCreateError::Generic { code }), + 422 => Err(GistsCreateError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(GistsCreateError::Status304.into()), + 404 => Err(GistsCreateError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(GistsCreateError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsCreateError::Generic { code }.into()), } } } @@ -954,19 +1090,19 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create(&self, body: PostGistsCreate) -> Result { + pub fn create(&self, body: PostGistsCreate) -> Result { let request_uri = format!("{}/gists", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostGistsCreate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -978,11 +1114,11 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GistsCreateError::Status422(github_response.to_json()?)), - 304 => Err(GistsCreateError::Status304), - 404 => Err(GistsCreateError::Status404(github_response.to_json()?)), - 403 => Err(GistsCreateError::Status403(github_response.to_json()?)), - code => Err(GistsCreateError::Generic { code }), + 422 => Err(GistsCreateError::Status422(github_response.to_json()?).into()), + 304 => Err(GistsCreateError::Status304.into()), + 404 => Err(GistsCreateError::Status404(github_response.to_json()?).into()), + 403 => Err(GistsCreateError::Status403(github_response.to_json()?).into()), + code => Err(GistsCreateError::Generic { code }.into()), } } } @@ -1001,19 +1137,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for create_comment](https://docs.github.com/rest/gists/comments#create-a-gist-comment) /// /// --- - pub async fn create_comment_async(&self, gist_id: &str, body: PostGistsCreateComment) -> Result { + pub async fn create_comment_async(&self, gist_id: &str, body: PostGistsCreateComment) -> Result { let request_uri = format!("{}/gists/{}/comments", super::GITHUB_BASE_API_URL, gist_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostGistsCreateComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1025,10 +1161,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(GistsCreateCommentError::Status304), - 404 => Err(GistsCreateCommentError::Status404(github_response.to_json_async().await?)), - 403 => Err(GistsCreateCommentError::Status403(github_response.to_json_async().await?)), - code => Err(GistsCreateCommentError::Generic { code }), + 304 => Err(GistsCreateCommentError::Status304.into()), + 404 => Err(GistsCreateCommentError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(GistsCreateCommentError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsCreateCommentError::Generic { code }.into()), } } } @@ -1048,19 +1184,19 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_comment(&self, gist_id: &str, body: PostGistsCreateComment) -> Result { + pub fn create_comment(&self, gist_id: &str, body: PostGistsCreateComment) -> Result { let request_uri = format!("{}/gists/{}/comments", super::GITHUB_BASE_API_URL, gist_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostGistsCreateComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1072,10 +1208,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(GistsCreateCommentError::Status304), - 404 => Err(GistsCreateCommentError::Status404(github_response.to_json()?)), - 403 => Err(GistsCreateCommentError::Status403(github_response.to_json()?)), - code => Err(GistsCreateCommentError::Generic { code }), + 304 => Err(GistsCreateCommentError::Status304.into()), + 404 => Err(GistsCreateCommentError::Status404(github_response.to_json()?).into()), + 403 => Err(GistsCreateCommentError::Status403(github_response.to_json()?).into()), + code => Err(GistsCreateCommentError::Generic { code }.into()), } } } @@ -1087,19 +1223,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for delete](https://docs.github.com/rest/gists/gists#delete-a-gist) /// /// --- - pub async fn delete_async(&self, gist_id: &str) -> Result<(), GistsDeleteError> { + pub async fn delete_async(&self, gist_id: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/gists/{}", super::GITHUB_BASE_API_URL, gist_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1111,10 +1247,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GistsDeleteError::Status404(github_response.to_json_async().await?)), - 304 => Err(GistsDeleteError::Status304), - 403 => Err(GistsDeleteError::Status403(github_response.to_json_async().await?)), - code => Err(GistsDeleteError::Generic { code }), + 404 => Err(GistsDeleteError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(GistsDeleteError::Status304.into()), + 403 => Err(GistsDeleteError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsDeleteError::Generic { code }.into()), } } } @@ -1127,7 +1263,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete(&self, gist_id: &str) -> Result<(), GistsDeleteError> { + pub fn delete(&self, gist_id: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/gists/{}", super::GITHUB_BASE_API_URL, gist_id); @@ -1139,7 +1275,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1151,10 +1287,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GistsDeleteError::Status404(github_response.to_json()?)), - 304 => Err(GistsDeleteError::Status304), - 403 => Err(GistsDeleteError::Status403(github_response.to_json()?)), - code => Err(GistsDeleteError::Generic { code }), + 404 => Err(GistsDeleteError::Status404(github_response.to_json()?).into()), + 304 => Err(GistsDeleteError::Status304.into()), + 403 => Err(GistsDeleteError::Status403(github_response.to_json()?).into()), + code => Err(GistsDeleteError::Generic { code }.into()), } } } @@ -1166,19 +1302,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for delete_comment](https://docs.github.com/rest/gists/comments#delete-a-gist-comment) /// /// --- - pub async fn delete_comment_async(&self, gist_id: &str, comment_id: i64) -> Result<(), GistsDeleteCommentError> { + pub async fn delete_comment_async(&self, gist_id: &str, comment_id: i64) -> Result<(), AdapterError> { let request_uri = format!("{}/gists/{}/comments/{}", super::GITHUB_BASE_API_URL, gist_id, comment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1190,10 +1326,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(GistsDeleteCommentError::Status304), - 404 => Err(GistsDeleteCommentError::Status404(github_response.to_json_async().await?)), - 403 => Err(GistsDeleteCommentError::Status403(github_response.to_json_async().await?)), - code => Err(GistsDeleteCommentError::Generic { code }), + 304 => Err(GistsDeleteCommentError::Status304.into()), + 404 => Err(GistsDeleteCommentError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(GistsDeleteCommentError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsDeleteCommentError::Generic { code }.into()), } } } @@ -1206,7 +1342,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_comment(&self, gist_id: &str, comment_id: i64) -> Result<(), GistsDeleteCommentError> { + pub fn delete_comment(&self, gist_id: &str, comment_id: i64) -> Result<(), AdapterError> { let request_uri = format!("{}/gists/{}/comments/{}", super::GITHUB_BASE_API_URL, gist_id, comment_id); @@ -1218,7 +1354,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1230,10 +1366,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(GistsDeleteCommentError::Status304), - 404 => Err(GistsDeleteCommentError::Status404(github_response.to_json()?)), - 403 => Err(GistsDeleteCommentError::Status403(github_response.to_json()?)), - code => Err(GistsDeleteCommentError::Generic { code }), + 304 => Err(GistsDeleteCommentError::Status304.into()), + 404 => Err(GistsDeleteCommentError::Status404(github_response.to_json()?).into()), + 403 => Err(GistsDeleteCommentError::Status403(github_response.to_json()?).into()), + code => Err(GistsDeleteCommentError::Generic { code }.into()), } } } @@ -1245,19 +1381,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for fork](https://docs.github.com/rest/gists/gists#fork-a-gist) /// /// --- - pub async fn fork_async(&self, gist_id: &str) -> Result { + pub async fn fork_async(&self, gist_id: &str) -> Result { let request_uri = format!("{}/gists/{}/forks", super::GITHUB_BASE_API_URL, gist_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1269,11 +1405,11 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GistsForkError::Status404(github_response.to_json_async().await?)), - 422 => Err(GistsForkError::Status422(github_response.to_json_async().await?)), - 304 => Err(GistsForkError::Status304), - 403 => Err(GistsForkError::Status403(github_response.to_json_async().await?)), - code => Err(GistsForkError::Generic { code }), + 404 => Err(GistsForkError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(GistsForkError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(GistsForkError::Status304.into()), + 403 => Err(GistsForkError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsForkError::Generic { code }.into()), } } } @@ -1286,7 +1422,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn fork(&self, gist_id: &str) -> Result { + pub fn fork(&self, gist_id: &str) -> Result { let request_uri = format!("{}/gists/{}/forks", super::GITHUB_BASE_API_URL, gist_id); @@ -1298,7 +1434,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1310,11 +1446,11 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GistsForkError::Status404(github_response.to_json()?)), - 422 => Err(GistsForkError::Status422(github_response.to_json()?)), - 304 => Err(GistsForkError::Status304), - 403 => Err(GistsForkError::Status403(github_response.to_json()?)), - code => Err(GistsForkError::Generic { code }), + 404 => Err(GistsForkError::Status404(github_response.to_json()?).into()), + 422 => Err(GistsForkError::Status422(github_response.to_json()?).into()), + 304 => Err(GistsForkError::Status304.into()), + 403 => Err(GistsForkError::Status403(github_response.to_json()?).into()), + code => Err(GistsForkError::Generic { code }.into()), } } } @@ -1333,19 +1469,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for get](https://docs.github.com/rest/gists/gists#get-a-gist) /// /// --- - pub async fn get_async(&self, gist_id: &str) -> Result { + pub async fn get_async(&self, gist_id: &str) -> Result { let request_uri = format!("{}/gists/{}", super::GITHUB_BASE_API_URL, gist_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1357,10 +1493,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(GistsGetError::Status403(github_response.to_json_async().await?)), - 404 => Err(GistsGetError::Status404(github_response.to_json_async().await?)), - 304 => Err(GistsGetError::Status304), - code => Err(GistsGetError::Generic { code }), + 403 => Err(GistsGetError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(GistsGetError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(GistsGetError::Status304.into()), + code => Err(GistsGetError::Generic { code }.into()), } } } @@ -1380,7 +1516,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get(&self, gist_id: &str) -> Result { + pub fn get(&self, gist_id: &str) -> Result { let request_uri = format!("{}/gists/{}", super::GITHUB_BASE_API_URL, gist_id); @@ -1392,7 +1528,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1404,10 +1540,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(GistsGetError::Status403(github_response.to_json()?)), - 404 => Err(GistsGetError::Status404(github_response.to_json()?)), - 304 => Err(GistsGetError::Status304), - code => Err(GistsGetError::Generic { code }), + 403 => Err(GistsGetError::Status403(github_response.to_json()?).into()), + 404 => Err(GistsGetError::Status404(github_response.to_json()?).into()), + 304 => Err(GistsGetError::Status304.into()), + code => Err(GistsGetError::Generic { code }.into()), } } } @@ -1426,19 +1562,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for get_comment](https://docs.github.com/rest/gists/comments#get-a-gist-comment) /// /// --- - pub async fn get_comment_async(&self, gist_id: &str, comment_id: i64) -> Result { + pub async fn get_comment_async(&self, gist_id: &str, comment_id: i64) -> Result { let request_uri = format!("{}/gists/{}/comments/{}", super::GITHUB_BASE_API_URL, gist_id, comment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1450,10 +1586,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(GistsGetCommentError::Status304), - 404 => Err(GistsGetCommentError::Status404(github_response.to_json_async().await?)), - 403 => Err(GistsGetCommentError::Status403(github_response.to_json_async().await?)), - code => Err(GistsGetCommentError::Generic { code }), + 304 => Err(GistsGetCommentError::Status304.into()), + 404 => Err(GistsGetCommentError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(GistsGetCommentError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsGetCommentError::Generic { code }.into()), } } } @@ -1473,7 +1609,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_comment(&self, gist_id: &str, comment_id: i64) -> Result { + pub fn get_comment(&self, gist_id: &str, comment_id: i64) -> Result { let request_uri = format!("{}/gists/{}/comments/{}", super::GITHUB_BASE_API_URL, gist_id, comment_id); @@ -1485,7 +1621,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1497,10 +1633,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(GistsGetCommentError::Status304), - 404 => Err(GistsGetCommentError::Status404(github_response.to_json()?)), - 403 => Err(GistsGetCommentError::Status403(github_response.to_json()?)), - code => Err(GistsGetCommentError::Generic { code }), + 304 => Err(GistsGetCommentError::Status304.into()), + 404 => Err(GistsGetCommentError::Status404(github_response.to_json()?).into()), + 403 => Err(GistsGetCommentError::Status403(github_response.to_json()?).into()), + code => Err(GistsGetCommentError::Generic { code }.into()), } } } @@ -1519,19 +1655,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for get_revision](https://docs.github.com/rest/gists/gists#get-a-gist-revision) /// /// --- - pub async fn get_revision_async(&self, gist_id: &str, sha: &str) -> Result { + pub async fn get_revision_async(&self, gist_id: &str, sha: &str) -> Result { let request_uri = format!("{}/gists/{}/{}", super::GITHUB_BASE_API_URL, gist_id, sha); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1543,10 +1679,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GistsGetRevisionError::Status422(github_response.to_json_async().await?)), - 404 => Err(GistsGetRevisionError::Status404(github_response.to_json_async().await?)), - 403 => Err(GistsGetRevisionError::Status403(github_response.to_json_async().await?)), - code => Err(GistsGetRevisionError::Generic { code }), + 422 => Err(GistsGetRevisionError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(GistsGetRevisionError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(GistsGetRevisionError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsGetRevisionError::Generic { code }.into()), } } } @@ -1566,7 +1702,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_revision(&self, gist_id: &str, sha: &str) -> Result { + pub fn get_revision(&self, gist_id: &str, sha: &str) -> Result { let request_uri = format!("{}/gists/{}/{}", super::GITHUB_BASE_API_URL, gist_id, sha); @@ -1578,7 +1714,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1590,10 +1726,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GistsGetRevisionError::Status422(github_response.to_json()?)), - 404 => Err(GistsGetRevisionError::Status404(github_response.to_json()?)), - 403 => Err(GistsGetRevisionError::Status403(github_response.to_json()?)), - code => Err(GistsGetRevisionError::Generic { code }), + 422 => Err(GistsGetRevisionError::Status422(github_response.to_json()?).into()), + 404 => Err(GistsGetRevisionError::Status404(github_response.to_json()?).into()), + 403 => Err(GistsGetRevisionError::Status403(github_response.to_json()?).into()), + code => Err(GistsGetRevisionError::Generic { code }.into()), } } } @@ -1607,7 +1743,7 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for list](https://docs.github.com/rest/gists/gists#list-gists-for-the-authenticated-user) /// /// --- - pub async fn list_async(&self, query_params: Option>) -> Result, GistsListError> { + pub async fn list_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists", super::GITHUB_BASE_API_URL); @@ -1618,12 +1754,12 @@ impl<'api, C: Client> Gists<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1635,9 +1771,9 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(GistsListError::Status304), - 403 => Err(GistsListError::Status403(github_response.to_json_async().await?)), - code => Err(GistsListError::Generic { code }), + 304 => Err(GistsListError::Status304.into()), + 403 => Err(GistsListError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsListError::Generic { code }.into()), } } } @@ -1652,7 +1788,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list(&self, query_params: Option>) -> Result, GistsListError> { + pub fn list(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists", super::GITHUB_BASE_API_URL); @@ -1669,7 +1805,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1681,9 +1817,9 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(GistsListError::Status304), - 403 => Err(GistsListError::Status403(github_response.to_json()?)), - code => Err(GistsListError::Generic { code }), + 304 => Err(GistsListError::Status304.into()), + 403 => Err(GistsListError::Status403(github_response.to_json()?).into()), + code => Err(GistsListError::Generic { code }.into()), } } } @@ -1702,7 +1838,7 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for list_comments](https://docs.github.com/rest/gists/comments#list-gist-comments) /// /// --- - pub async fn list_comments_async(&self, gist_id: &str, query_params: Option>) -> Result, GistsListCommentsError> { + pub async fn list_comments_async(&self, gist_id: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists/{}/comments", super::GITHUB_BASE_API_URL, gist_id); @@ -1713,12 +1849,12 @@ impl<'api, C: Client> Gists<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1730,10 +1866,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(GistsListCommentsError::Status304), - 404 => Err(GistsListCommentsError::Status404(github_response.to_json_async().await?)), - 403 => Err(GistsListCommentsError::Status403(github_response.to_json_async().await?)), - code => Err(GistsListCommentsError::Generic { code }), + 304 => Err(GistsListCommentsError::Status304.into()), + 404 => Err(GistsListCommentsError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(GistsListCommentsError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsListCommentsError::Generic { code }.into()), } } } @@ -1753,7 +1889,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_comments(&self, gist_id: &str, query_params: Option>) -> Result, GistsListCommentsError> { + pub fn list_comments(&self, gist_id: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists/{}/comments", super::GITHUB_BASE_API_URL, gist_id); @@ -1770,7 +1906,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1782,10 +1918,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(GistsListCommentsError::Status304), - 404 => Err(GistsListCommentsError::Status404(github_response.to_json()?)), - 403 => Err(GistsListCommentsError::Status403(github_response.to_json()?)), - code => Err(GistsListCommentsError::Generic { code }), + 304 => Err(GistsListCommentsError::Status304.into()), + 404 => Err(GistsListCommentsError::Status404(github_response.to_json()?).into()), + 403 => Err(GistsListCommentsError::Status403(github_response.to_json()?).into()), + code => Err(GistsListCommentsError::Generic { code }.into()), } } } @@ -1797,7 +1933,7 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for list_commits](https://docs.github.com/rest/gists/gists#list-gist-commits) /// /// --- - pub async fn list_commits_async(&self, gist_id: &str, query_params: Option>) -> Result, GistsListCommitsError> { + pub async fn list_commits_async(&self, gist_id: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists/{}/commits", super::GITHUB_BASE_API_URL, gist_id); @@ -1808,12 +1944,12 @@ impl<'api, C: Client> Gists<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1825,10 +1961,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GistsListCommitsError::Status404(github_response.to_json_async().await?)), - 304 => Err(GistsListCommitsError::Status304), - 403 => Err(GistsListCommitsError::Status403(github_response.to_json_async().await?)), - code => Err(GistsListCommitsError::Generic { code }), + 404 => Err(GistsListCommitsError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(GistsListCommitsError::Status304.into()), + 403 => Err(GistsListCommitsError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsListCommitsError::Generic { code }.into()), } } } @@ -1841,7 +1977,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_commits(&self, gist_id: &str, query_params: Option>) -> Result, GistsListCommitsError> { + pub fn list_commits(&self, gist_id: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists/{}/commits", super::GITHUB_BASE_API_URL, gist_id); @@ -1858,7 +1994,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1870,10 +2006,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GistsListCommitsError::Status404(github_response.to_json()?)), - 304 => Err(GistsListCommitsError::Status304), - 403 => Err(GistsListCommitsError::Status403(github_response.to_json()?)), - code => Err(GistsListCommitsError::Generic { code }), + 404 => Err(GistsListCommitsError::Status404(github_response.to_json()?).into()), + 304 => Err(GistsListCommitsError::Status304.into()), + 403 => Err(GistsListCommitsError::Status403(github_response.to_json()?).into()), + code => Err(GistsListCommitsError::Generic { code }.into()), } } } @@ -1887,7 +2023,7 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for list_for_user](https://docs.github.com/rest/gists/gists#list-gists-for-a-user) /// /// --- - pub async fn list_for_user_async(&self, username: &str, query_params: Option>) -> Result, GistsListForUserError> { + pub async fn list_for_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/gists", super::GITHUB_BASE_API_URL, username); @@ -1898,12 +2034,12 @@ impl<'api, C: Client> Gists<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1915,8 +2051,8 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GistsListForUserError::Status422(github_response.to_json_async().await?)), - code => Err(GistsListForUserError::Generic { code }), + 422 => Err(GistsListForUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(GistsListForUserError::Generic { code }.into()), } } } @@ -1931,7 +2067,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_user(&self, username: &str, query_params: Option>) -> Result, GistsListForUserError> { + pub fn list_for_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/gists", super::GITHUB_BASE_API_URL, username); @@ -1948,7 +2084,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1960,8 +2096,8 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GistsListForUserError::Status422(github_response.to_json()?)), - code => Err(GistsListForUserError::Generic { code }), + 422 => Err(GistsListForUserError::Status422(github_response.to_json()?).into()), + code => Err(GistsListForUserError::Generic { code }.into()), } } } @@ -1973,7 +2109,7 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for list_forks](https://docs.github.com/rest/gists/gists#list-gist-forks) /// /// --- - pub async fn list_forks_async(&self, gist_id: &str, query_params: Option>) -> Result, GistsListForksError> { + pub async fn list_forks_async(&self, gist_id: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists/{}/forks", super::GITHUB_BASE_API_URL, gist_id); @@ -1984,12 +2120,12 @@ impl<'api, C: Client> Gists<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2001,10 +2137,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GistsListForksError::Status404(github_response.to_json_async().await?)), - 304 => Err(GistsListForksError::Status304), - 403 => Err(GistsListForksError::Status403(github_response.to_json_async().await?)), - code => Err(GistsListForksError::Generic { code }), + 404 => Err(GistsListForksError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(GistsListForksError::Status304.into()), + 403 => Err(GistsListForksError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsListForksError::Generic { code }.into()), } } } @@ -2017,7 +2153,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_forks(&self, gist_id: &str, query_params: Option>) -> Result, GistsListForksError> { + pub fn list_forks(&self, gist_id: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists/{}/forks", super::GITHUB_BASE_API_URL, gist_id); @@ -2034,7 +2170,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2046,10 +2182,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GistsListForksError::Status404(github_response.to_json()?)), - 304 => Err(GistsListForksError::Status304), - 403 => Err(GistsListForksError::Status403(github_response.to_json()?)), - code => Err(GistsListForksError::Generic { code }), + 404 => Err(GistsListForksError::Status404(github_response.to_json()?).into()), + 304 => Err(GistsListForksError::Status304.into()), + 403 => Err(GistsListForksError::Status403(github_response.to_json()?).into()), + code => Err(GistsListForksError::Generic { code }.into()), } } } @@ -2065,7 +2201,7 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for list_public](https://docs.github.com/rest/gists/gists#list-public-gists) /// /// --- - pub async fn list_public_async(&self, query_params: Option>) -> Result, GistsListPublicError> { + pub async fn list_public_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists/public", super::GITHUB_BASE_API_URL); @@ -2076,12 +2212,12 @@ impl<'api, C: Client> Gists<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2093,10 +2229,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GistsListPublicError::Status422(github_response.to_json_async().await?)), - 304 => Err(GistsListPublicError::Status304), - 403 => Err(GistsListPublicError::Status403(github_response.to_json_async().await?)), - code => Err(GistsListPublicError::Generic { code }), + 422 => Err(GistsListPublicError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(GistsListPublicError::Status304.into()), + 403 => Err(GistsListPublicError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsListPublicError::Generic { code }.into()), } } } @@ -2113,7 +2249,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_public(&self, query_params: Option>) -> Result, GistsListPublicError> { + pub fn list_public(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists/public", super::GITHUB_BASE_API_URL); @@ -2130,7 +2266,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2142,10 +2278,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GistsListPublicError::Status422(github_response.to_json()?)), - 304 => Err(GistsListPublicError::Status304), - 403 => Err(GistsListPublicError::Status403(github_response.to_json()?)), - code => Err(GistsListPublicError::Generic { code }), + 422 => Err(GistsListPublicError::Status422(github_response.to_json()?).into()), + 304 => Err(GistsListPublicError::Status304.into()), + 403 => Err(GistsListPublicError::Status403(github_response.to_json()?).into()), + code => Err(GistsListPublicError::Generic { code }.into()), } } } @@ -2159,7 +2295,7 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for list_starred](https://docs.github.com/rest/gists/gists#list-starred-gists) /// /// --- - pub async fn list_starred_async(&self, query_params: Option>) -> Result, GistsListStarredError> { + pub async fn list_starred_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists/starred", super::GITHUB_BASE_API_URL); @@ -2170,12 +2306,12 @@ impl<'api, C: Client> Gists<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2187,10 +2323,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(GistsListStarredError::Status401(github_response.to_json_async().await?)), - 304 => Err(GistsListStarredError::Status304), - 403 => Err(GistsListStarredError::Status403(github_response.to_json_async().await?)), - code => Err(GistsListStarredError::Generic { code }), + 401 => Err(GistsListStarredError::Status401(github_response.to_json_async().await?).into()), + 304 => Err(GistsListStarredError::Status304.into()), + 403 => Err(GistsListStarredError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsListStarredError::Generic { code }.into()), } } } @@ -2205,7 +2341,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_starred(&self, query_params: Option>) -> Result, GistsListStarredError> { + pub fn list_starred(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/gists/starred", super::GITHUB_BASE_API_URL); @@ -2222,7 +2358,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2234,10 +2370,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(GistsListStarredError::Status401(github_response.to_json()?)), - 304 => Err(GistsListStarredError::Status304), - 403 => Err(GistsListStarredError::Status403(github_response.to_json()?)), - code => Err(GistsListStarredError::Generic { code }), + 401 => Err(GistsListStarredError::Status401(github_response.to_json()?).into()), + 304 => Err(GistsListStarredError::Status304.into()), + 403 => Err(GistsListStarredError::Status403(github_response.to_json()?).into()), + code => Err(GistsListStarredError::Generic { code }.into()), } } } @@ -2251,19 +2387,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for star](https://docs.github.com/rest/gists/gists#star-a-gist) /// /// --- - pub async fn star_async(&self, gist_id: &str) -> Result<(), GistsStarError> { + pub async fn star_async(&self, gist_id: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/gists/{}/star", super::GITHUB_BASE_API_URL, gist_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2275,10 +2411,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GistsStarError::Status404(github_response.to_json_async().await?)), - 304 => Err(GistsStarError::Status304), - 403 => Err(GistsStarError::Status403(github_response.to_json_async().await?)), - code => Err(GistsStarError::Generic { code }), + 404 => Err(GistsStarError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(GistsStarError::Status304.into()), + 403 => Err(GistsStarError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsStarError::Generic { code }.into()), } } } @@ -2293,7 +2429,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn star(&self, gist_id: &str) -> Result<(), GistsStarError> { + pub fn star(&self, gist_id: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/gists/{}/star", super::GITHUB_BASE_API_URL, gist_id); @@ -2305,7 +2441,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2317,10 +2453,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GistsStarError::Status404(github_response.to_json()?)), - 304 => Err(GistsStarError::Status304), - 403 => Err(GistsStarError::Status403(github_response.to_json()?)), - code => Err(GistsStarError::Generic { code }), + 404 => Err(GistsStarError::Status404(github_response.to_json()?).into()), + 304 => Err(GistsStarError::Status304.into()), + 403 => Err(GistsStarError::Status403(github_response.to_json()?).into()), + code => Err(GistsStarError::Generic { code }.into()), } } } @@ -2332,19 +2468,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for unstar](https://docs.github.com/rest/gists/gists#unstar-a-gist) /// /// --- - pub async fn unstar_async(&self, gist_id: &str) -> Result<(), GistsUnstarError> { + pub async fn unstar_async(&self, gist_id: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/gists/{}/star", super::GITHUB_BASE_API_URL, gist_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2356,10 +2492,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(GistsUnstarError::Status304), - 404 => Err(GistsUnstarError::Status404(github_response.to_json_async().await?)), - 403 => Err(GistsUnstarError::Status403(github_response.to_json_async().await?)), - code => Err(GistsUnstarError::Generic { code }), + 304 => Err(GistsUnstarError::Status304.into()), + 404 => Err(GistsUnstarError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(GistsUnstarError::Status403(github_response.to_json_async().await?).into()), + code => Err(GistsUnstarError::Generic { code }.into()), } } } @@ -2372,7 +2508,7 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn unstar(&self, gist_id: &str) -> Result<(), GistsUnstarError> { + pub fn unstar(&self, gist_id: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/gists/{}/star", super::GITHUB_BASE_API_URL, gist_id); @@ -2384,7 +2520,7 @@ impl<'api, C: Client> Gists<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2396,10 +2532,10 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(GistsUnstarError::Status304), - 404 => Err(GistsUnstarError::Status404(github_response.to_json()?)), - 403 => Err(GistsUnstarError::Status403(github_response.to_json()?)), - code => Err(GistsUnstarError::Generic { code }), + 304 => Err(GistsUnstarError::Status304.into()), + 404 => Err(GistsUnstarError::Status404(github_response.to_json()?).into()), + 403 => Err(GistsUnstarError::Status403(github_response.to_json()?).into()), + code => Err(GistsUnstarError::Generic { code }.into()), } } } @@ -2422,19 +2558,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for update](https://docs.github.com/rest/gists/gists#update-a-gist) /// /// --- - pub async fn update_async(&self, gist_id: &str, body: PatchGistsUpdate) -> Result { + pub async fn update_async(&self, gist_id: &str, body: PatchGistsUpdate) -> Result { let request_uri = format!("{}/gists/{}", super::GITHUB_BASE_API_URL, gist_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchGistsUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2446,9 +2582,9 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GistsUpdateError::Status422(github_response.to_json_async().await?)), - 404 => Err(GistsUpdateError::Status404(github_response.to_json_async().await?)), - code => Err(GistsUpdateError::Generic { code }), + 422 => Err(GistsUpdateError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(GistsUpdateError::Status404(github_response.to_json_async().await?).into()), + code => Err(GistsUpdateError::Generic { code }.into()), } } } @@ -2472,19 +2608,19 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update(&self, gist_id: &str, body: PatchGistsUpdate) -> Result { + pub fn update(&self, gist_id: &str, body: PatchGistsUpdate) -> Result { let request_uri = format!("{}/gists/{}", super::GITHUB_BASE_API_URL, gist_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchGistsUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2496,9 +2632,9 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GistsUpdateError::Status422(github_response.to_json()?)), - 404 => Err(GistsUpdateError::Status404(github_response.to_json()?)), - code => Err(GistsUpdateError::Generic { code }), + 422 => Err(GistsUpdateError::Status422(github_response.to_json()?).into()), + 404 => Err(GistsUpdateError::Status404(github_response.to_json()?).into()), + code => Err(GistsUpdateError::Generic { code }.into()), } } } @@ -2517,19 +2653,19 @@ impl<'api, C: Client> Gists<'api, C> { /// [GitHub API docs for update_comment](https://docs.github.com/rest/gists/comments#update-a-gist-comment) /// /// --- - pub async fn update_comment_async(&self, gist_id: &str, comment_id: i64, body: PatchGistsUpdateComment) -> Result { + pub async fn update_comment_async(&self, gist_id: &str, comment_id: i64, body: PatchGistsUpdateComment) -> Result { let request_uri = format!("{}/gists/{}/comments/{}", super::GITHUB_BASE_API_URL, gist_id, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchGistsUpdateComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2541,8 +2677,8 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GistsUpdateCommentError::Status404(github_response.to_json_async().await?)), - code => Err(GistsUpdateCommentError::Generic { code }), + 404 => Err(GistsUpdateCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(GistsUpdateCommentError::Generic { code }.into()), } } } @@ -2562,19 +2698,19 @@ impl<'api, C: Client> Gists<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_comment(&self, gist_id: &str, comment_id: i64, body: PatchGistsUpdateComment) -> Result { + pub fn update_comment(&self, gist_id: &str, comment_id: i64, body: PatchGistsUpdateComment) -> Result { let request_uri = format!("{}/gists/{}/comments/{}", super::GITHUB_BASE_API_URL, gist_id, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchGistsUpdateComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2586,8 +2722,8 @@ impl<'api, C: Client> Gists<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GistsUpdateCommentError::Status404(github_response.to_json()?)), - code => Err(GistsUpdateCommentError::Generic { code }), + 404 => Err(GistsUpdateCommentError::Status404(github_response.to_json()?).into()), + code => Err(GistsUpdateCommentError::Generic { code }.into()), } } } diff --git a/src/endpoints/git.rs b/src/endpoints/git.rs index 76a9102..bc127b1 100644 --- a/src/endpoints/git.rs +++ b/src/endpoints/git.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Git<'api, C: Client> { +pub struct Git<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Git { +pub fn new(client: &C) -> Git where AdapterError: From<::Err> { Git { client } } /// Errors for the [Create a blob](Git::create_blob_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitCreateBlobError { - #[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("Conflict")] @@ -55,19 +45,27 @@ pub enum GitCreateBlobError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitCreateBlobError) -> Self { + let (description, status_code) = match err { + GitCreateBlobError::Status404(_) => (String::from("Resource not found"), 404), + GitCreateBlobError::Status409(_) => (String::from("Conflict"), 409), + GitCreateBlobError::Status403(_) => (String::from("Forbidden"), 403), + GitCreateBlobError::Status422(_) => (String::from("Validation failed"), 422), + GitCreateBlobError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a commit](Git::create_commit_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitCreateCommitError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -78,19 +76,26 @@ pub enum GitCreateCommitError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitCreateCommitError) -> Self { + let (description, status_code) = match err { + GitCreateCommitError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GitCreateCommitError::Status404(_) => (String::from("Resource not found"), 404), + GitCreateCommitError::Status409(_) => (String::from("Conflict"), 409), + GitCreateCommitError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a reference](Git::create_ref_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitCreateRefError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Conflict")] @@ -99,19 +104,25 @@ pub enum GitCreateRefError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitCreateRefError) -> Self { + let (description, status_code) = match err { + GitCreateRefError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GitCreateRefError::Status409(_) => (String::from("Conflict"), 409), + GitCreateRefError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a tag object](Git::create_tag_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitCreateTagError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Conflict")] @@ -120,19 +131,25 @@ pub enum GitCreateTagError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitCreateTagError) -> Self { + let (description, status_code) = match err { + GitCreateTagError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GitCreateTagError::Status409(_) => (String::from("Conflict"), 409), + GitCreateTagError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a tree](Git::create_tree_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitCreateTreeError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -145,19 +162,27 @@ pub enum GitCreateTreeError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitCreateTreeError) -> Self { + let (description, status_code) = match err { + GitCreateTreeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GitCreateTreeError::Status404(_) => (String::from("Resource not found"), 404), + GitCreateTreeError::Status403(_) => (String::from("Forbidden"), 403), + GitCreateTreeError::Status409(_) => (String::from("Conflict"), 409), + GitCreateTreeError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a reference](Git::delete_ref_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitDeleteRefError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Conflict")] @@ -166,19 +191,25 @@ pub enum GitDeleteRefError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitDeleteRefError) -> Self { + let (description, status_code) = match err { + GitDeleteRefError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GitDeleteRefError::Status409(_) => (String::from("Conflict"), 409), + GitDeleteRefError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a blob](Git::get_blob_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitGetBlobError { - #[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, or the endpoint has been spammed.")] @@ -191,19 +222,27 @@ pub enum GitGetBlobError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitGetBlobError) -> Self { + let (description, status_code) = match err { + GitGetBlobError::Status404(_) => (String::from("Resource not found"), 404), + GitGetBlobError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GitGetBlobError::Status403(_) => (String::from("Forbidden"), 403), + GitGetBlobError::Status409(_) => (String::from("Conflict"), 409), + GitGetBlobError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a commit object](Git::get_commit_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitGetCommitError { - #[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("Conflict")] @@ -212,19 +251,25 @@ pub enum GitGetCommitError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitGetCommitError) -> Self { + let (description, status_code) = match err { + GitGetCommitError::Status404(_) => (String::from("Resource not found"), 404), + GitGetCommitError::Status409(_) => (String::from("Conflict"), 409), + GitGetCommitError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a reference](Git::get_ref_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitGetRefError { - #[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("Conflict")] @@ -233,19 +278,25 @@ pub enum GitGetRefError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitGetRefError) -> Self { + let (description, status_code) = match err { + GitGetRefError::Status404(_) => (String::from("Resource not found"), 404), + GitGetRefError::Status409(_) => (String::from("Conflict"), 409), + GitGetRefError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a tag](Git::get_tag_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitGetTagError { - #[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("Conflict")] @@ -254,19 +305,25 @@ pub enum GitGetTagError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitGetTagError) -> Self { + let (description, status_code) = match err { + GitGetTagError::Status404(_) => (String::from("Resource not found"), 404), + GitGetTagError::Status409(_) => (String::from("Conflict"), 409), + GitGetTagError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a tree](Git::get_tree_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitGetTreeError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -277,38 +334,50 @@ pub enum GitGetTreeError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitGetTreeError) -> Self { + let (description, status_code) = match err { + GitGetTreeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GitGetTreeError::Status404(_) => (String::from("Resource not found"), 404), + GitGetTreeError::Status409(_) => (String::from("Conflict"), 409), + GitGetTreeError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List matching references](Git::list_matching_refs_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitListMatchingRefsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Conflict")] Status409(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitListMatchingRefsError) -> Self { + let (description, status_code) = match err { + GitListMatchingRefsError::Status409(_) => (String::from("Conflict"), 409), + GitListMatchingRefsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a reference](Git::update_ref_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitUpdateRefError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Conflict")] @@ -317,6 +386,22 @@ pub enum GitUpdateRefError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitUpdateRefError) -> Self { + let (description, status_code) = match err { + GitUpdateRefError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + GitUpdateRefError::Status409(_) => (String::from("Conflict"), 409), + GitUpdateRefError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [Get a tree](Git::get_tree_async()) endpoint. #[derive(Default, Serialize)] @@ -339,7 +424,7 @@ impl<'req> GitGetTreeParams<'req> { } -impl<'api, C: Client> Git<'api, C> { +impl<'api, C: Client> Git<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Create a blob @@ -347,19 +432,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for create_blob](https://docs.github.com/rest/git/blobs#create-a-blob) /// /// --- - pub async fn create_blob_async(&self, owner: &str, repo: &str, body: PostGitCreateBlob) -> Result { + pub async fn create_blob_async(&self, owner: &str, repo: &str, body: PostGitCreateBlob) -> Result { let request_uri = format!("{}/repos/{}/{}/git/blobs", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostGitCreateBlob::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -371,11 +456,11 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GitCreateBlobError::Status404(github_response.to_json_async().await?)), - 409 => Err(GitCreateBlobError::Status409(github_response.to_json_async().await?)), - 403 => Err(GitCreateBlobError::Status403(github_response.to_json_async().await?)), - 422 => Err(GitCreateBlobError::Status422(github_response.to_json_async().await?)), - code => Err(GitCreateBlobError::Generic { code }), + 404 => Err(GitCreateBlobError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(GitCreateBlobError::Status409(github_response.to_json_async().await?).into()), + 403 => Err(GitCreateBlobError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(GitCreateBlobError::Status422(github_response.to_json_async().await?).into()), + code => Err(GitCreateBlobError::Generic { code }.into()), } } } @@ -388,19 +473,19 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_blob(&self, owner: &str, repo: &str, body: PostGitCreateBlob) -> Result { + pub fn create_blob(&self, owner: &str, repo: &str, body: PostGitCreateBlob) -> Result { let request_uri = format!("{}/repos/{}/{}/git/blobs", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostGitCreateBlob::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -412,11 +497,11 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GitCreateBlobError::Status404(github_response.to_json()?)), - 409 => Err(GitCreateBlobError::Status409(github_response.to_json()?)), - 403 => Err(GitCreateBlobError::Status403(github_response.to_json()?)), - 422 => Err(GitCreateBlobError::Status422(github_response.to_json()?)), - code => Err(GitCreateBlobError::Generic { code }), + 404 => Err(GitCreateBlobError::Status404(github_response.to_json()?).into()), + 409 => Err(GitCreateBlobError::Status409(github_response.to_json()?).into()), + 403 => Err(GitCreateBlobError::Status403(github_response.to_json()?).into()), + 422 => Err(GitCreateBlobError::Status422(github_response.to_json()?).into()), + code => Err(GitCreateBlobError::Generic { code }.into()), } } } @@ -459,19 +544,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for create_commit](https://docs.github.com/rest/git/commits#create-a-commit) /// /// --- - pub async fn create_commit_async(&self, owner: &str, repo: &str, body: PostGitCreateCommit) -> Result { + pub async fn create_commit_async(&self, owner: &str, repo: &str, body: PostGitCreateCommit) -> Result { let request_uri = format!("{}/repos/{}/{}/git/commits", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostGitCreateCommit::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -483,10 +568,10 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GitCreateCommitError::Status422(github_response.to_json_async().await?)), - 404 => Err(GitCreateCommitError::Status404(github_response.to_json_async().await?)), - 409 => Err(GitCreateCommitError::Status409(github_response.to_json_async().await?)), - code => Err(GitCreateCommitError::Generic { code }), + 422 => Err(GitCreateCommitError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(GitCreateCommitError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(GitCreateCommitError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitCreateCommitError::Generic { code }.into()), } } } @@ -530,19 +615,19 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_commit(&self, owner: &str, repo: &str, body: PostGitCreateCommit) -> Result { + pub fn create_commit(&self, owner: &str, repo: &str, body: PostGitCreateCommit) -> Result { let request_uri = format!("{}/repos/{}/{}/git/commits", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostGitCreateCommit::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -554,10 +639,10 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GitCreateCommitError::Status422(github_response.to_json()?)), - 404 => Err(GitCreateCommitError::Status404(github_response.to_json()?)), - 409 => Err(GitCreateCommitError::Status409(github_response.to_json()?)), - code => Err(GitCreateCommitError::Generic { code }), + 422 => Err(GitCreateCommitError::Status422(github_response.to_json()?).into()), + 404 => Err(GitCreateCommitError::Status404(github_response.to_json()?).into()), + 409 => Err(GitCreateCommitError::Status409(github_response.to_json()?).into()), + code => Err(GitCreateCommitError::Generic { code }.into()), } } } @@ -571,19 +656,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for create_ref](https://docs.github.com/rest/git/refs#create-a-reference) /// /// --- - pub async fn create_ref_async(&self, owner: &str, repo: &str, body: PostGitCreateRef) -> Result { + pub async fn create_ref_async(&self, owner: &str, repo: &str, body: PostGitCreateRef) -> Result { let request_uri = format!("{}/repos/{}/{}/git/refs", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostGitCreateRef::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -595,9 +680,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GitCreateRefError::Status422(github_response.to_json_async().await?)), - 409 => Err(GitCreateRefError::Status409(github_response.to_json_async().await?)), - code => Err(GitCreateRefError::Generic { code }), + 422 => Err(GitCreateRefError::Status422(github_response.to_json_async().await?).into()), + 409 => Err(GitCreateRefError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitCreateRefError::Generic { code }.into()), } } } @@ -612,19 +697,19 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_ref(&self, owner: &str, repo: &str, body: PostGitCreateRef) -> Result { + pub fn create_ref(&self, owner: &str, repo: &str, body: PostGitCreateRef) -> Result { let request_uri = format!("{}/repos/{}/{}/git/refs", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostGitCreateRef::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -636,9 +721,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GitCreateRefError::Status422(github_response.to_json()?)), - 409 => Err(GitCreateRefError::Status409(github_response.to_json()?)), - code => Err(GitCreateRefError::Generic { code }), + 422 => Err(GitCreateRefError::Status422(github_response.to_json()?).into()), + 409 => Err(GitCreateRefError::Status409(github_response.to_json()?).into()), + code => Err(GitCreateRefError::Generic { code }.into()), } } } @@ -681,19 +766,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for create_tag](https://docs.github.com/rest/git/tags#create-a-tag-object) /// /// --- - pub async fn create_tag_async(&self, owner: &str, repo: &str, body: PostGitCreateTag) -> Result { + pub async fn create_tag_async(&self, owner: &str, repo: &str, body: PostGitCreateTag) -> Result { let request_uri = format!("{}/repos/{}/{}/git/tags", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostGitCreateTag::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -705,9 +790,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GitCreateTagError::Status422(github_response.to_json_async().await?)), - 409 => Err(GitCreateTagError::Status409(github_response.to_json_async().await?)), - code => Err(GitCreateTagError::Generic { code }), + 422 => Err(GitCreateTagError::Status422(github_response.to_json_async().await?).into()), + 409 => Err(GitCreateTagError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitCreateTagError::Generic { code }.into()), } } } @@ -751,19 +836,19 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_tag(&self, owner: &str, repo: &str, body: PostGitCreateTag) -> Result { + pub fn create_tag(&self, owner: &str, repo: &str, body: PostGitCreateTag) -> Result { let request_uri = format!("{}/repos/{}/{}/git/tags", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostGitCreateTag::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -775,9 +860,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GitCreateTagError::Status422(github_response.to_json()?)), - 409 => Err(GitCreateTagError::Status409(github_response.to_json()?)), - code => Err(GitCreateTagError::Generic { code }), + 422 => Err(GitCreateTagError::Status422(github_response.to_json()?).into()), + 409 => Err(GitCreateTagError::Status409(github_response.to_json()?).into()), + code => Err(GitCreateTagError::Generic { code }.into()), } } } @@ -795,19 +880,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for create_tree](https://docs.github.com/rest/git/trees#create-a-tree) /// /// --- - pub async fn create_tree_async(&self, owner: &str, repo: &str, body: PostGitCreateTree) -> Result { + pub async fn create_tree_async(&self, owner: &str, repo: &str, body: PostGitCreateTree) -> Result { let request_uri = format!("{}/repos/{}/{}/git/trees", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostGitCreateTree::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -819,11 +904,11 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GitCreateTreeError::Status422(github_response.to_json_async().await?)), - 404 => Err(GitCreateTreeError::Status404(github_response.to_json_async().await?)), - 403 => Err(GitCreateTreeError::Status403(github_response.to_json_async().await?)), - 409 => Err(GitCreateTreeError::Status409(github_response.to_json_async().await?)), - code => Err(GitCreateTreeError::Generic { code }), + 422 => Err(GitCreateTreeError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(GitCreateTreeError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(GitCreateTreeError::Status403(github_response.to_json_async().await?).into()), + 409 => Err(GitCreateTreeError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitCreateTreeError::Generic { code }.into()), } } } @@ -842,19 +927,19 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_tree(&self, owner: &str, repo: &str, body: PostGitCreateTree) -> Result { + pub fn create_tree(&self, owner: &str, repo: &str, body: PostGitCreateTree) -> Result { let request_uri = format!("{}/repos/{}/{}/git/trees", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostGitCreateTree::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -866,11 +951,11 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GitCreateTreeError::Status422(github_response.to_json()?)), - 404 => Err(GitCreateTreeError::Status404(github_response.to_json()?)), - 403 => Err(GitCreateTreeError::Status403(github_response.to_json()?)), - 409 => Err(GitCreateTreeError::Status409(github_response.to_json()?)), - code => Err(GitCreateTreeError::Generic { code }), + 422 => Err(GitCreateTreeError::Status422(github_response.to_json()?).into()), + 404 => Err(GitCreateTreeError::Status404(github_response.to_json()?).into()), + 403 => Err(GitCreateTreeError::Status403(github_response.to_json()?).into()), + 409 => Err(GitCreateTreeError::Status409(github_response.to_json()?).into()), + code => Err(GitCreateTreeError::Generic { code }.into()), } } } @@ -884,19 +969,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for delete_ref](https://docs.github.com/rest/git/refs#delete-a-reference) /// /// --- - pub async fn delete_ref_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), GitDeleteRefError> { + pub async fn delete_ref_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/git/refs/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -908,9 +993,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GitDeleteRefError::Status422(github_response.to_json_async().await?)), - 409 => Err(GitDeleteRefError::Status409(github_response.to_json_async().await?)), - code => Err(GitDeleteRefError::Generic { code }), + 422 => Err(GitDeleteRefError::Status422(github_response.to_json_async().await?).into()), + 409 => Err(GitDeleteRefError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitDeleteRefError::Generic { code }.into()), } } } @@ -925,7 +1010,7 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_ref(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), GitDeleteRefError> { + pub fn delete_ref(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/git/refs/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -937,7 +1022,7 @@ impl<'api, C: Client> Git<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -949,9 +1034,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GitDeleteRefError::Status422(github_response.to_json()?)), - 409 => Err(GitDeleteRefError::Status409(github_response.to_json()?)), - code => Err(GitDeleteRefError::Generic { code }), + 422 => Err(GitDeleteRefError::Status422(github_response.to_json()?).into()), + 409 => Err(GitDeleteRefError::Status409(github_response.to_json()?).into()), + code => Err(GitDeleteRefError::Generic { code }.into()), } } } @@ -972,19 +1057,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for get_blob](https://docs.github.com/rest/git/blobs#get-a-blob) /// /// --- - pub async fn get_blob_async(&self, owner: &str, repo: &str, file_sha: &str) -> Result { + pub async fn get_blob_async(&self, owner: &str, repo: &str, file_sha: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/git/blobs/{}", super::GITHUB_BASE_API_URL, owner, repo, file_sha); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -996,11 +1081,11 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GitGetBlobError::Status404(github_response.to_json_async().await?)), - 422 => Err(GitGetBlobError::Status422(github_response.to_json_async().await?)), - 403 => Err(GitGetBlobError::Status403(github_response.to_json_async().await?)), - 409 => Err(GitGetBlobError::Status409(github_response.to_json_async().await?)), - code => Err(GitGetBlobError::Generic { code }), + 404 => Err(GitGetBlobError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(GitGetBlobError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(GitGetBlobError::Status403(github_response.to_json_async().await?).into()), + 409 => Err(GitGetBlobError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitGetBlobError::Generic { code }.into()), } } } @@ -1022,7 +1107,7 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_blob(&self, owner: &str, repo: &str, file_sha: &str) -> Result { + pub fn get_blob(&self, owner: &str, repo: &str, file_sha: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/git/blobs/{}", super::GITHUB_BASE_API_URL, owner, repo, file_sha); @@ -1034,7 +1119,7 @@ impl<'api, C: Client> Git<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1046,11 +1131,11 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GitGetBlobError::Status404(github_response.to_json()?)), - 422 => Err(GitGetBlobError::Status422(github_response.to_json()?)), - 403 => Err(GitGetBlobError::Status403(github_response.to_json()?)), - 409 => Err(GitGetBlobError::Status409(github_response.to_json()?)), - code => Err(GitGetBlobError::Generic { code }), + 404 => Err(GitGetBlobError::Status404(github_response.to_json()?).into()), + 422 => Err(GitGetBlobError::Status422(github_response.to_json()?).into()), + 403 => Err(GitGetBlobError::Status403(github_response.to_json()?).into()), + 409 => Err(GitGetBlobError::Status409(github_response.to_json()?).into()), + code => Err(GitGetBlobError::Generic { code }.into()), } } } @@ -1095,19 +1180,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for get_commit](https://docs.github.com/rest/git/commits#get-a-commit-object) /// /// --- - pub async fn get_commit_async(&self, owner: &str, repo: &str, commit_sha: &str) -> Result { + pub async fn get_commit_async(&self, owner: &str, repo: &str, commit_sha: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/git/commits/{}", super::GITHUB_BASE_API_URL, owner, repo, commit_sha); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1119,9 +1204,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GitGetCommitError::Status404(github_response.to_json_async().await?)), - 409 => Err(GitGetCommitError::Status409(github_response.to_json_async().await?)), - code => Err(GitGetCommitError::Generic { code }), + 404 => Err(GitGetCommitError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(GitGetCommitError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitGetCommitError::Generic { code }.into()), } } } @@ -1167,7 +1252,7 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_commit(&self, owner: &str, repo: &str, commit_sha: &str) -> Result { + pub fn get_commit(&self, owner: &str, repo: &str, commit_sha: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/git/commits/{}", super::GITHUB_BASE_API_URL, owner, repo, commit_sha); @@ -1179,7 +1264,7 @@ impl<'api, C: Client> Git<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1191,9 +1276,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GitGetCommitError::Status404(github_response.to_json()?)), - 409 => Err(GitGetCommitError::Status409(github_response.to_json()?)), - code => Err(GitGetCommitError::Generic { code }), + 404 => Err(GitGetCommitError::Status404(github_response.to_json()?).into()), + 409 => Err(GitGetCommitError::Status409(github_response.to_json()?).into()), + code => Err(GitGetCommitError::Generic { code }.into()), } } } @@ -1210,19 +1295,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for get_ref](https://docs.github.com/rest/git/refs#get-a-reference) /// /// --- - pub async fn get_ref_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result { + pub async fn get_ref_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/git/ref/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1234,9 +1319,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GitGetRefError::Status404(github_response.to_json_async().await?)), - 409 => Err(GitGetRefError::Status409(github_response.to_json_async().await?)), - code => Err(GitGetRefError::Generic { code }), + 404 => Err(GitGetRefError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(GitGetRefError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitGetRefError::Generic { code }.into()), } } } @@ -1254,7 +1339,7 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_ref(&self, owner: &str, repo: &str, git_ref: &str) -> Result { + pub fn get_ref(&self, owner: &str, repo: &str, git_ref: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/git/ref/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -1266,7 +1351,7 @@ impl<'api, C: Client> Git<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1278,9 +1363,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GitGetRefError::Status404(github_response.to_json()?)), - 409 => Err(GitGetRefError::Status409(github_response.to_json()?)), - code => Err(GitGetRefError::Generic { code }), + 404 => Err(GitGetRefError::Status404(github_response.to_json()?).into()), + 409 => Err(GitGetRefError::Status409(github_response.to_json()?).into()), + code => Err(GitGetRefError::Generic { code }.into()), } } } @@ -1321,19 +1406,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for get_tag](https://docs.github.com/rest/git/tags#get-a-tag) /// /// --- - pub async fn get_tag_async(&self, owner: &str, repo: &str, tag_sha: &str) -> Result { + pub async fn get_tag_async(&self, owner: &str, repo: &str, tag_sha: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/git/tags/{}", super::GITHUB_BASE_API_URL, owner, repo, tag_sha); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1345,9 +1430,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(GitGetTagError::Status404(github_response.to_json_async().await?)), - 409 => Err(GitGetTagError::Status409(github_response.to_json_async().await?)), - code => Err(GitGetTagError::Generic { code }), + 404 => Err(GitGetTagError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(GitGetTagError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitGetTagError::Generic { code }.into()), } } } @@ -1389,7 +1474,7 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_tag(&self, owner: &str, repo: &str, tag_sha: &str) -> Result { + pub fn get_tag(&self, owner: &str, repo: &str, tag_sha: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/git/tags/{}", super::GITHUB_BASE_API_URL, owner, repo, tag_sha); @@ -1401,7 +1486,7 @@ impl<'api, C: Client> Git<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1413,9 +1498,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(GitGetTagError::Status404(github_response.to_json()?)), - 409 => Err(GitGetTagError::Status409(github_response.to_json()?)), - code => Err(GitGetTagError::Generic { code }), + 404 => Err(GitGetTagError::Status404(github_response.to_json()?).into()), + 409 => Err(GitGetTagError::Status409(github_response.to_json()?).into()), + code => Err(GitGetTagError::Generic { code }.into()), } } } @@ -1434,7 +1519,7 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for get_tree](https://docs.github.com/rest/git/trees#get-a-tree) /// /// --- - pub async fn get_tree_async(&self, owner: &str, repo: &str, tree_sha: &str, query_params: Option>>) -> Result { + pub async fn get_tree_async(&self, owner: &str, repo: &str, tree_sha: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/git/trees/{}", super::GITHUB_BASE_API_URL, owner, repo, tree_sha); @@ -1445,12 +1530,12 @@ impl<'api, C: Client> Git<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1462,10 +1547,10 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GitGetTreeError::Status422(github_response.to_json_async().await?)), - 404 => Err(GitGetTreeError::Status404(github_response.to_json_async().await?)), - 409 => Err(GitGetTreeError::Status409(github_response.to_json_async().await?)), - code => Err(GitGetTreeError::Generic { code }), + 422 => Err(GitGetTreeError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(GitGetTreeError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(GitGetTreeError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitGetTreeError::Generic { code }.into()), } } } @@ -1485,7 +1570,7 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_tree(&self, owner: &str, repo: &str, tree_sha: &str, query_params: Option>>) -> Result { + pub fn get_tree(&self, owner: &str, repo: &str, tree_sha: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/git/trees/{}", super::GITHUB_BASE_API_URL, owner, repo, tree_sha); @@ -1502,7 +1587,7 @@ impl<'api, C: Client> Git<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1514,10 +1599,10 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GitGetTreeError::Status422(github_response.to_json()?)), - 404 => Err(GitGetTreeError::Status404(github_response.to_json()?)), - 409 => Err(GitGetTreeError::Status409(github_response.to_json()?)), - code => Err(GitGetTreeError::Generic { code }), + 422 => Err(GitGetTreeError::Status422(github_response.to_json()?).into()), + 404 => Err(GitGetTreeError::Status404(github_response.to_json()?).into()), + 409 => Err(GitGetTreeError::Status409(github_response.to_json()?).into()), + code => Err(GitGetTreeError::Generic { code }.into()), } } } @@ -1538,19 +1623,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for list_matching_refs](https://docs.github.com/rest/git/refs#list-matching-references) /// /// --- - pub async fn list_matching_refs_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result, GitListMatchingRefsError> { + pub async fn list_matching_refs_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/git/matching-refs/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1562,8 +1647,8 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(GitListMatchingRefsError::Status409(github_response.to_json_async().await?)), - code => Err(GitListMatchingRefsError::Generic { code }), + 409 => Err(GitListMatchingRefsError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitListMatchingRefsError::Generic { code }.into()), } } } @@ -1585,7 +1670,7 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_matching_refs(&self, owner: &str, repo: &str, git_ref: &str) -> Result, GitListMatchingRefsError> { + pub fn list_matching_refs(&self, owner: &str, repo: &str, git_ref: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/git/matching-refs/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -1597,7 +1682,7 @@ impl<'api, C: Client> Git<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1609,8 +1694,8 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(GitListMatchingRefsError::Status409(github_response.to_json()?)), - code => Err(GitListMatchingRefsError::Generic { code }), + 409 => Err(GitListMatchingRefsError::Status409(github_response.to_json()?).into()), + code => Err(GitListMatchingRefsError::Generic { code }.into()), } } } @@ -1624,19 +1709,19 @@ impl<'api, C: Client> Git<'api, C> { /// [GitHub API docs for update_ref](https://docs.github.com/rest/git/refs#update-a-reference) /// /// --- - pub async fn update_ref_async(&self, owner: &str, repo: &str, git_ref: &str, body: PatchGitUpdateRef) -> Result { + pub async fn update_ref_async(&self, owner: &str, repo: &str, git_ref: &str, body: PatchGitUpdateRef) -> Result { let request_uri = format!("{}/repos/{}/{}/git/refs/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); let req = GitHubRequest { uri: request_uri, - body: Some(PatchGitUpdateRef::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1648,9 +1733,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(GitUpdateRefError::Status422(github_response.to_json_async().await?)), - 409 => Err(GitUpdateRefError::Status409(github_response.to_json_async().await?)), - code => Err(GitUpdateRefError::Generic { code }), + 422 => Err(GitUpdateRefError::Status422(github_response.to_json_async().await?).into()), + 409 => Err(GitUpdateRefError::Status409(github_response.to_json_async().await?).into()), + code => Err(GitUpdateRefError::Generic { code }.into()), } } } @@ -1665,19 +1750,19 @@ impl<'api, C: Client> Git<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_ref(&self, owner: &str, repo: &str, git_ref: &str, body: PatchGitUpdateRef) -> Result { + pub fn update_ref(&self, owner: &str, repo: &str, git_ref: &str, body: PatchGitUpdateRef) -> Result { let request_uri = format!("{}/repos/{}/{}/git/refs/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); let req = GitHubRequest { uri: request_uri, - body: Some(PatchGitUpdateRef::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1689,9 +1774,9 @@ impl<'api, C: Client> Git<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(GitUpdateRefError::Status422(github_response.to_json()?)), - 409 => Err(GitUpdateRefError::Status409(github_response.to_json()?)), - code => Err(GitUpdateRefError::Generic { code }), + 422 => Err(GitUpdateRefError::Status422(github_response.to_json()?).into()), + 409 => Err(GitUpdateRefError::Status409(github_response.to_json()?).into()), + code => Err(GitUpdateRefError::Generic { code }.into()), } } } diff --git a/src/endpoints/gitignore.rs b/src/endpoints/gitignore.rs index 36373ee..12daa61 100644 --- a/src/endpoints/gitignore.rs +++ b/src/endpoints/gitignore.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,55 +22,65 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Gitignore<'api, C: Client> { +pub struct Gitignore<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Gitignore { +pub fn new(client: &C) -> Gitignore where AdapterError: From<::Err> { Gitignore { client } } /// Errors for the [Get all gitignore templates](Gitignore::get_all_templates_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitignoreGetAllTemplatesError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitignoreGetAllTemplatesError) -> Self { + let (description, status_code) = match err { + GitignoreGetAllTemplatesError::Status304 => (String::from("Not modified"), 304), + GitignoreGetAllTemplatesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a gitignore template](Gitignore::get_template_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum GitignoreGetTemplateError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: GitignoreGetTemplateError) -> Self { + let (description, status_code) = match err { + GitignoreGetTemplateError::Status304 => (String::from("Not modified"), 304), + GitignoreGetTemplateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + -impl<'api, C: Client> Gitignore<'api, C> { +impl<'api, C: Client> Gitignore<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Get all gitignore templates @@ -80,19 +90,19 @@ impl<'api, C: Client> Gitignore<'api, C> { /// [GitHub API docs for get_all_templates](https://docs.github.com/rest/gitignore/gitignore#get-all-gitignore-templates) /// /// --- - pub async fn get_all_templates_async(&self) -> Result, GitignoreGetAllTemplatesError> { + pub async fn get_all_templates_async(&self) -> Result, AdapterError> { let request_uri = format!("{}/gitignore/templates", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -104,8 +114,8 @@ impl<'api, C: Client> Gitignore<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(GitignoreGetAllTemplatesError::Status304), - code => Err(GitignoreGetAllTemplatesError::Generic { code }), + 304 => Err(GitignoreGetAllTemplatesError::Status304.into()), + code => Err(GitignoreGetAllTemplatesError::Generic { code }.into()), } } } @@ -120,7 +130,7 @@ impl<'api, C: Client> Gitignore<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_templates(&self) -> Result, GitignoreGetAllTemplatesError> { + pub fn get_all_templates(&self) -> Result, AdapterError> { let request_uri = format!("{}/gitignore/templates", super::GITHUB_BASE_API_URL); @@ -132,7 +142,7 @@ impl<'api, C: Client> Gitignore<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -144,8 +154,8 @@ impl<'api, C: Client> Gitignore<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(GitignoreGetAllTemplatesError::Status304), - code => Err(GitignoreGetAllTemplatesError::Generic { code }), + 304 => Err(GitignoreGetAllTemplatesError::Status304.into()), + code => Err(GitignoreGetAllTemplatesError::Generic { code }.into()), } } } @@ -163,19 +173,19 @@ impl<'api, C: Client> Gitignore<'api, C> { /// [GitHub API docs for get_template](https://docs.github.com/rest/gitignore/gitignore#get-a-gitignore-template) /// /// --- - pub async fn get_template_async(&self, name: &str) -> Result { + pub async fn get_template_async(&self, name: &str) -> Result { let request_uri = format!("{}/gitignore/templates/{}", super::GITHUB_BASE_API_URL, name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -187,8 +197,8 @@ impl<'api, C: Client> Gitignore<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(GitignoreGetTemplateError::Status304), - code => Err(GitignoreGetTemplateError::Generic { code }), + 304 => Err(GitignoreGetTemplateError::Status304.into()), + code => Err(GitignoreGetTemplateError::Generic { code }.into()), } } } @@ -207,7 +217,7 @@ impl<'api, C: Client> Gitignore<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_template(&self, name: &str) -> Result { + pub fn get_template(&self, name: &str) -> Result { let request_uri = format!("{}/gitignore/templates/{}", super::GITHUB_BASE_API_URL, name); @@ -219,7 +229,7 @@ impl<'api, C: Client> Gitignore<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -231,8 +241,8 @@ impl<'api, C: Client> Gitignore<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(GitignoreGetTemplateError::Status304), - code => Err(GitignoreGetTemplateError::Generic { code }), + 304 => Err(GitignoreGetTemplateError::Status304.into()), + code => Err(GitignoreGetTemplateError::Generic { code }.into()), } } } diff --git a/src/endpoints/interactions.rs b/src/endpoints/interactions.rs index 6c8932e..644c71a 100644 --- a/src/endpoints/interactions.rs +++ b/src/endpoints/interactions.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,180 +22,221 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Interactions<'api, C: Client> { +pub struct Interactions<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Interactions { +pub fn new(client: &C) -> Interactions where AdapterError: From<::Err> { Interactions { client } } /// Errors for the [Get interaction restrictions for your public repositories](Interactions::get_restrictions_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum InteractionsGetRestrictionsForAuthenticatedUserError { - #[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 there are no restrictions")] Status204, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: InteractionsGetRestrictionsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + InteractionsGetRestrictionsForAuthenticatedUserError::Status204 => (String::from("Response when there are no restrictions"), 204), + InteractionsGetRestrictionsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get interaction restrictions for an organization](Interactions::get_restrictions_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum InteractionsGetRestrictionsForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: InteractionsGetRestrictionsForOrgError) -> Self { + let (description, status_code) = match err { + InteractionsGetRestrictionsForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get interaction restrictions for a repository](Interactions::get_restrictions_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum InteractionsGetRestrictionsForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: InteractionsGetRestrictionsForRepoError) -> Self { + let (description, status_code) = match err { + InteractionsGetRestrictionsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove interaction restrictions from your public repositories](Interactions::remove_restrictions_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum InteractionsRemoveRestrictionsForAuthenticatedUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: InteractionsRemoveRestrictionsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + InteractionsRemoveRestrictionsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove interaction restrictions for an organization](Interactions::remove_restrictions_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum InteractionsRemoveRestrictionsForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: InteractionsRemoveRestrictionsForOrgError) -> Self { + let (description, status_code) = match err { + InteractionsRemoveRestrictionsForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove interaction restrictions for a repository](Interactions::remove_restrictions_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum InteractionsRemoveRestrictionsForRepoError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status409, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: InteractionsRemoveRestrictionsForRepoError) -> Self { + let (description, status_code) = match err { + InteractionsRemoveRestrictionsForRepoError::Status409 => (String::from("Response"), 409), + InteractionsRemoveRestrictionsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set interaction restrictions for your public repositories](Interactions::set_restrictions_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum InteractionsSetRestrictionsForAuthenticatedUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: InteractionsSetRestrictionsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + InteractionsSetRestrictionsForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + InteractionsSetRestrictionsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set interaction restrictions for an organization](Interactions::set_restrictions_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum InteractionsSetRestrictionsForOrgError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: InteractionsSetRestrictionsForOrgError) -> Self { + let (description, status_code) = match err { + InteractionsSetRestrictionsForOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + InteractionsSetRestrictionsForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set interaction restrictions for a repository](Interactions::set_restrictions_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum InteractionsSetRestrictionsForRepoError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status409, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: InteractionsSetRestrictionsForRepoError) -> Self { + let (description, status_code) = match err { + InteractionsSetRestrictionsForRepoError::Status409 => (String::from("Response"), 409), + InteractionsSetRestrictionsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} -impl<'api, C: Client> Interactions<'api, C> { + +impl<'api, C: Client> Interactions<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Get interaction restrictions for your public repositories @@ -205,19 +246,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// [GitHub API docs for get_restrictions_for_authenticated_user](https://docs.github.com/rest/interactions/user#get-interaction-restrictions-for-your-public-repositories) /// /// --- - pub async fn get_restrictions_for_authenticated_user_async(&self) -> Result { + pub async fn get_restrictions_for_authenticated_user_async(&self) -> Result { let request_uri = format!("{}/user/interaction-limits", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -229,8 +270,8 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(InteractionsGetRestrictionsForAuthenticatedUserError::Status204), - code => Err(InteractionsGetRestrictionsForAuthenticatedUserError::Generic { code }), + 204 => Err(InteractionsGetRestrictionsForAuthenticatedUserError::Status204.into()), + code => Err(InteractionsGetRestrictionsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -245,7 +286,7 @@ impl<'api, C: Client> Interactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_restrictions_for_authenticated_user(&self) -> Result { + pub fn get_restrictions_for_authenticated_user(&self) -> Result { let request_uri = format!("{}/user/interaction-limits", super::GITHUB_BASE_API_URL); @@ -257,7 +298,7 @@ impl<'api, C: Client> Interactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -269,8 +310,8 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(InteractionsGetRestrictionsForAuthenticatedUserError::Status204), - code => Err(InteractionsGetRestrictionsForAuthenticatedUserError::Generic { code }), + 204 => Err(InteractionsGetRestrictionsForAuthenticatedUserError::Status204.into()), + code => Err(InteractionsGetRestrictionsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -284,19 +325,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// [GitHub API docs for get_restrictions_for_org](https://docs.github.com/rest/interactions/orgs#get-interaction-restrictions-for-an-organization) /// /// --- - pub async fn get_restrictions_for_org_async(&self, org: &str) -> Result { + pub async fn get_restrictions_for_org_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/interaction-limits", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -308,7 +349,7 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(InteractionsGetRestrictionsForOrgError::Generic { code }), + code => Err(InteractionsGetRestrictionsForOrgError::Generic { code }.into()), } } } @@ -323,7 +364,7 @@ impl<'api, C: Client> Interactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_restrictions_for_org(&self, org: &str) -> Result { + pub fn get_restrictions_for_org(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/interaction-limits", super::GITHUB_BASE_API_URL, org); @@ -335,7 +376,7 @@ impl<'api, C: Client> Interactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -347,7 +388,7 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(InteractionsGetRestrictionsForOrgError::Generic { code }), + code => Err(InteractionsGetRestrictionsForOrgError::Generic { code }.into()), } } } @@ -361,19 +402,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// [GitHub API docs for get_restrictions_for_repo](https://docs.github.com/rest/interactions/repos#get-interaction-restrictions-for-a-repository) /// /// --- - pub async fn get_restrictions_for_repo_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_restrictions_for_repo_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/interaction-limits", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -385,7 +426,7 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(InteractionsGetRestrictionsForRepoError::Generic { code }), + code => Err(InteractionsGetRestrictionsForRepoError::Generic { code }.into()), } } } @@ -400,7 +441,7 @@ impl<'api, C: Client> Interactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_restrictions_for_repo(&self, owner: &str, repo: &str) -> Result { + pub fn get_restrictions_for_repo(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/interaction-limits", super::GITHUB_BASE_API_URL, owner, repo); @@ -412,7 +453,7 @@ impl<'api, C: Client> Interactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -424,7 +465,7 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(InteractionsGetRestrictionsForRepoError::Generic { code }), + code => Err(InteractionsGetRestrictionsForRepoError::Generic { code }.into()), } } } @@ -438,19 +479,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// [GitHub API docs for remove_restrictions_for_authenticated_user](https://docs.github.com/rest/interactions/user#remove-interaction-restrictions-from-your-public-repositories) /// /// --- - pub async fn remove_restrictions_for_authenticated_user_async(&self) -> Result<(), InteractionsRemoveRestrictionsForAuthenticatedUserError> { + pub async fn remove_restrictions_for_authenticated_user_async(&self) -> Result<(), AdapterError> { let request_uri = format!("{}/user/interaction-limits", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -462,7 +503,7 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(InteractionsRemoveRestrictionsForAuthenticatedUserError::Generic { code }), + code => Err(InteractionsRemoveRestrictionsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -477,7 +518,7 @@ impl<'api, C: Client> Interactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_restrictions_for_authenticated_user(&self) -> Result<(), InteractionsRemoveRestrictionsForAuthenticatedUserError> { + pub fn remove_restrictions_for_authenticated_user(&self) -> Result<(), AdapterError> { let request_uri = format!("{}/user/interaction-limits", super::GITHUB_BASE_API_URL); @@ -489,7 +530,7 @@ impl<'api, C: Client> Interactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -501,7 +542,7 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(InteractionsRemoveRestrictionsForAuthenticatedUserError::Generic { code }), + code => Err(InteractionsRemoveRestrictionsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -515,19 +556,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// [GitHub API docs for remove_restrictions_for_org](https://docs.github.com/rest/interactions/orgs#remove-interaction-restrictions-for-an-organization) /// /// --- - pub async fn remove_restrictions_for_org_async(&self, org: &str) -> Result<(), InteractionsRemoveRestrictionsForOrgError> { + pub async fn remove_restrictions_for_org_async(&self, org: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/interaction-limits", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -539,7 +580,7 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(InteractionsRemoveRestrictionsForOrgError::Generic { code }), + code => Err(InteractionsRemoveRestrictionsForOrgError::Generic { code }.into()), } } } @@ -554,7 +595,7 @@ impl<'api, C: Client> Interactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_restrictions_for_org(&self, org: &str) -> Result<(), InteractionsRemoveRestrictionsForOrgError> { + pub fn remove_restrictions_for_org(&self, org: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/interaction-limits", super::GITHUB_BASE_API_URL, org); @@ -566,7 +607,7 @@ impl<'api, C: Client> Interactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -578,7 +619,7 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(InteractionsRemoveRestrictionsForOrgError::Generic { code }), + code => Err(InteractionsRemoveRestrictionsForOrgError::Generic { code }.into()), } } } @@ -592,19 +633,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// [GitHub API docs for remove_restrictions_for_repo](https://docs.github.com/rest/interactions/repos#remove-interaction-restrictions-for-a-repository) /// /// --- - pub async fn remove_restrictions_for_repo_async(&self, owner: &str, repo: &str) -> Result<(), InteractionsRemoveRestrictionsForRepoError> { + pub async fn remove_restrictions_for_repo_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/interaction-limits", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -616,8 +657,8 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(InteractionsRemoveRestrictionsForRepoError::Status409), - code => Err(InteractionsRemoveRestrictionsForRepoError::Generic { code }), + 409 => Err(InteractionsRemoveRestrictionsForRepoError::Status409.into()), + code => Err(InteractionsRemoveRestrictionsForRepoError::Generic { code }.into()), } } } @@ -632,7 +673,7 @@ impl<'api, C: Client> Interactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_restrictions_for_repo(&self, owner: &str, repo: &str) -> Result<(), InteractionsRemoveRestrictionsForRepoError> { + pub fn remove_restrictions_for_repo(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/interaction-limits", super::GITHUB_BASE_API_URL, owner, repo); @@ -644,7 +685,7 @@ impl<'api, C: Client> Interactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -656,8 +697,8 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(InteractionsRemoveRestrictionsForRepoError::Status409), - code => Err(InteractionsRemoveRestrictionsForRepoError::Generic { code }), + 409 => Err(InteractionsRemoveRestrictionsForRepoError::Status409.into()), + code => Err(InteractionsRemoveRestrictionsForRepoError::Generic { code }.into()), } } } @@ -671,19 +712,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// [GitHub API docs for set_restrictions_for_authenticated_user](https://docs.github.com/rest/interactions/user#set-interaction-restrictions-for-your-public-repositories) /// /// --- - pub async fn set_restrictions_for_authenticated_user_async(&self, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { + pub async fn set_restrictions_for_authenticated_user_async(&self, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/interaction-limits", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PutInteractionsSetRestrictionsForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -695,8 +736,8 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(InteractionsSetRestrictionsForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - code => Err(InteractionsSetRestrictionsForAuthenticatedUserError::Generic { code }), + 422 => Err(InteractionsSetRestrictionsForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(InteractionsSetRestrictionsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -711,19 +752,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_restrictions_for_authenticated_user(&self, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { + pub fn set_restrictions_for_authenticated_user(&self, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/interaction-limits", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PutInteractionsSetRestrictionsForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -735,8 +776,8 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(InteractionsSetRestrictionsForAuthenticatedUserError::Status422(github_response.to_json()?)), - code => Err(InteractionsSetRestrictionsForAuthenticatedUserError::Generic { code }), + 422 => Err(InteractionsSetRestrictionsForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + code => Err(InteractionsSetRestrictionsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -750,19 +791,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// [GitHub API docs for set_restrictions_for_org](https://docs.github.com/rest/interactions/orgs#set-interaction-restrictions-for-an-organization) /// /// --- - pub async fn set_restrictions_for_org_async(&self, org: &str, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { + pub async fn set_restrictions_for_org_async(&self, org: &str, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { let request_uri = format!("{}/orgs/{}/interaction-limits", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutInteractionsSetRestrictionsForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -774,8 +815,8 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(InteractionsSetRestrictionsForOrgError::Status422(github_response.to_json_async().await?)), - code => Err(InteractionsSetRestrictionsForOrgError::Generic { code }), + 422 => Err(InteractionsSetRestrictionsForOrgError::Status422(github_response.to_json_async().await?).into()), + code => Err(InteractionsSetRestrictionsForOrgError::Generic { code }.into()), } } } @@ -790,19 +831,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_restrictions_for_org(&self, org: &str, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { + pub fn set_restrictions_for_org(&self, org: &str, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { let request_uri = format!("{}/orgs/{}/interaction-limits", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PutInteractionsSetRestrictionsForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -814,8 +855,8 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(InteractionsSetRestrictionsForOrgError::Status422(github_response.to_json()?)), - code => Err(InteractionsSetRestrictionsForOrgError::Generic { code }), + 422 => Err(InteractionsSetRestrictionsForOrgError::Status422(github_response.to_json()?).into()), + code => Err(InteractionsSetRestrictionsForOrgError::Generic { code }.into()), } } } @@ -829,19 +870,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// [GitHub API docs for set_restrictions_for_repo](https://docs.github.com/rest/interactions/repos#set-interaction-restrictions-for-a-repository) /// /// --- - pub async fn set_restrictions_for_repo_async(&self, owner: &str, repo: &str, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { + pub async fn set_restrictions_for_repo_async(&self, owner: &str, repo: &str, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { let request_uri = format!("{}/repos/{}/{}/interaction-limits", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutInteractionsSetRestrictionsForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -853,8 +894,8 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(InteractionsSetRestrictionsForRepoError::Status409), - code => Err(InteractionsSetRestrictionsForRepoError::Generic { code }), + 409 => Err(InteractionsSetRestrictionsForRepoError::Status409.into()), + code => Err(InteractionsSetRestrictionsForRepoError::Generic { code }.into()), } } } @@ -869,19 +910,19 @@ impl<'api, C: Client> Interactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_restrictions_for_repo(&self, owner: &str, repo: &str, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { + pub fn set_restrictions_for_repo(&self, owner: &str, repo: &str, body: PutInteractionsSetRestrictionsForAuthenticatedUser) -> Result { let request_uri = format!("{}/repos/{}/{}/interaction-limits", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutInteractionsSetRestrictionsForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -893,8 +934,8 @@ impl<'api, C: Client> Interactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(InteractionsSetRestrictionsForRepoError::Status409), - code => Err(InteractionsSetRestrictionsForRepoError::Generic { code }), + 409 => Err(InteractionsSetRestrictionsForRepoError::Status409.into()), + code => Err(InteractionsSetRestrictionsForRepoError::Generic { code }.into()), } } } diff --git a/src/endpoints/issues.rs b/src/endpoints/issues.rs index f733cda..60ed530 100644 --- a/src/endpoints/issues.rs +++ b/src/endpoints/issues.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,44 +22,38 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Issues<'api, C: Client> { +pub struct Issues<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Issues { +pub fn new(client: &C) -> Issues where AdapterError: From<::Err> { Issues { client } } /// Errors for the [Add assignees to an issue](Issues::add_assignees_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesAddAssigneesError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesAddAssigneesError) -> Self { + let (description, status_code) = match err { + IssuesAddAssigneesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add labels to an issue](Issues::add_labels_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesAddLabelsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Moved permanently")] Status301(BasicError), #[error("Resource not found")] @@ -72,57 +66,75 @@ pub enum IssuesAddLabelsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesAddLabelsError) -> Self { + let (description, status_code) = match err { + IssuesAddLabelsError::Status301(_) => (String::from("Moved permanently"), 301), + IssuesAddLabelsError::Status404(_) => (String::from("Resource not found"), 404), + IssuesAddLabelsError::Status410(_) => (String::from("Gone"), 410), + IssuesAddLabelsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesAddLabelsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check if a user can be assigned](Issues::check_user_can_be_assigned_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesCheckUserCanBeAssignedError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Otherwise a `404` status code is returned.")] Status404(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesCheckUserCanBeAssignedError) -> Self { + let (description, status_code) = match err { + IssuesCheckUserCanBeAssignedError::Status404(_) => (String::from("Otherwise a `404` status code is returned."), 404), + IssuesCheckUserCanBeAssignedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check if a user can be assigned to a issue](Issues::check_user_can_be_assigned_to_issue_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesCheckUserCanBeAssignedToIssueError { - #[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 `assignee` can not be assigned to `issue_number`")] Status404(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesCheckUserCanBeAssignedToIssueError) -> Self { + let (description, status_code) = match err { + IssuesCheckUserCanBeAssignedToIssueError::Status404(_) => (String::from("Response if `assignee` can not be assigned to `issue_number`"), 404), + IssuesCheckUserCanBeAssignedToIssueError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an issue](Issues::create_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesCreateError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Forbidden")] @@ -139,19 +151,29 @@ pub enum IssuesCreateError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesCreateError) -> Self { + let (description, status_code) = match err { + IssuesCreateError::Status400(_) => (String::from("Bad Request"), 400), + IssuesCreateError::Status403(_) => (String::from("Forbidden"), 403), + IssuesCreateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesCreateError::Status503(_) => (String::from("Service unavailable"), 503), + IssuesCreateError::Status404(_) => (String::from("Resource not found"), 404), + IssuesCreateError::Status410(_) => (String::from("Gone"), 410), + IssuesCreateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an issue comment](Issues::create_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesCreateCommentError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Gone")] @@ -164,19 +186,27 @@ pub enum IssuesCreateCommentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesCreateCommentError) -> Self { + let (description, status_code) = match err { + IssuesCreateCommentError::Status403(_) => (String::from("Forbidden"), 403), + IssuesCreateCommentError::Status410(_) => (String::from("Gone"), 410), + IssuesCreateCommentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesCreateCommentError::Status404(_) => (String::from("Resource not found"), 404), + IssuesCreateCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a label](Issues::create_label_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesCreateLabelError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -185,19 +215,25 @@ pub enum IssuesCreateLabelError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesCreateLabelError) -> Self { + let (description, status_code) = match err { + IssuesCreateLabelError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesCreateLabelError::Status404(_) => (String::from("Resource not found"), 404), + IssuesCreateLabelError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a milestone](Issues::create_milestone_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesCreateMilestoneError { - #[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, or the endpoint has been spammed.")] @@ -206,72 +242,91 @@ pub enum IssuesCreateMilestoneError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesCreateMilestoneError) -> Self { + let (description, status_code) = match err { + IssuesCreateMilestoneError::Status404(_) => (String::from("Resource not found"), 404), + IssuesCreateMilestoneError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesCreateMilestoneError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an issue comment](Issues::delete_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesDeleteCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesDeleteCommentError) -> Self { + let (description, status_code) = match err { + IssuesDeleteCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a label](Issues::delete_label_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesDeleteLabelError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesDeleteLabelError) -> Self { + let (description, status_code) = match err { + IssuesDeleteLabelError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a milestone](Issues::delete_milestone_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesDeleteMilestoneError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesDeleteMilestoneError) -> Self { + let (description, status_code) = match err { + IssuesDeleteMilestoneError::Status404(_) => (String::from("Resource not found"), 404), + IssuesDeleteMilestoneError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an issue](Issues::get_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesGetError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Moved permanently")] Status301(BasicError), #[error("Resource not found")] @@ -284,38 +339,51 @@ pub enum IssuesGetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesGetError) -> Self { + let (description, status_code) = match err { + IssuesGetError::Status301(_) => (String::from("Moved permanently"), 301), + IssuesGetError::Status404(_) => (String::from("Resource not found"), 404), + IssuesGetError::Status410(_) => (String::from("Gone"), 410), + IssuesGetError::Status304 => (String::from("Not modified"), 304), + IssuesGetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an issue comment](Issues::get_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesGetCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesGetCommentError) -> Self { + let (description, status_code) = match err { + IssuesGetCommentError::Status404(_) => (String::from("Resource not found"), 404), + IssuesGetCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an issue event](Issues::get_event_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesGetEventError { - #[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("Gone")] @@ -326,57 +394,74 @@ pub enum IssuesGetEventError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesGetEventError) -> Self { + let (description, status_code) = match err { + IssuesGetEventError::Status404(_) => (String::from("Resource not found"), 404), + IssuesGetEventError::Status410(_) => (String::from("Gone"), 410), + IssuesGetEventError::Status403(_) => (String::from("Forbidden"), 403), + IssuesGetEventError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a label](Issues::get_label_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesGetLabelError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesGetLabelError) -> Self { + let (description, status_code) = match err { + IssuesGetLabelError::Status404(_) => (String::from("Resource not found"), 404), + IssuesGetLabelError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a milestone](Issues::get_milestone_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesGetMilestoneError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesGetMilestoneError) -> Self { + let (description, status_code) = match err { + IssuesGetMilestoneError::Status404(_) => (String::from("Resource not found"), 404), + IssuesGetMilestoneError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List issues assigned to the authenticated user](Issues::list_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -387,38 +472,50 @@ pub enum IssuesListError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesListError) -> Self { + let (description, status_code) = match err { + IssuesListError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesListError::Status304 => (String::from("Not modified"), 304), + IssuesListError::Status404(_) => (String::from("Resource not found"), 404), + IssuesListError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List assignees](Issues::list_assignees_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListAssigneesError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesListAssigneesError) -> Self { + let (description, status_code) = match err { + IssuesListAssigneesError::Status404(_) => (String::from("Resource not found"), 404), + IssuesListAssigneesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List issue comments](Issues::list_comments_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListCommentsError { - #[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("Gone")] @@ -427,19 +524,25 @@ pub enum IssuesListCommentsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesListCommentsError) -> Self { + let (description, status_code) = match err { + IssuesListCommentsError::Status404(_) => (String::from("Resource not found"), 404), + IssuesListCommentsError::Status410(_) => (String::from("Gone"), 410), + IssuesListCommentsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List issue comments for a repository](Issues::list_comments_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListCommentsForRepoError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -448,57 +551,73 @@ pub enum IssuesListCommentsForRepoError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesListCommentsForRepoError) -> Self { + let (description, status_code) = match err { + IssuesListCommentsForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesListCommentsForRepoError::Status404(_) => (String::from("Resource not found"), 404), + IssuesListCommentsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List issue events](Issues::list_events_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListEventsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Gone")] Status410(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesListEventsError) -> Self { + let (description, status_code) = match err { + IssuesListEventsError::Status410(_) => (String::from("Gone"), 410), + IssuesListEventsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List issue events for a repository](Issues::list_events_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListEventsForRepoError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesListEventsForRepoError) -> Self { + let (description, status_code) = match err { + IssuesListEventsForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesListEventsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List timeline events for an issue](Issues::list_events_for_timeline_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListEventsForTimelineError { - #[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("Gone")] @@ -507,19 +626,25 @@ pub enum IssuesListEventsForTimelineError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesListEventsForTimelineError) -> Self { + let (description, status_code) = match err { + IssuesListEventsForTimelineError::Status404(_) => (String::from("Resource not found"), 404), + IssuesListEventsForTimelineError::Status410(_) => (String::from("Gone"), 410), + IssuesListEventsForTimelineError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List user account issues assigned to the authenticated user](Issues::list_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListForAuthenticatedUserError { - #[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("Not modified")] @@ -528,38 +653,49 @@ pub enum IssuesListForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesListForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + IssuesListForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + IssuesListForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + IssuesListForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization issues assigned to the authenticated user](Issues::list_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesListForOrgError) -> Self { + let (description, status_code) = match err { + IssuesListForOrgError::Status404(_) => (String::from("Resource not found"), 404), + IssuesListForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository issues](Issues::list_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListForRepoError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Moved permanently")] Status301(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -570,55 +706,71 @@ pub enum IssuesListForRepoError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesListForRepoError) -> Self { + let (description, status_code) = match err { + IssuesListForRepoError::Status301(_) => (String::from("Moved permanently"), 301), + IssuesListForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesListForRepoError::Status404(_) => (String::from("Resource not found"), 404), + IssuesListForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List labels for issues in a milestone](Issues::list_labels_for_milestone_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListLabelsForMilestoneError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesListLabelsForMilestoneError) -> Self { + let (description, status_code) = match err { + IssuesListLabelsForMilestoneError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List labels for a repository](Issues::list_labels_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListLabelsForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesListLabelsForRepoError) -> Self { + let (description, status_code) = match err { + IssuesListLabelsForRepoError::Status404(_) => (String::from("Resource not found"), 404), + IssuesListLabelsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List labels for an issue](Issues::list_labels_on_issue_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListLabelsOnIssueError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Moved permanently")] Status301(BasicError), #[error("Resource not found")] @@ -629,38 +781,50 @@ pub enum IssuesListLabelsOnIssueError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesListLabelsOnIssueError) -> Self { + let (description, status_code) = match err { + IssuesListLabelsOnIssueError::Status301(_) => (String::from("Moved permanently"), 301), + IssuesListLabelsOnIssueError::Status404(_) => (String::from("Resource not found"), 404), + IssuesListLabelsOnIssueError::Status410(_) => (String::from("Gone"), 410), + IssuesListLabelsOnIssueError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List milestones](Issues::list_milestones_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesListMilestonesError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesListMilestonesError) -> Self { + let (description, status_code) = match err { + IssuesListMilestonesError::Status404(_) => (String::from("Resource not found"), 404), + IssuesListMilestonesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Lock an issue](Issues::lock_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesLockError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Gone")] @@ -673,19 +837,27 @@ pub enum IssuesLockError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesLockError) -> Self { + let (description, status_code) = match err { + IssuesLockError::Status403(_) => (String::from("Forbidden"), 403), + IssuesLockError::Status410(_) => (String::from("Gone"), 410), + IssuesLockError::Status404(_) => (String::from("Resource not found"), 404), + IssuesLockError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesLockError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove all labels from an issue](Issues::remove_all_labels_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesRemoveAllLabelsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Moved permanently")] Status301(BasicError), #[error("Resource not found")] @@ -696,36 +868,47 @@ pub enum IssuesRemoveAllLabelsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesRemoveAllLabelsError) -> Self { + let (description, status_code) = match err { + IssuesRemoveAllLabelsError::Status301(_) => (String::from("Moved permanently"), 301), + IssuesRemoveAllLabelsError::Status404(_) => (String::from("Resource not found"), 404), + IssuesRemoveAllLabelsError::Status410(_) => (String::from("Gone"), 410), + IssuesRemoveAllLabelsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove assignees from an issue](Issues::remove_assignees_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesRemoveAssigneesError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesRemoveAssigneesError) -> Self { + let (description, status_code) = match err { + IssuesRemoveAssigneesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove a label from an issue](Issues::remove_label_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesRemoveLabelError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Moved permanently")] Status301(BasicError), #[error("Resource not found")] @@ -736,19 +919,26 @@ pub enum IssuesRemoveLabelError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesRemoveLabelError) -> Self { + let (description, status_code) = match err { + IssuesRemoveLabelError::Status301(_) => (String::from("Moved permanently"), 301), + IssuesRemoveLabelError::Status404(_) => (String::from("Resource not found"), 404), + IssuesRemoveLabelError::Status410(_) => (String::from("Gone"), 410), + IssuesRemoveLabelError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set labels for an issue](Issues::set_labels_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesSetLabelsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Moved permanently")] Status301(BasicError), #[error("Resource not found")] @@ -761,19 +951,27 @@ pub enum IssuesSetLabelsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesSetLabelsError) -> Self { + let (description, status_code) = match err { + IssuesSetLabelsError::Status301(_) => (String::from("Moved permanently"), 301), + IssuesSetLabelsError::Status404(_) => (String::from("Resource not found"), 404), + IssuesSetLabelsError::Status410(_) => (String::from("Gone"), 410), + IssuesSetLabelsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesSetLabelsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Unlock an issue](Issues::unlock_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesUnlockError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -782,19 +980,25 @@ pub enum IssuesUnlockError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesUnlockError) -> Self { + let (description, status_code) = match err { + IssuesUnlockError::Status403(_) => (String::from("Forbidden"), 403), + IssuesUnlockError::Status404(_) => (String::from("Resource not found"), 404), + IssuesUnlockError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update an issue](Issues::update_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesUpdateError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Service unavailable")] @@ -811,59 +1015,92 @@ pub enum IssuesUpdateError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesUpdateError) -> Self { + let (description, status_code) = match err { + IssuesUpdateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesUpdateError::Status503(_) => (String::from("Service unavailable"), 503), + IssuesUpdateError::Status403(_) => (String::from("Forbidden"), 403), + IssuesUpdateError::Status301(_) => (String::from("Moved permanently"), 301), + IssuesUpdateError::Status404(_) => (String::from("Resource not found"), 404), + IssuesUpdateError::Status410(_) => (String::from("Gone"), 410), + IssuesUpdateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update an issue comment](Issues::update_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesUpdateCommentError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: IssuesUpdateCommentError) -> Self { + let (description, status_code) = match err { + IssuesUpdateCommentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + IssuesUpdateCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a label](Issues::update_label_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesUpdateLabelError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesUpdateLabelError) -> Self { + let (description, status_code) = match err { + IssuesUpdateLabelError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a milestone](Issues::update_milestone_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum IssuesUpdateMilestoneError { - #[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 }, } +impl From for AdapterError { + fn from(err: IssuesUpdateMilestoneError) -> Self { + let (description, status_code) = match err { + IssuesUpdateMilestoneError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List issues assigned to the authenticated user](Issues::list_async()) endpoint. #[derive(Default, Serialize)] @@ -2154,7 +2391,7 @@ impl<'enc> From<&'enc PerPage> for IssuesListMilestonesParams<'enc> { } } -impl<'api, C: Client> Issues<'api, C> { +impl<'api, C: Client> Issues<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Add assignees to an issue @@ -2164,19 +2401,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for add_assignees](https://docs.github.com/rest/issues/assignees#add-assignees-to-an-issue) /// /// --- - pub async fn add_assignees_async(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesAddAssignees) -> Result { + pub async fn add_assignees_async(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesAddAssignees) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}/assignees", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesAddAssignees::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2188,7 +2425,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(IssuesAddAssigneesError::Generic { code }), + code => Err(IssuesAddAssigneesError::Generic { code }.into()), } } } @@ -2203,19 +2440,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_assignees(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesAddAssignees) -> Result { + pub fn add_assignees(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesAddAssignees) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}/assignees", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesAddAssignees::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2227,7 +2464,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(IssuesAddAssigneesError::Generic { code }), + code => Err(IssuesAddAssigneesError::Generic { code }.into()), } } } @@ -2241,19 +2478,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for add_labels](https://docs.github.com/rest/issues/labels#add-labels-to-an-issue) /// /// --- - pub async fn add_labels_async(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesAddLabels) -> Result, IssuesAddLabelsError> { + pub async fn add_labels_async(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesAddLabels) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesAddLabels::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2265,11 +2502,11 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 301 => Err(IssuesAddLabelsError::Status301(github_response.to_json_async().await?)), - 404 => Err(IssuesAddLabelsError::Status404(github_response.to_json_async().await?)), - 410 => Err(IssuesAddLabelsError::Status410(github_response.to_json_async().await?)), - 422 => Err(IssuesAddLabelsError::Status422(github_response.to_json_async().await?)), - code => Err(IssuesAddLabelsError::Generic { code }), + 301 => Err(IssuesAddLabelsError::Status301(github_response.to_json_async().await?).into()), + 404 => Err(IssuesAddLabelsError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(IssuesAddLabelsError::Status410(github_response.to_json_async().await?).into()), + 422 => Err(IssuesAddLabelsError::Status422(github_response.to_json_async().await?).into()), + code => Err(IssuesAddLabelsError::Generic { code }.into()), } } } @@ -2284,19 +2521,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_labels(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesAddLabels) -> Result, IssuesAddLabelsError> { + pub fn add_labels(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesAddLabels) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesAddLabels::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2308,11 +2545,11 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 301 => Err(IssuesAddLabelsError::Status301(github_response.to_json()?)), - 404 => Err(IssuesAddLabelsError::Status404(github_response.to_json()?)), - 410 => Err(IssuesAddLabelsError::Status410(github_response.to_json()?)), - 422 => Err(IssuesAddLabelsError::Status422(github_response.to_json()?)), - code => Err(IssuesAddLabelsError::Generic { code }), + 301 => Err(IssuesAddLabelsError::Status301(github_response.to_json()?).into()), + 404 => Err(IssuesAddLabelsError::Status404(github_response.to_json()?).into()), + 410 => Err(IssuesAddLabelsError::Status410(github_response.to_json()?).into()), + 422 => Err(IssuesAddLabelsError::Status422(github_response.to_json()?).into()), + code => Err(IssuesAddLabelsError::Generic { code }.into()), } } } @@ -2330,19 +2567,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for check_user_can_be_assigned](https://docs.github.com/rest/issues/assignees#check-if-a-user-can-be-assigned) /// /// --- - pub async fn check_user_can_be_assigned_async(&self, owner: &str, repo: &str, assignee: &str) -> Result<(), IssuesCheckUserCanBeAssignedError> { + pub async fn check_user_can_be_assigned_async(&self, owner: &str, repo: &str, assignee: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/assignees/{}", super::GITHUB_BASE_API_URL, owner, repo, assignee); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2354,8 +2591,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesCheckUserCanBeAssignedError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesCheckUserCanBeAssignedError::Generic { code }), + 404 => Err(IssuesCheckUserCanBeAssignedError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesCheckUserCanBeAssignedError::Generic { code }.into()), } } } @@ -2374,7 +2611,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_user_can_be_assigned(&self, owner: &str, repo: &str, assignee: &str) -> Result<(), IssuesCheckUserCanBeAssignedError> { + pub fn check_user_can_be_assigned(&self, owner: &str, repo: &str, assignee: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/assignees/{}", super::GITHUB_BASE_API_URL, owner, repo, assignee); @@ -2386,7 +2623,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2398,8 +2635,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesCheckUserCanBeAssignedError::Status404(github_response.to_json()?)), - code => Err(IssuesCheckUserCanBeAssignedError::Generic { code }), + 404 => Err(IssuesCheckUserCanBeAssignedError::Status404(github_response.to_json()?).into()), + code => Err(IssuesCheckUserCanBeAssignedError::Generic { code }.into()), } } } @@ -2417,19 +2654,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for check_user_can_be_assigned_to_issue](https://docs.github.com/rest/issues/assignees#check-if-a-user-can-be-assigned-to-a-issue) /// /// --- - pub async fn check_user_can_be_assigned_to_issue_async(&self, owner: &str, repo: &str, issue_number: i32, assignee: &str) -> Result<(), IssuesCheckUserCanBeAssignedToIssueError> { + pub async fn check_user_can_be_assigned_to_issue_async(&self, owner: &str, repo: &str, issue_number: i32, assignee: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/assignees/{}", super::GITHUB_BASE_API_URL, owner, repo, issue_number, assignee); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2441,8 +2678,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesCheckUserCanBeAssignedToIssueError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesCheckUserCanBeAssignedToIssueError::Generic { code }), + 404 => Err(IssuesCheckUserCanBeAssignedToIssueError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesCheckUserCanBeAssignedToIssueError::Generic { code }.into()), } } } @@ -2461,7 +2698,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_user_can_be_assigned_to_issue(&self, owner: &str, repo: &str, issue_number: i32, assignee: &str) -> Result<(), IssuesCheckUserCanBeAssignedToIssueError> { + pub fn check_user_can_be_assigned_to_issue(&self, owner: &str, repo: &str, issue_number: i32, assignee: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/assignees/{}", super::GITHUB_BASE_API_URL, owner, repo, issue_number, assignee); @@ -2473,7 +2710,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2485,8 +2722,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesCheckUserCanBeAssignedToIssueError::Status404(github_response.to_json()?)), - code => Err(IssuesCheckUserCanBeAssignedToIssueError::Generic { code }), + 404 => Err(IssuesCheckUserCanBeAssignedToIssueError::Status404(github_response.to_json()?).into()), + code => Err(IssuesCheckUserCanBeAssignedToIssueError::Generic { code }.into()), } } } @@ -2510,19 +2747,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for create](https://docs.github.com/rest/issues/issues#create-an-issue) /// /// --- - pub async fn create_async(&self, owner: &str, repo: &str, body: PostIssuesCreate) -> Result { + pub async fn create_async(&self, owner: &str, repo: &str, body: PostIssuesCreate) -> Result { let request_uri = format!("{}/repos/{}/{}/issues", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesCreate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2534,13 +2771,13 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(IssuesCreateError::Status400(github_response.to_json_async().await?)), - 403 => Err(IssuesCreateError::Status403(github_response.to_json_async().await?)), - 422 => Err(IssuesCreateError::Status422(github_response.to_json_async().await?)), - 503 => Err(IssuesCreateError::Status503(github_response.to_json_async().await?)), - 404 => Err(IssuesCreateError::Status404(github_response.to_json_async().await?)), - 410 => Err(IssuesCreateError::Status410(github_response.to_json_async().await?)), - code => Err(IssuesCreateError::Generic { code }), + 400 => Err(IssuesCreateError::Status400(github_response.to_json_async().await?).into()), + 403 => Err(IssuesCreateError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(IssuesCreateError::Status422(github_response.to_json_async().await?).into()), + 503 => Err(IssuesCreateError::Status503(github_response.to_json_async().await?).into()), + 404 => Err(IssuesCreateError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(IssuesCreateError::Status410(github_response.to_json_async().await?).into()), + code => Err(IssuesCreateError::Generic { code }.into()), } } } @@ -2565,19 +2802,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create(&self, owner: &str, repo: &str, body: PostIssuesCreate) -> Result { + pub fn create(&self, owner: &str, repo: &str, body: PostIssuesCreate) -> Result { let request_uri = format!("{}/repos/{}/{}/issues", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesCreate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2589,13 +2826,13 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(IssuesCreateError::Status400(github_response.to_json()?)), - 403 => Err(IssuesCreateError::Status403(github_response.to_json()?)), - 422 => Err(IssuesCreateError::Status422(github_response.to_json()?)), - 503 => Err(IssuesCreateError::Status503(github_response.to_json()?)), - 404 => Err(IssuesCreateError::Status404(github_response.to_json()?)), - 410 => Err(IssuesCreateError::Status410(github_response.to_json()?)), - code => Err(IssuesCreateError::Generic { code }), + 400 => Err(IssuesCreateError::Status400(github_response.to_json()?).into()), + 403 => Err(IssuesCreateError::Status403(github_response.to_json()?).into()), + 422 => Err(IssuesCreateError::Status422(github_response.to_json()?).into()), + 503 => Err(IssuesCreateError::Status503(github_response.to_json()?).into()), + 404 => Err(IssuesCreateError::Status404(github_response.to_json()?).into()), + 410 => Err(IssuesCreateError::Status410(github_response.to_json()?).into()), + code => Err(IssuesCreateError::Generic { code }.into()), } } } @@ -2621,19 +2858,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for create_comment](https://docs.github.com/rest/issues/comments#create-an-issue-comment) /// /// --- - pub async fn create_comment_async(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesCreateComment) -> Result { + pub async fn create_comment_async(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesCreateComment) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesCreateComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2645,11 +2882,11 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(IssuesCreateCommentError::Status403(github_response.to_json_async().await?)), - 410 => Err(IssuesCreateCommentError::Status410(github_response.to_json_async().await?)), - 422 => Err(IssuesCreateCommentError::Status422(github_response.to_json_async().await?)), - 404 => Err(IssuesCreateCommentError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesCreateCommentError::Generic { code }), + 403 => Err(IssuesCreateCommentError::Status403(github_response.to_json_async().await?).into()), + 410 => Err(IssuesCreateCommentError::Status410(github_response.to_json_async().await?).into()), + 422 => Err(IssuesCreateCommentError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(IssuesCreateCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesCreateCommentError::Generic { code }.into()), } } } @@ -2676,19 +2913,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_comment(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesCreateComment) -> Result { + pub fn create_comment(&self, owner: &str, repo: &str, issue_number: i32, body: PostIssuesCreateComment) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesCreateComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2700,11 +2937,11 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(IssuesCreateCommentError::Status403(github_response.to_json()?)), - 410 => Err(IssuesCreateCommentError::Status410(github_response.to_json()?)), - 422 => Err(IssuesCreateCommentError::Status422(github_response.to_json()?)), - 404 => Err(IssuesCreateCommentError::Status404(github_response.to_json()?)), - code => Err(IssuesCreateCommentError::Generic { code }), + 403 => Err(IssuesCreateCommentError::Status403(github_response.to_json()?).into()), + 410 => Err(IssuesCreateCommentError::Status410(github_response.to_json()?).into()), + 422 => Err(IssuesCreateCommentError::Status422(github_response.to_json()?).into()), + 404 => Err(IssuesCreateCommentError::Status404(github_response.to_json()?).into()), + code => Err(IssuesCreateCommentError::Generic { code }.into()), } } } @@ -2718,19 +2955,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for create_label](https://docs.github.com/rest/issues/labels#create-a-label) /// /// --- - pub async fn create_label_async(&self, owner: &str, repo: &str, body: PostIssuesCreateLabel) -> Result { + pub async fn create_label_async(&self, owner: &str, repo: &str, body: PostIssuesCreateLabel) -> Result { let request_uri = format!("{}/repos/{}/{}/labels", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesCreateLabel::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2742,9 +2979,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(IssuesCreateLabelError::Status422(github_response.to_json_async().await?)), - 404 => Err(IssuesCreateLabelError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesCreateLabelError::Generic { code }), + 422 => Err(IssuesCreateLabelError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(IssuesCreateLabelError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesCreateLabelError::Generic { code }.into()), } } } @@ -2759,19 +2996,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_label(&self, owner: &str, repo: &str, body: PostIssuesCreateLabel) -> Result { + pub fn create_label(&self, owner: &str, repo: &str, body: PostIssuesCreateLabel) -> Result { let request_uri = format!("{}/repos/{}/{}/labels", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesCreateLabel::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2783,9 +3020,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(IssuesCreateLabelError::Status422(github_response.to_json()?)), - 404 => Err(IssuesCreateLabelError::Status404(github_response.to_json()?)), - code => Err(IssuesCreateLabelError::Generic { code }), + 422 => Err(IssuesCreateLabelError::Status422(github_response.to_json()?).into()), + 404 => Err(IssuesCreateLabelError::Status404(github_response.to_json()?).into()), + code => Err(IssuesCreateLabelError::Generic { code }.into()), } } } @@ -2799,19 +3036,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for create_milestone](https://docs.github.com/rest/issues/milestones#create-a-milestone) /// /// --- - pub async fn create_milestone_async(&self, owner: &str, repo: &str, body: PostIssuesCreateMilestone) -> Result { + pub async fn create_milestone_async(&self, owner: &str, repo: &str, body: PostIssuesCreateMilestone) -> Result { let request_uri = format!("{}/repos/{}/{}/milestones", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesCreateMilestone::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2823,9 +3060,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesCreateMilestoneError::Status404(github_response.to_json_async().await?)), - 422 => Err(IssuesCreateMilestoneError::Status422(github_response.to_json_async().await?)), - code => Err(IssuesCreateMilestoneError::Generic { code }), + 404 => Err(IssuesCreateMilestoneError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(IssuesCreateMilestoneError::Status422(github_response.to_json_async().await?).into()), + code => Err(IssuesCreateMilestoneError::Generic { code }.into()), } } } @@ -2840,19 +3077,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_milestone(&self, owner: &str, repo: &str, body: PostIssuesCreateMilestone) -> Result { + pub fn create_milestone(&self, owner: &str, repo: &str, body: PostIssuesCreateMilestone) -> Result { let request_uri = format!("{}/repos/{}/{}/milestones", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostIssuesCreateMilestone::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2864,9 +3101,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesCreateMilestoneError::Status404(github_response.to_json()?)), - 422 => Err(IssuesCreateMilestoneError::Status422(github_response.to_json()?)), - code => Err(IssuesCreateMilestoneError::Generic { code }), + 404 => Err(IssuesCreateMilestoneError::Status404(github_response.to_json()?).into()), + 422 => Err(IssuesCreateMilestoneError::Status422(github_response.to_json()?).into()), + code => Err(IssuesCreateMilestoneError::Generic { code }.into()), } } } @@ -2880,19 +3117,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for delete_comment](https://docs.github.com/rest/issues/comments#delete-an-issue-comment) /// /// --- - pub async fn delete_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), IssuesDeleteCommentError> { + pub async fn delete_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2904,7 +3141,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(IssuesDeleteCommentError::Generic { code }), + code => Err(IssuesDeleteCommentError::Generic { code }.into()), } } } @@ -2919,7 +3156,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), IssuesDeleteCommentError> { + pub fn delete_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -2931,7 +3168,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2943,7 +3180,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(IssuesDeleteCommentError::Generic { code }), + code => Err(IssuesDeleteCommentError::Generic { code }.into()), } } } @@ -2957,19 +3194,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for delete_label](https://docs.github.com/rest/issues/labels#delete-a-label) /// /// --- - pub async fn delete_label_async(&self, owner: &str, repo: &str, name: &str) -> Result<(), IssuesDeleteLabelError> { + pub async fn delete_label_async(&self, owner: &str, repo: &str, name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2981,7 +3218,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(IssuesDeleteLabelError::Generic { code }), + code => Err(IssuesDeleteLabelError::Generic { code }.into()), } } } @@ -2996,7 +3233,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_label(&self, owner: &str, repo: &str, name: &str) -> Result<(), IssuesDeleteLabelError> { + pub fn delete_label(&self, owner: &str, repo: &str, name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, name); @@ -3008,7 +3245,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3020,7 +3257,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(IssuesDeleteLabelError::Generic { code }), + code => Err(IssuesDeleteLabelError::Generic { code }.into()), } } } @@ -3034,19 +3271,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for delete_milestone](https://docs.github.com/rest/issues/milestones#delete-a-milestone) /// /// --- - pub async fn delete_milestone_async(&self, owner: &str, repo: &str, milestone_number: i32) -> Result<(), IssuesDeleteMilestoneError> { + pub async fn delete_milestone_async(&self, owner: &str, repo: &str, milestone_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/milestones/{}", super::GITHUB_BASE_API_URL, owner, repo, milestone_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3058,8 +3295,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesDeleteMilestoneError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesDeleteMilestoneError::Generic { code }), + 404 => Err(IssuesDeleteMilestoneError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesDeleteMilestoneError::Generic { code }.into()), } } } @@ -3074,7 +3311,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_milestone(&self, owner: &str, repo: &str, milestone_number: i32) -> Result<(), IssuesDeleteMilestoneError> { + pub fn delete_milestone(&self, owner: &str, repo: &str, milestone_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/milestones/{}", super::GITHUB_BASE_API_URL, owner, repo, milestone_number); @@ -3086,7 +3323,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3098,8 +3335,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesDeleteMilestoneError::Status404(github_response.to_json()?)), - code => Err(IssuesDeleteMilestoneError::Generic { code }), + 404 => Err(IssuesDeleteMilestoneError::Status404(github_response.to_json()?).into()), + code => Err(IssuesDeleteMilestoneError::Generic { code }.into()), } } } @@ -3128,19 +3365,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for get](https://docs.github.com/rest/issues/issues#get-an-issue) /// /// --- - pub async fn get_async(&self, owner: &str, repo: &str, issue_number: i32) -> Result { + pub async fn get_async(&self, owner: &str, repo: &str, issue_number: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3152,11 +3389,11 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 301 => Err(IssuesGetError::Status301(github_response.to_json_async().await?)), - 404 => Err(IssuesGetError::Status404(github_response.to_json_async().await?)), - 410 => Err(IssuesGetError::Status410(github_response.to_json_async().await?)), - 304 => Err(IssuesGetError::Status304), - code => Err(IssuesGetError::Generic { code }), + 301 => Err(IssuesGetError::Status301(github_response.to_json_async().await?).into()), + 404 => Err(IssuesGetError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(IssuesGetError::Status410(github_response.to_json_async().await?).into()), + 304 => Err(IssuesGetError::Status304.into()), + code => Err(IssuesGetError::Generic { code }.into()), } } } @@ -3186,7 +3423,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get(&self, owner: &str, repo: &str, issue_number: i32) -> Result { + pub fn get(&self, owner: &str, repo: &str, issue_number: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -3198,7 +3435,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3210,11 +3447,11 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 301 => Err(IssuesGetError::Status301(github_response.to_json()?)), - 404 => Err(IssuesGetError::Status404(github_response.to_json()?)), - 410 => Err(IssuesGetError::Status410(github_response.to_json()?)), - 304 => Err(IssuesGetError::Status304), - code => Err(IssuesGetError::Generic { code }), + 301 => Err(IssuesGetError::Status301(github_response.to_json()?).into()), + 404 => Err(IssuesGetError::Status404(github_response.to_json()?).into()), + 410 => Err(IssuesGetError::Status410(github_response.to_json()?).into()), + 304 => Err(IssuesGetError::Status304.into()), + code => Err(IssuesGetError::Generic { code }.into()), } } } @@ -3235,19 +3472,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for get_comment](https://docs.github.com/rest/issues/comments#get-an-issue-comment) /// /// --- - pub async fn get_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result { + pub async fn get_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3259,8 +3496,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesGetCommentError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesGetCommentError::Generic { code }), + 404 => Err(IssuesGetCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesGetCommentError::Generic { code }.into()), } } } @@ -3282,7 +3519,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result { + pub fn get_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -3294,7 +3531,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3306,8 +3543,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesGetCommentError::Status404(github_response.to_json()?)), - code => Err(IssuesGetCommentError::Generic { code }), + 404 => Err(IssuesGetCommentError::Status404(github_response.to_json()?).into()), + code => Err(IssuesGetCommentError::Generic { code }.into()), } } } @@ -3321,19 +3558,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for get_event](https://docs.github.com/rest/issues/events#get-an-issue-event) /// /// --- - pub async fn get_event_async(&self, owner: &str, repo: &str, event_id: i32) -> Result { + pub async fn get_event_async(&self, owner: &str, repo: &str, event_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/events/{}", super::GITHUB_BASE_API_URL, owner, repo, event_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3345,10 +3582,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesGetEventError::Status404(github_response.to_json_async().await?)), - 410 => Err(IssuesGetEventError::Status410(github_response.to_json_async().await?)), - 403 => Err(IssuesGetEventError::Status403(github_response.to_json_async().await?)), - code => Err(IssuesGetEventError::Generic { code }), + 404 => Err(IssuesGetEventError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(IssuesGetEventError::Status410(github_response.to_json_async().await?).into()), + 403 => Err(IssuesGetEventError::Status403(github_response.to_json_async().await?).into()), + code => Err(IssuesGetEventError::Generic { code }.into()), } } } @@ -3363,7 +3600,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_event(&self, owner: &str, repo: &str, event_id: i32) -> Result { + pub fn get_event(&self, owner: &str, repo: &str, event_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/events/{}", super::GITHUB_BASE_API_URL, owner, repo, event_id); @@ -3375,7 +3612,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3387,10 +3624,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesGetEventError::Status404(github_response.to_json()?)), - 410 => Err(IssuesGetEventError::Status410(github_response.to_json()?)), - 403 => Err(IssuesGetEventError::Status403(github_response.to_json()?)), - code => Err(IssuesGetEventError::Generic { code }), + 404 => Err(IssuesGetEventError::Status404(github_response.to_json()?).into()), + 410 => Err(IssuesGetEventError::Status410(github_response.to_json()?).into()), + 403 => Err(IssuesGetEventError::Status403(github_response.to_json()?).into()), + code => Err(IssuesGetEventError::Generic { code }.into()), } } } @@ -3404,19 +3641,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for get_label](https://docs.github.com/rest/issues/labels#get-a-label) /// /// --- - pub async fn get_label_async(&self, owner: &str, repo: &str, name: &str) -> Result { + pub async fn get_label_async(&self, owner: &str, repo: &str, name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3428,8 +3665,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesGetLabelError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesGetLabelError::Generic { code }), + 404 => Err(IssuesGetLabelError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesGetLabelError::Generic { code }.into()), } } } @@ -3444,7 +3681,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_label(&self, owner: &str, repo: &str, name: &str) -> Result { + pub fn get_label(&self, owner: &str, repo: &str, name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, name); @@ -3456,7 +3693,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3468,8 +3705,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesGetLabelError::Status404(github_response.to_json()?)), - code => Err(IssuesGetLabelError::Generic { code }), + 404 => Err(IssuesGetLabelError::Status404(github_response.to_json()?).into()), + code => Err(IssuesGetLabelError::Generic { code }.into()), } } } @@ -3483,19 +3720,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for get_milestone](https://docs.github.com/rest/issues/milestones#get-a-milestone) /// /// --- - pub async fn get_milestone_async(&self, owner: &str, repo: &str, milestone_number: i32) -> Result { + pub async fn get_milestone_async(&self, owner: &str, repo: &str, milestone_number: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/milestones/{}", super::GITHUB_BASE_API_URL, owner, repo, milestone_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3507,8 +3744,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesGetMilestoneError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesGetMilestoneError::Generic { code }), + 404 => Err(IssuesGetMilestoneError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesGetMilestoneError::Generic { code }.into()), } } } @@ -3523,7 +3760,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_milestone(&self, owner: &str, repo: &str, milestone_number: i32) -> Result { + pub fn get_milestone(&self, owner: &str, repo: &str, milestone_number: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/milestones/{}", super::GITHUB_BASE_API_URL, owner, repo, milestone_number); @@ -3535,7 +3772,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3547,8 +3784,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesGetMilestoneError::Status404(github_response.to_json()?)), - code => Err(IssuesGetMilestoneError::Generic { code }), + 404 => Err(IssuesGetMilestoneError::Status404(github_response.to_json()?).into()), + code => Err(IssuesGetMilestoneError::Generic { code }.into()), } } } @@ -3574,7 +3811,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list](https://docs.github.com/rest/issues/issues#list-issues-assigned-to-the-authenticated-user) /// /// --- - pub async fn list_async(&self, query_params: Option>>) -> Result, IssuesListError> { + pub async fn list_async(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/issues", super::GITHUB_BASE_API_URL); @@ -3585,12 +3822,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3602,10 +3839,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(IssuesListError::Status422(github_response.to_json_async().await?)), - 304 => Err(IssuesListError::Status304), - 404 => Err(IssuesListError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesListError::Generic { code }), + 422 => Err(IssuesListError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(IssuesListError::Status304.into()), + 404 => Err(IssuesListError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesListError::Generic { code }.into()), } } } @@ -3632,7 +3869,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list(&self, query_params: Option>>) -> Result, IssuesListError> { + pub fn list(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/issues", super::GITHUB_BASE_API_URL); @@ -3649,7 +3886,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3661,10 +3898,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(IssuesListError::Status422(github_response.to_json()?)), - 304 => Err(IssuesListError::Status304), - 404 => Err(IssuesListError::Status404(github_response.to_json()?)), - code => Err(IssuesListError::Generic { code }), + 422 => Err(IssuesListError::Status422(github_response.to_json()?).into()), + 304 => Err(IssuesListError::Status304.into()), + 404 => Err(IssuesListError::Status404(github_response.to_json()?).into()), + code => Err(IssuesListError::Generic { code }.into()), } } } @@ -3678,7 +3915,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_assignees](https://docs.github.com/rest/issues/assignees#list-assignees) /// /// --- - pub async fn list_assignees_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, IssuesListAssigneesError> { + pub async fn list_assignees_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/assignees", super::GITHUB_BASE_API_URL, owner, repo); @@ -3689,12 +3926,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3706,8 +3943,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesListAssigneesError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesListAssigneesError::Generic { code }), + 404 => Err(IssuesListAssigneesError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesListAssigneesError::Generic { code }.into()), } } } @@ -3722,7 +3959,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_assignees(&self, owner: &str, repo: &str, query_params: Option>) -> Result, IssuesListAssigneesError> { + pub fn list_assignees(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/assignees", super::GITHUB_BASE_API_URL, owner, repo); @@ -3739,7 +3976,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3751,8 +3988,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesListAssigneesError::Status404(github_response.to_json()?)), - code => Err(IssuesListAssigneesError::Generic { code }), + 404 => Err(IssuesListAssigneesError::Status404(github_response.to_json()?).into()), + code => Err(IssuesListAssigneesError::Generic { code }.into()), } } } @@ -3775,7 +4012,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_comments](https://docs.github.com/rest/issues/comments#list-issue-comments) /// /// --- - pub async fn list_comments_async(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, IssuesListCommentsError> { + pub async fn list_comments_async(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -3786,12 +4023,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3803,9 +4040,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesListCommentsError::Status404(github_response.to_json_async().await?)), - 410 => Err(IssuesListCommentsError::Status410(github_response.to_json_async().await?)), - code => Err(IssuesListCommentsError::Generic { code }), + 404 => Err(IssuesListCommentsError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(IssuesListCommentsError::Status410(github_response.to_json_async().await?).into()), + code => Err(IssuesListCommentsError::Generic { code }.into()), } } } @@ -3829,7 +4066,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_comments(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, IssuesListCommentsError> { + pub fn list_comments(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -3846,7 +4083,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3858,9 +4095,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesListCommentsError::Status404(github_response.to_json()?)), - 410 => Err(IssuesListCommentsError::Status410(github_response.to_json()?)), - code => Err(IssuesListCommentsError::Generic { code }), + 404 => Err(IssuesListCommentsError::Status404(github_response.to_json()?).into()), + 410 => Err(IssuesListCommentsError::Status410(github_response.to_json()?).into()), + code => Err(IssuesListCommentsError::Generic { code }.into()), } } } @@ -3883,7 +4120,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_comments_for_repo](https://docs.github.com/rest/issues/comments#list-issue-comments-for-a-repository) /// /// --- - pub async fn list_comments_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, IssuesListCommentsForRepoError> { + pub async fn list_comments_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/comments", super::GITHUB_BASE_API_URL, owner, repo); @@ -3894,12 +4131,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3911,9 +4148,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(IssuesListCommentsForRepoError::Status422(github_response.to_json_async().await?)), - 404 => Err(IssuesListCommentsForRepoError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesListCommentsForRepoError::Generic { code }), + 422 => Err(IssuesListCommentsForRepoError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(IssuesListCommentsForRepoError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesListCommentsForRepoError::Generic { code }.into()), } } } @@ -3937,7 +4174,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_comments_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, IssuesListCommentsForRepoError> { + pub fn list_comments_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/comments", super::GITHUB_BASE_API_URL, owner, repo); @@ -3954,7 +4191,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3966,9 +4203,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(IssuesListCommentsForRepoError::Status422(github_response.to_json()?)), - 404 => Err(IssuesListCommentsForRepoError::Status404(github_response.to_json()?)), - code => Err(IssuesListCommentsForRepoError::Generic { code }), + 422 => Err(IssuesListCommentsForRepoError::Status422(github_response.to_json()?).into()), + 404 => Err(IssuesListCommentsForRepoError::Status404(github_response.to_json()?).into()), + code => Err(IssuesListCommentsForRepoError::Generic { code }.into()), } } } @@ -3982,7 +4219,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_events](https://docs.github.com/rest/issues/events#list-issue-events) /// /// --- - pub async fn list_events_async(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, IssuesListEventsError> { + pub async fn list_events_async(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/{}/events", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -3993,12 +4230,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4010,8 +4247,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 410 => Err(IssuesListEventsError::Status410(github_response.to_json_async().await?)), - code => Err(IssuesListEventsError::Generic { code }), + 410 => Err(IssuesListEventsError::Status410(github_response.to_json_async().await?).into()), + code => Err(IssuesListEventsError::Generic { code }.into()), } } } @@ -4026,7 +4263,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_events(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, IssuesListEventsError> { + pub fn list_events(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/{}/events", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -4043,7 +4280,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4055,8 +4292,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 410 => Err(IssuesListEventsError::Status410(github_response.to_json()?)), - code => Err(IssuesListEventsError::Generic { code }), + 410 => Err(IssuesListEventsError::Status410(github_response.to_json()?).into()), + code => Err(IssuesListEventsError::Generic { code }.into()), } } } @@ -4070,7 +4307,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_events_for_repo](https://docs.github.com/rest/issues/events#list-issue-events-for-a-repository) /// /// --- - pub async fn list_events_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, IssuesListEventsForRepoError> { + pub async fn list_events_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/events", super::GITHUB_BASE_API_URL, owner, repo); @@ -4081,12 +4318,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4098,8 +4335,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(IssuesListEventsForRepoError::Status422(github_response.to_json_async().await?)), - code => Err(IssuesListEventsForRepoError::Generic { code }), + 422 => Err(IssuesListEventsForRepoError::Status422(github_response.to_json_async().await?).into()), + code => Err(IssuesListEventsForRepoError::Generic { code }.into()), } } } @@ -4114,7 +4351,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_events_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result, IssuesListEventsForRepoError> { + pub fn list_events_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/events", super::GITHUB_BASE_API_URL, owner, repo); @@ -4131,7 +4368,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4143,8 +4380,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(IssuesListEventsForRepoError::Status422(github_response.to_json()?)), - code => Err(IssuesListEventsForRepoError::Generic { code }), + 422 => Err(IssuesListEventsForRepoError::Status422(github_response.to_json()?).into()), + code => Err(IssuesListEventsForRepoError::Generic { code }.into()), } } } @@ -4158,7 +4395,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_events_for_timeline](https://docs.github.com/rest/issues/timeline#list-timeline-events-for-an-issue) /// /// --- - pub async fn list_events_for_timeline_async(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, IssuesListEventsForTimelineError> { + pub async fn list_events_for_timeline_async(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/{}/timeline", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -4169,12 +4406,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4186,9 +4423,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesListEventsForTimelineError::Status404(github_response.to_json_async().await?)), - 410 => Err(IssuesListEventsForTimelineError::Status410(github_response.to_json_async().await?)), - code => Err(IssuesListEventsForTimelineError::Generic { code }), + 404 => Err(IssuesListEventsForTimelineError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(IssuesListEventsForTimelineError::Status410(github_response.to_json_async().await?).into()), + code => Err(IssuesListEventsForTimelineError::Generic { code }.into()), } } } @@ -4203,7 +4440,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_events_for_timeline(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, IssuesListEventsForTimelineError> { + pub fn list_events_for_timeline(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/{}/timeline", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -4220,7 +4457,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4232,9 +4469,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesListEventsForTimelineError::Status404(github_response.to_json()?)), - 410 => Err(IssuesListEventsForTimelineError::Status410(github_response.to_json()?)), - code => Err(IssuesListEventsForTimelineError::Generic { code }), + 404 => Err(IssuesListEventsForTimelineError::Status404(github_response.to_json()?).into()), + 410 => Err(IssuesListEventsForTimelineError::Status410(github_response.to_json()?).into()), + code => Err(IssuesListEventsForTimelineError::Generic { code }.into()), } } } @@ -4258,7 +4495,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/issues/issues#list-user-account-issues-assigned-to-the-authenticated-user) /// /// --- - pub async fn list_for_authenticated_user_async(&self, query_params: Option>>) -> Result, IssuesListForAuthenticatedUserError> { + pub async fn list_for_authenticated_user_async(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/issues", super::GITHUB_BASE_API_URL); @@ -4269,12 +4506,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4286,9 +4523,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesListForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 304 => Err(IssuesListForAuthenticatedUserError::Status304), - code => Err(IssuesListForAuthenticatedUserError::Generic { code }), + 404 => Err(IssuesListForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(IssuesListForAuthenticatedUserError::Status304.into()), + code => Err(IssuesListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4313,7 +4550,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_authenticated_user(&self, query_params: Option>>) -> Result, IssuesListForAuthenticatedUserError> { + pub fn list_for_authenticated_user(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/issues", super::GITHUB_BASE_API_URL); @@ -4330,7 +4567,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4342,9 +4579,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesListForAuthenticatedUserError::Status404(github_response.to_json()?)), - 304 => Err(IssuesListForAuthenticatedUserError::Status304), - code => Err(IssuesListForAuthenticatedUserError::Generic { code }), + 404 => Err(IssuesListForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 304 => Err(IssuesListForAuthenticatedUserError::Status304.into()), + code => Err(IssuesListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4368,7 +4605,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_for_org](https://docs.github.com/rest/issues/issues#list-organization-issues-assigned-to-the-authenticated-user) /// /// --- - pub async fn list_for_org_async(&self, org: &str, query_params: Option>>) -> Result, IssuesListForOrgError> { + pub async fn list_for_org_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/issues", super::GITHUB_BASE_API_URL, org); @@ -4379,12 +4616,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4396,8 +4633,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesListForOrgError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesListForOrgError::Generic { code }), + 404 => Err(IssuesListForOrgError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesListForOrgError::Generic { code }.into()), } } } @@ -4422,7 +4659,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_org(&self, org: &str, query_params: Option>>) -> Result, IssuesListForOrgError> { + pub fn list_for_org(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/issues", super::GITHUB_BASE_API_URL, org); @@ -4439,7 +4676,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4451,8 +4688,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesListForOrgError::Status404(github_response.to_json()?)), - code => Err(IssuesListForOrgError::Generic { code }), + 404 => Err(IssuesListForOrgError::Status404(github_response.to_json()?).into()), + code => Err(IssuesListForOrgError::Generic { code }.into()), } } } @@ -4476,7 +4713,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_for_repo](https://docs.github.com/rest/issues/issues#list-repository-issues) /// /// --- - pub async fn list_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, IssuesListForRepoError> { + pub async fn list_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues", super::GITHUB_BASE_API_URL, owner, repo); @@ -4487,12 +4724,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4504,10 +4741,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 301 => Err(IssuesListForRepoError::Status301(github_response.to_json_async().await?)), - 422 => Err(IssuesListForRepoError::Status422(github_response.to_json_async().await?)), - 404 => Err(IssuesListForRepoError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesListForRepoError::Generic { code }), + 301 => Err(IssuesListForRepoError::Status301(github_response.to_json_async().await?).into()), + 422 => Err(IssuesListForRepoError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(IssuesListForRepoError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesListForRepoError::Generic { code }.into()), } } } @@ -4532,7 +4769,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, IssuesListForRepoError> { + pub fn list_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues", super::GITHUB_BASE_API_URL, owner, repo); @@ -4549,7 +4786,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4561,10 +4798,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 301 => Err(IssuesListForRepoError::Status301(github_response.to_json()?)), - 422 => Err(IssuesListForRepoError::Status422(github_response.to_json()?)), - 404 => Err(IssuesListForRepoError::Status404(github_response.to_json()?)), - code => Err(IssuesListForRepoError::Generic { code }), + 301 => Err(IssuesListForRepoError::Status301(github_response.to_json()?).into()), + 422 => Err(IssuesListForRepoError::Status422(github_response.to_json()?).into()), + 404 => Err(IssuesListForRepoError::Status404(github_response.to_json()?).into()), + code => Err(IssuesListForRepoError::Generic { code }.into()), } } } @@ -4578,7 +4815,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_labels_for_milestone](https://docs.github.com/rest/issues/labels#list-labels-for-issues-in-a-milestone) /// /// --- - pub async fn list_labels_for_milestone_async(&self, owner: &str, repo: &str, milestone_number: i32, query_params: Option>) -> Result, IssuesListLabelsForMilestoneError> { + pub async fn list_labels_for_milestone_async(&self, owner: &str, repo: &str, milestone_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/milestones/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, milestone_number); @@ -4589,12 +4826,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4606,7 +4843,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(IssuesListLabelsForMilestoneError::Generic { code }), + code => Err(IssuesListLabelsForMilestoneError::Generic { code }.into()), } } } @@ -4621,7 +4858,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_labels_for_milestone(&self, owner: &str, repo: &str, milestone_number: i32, query_params: Option>) -> Result, IssuesListLabelsForMilestoneError> { + pub fn list_labels_for_milestone(&self, owner: &str, repo: &str, milestone_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/milestones/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, milestone_number); @@ -4638,7 +4875,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4650,7 +4887,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(IssuesListLabelsForMilestoneError::Generic { code }), + code => Err(IssuesListLabelsForMilestoneError::Generic { code }.into()), } } } @@ -4664,7 +4901,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_labels_for_repo](https://docs.github.com/rest/issues/labels#list-labels-for-a-repository) /// /// --- - pub async fn list_labels_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, IssuesListLabelsForRepoError> { + pub async fn list_labels_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/labels", super::GITHUB_BASE_API_URL, owner, repo); @@ -4675,12 +4912,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4692,8 +4929,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesListLabelsForRepoError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesListLabelsForRepoError::Generic { code }), + 404 => Err(IssuesListLabelsForRepoError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesListLabelsForRepoError::Generic { code }.into()), } } } @@ -4708,7 +4945,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_labels_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result, IssuesListLabelsForRepoError> { + pub fn list_labels_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/labels", super::GITHUB_BASE_API_URL, owner, repo); @@ -4725,7 +4962,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4737,8 +4974,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesListLabelsForRepoError::Status404(github_response.to_json()?)), - code => Err(IssuesListLabelsForRepoError::Generic { code }), + 404 => Err(IssuesListLabelsForRepoError::Status404(github_response.to_json()?).into()), + code => Err(IssuesListLabelsForRepoError::Generic { code }.into()), } } } @@ -4752,7 +4989,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_labels_on_issue](https://docs.github.com/rest/issues/labels#list-labels-for-an-issue) /// /// --- - pub async fn list_labels_on_issue_async(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, IssuesListLabelsOnIssueError> { + pub async fn list_labels_on_issue_async(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -4763,12 +5000,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4780,10 +5017,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 301 => Err(IssuesListLabelsOnIssueError::Status301(github_response.to_json_async().await?)), - 404 => Err(IssuesListLabelsOnIssueError::Status404(github_response.to_json_async().await?)), - 410 => Err(IssuesListLabelsOnIssueError::Status410(github_response.to_json_async().await?)), - code => Err(IssuesListLabelsOnIssueError::Generic { code }), + 301 => Err(IssuesListLabelsOnIssueError::Status301(github_response.to_json_async().await?).into()), + 404 => Err(IssuesListLabelsOnIssueError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(IssuesListLabelsOnIssueError::Status410(github_response.to_json_async().await?).into()), + code => Err(IssuesListLabelsOnIssueError::Generic { code }.into()), } } } @@ -4798,7 +5035,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_labels_on_issue(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, IssuesListLabelsOnIssueError> { + pub fn list_labels_on_issue(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -4815,7 +5052,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4827,10 +5064,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 301 => Err(IssuesListLabelsOnIssueError::Status301(github_response.to_json()?)), - 404 => Err(IssuesListLabelsOnIssueError::Status404(github_response.to_json()?)), - 410 => Err(IssuesListLabelsOnIssueError::Status410(github_response.to_json()?)), - code => Err(IssuesListLabelsOnIssueError::Generic { code }), + 301 => Err(IssuesListLabelsOnIssueError::Status301(github_response.to_json()?).into()), + 404 => Err(IssuesListLabelsOnIssueError::Status404(github_response.to_json()?).into()), + 410 => Err(IssuesListLabelsOnIssueError::Status410(github_response.to_json()?).into()), + code => Err(IssuesListLabelsOnIssueError::Generic { code }.into()), } } } @@ -4844,7 +5081,7 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for list_milestones](https://docs.github.com/rest/issues/milestones#list-milestones) /// /// --- - pub async fn list_milestones_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, IssuesListMilestonesError> { + pub async fn list_milestones_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/milestones", super::GITHUB_BASE_API_URL, owner, repo); @@ -4855,12 +5092,12 @@ impl<'api, C: Client> Issues<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4872,8 +5109,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(IssuesListMilestonesError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesListMilestonesError::Generic { code }), + 404 => Err(IssuesListMilestonesError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesListMilestonesError::Generic { code }.into()), } } } @@ -4888,7 +5125,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_milestones(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, IssuesListMilestonesError> { + pub fn list_milestones(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/milestones", super::GITHUB_BASE_API_URL, owner, repo); @@ -4905,7 +5142,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4917,8 +5154,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(IssuesListMilestonesError::Status404(github_response.to_json()?)), - code => Err(IssuesListMilestonesError::Generic { code }), + 404 => Err(IssuesListMilestonesError::Status404(github_response.to_json()?).into()), + code => Err(IssuesListMilestonesError::Generic { code }.into()), } } } @@ -4934,19 +5171,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for lock](https://docs.github.com/rest/issues/issues#lock-an-issue) /// /// --- - pub async fn lock_async(&self, owner: &str, repo: &str, issue_number: i32, body: PutIssuesLock) -> Result<(), IssuesLockError> { + pub async fn lock_async(&self, owner: &str, repo: &str, issue_number: i32, body: PutIssuesLock) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/lock", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PutIssuesLock::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4958,11 +5195,11 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(IssuesLockError::Status403(github_response.to_json_async().await?)), - 410 => Err(IssuesLockError::Status410(github_response.to_json_async().await?)), - 404 => Err(IssuesLockError::Status404(github_response.to_json_async().await?)), - 422 => Err(IssuesLockError::Status422(github_response.to_json_async().await?)), - code => Err(IssuesLockError::Generic { code }), + 403 => Err(IssuesLockError::Status403(github_response.to_json_async().await?).into()), + 410 => Err(IssuesLockError::Status410(github_response.to_json_async().await?).into()), + 404 => Err(IssuesLockError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(IssuesLockError::Status422(github_response.to_json_async().await?).into()), + code => Err(IssuesLockError::Generic { code }.into()), } } } @@ -4979,19 +5216,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn lock(&self, owner: &str, repo: &str, issue_number: i32, body: PutIssuesLock) -> Result<(), IssuesLockError> { + pub fn lock(&self, owner: &str, repo: &str, issue_number: i32, body: PutIssuesLock) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/lock", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PutIssuesLock::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5003,11 +5240,11 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(IssuesLockError::Status403(github_response.to_json()?)), - 410 => Err(IssuesLockError::Status410(github_response.to_json()?)), - 404 => Err(IssuesLockError::Status404(github_response.to_json()?)), - 422 => Err(IssuesLockError::Status422(github_response.to_json()?)), - code => Err(IssuesLockError::Generic { code }), + 403 => Err(IssuesLockError::Status403(github_response.to_json()?).into()), + 410 => Err(IssuesLockError::Status410(github_response.to_json()?).into()), + 404 => Err(IssuesLockError::Status404(github_response.to_json()?).into()), + 422 => Err(IssuesLockError::Status422(github_response.to_json()?).into()), + code => Err(IssuesLockError::Generic { code }.into()), } } } @@ -5021,19 +5258,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for remove_all_labels](https://docs.github.com/rest/issues/labels#remove-all-labels-from-an-issue) /// /// --- - pub async fn remove_all_labels_async(&self, owner: &str, repo: &str, issue_number: i32) -> Result<(), IssuesRemoveAllLabelsError> { + pub async fn remove_all_labels_async(&self, owner: &str, repo: &str, issue_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5045,10 +5282,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 301 => Err(IssuesRemoveAllLabelsError::Status301(github_response.to_json_async().await?)), - 404 => Err(IssuesRemoveAllLabelsError::Status404(github_response.to_json_async().await?)), - 410 => Err(IssuesRemoveAllLabelsError::Status410(github_response.to_json_async().await?)), - code => Err(IssuesRemoveAllLabelsError::Generic { code }), + 301 => Err(IssuesRemoveAllLabelsError::Status301(github_response.to_json_async().await?).into()), + 404 => Err(IssuesRemoveAllLabelsError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(IssuesRemoveAllLabelsError::Status410(github_response.to_json_async().await?).into()), + code => Err(IssuesRemoveAllLabelsError::Generic { code }.into()), } } } @@ -5063,7 +5300,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_all_labels(&self, owner: &str, repo: &str, issue_number: i32) -> Result<(), IssuesRemoveAllLabelsError> { + pub fn remove_all_labels(&self, owner: &str, repo: &str, issue_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -5075,7 +5312,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5087,10 +5324,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 301 => Err(IssuesRemoveAllLabelsError::Status301(github_response.to_json()?)), - 404 => Err(IssuesRemoveAllLabelsError::Status404(github_response.to_json()?)), - 410 => Err(IssuesRemoveAllLabelsError::Status410(github_response.to_json()?)), - code => Err(IssuesRemoveAllLabelsError::Generic { code }), + 301 => Err(IssuesRemoveAllLabelsError::Status301(github_response.to_json()?).into()), + 404 => Err(IssuesRemoveAllLabelsError::Status404(github_response.to_json()?).into()), + 410 => Err(IssuesRemoveAllLabelsError::Status410(github_response.to_json()?).into()), + code => Err(IssuesRemoveAllLabelsError::Generic { code }.into()), } } } @@ -5104,19 +5341,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for remove_assignees](https://docs.github.com/rest/issues/assignees#remove-assignees-from-an-issue) /// /// --- - pub async fn remove_assignees_async(&self, owner: &str, repo: &str, issue_number: i32, body: DeleteIssuesRemoveAssignees) -> Result { + pub async fn remove_assignees_async(&self, owner: &str, repo: &str, issue_number: i32, body: DeleteIssuesRemoveAssignees) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}/assignees", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteIssuesRemoveAssignees::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5128,7 +5365,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(IssuesRemoveAssigneesError::Generic { code }), + code => Err(IssuesRemoveAssigneesError::Generic { code }.into()), } } } @@ -5143,19 +5380,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_assignees(&self, owner: &str, repo: &str, issue_number: i32, body: DeleteIssuesRemoveAssignees) -> Result { + pub fn remove_assignees(&self, owner: &str, repo: &str, issue_number: i32, body: DeleteIssuesRemoveAssignees) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}/assignees", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteIssuesRemoveAssignees::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5167,7 +5404,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(IssuesRemoveAssigneesError::Generic { code }), + code => Err(IssuesRemoveAssigneesError::Generic { code }.into()), } } } @@ -5181,19 +5418,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for remove_label](https://docs.github.com/rest/issues/labels#remove-a-label-from-an-issue) /// /// --- - pub async fn remove_label_async(&self, owner: &str, repo: &str, issue_number: i32, name: &str) -> Result, IssuesRemoveLabelError> { + pub async fn remove_label_async(&self, owner: &str, repo: &str, issue_number: i32, name: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, issue_number, name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5205,10 +5442,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 301 => Err(IssuesRemoveLabelError::Status301(github_response.to_json_async().await?)), - 404 => Err(IssuesRemoveLabelError::Status404(github_response.to_json_async().await?)), - 410 => Err(IssuesRemoveLabelError::Status410(github_response.to_json_async().await?)), - code => Err(IssuesRemoveLabelError::Generic { code }), + 301 => Err(IssuesRemoveLabelError::Status301(github_response.to_json_async().await?).into()), + 404 => Err(IssuesRemoveLabelError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(IssuesRemoveLabelError::Status410(github_response.to_json_async().await?).into()), + code => Err(IssuesRemoveLabelError::Generic { code }.into()), } } } @@ -5223,7 +5460,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_label(&self, owner: &str, repo: &str, issue_number: i32, name: &str) -> Result, IssuesRemoveLabelError> { + pub fn remove_label(&self, owner: &str, repo: &str, issue_number: i32, name: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, issue_number, name); @@ -5235,7 +5472,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5247,10 +5484,10 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 301 => Err(IssuesRemoveLabelError::Status301(github_response.to_json()?)), - 404 => Err(IssuesRemoveLabelError::Status404(github_response.to_json()?)), - 410 => Err(IssuesRemoveLabelError::Status410(github_response.to_json()?)), - code => Err(IssuesRemoveLabelError::Generic { code }), + 301 => Err(IssuesRemoveLabelError::Status301(github_response.to_json()?).into()), + 404 => Err(IssuesRemoveLabelError::Status404(github_response.to_json()?).into()), + 410 => Err(IssuesRemoveLabelError::Status410(github_response.to_json()?).into()), + code => Err(IssuesRemoveLabelError::Generic { code }.into()), } } } @@ -5264,19 +5501,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for set_labels](https://docs.github.com/rest/issues/labels#set-labels-for-an-issue) /// /// --- - pub async fn set_labels_async(&self, owner: &str, repo: &str, issue_number: i32, body: PutIssuesSetLabels) -> Result, IssuesSetLabelsError> { + pub async fn set_labels_async(&self, owner: &str, repo: &str, issue_number: i32, body: PutIssuesSetLabels) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PutIssuesSetLabels::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5288,11 +5525,11 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 301 => Err(IssuesSetLabelsError::Status301(github_response.to_json_async().await?)), - 404 => Err(IssuesSetLabelsError::Status404(github_response.to_json_async().await?)), - 410 => Err(IssuesSetLabelsError::Status410(github_response.to_json_async().await?)), - 422 => Err(IssuesSetLabelsError::Status422(github_response.to_json_async().await?)), - code => Err(IssuesSetLabelsError::Generic { code }), + 301 => Err(IssuesSetLabelsError::Status301(github_response.to_json_async().await?).into()), + 404 => Err(IssuesSetLabelsError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(IssuesSetLabelsError::Status410(github_response.to_json_async().await?).into()), + 422 => Err(IssuesSetLabelsError::Status422(github_response.to_json_async().await?).into()), + code => Err(IssuesSetLabelsError::Generic { code }.into()), } } } @@ -5307,19 +5544,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_labels(&self, owner: &str, repo: &str, issue_number: i32, body: PutIssuesSetLabels) -> Result, IssuesSetLabelsError> { + pub fn set_labels(&self, owner: &str, repo: &str, issue_number: i32, body: PutIssuesSetLabels) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/labels", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PutIssuesSetLabels::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5331,11 +5568,11 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 301 => Err(IssuesSetLabelsError::Status301(github_response.to_json()?)), - 404 => Err(IssuesSetLabelsError::Status404(github_response.to_json()?)), - 410 => Err(IssuesSetLabelsError::Status410(github_response.to_json()?)), - 422 => Err(IssuesSetLabelsError::Status422(github_response.to_json()?)), - code => Err(IssuesSetLabelsError::Generic { code }), + 301 => Err(IssuesSetLabelsError::Status301(github_response.to_json()?).into()), + 404 => Err(IssuesSetLabelsError::Status404(github_response.to_json()?).into()), + 410 => Err(IssuesSetLabelsError::Status410(github_response.to_json()?).into()), + 422 => Err(IssuesSetLabelsError::Status422(github_response.to_json()?).into()), + code => Err(IssuesSetLabelsError::Generic { code }.into()), } } } @@ -5349,19 +5586,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for unlock](https://docs.github.com/rest/issues/issues#unlock-an-issue) /// /// --- - pub async fn unlock_async(&self, owner: &str, repo: &str, issue_number: i32) -> Result<(), IssuesUnlockError> { + pub async fn unlock_async(&self, owner: &str, repo: &str, issue_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/lock", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5373,9 +5610,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(IssuesUnlockError::Status403(github_response.to_json_async().await?)), - 404 => Err(IssuesUnlockError::Status404(github_response.to_json_async().await?)), - code => Err(IssuesUnlockError::Generic { code }), + 403 => Err(IssuesUnlockError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(IssuesUnlockError::Status404(github_response.to_json_async().await?).into()), + code => Err(IssuesUnlockError::Generic { code }.into()), } } } @@ -5390,7 +5627,7 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn unlock(&self, owner: &str, repo: &str, issue_number: i32) -> Result<(), IssuesUnlockError> { + pub fn unlock(&self, owner: &str, repo: &str, issue_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/lock", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -5402,7 +5639,7 @@ impl<'api, C: Client> Issues<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5414,9 +5651,9 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(IssuesUnlockError::Status403(github_response.to_json()?)), - 404 => Err(IssuesUnlockError::Status404(github_response.to_json()?)), - code => Err(IssuesUnlockError::Generic { code }), + 403 => Err(IssuesUnlockError::Status403(github_response.to_json()?).into()), + 404 => Err(IssuesUnlockError::Status404(github_response.to_json()?).into()), + code => Err(IssuesUnlockError::Generic { code }.into()), } } } @@ -5437,19 +5674,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for update](https://docs.github.com/rest/issues/issues#update-an-issue) /// /// --- - pub async fn update_async(&self, owner: &str, repo: &str, issue_number: i32, body: PatchIssuesUpdate) -> Result { + pub async fn update_async(&self, owner: &str, repo: &str, issue_number: i32, body: PatchIssuesUpdate) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchIssuesUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5461,13 +5698,13 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(IssuesUpdateError::Status422(github_response.to_json_async().await?)), - 503 => Err(IssuesUpdateError::Status503(github_response.to_json_async().await?)), - 403 => Err(IssuesUpdateError::Status403(github_response.to_json_async().await?)), - 301 => Err(IssuesUpdateError::Status301(github_response.to_json_async().await?)), - 404 => Err(IssuesUpdateError::Status404(github_response.to_json_async().await?)), - 410 => Err(IssuesUpdateError::Status410(github_response.to_json_async().await?)), - code => Err(IssuesUpdateError::Generic { code }), + 422 => Err(IssuesUpdateError::Status422(github_response.to_json_async().await?).into()), + 503 => Err(IssuesUpdateError::Status503(github_response.to_json_async().await?).into()), + 403 => Err(IssuesUpdateError::Status403(github_response.to_json_async().await?).into()), + 301 => Err(IssuesUpdateError::Status301(github_response.to_json_async().await?).into()), + 404 => Err(IssuesUpdateError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(IssuesUpdateError::Status410(github_response.to_json_async().await?).into()), + code => Err(IssuesUpdateError::Generic { code }.into()), } } } @@ -5489,19 +5726,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update(&self, owner: &str, repo: &str, issue_number: i32, body: PatchIssuesUpdate) -> Result { + pub fn update(&self, owner: &str, repo: &str, issue_number: i32, body: PatchIssuesUpdate) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchIssuesUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5513,13 +5750,13 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(IssuesUpdateError::Status422(github_response.to_json()?)), - 503 => Err(IssuesUpdateError::Status503(github_response.to_json()?)), - 403 => Err(IssuesUpdateError::Status403(github_response.to_json()?)), - 301 => Err(IssuesUpdateError::Status301(github_response.to_json()?)), - 404 => Err(IssuesUpdateError::Status404(github_response.to_json()?)), - 410 => Err(IssuesUpdateError::Status410(github_response.to_json()?)), - code => Err(IssuesUpdateError::Generic { code }), + 422 => Err(IssuesUpdateError::Status422(github_response.to_json()?).into()), + 503 => Err(IssuesUpdateError::Status503(github_response.to_json()?).into()), + 403 => Err(IssuesUpdateError::Status403(github_response.to_json()?).into()), + 301 => Err(IssuesUpdateError::Status301(github_response.to_json()?).into()), + 404 => Err(IssuesUpdateError::Status404(github_response.to_json()?).into()), + 410 => Err(IssuesUpdateError::Status410(github_response.to_json()?).into()), + code => Err(IssuesUpdateError::Generic { code }.into()), } } } @@ -5540,19 +5777,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for update_comment](https://docs.github.com/rest/issues/comments#update-an-issue-comment) /// /// --- - pub async fn update_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PatchIssuesUpdateComment) -> Result { + pub async fn update_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PatchIssuesUpdateComment) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchIssuesUpdateComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5564,8 +5801,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(IssuesUpdateCommentError::Status422(github_response.to_json_async().await?)), - code => Err(IssuesUpdateCommentError::Generic { code }), + 422 => Err(IssuesUpdateCommentError::Status422(github_response.to_json_async().await?).into()), + code => Err(IssuesUpdateCommentError::Generic { code }.into()), } } } @@ -5587,19 +5824,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PatchIssuesUpdateComment) -> Result { + pub fn update_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PatchIssuesUpdateComment) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchIssuesUpdateComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5611,8 +5848,8 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(IssuesUpdateCommentError::Status422(github_response.to_json()?)), - code => Err(IssuesUpdateCommentError::Generic { code }), + 422 => Err(IssuesUpdateCommentError::Status422(github_response.to_json()?).into()), + code => Err(IssuesUpdateCommentError::Generic { code }.into()), } } } @@ -5626,19 +5863,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for update_label](https://docs.github.com/rest/issues/labels#update-a-label) /// /// --- - pub async fn update_label_async(&self, owner: &str, repo: &str, name: &str, body: PatchIssuesUpdateLabel) -> Result { + pub async fn update_label_async(&self, owner: &str, repo: &str, name: &str, body: PatchIssuesUpdateLabel) -> Result { let request_uri = format!("{}/repos/{}/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, name); let req = GitHubRequest { uri: request_uri, - body: Some(PatchIssuesUpdateLabel::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5650,7 +5887,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(IssuesUpdateLabelError::Generic { code }), + code => Err(IssuesUpdateLabelError::Generic { code }.into()), } } } @@ -5665,19 +5902,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_label(&self, owner: &str, repo: &str, name: &str, body: PatchIssuesUpdateLabel) -> Result { + pub fn update_label(&self, owner: &str, repo: &str, name: &str, body: PatchIssuesUpdateLabel) -> Result { let request_uri = format!("{}/repos/{}/{}/labels/{}", super::GITHUB_BASE_API_URL, owner, repo, name); let req = GitHubRequest { uri: request_uri, - body: Some(PatchIssuesUpdateLabel::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5689,7 +5926,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(IssuesUpdateLabelError::Generic { code }), + code => Err(IssuesUpdateLabelError::Generic { code }.into()), } } } @@ -5701,19 +5938,19 @@ impl<'api, C: Client> Issues<'api, C> { /// [GitHub API docs for update_milestone](https://docs.github.com/rest/issues/milestones#update-a-milestone) /// /// --- - pub async fn update_milestone_async(&self, owner: &str, repo: &str, milestone_number: i32, body: PatchIssuesUpdateMilestone) -> Result { + pub async fn update_milestone_async(&self, owner: &str, repo: &str, milestone_number: i32, body: PatchIssuesUpdateMilestone) -> Result { let request_uri = format!("{}/repos/{}/{}/milestones/{}", super::GITHUB_BASE_API_URL, owner, repo, milestone_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchIssuesUpdateMilestone::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5725,7 +5962,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(IssuesUpdateMilestoneError::Generic { code }), + code => Err(IssuesUpdateMilestoneError::Generic { code }.into()), } } } @@ -5738,19 +5975,19 @@ impl<'api, C: Client> Issues<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_milestone(&self, owner: &str, repo: &str, milestone_number: i32, body: PatchIssuesUpdateMilestone) -> Result { + pub fn update_milestone(&self, owner: &str, repo: &str, milestone_number: i32, body: PatchIssuesUpdateMilestone) -> Result { let request_uri = format!("{}/repos/{}/{}/milestones/{}", super::GITHUB_BASE_API_URL, owner, repo, milestone_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchIssuesUpdateMilestone::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5762,7 +5999,7 @@ impl<'api, C: Client> Issues<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(IssuesUpdateMilestoneError::Generic { code }), + code => Err(IssuesUpdateMilestoneError::Generic { code }.into()), } } } diff --git a/src/endpoints/licenses.rs b/src/endpoints/licenses.rs index 5b68dc1..c212c95 100644 --- a/src/endpoints/licenses.rs +++ b/src/endpoints/licenses.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Licenses<'api, C: Client> { +pub struct Licenses<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Licenses { +pub fn new(client: &C) -> Licenses where AdapterError: From<::Err> { Licenses { client } } /// Errors for the [Get a license](Licenses::get_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum LicensesGetError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -53,44 +43,71 @@ pub enum LicensesGetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: LicensesGetError) -> Self { + let (description, status_code) = match err { + LicensesGetError::Status403(_) => (String::from("Forbidden"), 403), + LicensesGetError::Status404(_) => (String::from("Resource not found"), 404), + LicensesGetError::Status304 => (String::from("Not modified"), 304), + LicensesGetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all commonly used licenses](Licenses::get_all_commonly_used_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum LicensesGetAllCommonlyUsedError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: LicensesGetAllCommonlyUsedError) -> Self { + let (description, status_code) = match err { + LicensesGetAllCommonlyUsedError::Status304 => (String::from("Not modified"), 304), + LicensesGetAllCommonlyUsedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the license for a repository](Licenses::get_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum LicensesGetForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: LicensesGetForRepoError) -> Self { + let (description, status_code) = match err { + LicensesGetForRepoError::Status404(_) => (String::from("Resource not found"), 404), + LicensesGetForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [Get all commonly used licenses](Licenses::get_all_commonly_used_async()) endpoint. #[derive(Default, Serialize)] @@ -166,7 +183,7 @@ impl LicensesGetForRepoParams { } -impl<'api, C: Client> Licenses<'api, C> { +impl<'api, C: Client> Licenses<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Get a license @@ -176,19 +193,19 @@ impl<'api, C: Client> Licenses<'api, C> { /// [GitHub API docs for get](https://docs.github.com/rest/licenses/licenses#get-a-license) /// /// --- - pub async fn get_async(&self, license: &str) -> Result { + pub async fn get_async(&self, license: &str) -> Result { let request_uri = format!("{}/licenses/{}", super::GITHUB_BASE_API_URL, license); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -200,10 +217,10 @@ impl<'api, C: Client> Licenses<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(LicensesGetError::Status403(github_response.to_json_async().await?)), - 404 => Err(LicensesGetError::Status404(github_response.to_json_async().await?)), - 304 => Err(LicensesGetError::Status304), - code => Err(LicensesGetError::Generic { code }), + 403 => Err(LicensesGetError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(LicensesGetError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(LicensesGetError::Status304.into()), + code => Err(LicensesGetError::Generic { code }.into()), } } } @@ -218,7 +235,7 @@ impl<'api, C: Client> Licenses<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get(&self, license: &str) -> Result { + pub fn get(&self, license: &str) -> Result { let request_uri = format!("{}/licenses/{}", super::GITHUB_BASE_API_URL, license); @@ -230,7 +247,7 @@ impl<'api, C: Client> Licenses<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -242,10 +259,10 @@ impl<'api, C: Client> Licenses<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(LicensesGetError::Status403(github_response.to_json()?)), - 404 => Err(LicensesGetError::Status404(github_response.to_json()?)), - 304 => Err(LicensesGetError::Status304), - code => Err(LicensesGetError::Generic { code }), + 403 => Err(LicensesGetError::Status403(github_response.to_json()?).into()), + 404 => Err(LicensesGetError::Status404(github_response.to_json()?).into()), + 304 => Err(LicensesGetError::Status304.into()), + code => Err(LicensesGetError::Generic { code }.into()), } } } @@ -259,7 +276,7 @@ impl<'api, C: Client> Licenses<'api, C> { /// [GitHub API docs for get_all_commonly_used](https://docs.github.com/rest/licenses/licenses#get-all-commonly-used-licenses) /// /// --- - pub async fn get_all_commonly_used_async(&self, query_params: Option>) -> Result, LicensesGetAllCommonlyUsedError> { + pub async fn get_all_commonly_used_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/licenses", super::GITHUB_BASE_API_URL); @@ -270,12 +287,12 @@ impl<'api, C: Client> Licenses<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -287,8 +304,8 @@ impl<'api, C: Client> Licenses<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(LicensesGetAllCommonlyUsedError::Status304), - code => Err(LicensesGetAllCommonlyUsedError::Generic { code }), + 304 => Err(LicensesGetAllCommonlyUsedError::Status304.into()), + code => Err(LicensesGetAllCommonlyUsedError::Generic { code }.into()), } } } @@ -303,7 +320,7 @@ impl<'api, C: Client> Licenses<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_commonly_used(&self, query_params: Option>) -> Result, LicensesGetAllCommonlyUsedError> { + pub fn get_all_commonly_used(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/licenses", super::GITHUB_BASE_API_URL); @@ -320,7 +337,7 @@ impl<'api, C: Client> Licenses<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -332,8 +349,8 @@ impl<'api, C: Client> Licenses<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(LicensesGetAllCommonlyUsedError::Status304), - code => Err(LicensesGetAllCommonlyUsedError::Generic { code }), + 304 => Err(LicensesGetAllCommonlyUsedError::Status304.into()), + code => Err(LicensesGetAllCommonlyUsedError::Generic { code }.into()), } } } @@ -352,7 +369,7 @@ impl<'api, C: Client> Licenses<'api, C> { /// [GitHub API docs for get_for_repo](https://docs.github.com/rest/licenses/licenses#get-the-license-for-a-repository) /// /// --- - pub async fn get_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub async fn get_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/license", super::GITHUB_BASE_API_URL, owner, repo); @@ -363,12 +380,12 @@ impl<'api, C: Client> Licenses<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -380,8 +397,8 @@ impl<'api, C: Client> Licenses<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(LicensesGetForRepoError::Status404(github_response.to_json_async().await?)), - code => Err(LicensesGetForRepoError::Generic { code }), + 404 => Err(LicensesGetForRepoError::Status404(github_response.to_json_async().await?).into()), + code => Err(LicensesGetForRepoError::Generic { code }.into()), } } } @@ -401,7 +418,7 @@ impl<'api, C: Client> Licenses<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub fn get_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/license", super::GITHUB_BASE_API_URL, owner, repo); @@ -418,7 +435,7 @@ impl<'api, C: Client> Licenses<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -430,8 +447,8 @@ impl<'api, C: Client> Licenses<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(LicensesGetForRepoError::Status404(github_response.to_json()?)), - code => Err(LicensesGetForRepoError::Generic { code }), + 404 => Err(LicensesGetForRepoError::Status404(github_response.to_json()?).into()), + code => Err(LicensesGetForRepoError::Generic { code }.into()), } } } diff --git a/src/endpoints/markdown.rs b/src/endpoints/markdown.rs index 1cd5aa0..066f074 100644 --- a/src/endpoints/markdown.rs +++ b/src/endpoints/markdown.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,55 +22,65 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Markdown<'api, C: Client> { +pub struct Markdown<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Markdown { +pub fn new(client: &C) -> Markdown where AdapterError: From<::Err> { Markdown { client } } /// Errors for the [Render a Markdown document](Markdown::render_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MarkdownRenderError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MarkdownRenderError) -> Self { + let (description, status_code) = match err { + MarkdownRenderError::Status304 => (String::from("Not modified"), 304), + MarkdownRenderError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Render a Markdown document in raw mode](Markdown::render_raw_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MarkdownRenderRawError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MarkdownRenderRawError) -> Self { + let (description, status_code) = match err { + MarkdownRenderRawError::Status304 => (String::from("Not modified"), 304), + MarkdownRenderRawError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + -impl<'api, C: Client> Markdown<'api, C> { +impl<'api, C: Client> Markdown<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Render a Markdown document @@ -78,19 +88,19 @@ impl<'api, C: Client> Markdown<'api, C> { /// [GitHub API docs for render](https://docs.github.com/rest/markdown/markdown#render-a-markdown-document) /// /// --- - pub async fn render_async(&self, body: PostMarkdownRender) -> Result { + pub async fn render_async(&self, body: PostMarkdownRender) -> Result { let request_uri = format!("{}/markdown", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostMarkdownRender::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -102,8 +112,8 @@ impl<'api, C: Client> Markdown<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(MarkdownRenderError::Status304), - code => Err(MarkdownRenderError::Generic { code }), + 304 => Err(MarkdownRenderError::Status304.into()), + code => Err(MarkdownRenderError::Generic { code }.into()), } } } @@ -116,19 +126,19 @@ impl<'api, C: Client> Markdown<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn render(&self, body: PostMarkdownRender) -> Result { + pub fn render(&self, body: PostMarkdownRender) -> Result { let request_uri = format!("{}/markdown", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostMarkdownRender::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -140,8 +150,8 @@ impl<'api, C: Client> Markdown<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(MarkdownRenderError::Status304), - code => Err(MarkdownRenderError::Generic { code }), + 304 => Err(MarkdownRenderError::Status304.into()), + code => Err(MarkdownRenderError::Generic { code }.into()), } } } @@ -155,19 +165,19 @@ impl<'api, C: Client> Markdown<'api, C> { /// [GitHub API docs for render_raw](https://docs.github.com/rest/markdown/markdown#render-a-markdown-document-in-raw-mode) /// /// --- - pub async fn render_raw_async(&self, body: String) -> Result { + pub async fn render_raw_async(&self, body: String) -> Result { let request_uri = format!("{}/markdown/raw", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(String::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -179,8 +189,8 @@ impl<'api, C: Client> Markdown<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(MarkdownRenderRawError::Status304), - code => Err(MarkdownRenderRawError::Generic { code }), + 304 => Err(MarkdownRenderRawError::Status304.into()), + code => Err(MarkdownRenderRawError::Generic { code }.into()), } } } @@ -195,19 +205,19 @@ impl<'api, C: Client> Markdown<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn render_raw(&self, body: String) -> Result { + pub fn render_raw(&self, body: String) -> Result { let request_uri = format!("{}/markdown/raw", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(String::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -219,8 +229,8 @@ impl<'api, C: Client> Markdown<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(MarkdownRenderRawError::Status304), - code => Err(MarkdownRenderRawError::Generic { code }), + 304 => Err(MarkdownRenderRawError::Status304.into()), + code => Err(MarkdownRenderRawError::Generic { code }.into()), } } } diff --git a/src/endpoints/meta.rs b/src/endpoints/meta.rs index 31cbfc4..9a29e11 100644 --- a/src/endpoints/meta.rs +++ b/src/endpoints/meta.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,103 +22,125 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Meta<'api, C: Client> { +pub struct Meta<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Meta { +pub fn new(client: &C) -> Meta where AdapterError: From<::Err> { Meta { client } } /// Errors for the [Get GitHub meta information](Meta::get_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MetaGetError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MetaGetError) -> Self { + let (description, status_code) = match err { + MetaGetError::Status304 => (String::from("Not modified"), 304), + MetaGetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all API versions](Meta::get_all_versions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MetaGetAllVersionsError { - #[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 }, } +impl From for AdapterError { + fn from(err: MetaGetAllVersionsError) -> Self { + let (description, status_code) = match err { + MetaGetAllVersionsError::Status404(_) => (String::from("Resource not found"), 404), + MetaGetAllVersionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get Octocat](Meta::get_octocat_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MetaGetOctocatError { - #[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 }, } +impl From for AdapterError { + fn from(err: MetaGetOctocatError) -> Self { + let (description, status_code) = match err { + MetaGetOctocatError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the Zen of GitHub](Meta::get_zen_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MetaGetZenError { - #[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 }, } +impl From for AdapterError { + fn from(err: MetaGetZenError) -> Self { + let (description, status_code) = match err { + MetaGetZenError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [GitHub API Root](Meta::root_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MetaRootError { - #[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 }, } +impl From for AdapterError { + fn from(err: MetaRootError) -> Self { + let (description, status_code) = match err { + MetaRootError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [Get Octocat](Meta::get_octocat_async()) endpoint. #[derive(Default, Serialize)] @@ -141,7 +163,7 @@ impl<'req> MetaGetOctocatParams<'req> { } -impl<'api, C: Client> Meta<'api, C> { +impl<'api, C: Client> Meta<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Get GitHub meta information @@ -158,19 +180,19 @@ impl<'api, C: Client> Meta<'api, C> { /// [GitHub API docs for get](https://docs.github.com/rest/meta/meta#get-apiname-meta-information) /// /// --- - pub async fn get_async(&self) -> Result { + pub async fn get_async(&self) -> Result { let request_uri = format!("{}/meta", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -182,8 +204,8 @@ impl<'api, C: Client> Meta<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(MetaGetError::Status304), - code => Err(MetaGetError::Generic { code }), + 304 => Err(MetaGetError::Status304.into()), + code => Err(MetaGetError::Generic { code }.into()), } } } @@ -205,7 +227,7 @@ impl<'api, C: Client> Meta<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get(&self) -> Result { + pub fn get(&self) -> Result { let request_uri = format!("{}/meta", super::GITHUB_BASE_API_URL); @@ -217,7 +239,7 @@ impl<'api, C: Client> Meta<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -229,8 +251,8 @@ impl<'api, C: Client> Meta<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(MetaGetError::Status304), - code => Err(MetaGetError::Generic { code }), + 304 => Err(MetaGetError::Status304.into()), + code => Err(MetaGetError::Generic { code }.into()), } } } @@ -244,19 +266,19 @@ impl<'api, C: Client> Meta<'api, C> { /// [GitHub API docs for get_all_versions](https://docs.github.com/rest/meta/meta#get-all-api-versions) /// /// --- - pub async fn get_all_versions_async(&self) -> Result>, MetaGetAllVersionsError> { + pub async fn get_all_versions_async(&self) -> Result>, AdapterError> { let request_uri = format!("{}/versions", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -268,8 +290,8 @@ impl<'api, C: Client> Meta<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(MetaGetAllVersionsError::Status404(github_response.to_json_async().await?)), - code => Err(MetaGetAllVersionsError::Generic { code }), + 404 => Err(MetaGetAllVersionsError::Status404(github_response.to_json_async().await?).into()), + code => Err(MetaGetAllVersionsError::Generic { code }.into()), } } } @@ -284,7 +306,7 @@ impl<'api, C: Client> Meta<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_versions(&self) -> Result>, MetaGetAllVersionsError> { + pub fn get_all_versions(&self) -> Result>, AdapterError> { let request_uri = format!("{}/versions", super::GITHUB_BASE_API_URL); @@ -296,7 +318,7 @@ impl<'api, C: Client> Meta<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -308,8 +330,8 @@ impl<'api, C: Client> Meta<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(MetaGetAllVersionsError::Status404(github_response.to_json()?)), - code => Err(MetaGetAllVersionsError::Generic { code }), + 404 => Err(MetaGetAllVersionsError::Status404(github_response.to_json()?).into()), + code => Err(MetaGetAllVersionsError::Generic { code }.into()), } } } @@ -323,7 +345,7 @@ impl<'api, C: Client> Meta<'api, C> { /// [GitHub API docs for get_octocat](https://docs.github.com/rest/meta/meta#get-octocat) /// /// --- - pub async fn get_octocat_async(&self, query_params: Option>>) -> Result { + pub async fn get_octocat_async(&self, query_params: Option>>) -> Result { let mut request_uri = format!("{}/octocat", super::GITHUB_BASE_API_URL); @@ -334,12 +356,12 @@ impl<'api, C: Client> Meta<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -351,7 +373,7 @@ impl<'api, C: Client> Meta<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(MetaGetOctocatError::Generic { code }), + code => Err(MetaGetOctocatError::Generic { code }.into()), } } } @@ -366,7 +388,7 @@ impl<'api, C: Client> Meta<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_octocat(&self, query_params: Option>>) -> Result { + pub fn get_octocat(&self, query_params: Option>>) -> Result { let mut request_uri = format!("{}/octocat", super::GITHUB_BASE_API_URL); @@ -383,7 +405,7 @@ impl<'api, C: Client> Meta<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -395,7 +417,7 @@ impl<'api, C: Client> Meta<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(MetaGetOctocatError::Generic { code }), + code => Err(MetaGetOctocatError::Generic { code }.into()), } } } @@ -409,19 +431,19 @@ impl<'api, C: Client> Meta<'api, C> { /// [GitHub API docs for get_zen](https://docs.github.com/rest/meta/meta#get-the-zen-of-github) /// /// --- - pub async fn get_zen_async(&self) -> Result { + pub async fn get_zen_async(&self) -> Result { let request_uri = format!("{}/zen", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -433,7 +455,7 @@ impl<'api, C: Client> Meta<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(MetaGetZenError::Generic { code }), + code => Err(MetaGetZenError::Generic { code }.into()), } } } @@ -448,7 +470,7 @@ impl<'api, C: Client> Meta<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_zen(&self) -> Result { + pub fn get_zen(&self) -> Result { let request_uri = format!("{}/zen", super::GITHUB_BASE_API_URL); @@ -460,7 +482,7 @@ impl<'api, C: Client> Meta<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -472,7 +494,7 @@ impl<'api, C: Client> Meta<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(MetaGetZenError::Generic { code }), + code => Err(MetaGetZenError::Generic { code }.into()), } } } @@ -486,19 +508,19 @@ impl<'api, C: Client> Meta<'api, C> { /// [GitHub API docs for root](https://docs.github.com/rest/meta/meta#github-api-root) /// /// --- - pub async fn root_async(&self) -> Result { + pub async fn root_async(&self) -> Result { let request_uri = format!("{}/", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -510,7 +532,7 @@ impl<'api, C: Client> Meta<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(MetaRootError::Generic { code }), + code => Err(MetaRootError::Generic { code }.into()), } } } @@ -525,7 +547,7 @@ impl<'api, C: Client> Meta<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn root(&self) -> Result { + pub fn root(&self) -> Result { let request_uri = format!("{}/", super::GITHUB_BASE_API_URL); @@ -537,7 +559,7 @@ impl<'api, C: Client> Meta<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -549,7 +571,7 @@ impl<'api, C: Client> Meta<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(MetaRootError::Generic { code }), + code => Err(MetaRootError::Generic { code }.into()), } } } diff --git a/src/endpoints/migrations.rs b/src/endpoints/migrations.rs index 0e76766..a319247 100644 --- a/src/endpoints/migrations.rs +++ b/src/endpoints/migrations.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,46 +22,41 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Migrations<'api, C: Client> { +pub struct Migrations<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Migrations { +pub fn new(client: &C) -> Migrations where AdapterError: From<::Err> { Migrations { client } } /// Errors for the [Cancel an import](Migrations::cancel_import_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsCancelImportError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Unavailable due to service under maintenance.")] Status503(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsCancelImportError) -> Self { + let (description, status_code) = match err { + MigrationsCancelImportError::Status503(_) => (String::from("Unavailable due to service under maintenance."), 503), + MigrationsCancelImportError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a user migration archive](Migrations::delete_archive_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsDeleteArchiveForAuthenticatedUserError { - #[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("Not modified")] @@ -74,38 +69,51 @@ pub enum MigrationsDeleteArchiveForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsDeleteArchiveForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + MigrationsDeleteArchiveForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsDeleteArchiveForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + MigrationsDeleteArchiveForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + MigrationsDeleteArchiveForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + MigrationsDeleteArchiveForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an organization migration archive](Migrations::delete_archive_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsDeleteArchiveForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: MigrationsDeleteArchiveForOrgError) -> Self { + let (description, status_code) = match err { + MigrationsDeleteArchiveForOrgError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsDeleteArchiveForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Download an organization migration archive](Migrations::download_archive_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsDownloadArchiveForOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status302, #[error("Resource not found")] @@ -114,19 +122,25 @@ pub enum MigrationsDownloadArchiveForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsDownloadArchiveForOrgError) -> Self { + let (description, status_code) = match err { + MigrationsDownloadArchiveForOrgError::Status302 => (String::from("Response"), 302), + MigrationsDownloadArchiveForOrgError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsDownloadArchiveForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Download a user migration archive](Migrations::get_archive_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsGetArchiveForAuthenticatedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status302, #[error("Not modified")] @@ -139,19 +153,27 @@ pub enum MigrationsGetArchiveForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsGetArchiveForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + MigrationsGetArchiveForAuthenticatedUserError::Status302 => (String::from("Response"), 302), + MigrationsGetArchiveForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + MigrationsGetArchiveForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + MigrationsGetArchiveForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + MigrationsGetArchiveForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get commit authors](Migrations::get_commit_authors_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsGetCommitAuthorsError { - #[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("Unavailable due to service under maintenance.")] @@ -160,19 +182,25 @@ pub enum MigrationsGetCommitAuthorsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsGetCommitAuthorsError) -> Self { + let (description, status_code) = match err { + MigrationsGetCommitAuthorsError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsGetCommitAuthorsError::Status503(_) => (String::from("Unavailable due to service under maintenance."), 503), + MigrationsGetCommitAuthorsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an import status](Migrations::get_import_status_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsGetImportStatusError { - #[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("Unavailable due to service under maintenance.")] @@ -181,38 +209,49 @@ pub enum MigrationsGetImportStatusError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsGetImportStatusError) -> Self { + let (description, status_code) = match err { + MigrationsGetImportStatusError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsGetImportStatusError::Status503(_) => (String::from("Unavailable due to service under maintenance."), 503), + MigrationsGetImportStatusError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get large files](Migrations::get_large_files_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsGetLargeFilesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Unavailable due to service under maintenance.")] Status503(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsGetLargeFilesError) -> Self { + let (description, status_code) = match err { + MigrationsGetLargeFilesError::Status503(_) => (String::from("Unavailable due to service under maintenance."), 503), + MigrationsGetLargeFilesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a user migration status](Migrations::get_status_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsGetStatusForAuthenticatedUserError { - #[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("Not modified")] @@ -225,38 +264,51 @@ pub enum MigrationsGetStatusForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsGetStatusForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + MigrationsGetStatusForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsGetStatusForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + MigrationsGetStatusForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + MigrationsGetStatusForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + MigrationsGetStatusForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization migration status](Migrations::get_status_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsGetStatusForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: MigrationsGetStatusForOrgError) -> Self { + let (description, status_code) = match err { + MigrationsGetStatusForOrgError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsGetStatusForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List user migrations](Migrations::list_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsListForAuthenticatedUserError { - #[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("Forbidden")] @@ -267,74 +319,95 @@ pub enum MigrationsListForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsListForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + MigrationsListForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + MigrationsListForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + MigrationsListForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + MigrationsListForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization migrations](Migrations::list_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsListForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: MigrationsListForOrgError) -> Self { + let (description, status_code) = match err { + MigrationsListForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories for a user migration](Migrations::list_repos_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsListReposForAuthenticatedUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: MigrationsListReposForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + MigrationsListReposForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsListReposForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories in an organization migration](Migrations::list_repos_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsListReposForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: MigrationsListReposForOrgError) -> Self { + let (description, status_code) = match err { + MigrationsListReposForOrgError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsListReposForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Map a commit author](Migrations::map_commit_author_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsMapCommitAuthorError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -345,19 +418,26 @@ pub enum MigrationsMapCommitAuthorError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsMapCommitAuthorError) -> Self { + let (description, status_code) = match err { + MigrationsMapCommitAuthorError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + MigrationsMapCommitAuthorError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsMapCommitAuthorError::Status503(_) => (String::from("Unavailable due to service under maintenance."), 503), + MigrationsMapCommitAuthorError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update Git LFS preference](Migrations::set_lfs_preference_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsSetLfsPreferenceError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Unavailable due to service under maintenance.")] @@ -366,19 +446,25 @@ pub enum MigrationsSetLfsPreferenceError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsSetLfsPreferenceError) -> Self { + let (description, status_code) = match err { + MigrationsSetLfsPreferenceError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + MigrationsSetLfsPreferenceError::Status503(_) => (String::from("Unavailable due to service under maintenance."), 503), + MigrationsSetLfsPreferenceError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Start a user migration](Migrations::start_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsStartForAuthenticatedUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -391,19 +477,27 @@ pub enum MigrationsStartForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsStartForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + MigrationsStartForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + MigrationsStartForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + MigrationsStartForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + MigrationsStartForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + MigrationsStartForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Start an organization migration](Migrations::start_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsStartForOrgError { - #[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, or the endpoint has been spammed.")] @@ -412,19 +506,25 @@ pub enum MigrationsStartForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsStartForOrgError) -> Self { + let (description, status_code) = match err { + MigrationsStartForOrgError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsStartForOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + MigrationsStartForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Start an import](Migrations::start_import_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsStartImportError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -435,19 +535,26 @@ pub enum MigrationsStartImportError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsStartImportError) -> Self { + let (description, status_code) = match err { + MigrationsStartImportError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + MigrationsStartImportError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsStartImportError::Status503(_) => (String::from("Unavailable due to service under maintenance."), 503), + MigrationsStartImportError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Unlock a user repository](Migrations::unlock_repo_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsUnlockRepoForAuthenticatedUserError { - #[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("Resource not found")] @@ -460,44 +567,72 @@ pub enum MigrationsUnlockRepoForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsUnlockRepoForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + MigrationsUnlockRepoForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + MigrationsUnlockRepoForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsUnlockRepoForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + MigrationsUnlockRepoForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + MigrationsUnlockRepoForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Unlock an organization repository](Migrations::unlock_repo_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsUnlockRepoForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: MigrationsUnlockRepoForOrgError) -> Self { + let (description, status_code) = match err { + MigrationsUnlockRepoForOrgError::Status404(_) => (String::from("Resource not found"), 404), + MigrationsUnlockRepoForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update an import](Migrations::update_import_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum MigrationsUpdateImportError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Unavailable due to service under maintenance.")] Status503(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: MigrationsUpdateImportError) -> Self { + let (description, status_code) = match err { + MigrationsUpdateImportError::Status503(_) => (String::from("Unavailable due to service under maintenance."), 503), + MigrationsUpdateImportError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [Get commit authors](Migrations::get_commit_authors_async()) endpoint. #[derive(Default, Serialize)] @@ -733,7 +868,7 @@ impl<'enc> From<&'enc PerPage> for MigrationsListReposForOrgParams { } } -impl<'api, C: Client> Migrations<'api, C> { +impl<'api, C: Client> Migrations<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Cancel an import @@ -746,19 +881,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for cancel_import](https://docs.github.com/rest/migrations/source-imports#cancel-an-import) /// /// --- - pub async fn cancel_import_async(&self, owner: &str, repo: &str) -> Result<(), MigrationsCancelImportError> { + pub async fn cancel_import_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/import", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -770,8 +905,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 503 => Err(MigrationsCancelImportError::Status503(github_response.to_json_async().await?)), - code => Err(MigrationsCancelImportError::Generic { code }), + 503 => Err(MigrationsCancelImportError::Status503(github_response.to_json_async().await?).into()), + code => Err(MigrationsCancelImportError::Generic { code }.into()), } } } @@ -789,7 +924,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn cancel_import(&self, owner: &str, repo: &str) -> Result<(), MigrationsCancelImportError> { + pub fn cancel_import(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/import", super::GITHUB_BASE_API_URL, owner, repo); @@ -801,7 +936,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -813,8 +948,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 503 => Err(MigrationsCancelImportError::Status503(github_response.to_json()?)), - code => Err(MigrationsCancelImportError::Generic { code }), + 503 => Err(MigrationsCancelImportError::Status503(github_response.to_json()?).into()), + code => Err(MigrationsCancelImportError::Generic { code }.into()), } } } @@ -828,19 +963,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for delete_archive_for_authenticated_user](https://docs.github.com/rest/migrations/users#delete-a-user-migration-archive) /// /// --- - pub async fn delete_archive_for_authenticated_user_async(&self, migration_id: i32) -> Result<(), MigrationsDeleteArchiveForAuthenticatedUserError> { + pub async fn delete_archive_for_authenticated_user_async(&self, migration_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/migrations/{}/archive", super::GITHUB_BASE_API_URL, migration_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -852,11 +987,11 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 304 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status304), - 403 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Generic { code }), + 404 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status304.into()), + 403 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Generic { code }.into()), } } } @@ -871,7 +1006,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_archive_for_authenticated_user(&self, migration_id: i32) -> Result<(), MigrationsDeleteArchiveForAuthenticatedUserError> { + pub fn delete_archive_for_authenticated_user(&self, migration_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/migrations/{}/archive", super::GITHUB_BASE_API_URL, migration_id); @@ -883,7 +1018,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -895,11 +1030,11 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status404(github_response.to_json()?)), - 304 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status304), - 403 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Generic { code }), + 404 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 304 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status304.into()), + 403 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(MigrationsDeleteArchiveForAuthenticatedUserError::Generic { code }.into()), } } } @@ -913,19 +1048,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for delete_archive_for_org](https://docs.github.com/rest/migrations/orgs#delete-an-organization-migration-archive) /// /// --- - pub async fn delete_archive_for_org_async(&self, org: &str, migration_id: i32) -> Result<(), MigrationsDeleteArchiveForOrgError> { + pub async fn delete_archive_for_org_async(&self, org: &str, migration_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/migrations/{}/archive", super::GITHUB_BASE_API_URL, org, migration_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -937,8 +1072,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(MigrationsDeleteArchiveForOrgError::Status404(github_response.to_json_async().await?)), - code => Err(MigrationsDeleteArchiveForOrgError::Generic { code }), + 404 => Err(MigrationsDeleteArchiveForOrgError::Status404(github_response.to_json_async().await?).into()), + code => Err(MigrationsDeleteArchiveForOrgError::Generic { code }.into()), } } } @@ -953,7 +1088,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_archive_for_org(&self, org: &str, migration_id: i32) -> Result<(), MigrationsDeleteArchiveForOrgError> { + pub fn delete_archive_for_org(&self, org: &str, migration_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/migrations/{}/archive", super::GITHUB_BASE_API_URL, org, migration_id); @@ -965,7 +1100,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -977,8 +1112,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(MigrationsDeleteArchiveForOrgError::Status404(github_response.to_json()?)), - code => Err(MigrationsDeleteArchiveForOrgError::Generic { code }), + 404 => Err(MigrationsDeleteArchiveForOrgError::Status404(github_response.to_json()?).into()), + code => Err(MigrationsDeleteArchiveForOrgError::Generic { code }.into()), } } } @@ -992,19 +1127,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for download_archive_for_org](https://docs.github.com/rest/migrations/orgs#download-an-organization-migration-archive) /// /// --- - pub async fn download_archive_for_org_async(&self, org: &str, migration_id: i32) -> Result<(), MigrationsDownloadArchiveForOrgError> { + pub async fn download_archive_for_org_async(&self, org: &str, migration_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/migrations/{}/archive", super::GITHUB_BASE_API_URL, org, migration_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1016,9 +1151,9 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 302 => Err(MigrationsDownloadArchiveForOrgError::Status302), - 404 => Err(MigrationsDownloadArchiveForOrgError::Status404(github_response.to_json_async().await?)), - code => Err(MigrationsDownloadArchiveForOrgError::Generic { code }), + 302 => Err(MigrationsDownloadArchiveForOrgError::Status302.into()), + 404 => Err(MigrationsDownloadArchiveForOrgError::Status404(github_response.to_json_async().await?).into()), + code => Err(MigrationsDownloadArchiveForOrgError::Generic { code }.into()), } } } @@ -1033,7 +1168,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn download_archive_for_org(&self, org: &str, migration_id: i32) -> Result<(), MigrationsDownloadArchiveForOrgError> { + pub fn download_archive_for_org(&self, org: &str, migration_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/migrations/{}/archive", super::GITHUB_BASE_API_URL, org, migration_id); @@ -1045,7 +1180,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1057,9 +1192,9 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 302 => Err(MigrationsDownloadArchiveForOrgError::Status302), - 404 => Err(MigrationsDownloadArchiveForOrgError::Status404(github_response.to_json()?)), - code => Err(MigrationsDownloadArchiveForOrgError::Generic { code }), + 302 => Err(MigrationsDownloadArchiveForOrgError::Status302.into()), + 404 => Err(MigrationsDownloadArchiveForOrgError::Status404(github_response.to_json()?).into()), + code => Err(MigrationsDownloadArchiveForOrgError::Generic { code }.into()), } } } @@ -1093,19 +1228,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for get_archive_for_authenticated_user](https://docs.github.com/rest/migrations/users#download-a-user-migration-archive) /// /// --- - pub async fn get_archive_for_authenticated_user_async(&self, migration_id: i32) -> Result<(), MigrationsGetArchiveForAuthenticatedUserError> { + pub async fn get_archive_for_authenticated_user_async(&self, migration_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/migrations/{}/archive", super::GITHUB_BASE_API_URL, migration_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1117,11 +1252,11 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 302 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status302), - 304 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status304), - 403 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(MigrationsGetArchiveForAuthenticatedUserError::Generic { code }), + 302 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status302.into()), + 304 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status304.into()), + 403 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(MigrationsGetArchiveForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1156,7 +1291,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_archive_for_authenticated_user(&self, migration_id: i32) -> Result<(), MigrationsGetArchiveForAuthenticatedUserError> { + pub fn get_archive_for_authenticated_user(&self, migration_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/migrations/{}/archive", super::GITHUB_BASE_API_URL, migration_id); @@ -1168,7 +1303,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1180,11 +1315,11 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 302 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status302), - 304 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status304), - 403 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(MigrationsGetArchiveForAuthenticatedUserError::Generic { code }), + 302 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status302.into()), + 304 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status304.into()), + 403 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(MigrationsGetArchiveForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(MigrationsGetArchiveForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1203,7 +1338,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for get_commit_authors](https://docs.github.com/rest/migrations/source-imports#get-commit-authors) /// /// --- - pub async fn get_commit_authors_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, MigrationsGetCommitAuthorsError> { + pub async fn get_commit_authors_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/import/authors", super::GITHUB_BASE_API_URL, owner, repo); @@ -1214,12 +1349,12 @@ impl<'api, C: Client> Migrations<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1231,9 +1366,9 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(MigrationsGetCommitAuthorsError::Status404(github_response.to_json_async().await?)), - 503 => Err(MigrationsGetCommitAuthorsError::Status503(github_response.to_json_async().await?)), - code => Err(MigrationsGetCommitAuthorsError::Generic { code }), + 404 => Err(MigrationsGetCommitAuthorsError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(MigrationsGetCommitAuthorsError::Status503(github_response.to_json_async().await?).into()), + code => Err(MigrationsGetCommitAuthorsError::Generic { code }.into()), } } } @@ -1253,7 +1388,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_commit_authors(&self, owner: &str, repo: &str, query_params: Option>) -> Result, MigrationsGetCommitAuthorsError> { + pub fn get_commit_authors(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/import/authors", super::GITHUB_BASE_API_URL, owner, repo); @@ -1270,7 +1405,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1282,9 +1417,9 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(MigrationsGetCommitAuthorsError::Status404(github_response.to_json()?)), - 503 => Err(MigrationsGetCommitAuthorsError::Status503(github_response.to_json()?)), - code => Err(MigrationsGetCommitAuthorsError::Generic { code }), + 404 => Err(MigrationsGetCommitAuthorsError::Status404(github_response.to_json()?).into()), + 503 => Err(MigrationsGetCommitAuthorsError::Status503(github_response.to_json()?).into()), + code => Err(MigrationsGetCommitAuthorsError::Generic { code }.into()), } } } @@ -1334,19 +1469,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for get_import_status](https://docs.github.com/rest/migrations/source-imports#get-an-import-status) /// /// --- - pub async fn get_import_status_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_import_status_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/import", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1358,9 +1493,9 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(MigrationsGetImportStatusError::Status404(github_response.to_json_async().await?)), - 503 => Err(MigrationsGetImportStatusError::Status503(github_response.to_json_async().await?)), - code => Err(MigrationsGetImportStatusError::Generic { code }), + 404 => Err(MigrationsGetImportStatusError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(MigrationsGetImportStatusError::Status503(github_response.to_json_async().await?).into()), + code => Err(MigrationsGetImportStatusError::Generic { code }.into()), } } } @@ -1411,7 +1546,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_import_status(&self, owner: &str, repo: &str) -> Result { + pub fn get_import_status(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/import", super::GITHUB_BASE_API_URL, owner, repo); @@ -1423,7 +1558,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1435,9 +1570,9 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(MigrationsGetImportStatusError::Status404(github_response.to_json()?)), - 503 => Err(MigrationsGetImportStatusError::Status503(github_response.to_json()?)), - code => Err(MigrationsGetImportStatusError::Generic { code }), + 404 => Err(MigrationsGetImportStatusError::Status404(github_response.to_json()?).into()), + 503 => Err(MigrationsGetImportStatusError::Status503(github_response.to_json()?).into()), + code => Err(MigrationsGetImportStatusError::Generic { code }.into()), } } } @@ -1454,19 +1589,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for get_large_files](https://docs.github.com/rest/migrations/source-imports#get-large-files) /// /// --- - pub async fn get_large_files_async(&self, owner: &str, repo: &str) -> Result, MigrationsGetLargeFilesError> { + pub async fn get_large_files_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/import/large_files", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1478,8 +1613,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 503 => Err(MigrationsGetLargeFilesError::Status503(github_response.to_json_async().await?)), - code => Err(MigrationsGetLargeFilesError::Generic { code }), + 503 => Err(MigrationsGetLargeFilesError::Status503(github_response.to_json_async().await?).into()), + code => Err(MigrationsGetLargeFilesError::Generic { code }.into()), } } } @@ -1497,7 +1632,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_large_files(&self, owner: &str, repo: &str) -> Result, MigrationsGetLargeFilesError> { + pub fn get_large_files(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/import/large_files", super::GITHUB_BASE_API_URL, owner, repo); @@ -1509,7 +1644,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1521,8 +1656,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 503 => Err(MigrationsGetLargeFilesError::Status503(github_response.to_json()?)), - code => Err(MigrationsGetLargeFilesError::Generic { code }), + 503 => Err(MigrationsGetLargeFilesError::Status503(github_response.to_json()?).into()), + code => Err(MigrationsGetLargeFilesError::Generic { code }.into()), } } } @@ -1543,7 +1678,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for get_status_for_authenticated_user](https://docs.github.com/rest/migrations/users#get-a-user-migration-status) /// /// --- - pub async fn get_status_for_authenticated_user_async(&self, migration_id: i32, query_params: Option>) -> Result { + pub async fn get_status_for_authenticated_user_async(&self, migration_id: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/user/migrations/{}", super::GITHUB_BASE_API_URL, migration_id); @@ -1554,12 +1689,12 @@ impl<'api, C: Client> Migrations<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1571,11 +1706,11 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(MigrationsGetStatusForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 304 => Err(MigrationsGetStatusForAuthenticatedUserError::Status304), - 403 => Err(MigrationsGetStatusForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(MigrationsGetStatusForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(MigrationsGetStatusForAuthenticatedUserError::Generic { code }), + 404 => Err(MigrationsGetStatusForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(MigrationsGetStatusForAuthenticatedUserError::Status304.into()), + 403 => Err(MigrationsGetStatusForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(MigrationsGetStatusForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(MigrationsGetStatusForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1597,7 +1732,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_status_for_authenticated_user(&self, migration_id: i32, query_params: Option>) -> Result { + pub fn get_status_for_authenticated_user(&self, migration_id: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/user/migrations/{}", super::GITHUB_BASE_API_URL, migration_id); @@ -1614,7 +1749,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1626,11 +1761,11 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(MigrationsGetStatusForAuthenticatedUserError::Status404(github_response.to_json()?)), - 304 => Err(MigrationsGetStatusForAuthenticatedUserError::Status304), - 403 => Err(MigrationsGetStatusForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(MigrationsGetStatusForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(MigrationsGetStatusForAuthenticatedUserError::Generic { code }), + 404 => Err(MigrationsGetStatusForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 304 => Err(MigrationsGetStatusForAuthenticatedUserError::Status304.into()), + 403 => Err(MigrationsGetStatusForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(MigrationsGetStatusForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(MigrationsGetStatusForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1651,7 +1786,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for get_status_for_org](https://docs.github.com/rest/migrations/orgs#get-an-organization-migration-status) /// /// --- - pub async fn get_status_for_org_async(&self, org: &str, migration_id: i32, query_params: Option>) -> Result { + pub async fn get_status_for_org_async(&self, org: &str, migration_id: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/migrations/{}", super::GITHUB_BASE_API_URL, org, migration_id); @@ -1662,12 +1797,12 @@ impl<'api, C: Client> Migrations<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1679,8 +1814,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(MigrationsGetStatusForOrgError::Status404(github_response.to_json_async().await?)), - code => Err(MigrationsGetStatusForOrgError::Generic { code }), + 404 => Err(MigrationsGetStatusForOrgError::Status404(github_response.to_json_async().await?).into()), + code => Err(MigrationsGetStatusForOrgError::Generic { code }.into()), } } } @@ -1702,7 +1837,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_status_for_org(&self, org: &str, migration_id: i32, query_params: Option>) -> Result { + pub fn get_status_for_org(&self, org: &str, migration_id: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/migrations/{}", super::GITHUB_BASE_API_URL, org, migration_id); @@ -1719,7 +1854,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1731,8 +1866,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(MigrationsGetStatusForOrgError::Status404(github_response.to_json()?)), - code => Err(MigrationsGetStatusForOrgError::Generic { code }), + 404 => Err(MigrationsGetStatusForOrgError::Status404(github_response.to_json()?).into()), + code => Err(MigrationsGetStatusForOrgError::Generic { code }.into()), } } } @@ -1746,7 +1881,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/migrations/users#list-user-migrations) /// /// --- - pub async fn list_for_authenticated_user_async(&self, query_params: Option>) -> Result, MigrationsListForAuthenticatedUserError> { + pub async fn list_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/migrations", super::GITHUB_BASE_API_URL); @@ -1757,12 +1892,12 @@ impl<'api, C: Client> Migrations<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1774,10 +1909,10 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(MigrationsListForAuthenticatedUserError::Status304), - 403 => Err(MigrationsListForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(MigrationsListForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(MigrationsListForAuthenticatedUserError::Generic { code }), + 304 => Err(MigrationsListForAuthenticatedUserError::Status304.into()), + 403 => Err(MigrationsListForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(MigrationsListForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(MigrationsListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1792,7 +1927,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_authenticated_user(&self, query_params: Option>) -> Result, MigrationsListForAuthenticatedUserError> { + pub fn list_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/migrations", super::GITHUB_BASE_API_URL); @@ -1809,7 +1944,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1821,10 +1956,10 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(MigrationsListForAuthenticatedUserError::Status304), - 403 => Err(MigrationsListForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(MigrationsListForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(MigrationsListForAuthenticatedUserError::Generic { code }), + 304 => Err(MigrationsListForAuthenticatedUserError::Status304.into()), + 403 => Err(MigrationsListForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(MigrationsListForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(MigrationsListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1840,7 +1975,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for list_for_org](https://docs.github.com/rest/migrations/orgs#list-organization-migrations) /// /// --- - pub async fn list_for_org_async(&self, org: &str, query_params: Option>) -> Result, MigrationsListForOrgError> { + pub async fn list_for_org_async(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/migrations", super::GITHUB_BASE_API_URL, org); @@ -1851,12 +1986,12 @@ impl<'api, C: Client> Migrations<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1868,7 +2003,7 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(MigrationsListForOrgError::Generic { code }), + code => Err(MigrationsListForOrgError::Generic { code }.into()), } } } @@ -1885,7 +2020,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_org(&self, org: &str, query_params: Option>) -> Result, MigrationsListForOrgError> { + pub fn list_for_org(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/migrations", super::GITHUB_BASE_API_URL, org); @@ -1902,7 +2037,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1914,7 +2049,7 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(MigrationsListForOrgError::Generic { code }), + code => Err(MigrationsListForOrgError::Generic { code }.into()), } } } @@ -1928,7 +2063,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for list_repos_for_authenticated_user](https://docs.github.com/rest/migrations/users#list-repositories-for-a-user-migration) /// /// --- - pub async fn list_repos_for_authenticated_user_async(&self, migration_id: i32, query_params: Option>) -> Result, MigrationsListReposForAuthenticatedUserError> { + pub async fn list_repos_for_authenticated_user_async(&self, migration_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/migrations/{}/repositories", super::GITHUB_BASE_API_URL, migration_id); @@ -1939,12 +2074,12 @@ impl<'api, C: Client> Migrations<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1956,8 +2091,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(MigrationsListReposForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(MigrationsListReposForAuthenticatedUserError::Generic { code }), + 404 => Err(MigrationsListReposForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(MigrationsListReposForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1972,7 +2107,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repos_for_authenticated_user(&self, migration_id: i32, query_params: Option>) -> Result, MigrationsListReposForAuthenticatedUserError> { + pub fn list_repos_for_authenticated_user(&self, migration_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/migrations/{}/repositories", super::GITHUB_BASE_API_URL, migration_id); @@ -1989,7 +2124,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2001,8 +2136,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(MigrationsListReposForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(MigrationsListReposForAuthenticatedUserError::Generic { code }), + 404 => Err(MigrationsListReposForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(MigrationsListReposForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2016,7 +2151,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for list_repos_for_org](https://docs.github.com/rest/migrations/orgs#list-repositories-in-an-organization-migration) /// /// --- - pub async fn list_repos_for_org_async(&self, org: &str, migration_id: i32, query_params: Option>) -> Result, MigrationsListReposForOrgError> { + pub async fn list_repos_for_org_async(&self, org: &str, migration_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/migrations/{}/repositories", super::GITHUB_BASE_API_URL, org, migration_id); @@ -2027,12 +2162,12 @@ impl<'api, C: Client> Migrations<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2044,8 +2179,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(MigrationsListReposForOrgError::Status404(github_response.to_json_async().await?)), - code => Err(MigrationsListReposForOrgError::Generic { code }), + 404 => Err(MigrationsListReposForOrgError::Status404(github_response.to_json_async().await?).into()), + code => Err(MigrationsListReposForOrgError::Generic { code }.into()), } } } @@ -2060,7 +2195,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repos_for_org(&self, org: &str, migration_id: i32, query_params: Option>) -> Result, MigrationsListReposForOrgError> { + pub fn list_repos_for_org(&self, org: &str, migration_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/migrations/{}/repositories", super::GITHUB_BASE_API_URL, org, migration_id); @@ -2077,7 +2212,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2089,8 +2224,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(MigrationsListReposForOrgError::Status404(github_response.to_json()?)), - code => Err(MigrationsListReposForOrgError::Generic { code }), + 404 => Err(MigrationsListReposForOrgError::Status404(github_response.to_json()?).into()), + code => Err(MigrationsListReposForOrgError::Generic { code }.into()), } } } @@ -2108,19 +2243,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for map_commit_author](https://docs.github.com/rest/migrations/source-imports#map-a-commit-author) /// /// --- - pub async fn map_commit_author_async(&self, owner: &str, repo: &str, author_id: i32, body: PatchMigrationsMapCommitAuthor) -> Result { + pub async fn map_commit_author_async(&self, owner: &str, repo: &str, author_id: i32, body: PatchMigrationsMapCommitAuthor) -> Result { let request_uri = format!("{}/repos/{}/{}/import/authors/{}", super::GITHUB_BASE_API_URL, owner, repo, author_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchMigrationsMapCommitAuthor::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2132,10 +2267,10 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(MigrationsMapCommitAuthorError::Status422(github_response.to_json_async().await?)), - 404 => Err(MigrationsMapCommitAuthorError::Status404(github_response.to_json_async().await?)), - 503 => Err(MigrationsMapCommitAuthorError::Status503(github_response.to_json_async().await?)), - code => Err(MigrationsMapCommitAuthorError::Generic { code }), + 422 => Err(MigrationsMapCommitAuthorError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(MigrationsMapCommitAuthorError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(MigrationsMapCommitAuthorError::Status503(github_response.to_json_async().await?).into()), + code => Err(MigrationsMapCommitAuthorError::Generic { code }.into()), } } } @@ -2154,19 +2289,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn map_commit_author(&self, owner: &str, repo: &str, author_id: i32, body: PatchMigrationsMapCommitAuthor) -> Result { + pub fn map_commit_author(&self, owner: &str, repo: &str, author_id: i32, body: PatchMigrationsMapCommitAuthor) -> Result { let request_uri = format!("{}/repos/{}/{}/import/authors/{}", super::GITHUB_BASE_API_URL, owner, repo, author_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchMigrationsMapCommitAuthor::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2178,10 +2313,10 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(MigrationsMapCommitAuthorError::Status422(github_response.to_json()?)), - 404 => Err(MigrationsMapCommitAuthorError::Status404(github_response.to_json()?)), - 503 => Err(MigrationsMapCommitAuthorError::Status503(github_response.to_json()?)), - code => Err(MigrationsMapCommitAuthorError::Generic { code }), + 422 => Err(MigrationsMapCommitAuthorError::Status422(github_response.to_json()?).into()), + 404 => Err(MigrationsMapCommitAuthorError::Status404(github_response.to_json()?).into()), + 503 => Err(MigrationsMapCommitAuthorError::Status503(github_response.to_json()?).into()), + code => Err(MigrationsMapCommitAuthorError::Generic { code }.into()), } } } @@ -2202,19 +2337,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for set_lfs_preference](https://docs.github.com/rest/migrations/source-imports#update-git-lfs-preference) /// /// --- - pub async fn set_lfs_preference_async(&self, owner: &str, repo: &str, body: PatchMigrationsSetLfsPreference) -> Result { + pub async fn set_lfs_preference_async(&self, owner: &str, repo: &str, body: PatchMigrationsSetLfsPreference) -> Result { let request_uri = format!("{}/repos/{}/{}/import/lfs", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchMigrationsSetLfsPreference::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2226,9 +2361,9 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(MigrationsSetLfsPreferenceError::Status422(github_response.to_json_async().await?)), - 503 => Err(MigrationsSetLfsPreferenceError::Status503(github_response.to_json_async().await?)), - code => Err(MigrationsSetLfsPreferenceError::Generic { code }), + 422 => Err(MigrationsSetLfsPreferenceError::Status422(github_response.to_json_async().await?).into()), + 503 => Err(MigrationsSetLfsPreferenceError::Status503(github_response.to_json_async().await?).into()), + code => Err(MigrationsSetLfsPreferenceError::Generic { code }.into()), } } } @@ -2250,19 +2385,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_lfs_preference(&self, owner: &str, repo: &str, body: PatchMigrationsSetLfsPreference) -> Result { + pub fn set_lfs_preference(&self, owner: &str, repo: &str, body: PatchMigrationsSetLfsPreference) -> Result { let request_uri = format!("{}/repos/{}/{}/import/lfs", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchMigrationsSetLfsPreference::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2274,9 +2409,9 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(MigrationsSetLfsPreferenceError::Status422(github_response.to_json()?)), - 503 => Err(MigrationsSetLfsPreferenceError::Status503(github_response.to_json()?)), - code => Err(MigrationsSetLfsPreferenceError::Generic { code }), + 422 => Err(MigrationsSetLfsPreferenceError::Status422(github_response.to_json()?).into()), + 503 => Err(MigrationsSetLfsPreferenceError::Status503(github_response.to_json()?).into()), + code => Err(MigrationsSetLfsPreferenceError::Generic { code }.into()), } } } @@ -2290,19 +2425,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for start_for_authenticated_user](https://docs.github.com/rest/migrations/users#start-a-user-migration) /// /// --- - pub async fn start_for_authenticated_user_async(&self, body: PostMigrationsStartForAuthenticatedUser) -> Result { + pub async fn start_for_authenticated_user_async(&self, body: PostMigrationsStartForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/migrations", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostMigrationsStartForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2314,11 +2449,11 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(MigrationsStartForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - 304 => Err(MigrationsStartForAuthenticatedUserError::Status304), - 403 => Err(MigrationsStartForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(MigrationsStartForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(MigrationsStartForAuthenticatedUserError::Generic { code }), + 422 => Err(MigrationsStartForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(MigrationsStartForAuthenticatedUserError::Status304.into()), + 403 => Err(MigrationsStartForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(MigrationsStartForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(MigrationsStartForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2333,19 +2468,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn start_for_authenticated_user(&self, body: PostMigrationsStartForAuthenticatedUser) -> Result { + pub fn start_for_authenticated_user(&self, body: PostMigrationsStartForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/migrations", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostMigrationsStartForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2357,11 +2492,11 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(MigrationsStartForAuthenticatedUserError::Status422(github_response.to_json()?)), - 304 => Err(MigrationsStartForAuthenticatedUserError::Status304), - 403 => Err(MigrationsStartForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(MigrationsStartForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(MigrationsStartForAuthenticatedUserError::Generic { code }), + 422 => Err(MigrationsStartForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + 304 => Err(MigrationsStartForAuthenticatedUserError::Status304.into()), + 403 => Err(MigrationsStartForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(MigrationsStartForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(MigrationsStartForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2375,19 +2510,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for start_for_org](https://docs.github.com/rest/migrations/orgs#start-an-organization-migration) /// /// --- - pub async fn start_for_org_async(&self, org: &str, body: PostMigrationsStartForOrg) -> Result { + pub async fn start_for_org_async(&self, org: &str, body: PostMigrationsStartForOrg) -> Result { let request_uri = format!("{}/orgs/{}/migrations", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostMigrationsStartForOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2399,9 +2534,9 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(MigrationsStartForOrgError::Status404(github_response.to_json_async().await?)), - 422 => Err(MigrationsStartForOrgError::Status422(github_response.to_json_async().await?)), - code => Err(MigrationsStartForOrgError::Generic { code }), + 404 => Err(MigrationsStartForOrgError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(MigrationsStartForOrgError::Status422(github_response.to_json_async().await?).into()), + code => Err(MigrationsStartForOrgError::Generic { code }.into()), } } } @@ -2416,19 +2551,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn start_for_org(&self, org: &str, body: PostMigrationsStartForOrg) -> Result { + pub fn start_for_org(&self, org: &str, body: PostMigrationsStartForOrg) -> Result { let request_uri = format!("{}/orgs/{}/migrations", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostMigrationsStartForOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2440,9 +2575,9 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(MigrationsStartForOrgError::Status404(github_response.to_json()?)), - 422 => Err(MigrationsStartForOrgError::Status422(github_response.to_json()?)), - code => Err(MigrationsStartForOrgError::Generic { code }), + 404 => Err(MigrationsStartForOrgError::Status404(github_response.to_json()?).into()), + 422 => Err(MigrationsStartForOrgError::Status422(github_response.to_json()?).into()), + code => Err(MigrationsStartForOrgError::Generic { code }.into()), } } } @@ -2461,19 +2596,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for start_import](https://docs.github.com/rest/migrations/source-imports#start-an-import) /// /// --- - pub async fn start_import_async(&self, owner: &str, repo: &str, body: PutMigrationsStartImport) -> Result { + pub async fn start_import_async(&self, owner: &str, repo: &str, body: PutMigrationsStartImport) -> Result { let request_uri = format!("{}/repos/{}/{}/import", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutMigrationsStartImport::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2485,10 +2620,10 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(MigrationsStartImportError::Status422(github_response.to_json_async().await?)), - 404 => Err(MigrationsStartImportError::Status404(github_response.to_json_async().await?)), - 503 => Err(MigrationsStartImportError::Status503(github_response.to_json_async().await?)), - code => Err(MigrationsStartImportError::Generic { code }), + 422 => Err(MigrationsStartImportError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(MigrationsStartImportError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(MigrationsStartImportError::Status503(github_response.to_json_async().await?).into()), + code => Err(MigrationsStartImportError::Generic { code }.into()), } } } @@ -2508,19 +2643,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn start_import(&self, owner: &str, repo: &str, body: PutMigrationsStartImport) -> Result { + pub fn start_import(&self, owner: &str, repo: &str, body: PutMigrationsStartImport) -> Result { let request_uri = format!("{}/repos/{}/{}/import", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutMigrationsStartImport::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2532,10 +2667,10 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(MigrationsStartImportError::Status422(github_response.to_json()?)), - 404 => Err(MigrationsStartImportError::Status404(github_response.to_json()?)), - 503 => Err(MigrationsStartImportError::Status503(github_response.to_json()?)), - code => Err(MigrationsStartImportError::Generic { code }), + 422 => Err(MigrationsStartImportError::Status422(github_response.to_json()?).into()), + 404 => Err(MigrationsStartImportError::Status404(github_response.to_json()?).into()), + 503 => Err(MigrationsStartImportError::Status503(github_response.to_json()?).into()), + code => Err(MigrationsStartImportError::Generic { code }.into()), } } } @@ -2549,19 +2684,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for unlock_repo_for_authenticated_user](https://docs.github.com/rest/migrations/users#unlock-a-user-repository) /// /// --- - pub async fn unlock_repo_for_authenticated_user_async(&self, migration_id: i32, repo_name: &str) -> Result<(), MigrationsUnlockRepoForAuthenticatedUserError> { + pub async fn unlock_repo_for_authenticated_user_async(&self, migration_id: i32, repo_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/migrations/{}/repos/{}/lock", super::GITHUB_BASE_API_URL, migration_id, repo_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2573,11 +2708,11 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status304), - 404 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(MigrationsUnlockRepoForAuthenticatedUserError::Generic { code }), + 304 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status304.into()), + 404 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(MigrationsUnlockRepoForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2592,7 +2727,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn unlock_repo_for_authenticated_user(&self, migration_id: i32, repo_name: &str) -> Result<(), MigrationsUnlockRepoForAuthenticatedUserError> { + pub fn unlock_repo_for_authenticated_user(&self, migration_id: i32, repo_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/migrations/{}/repos/{}/lock", super::GITHUB_BASE_API_URL, migration_id, repo_name); @@ -2604,7 +2739,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2616,11 +2751,11 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status304), - 404 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(MigrationsUnlockRepoForAuthenticatedUserError::Generic { code }), + 304 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status304.into()), + 404 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(MigrationsUnlockRepoForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(MigrationsUnlockRepoForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2634,19 +2769,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for unlock_repo_for_org](https://docs.github.com/rest/migrations/orgs#unlock-an-organization-repository) /// /// --- - pub async fn unlock_repo_for_org_async(&self, org: &str, migration_id: i32, repo_name: &str) -> Result<(), MigrationsUnlockRepoForOrgError> { + pub async fn unlock_repo_for_org_async(&self, org: &str, migration_id: i32, repo_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/migrations/{}/repos/{}/lock", super::GITHUB_BASE_API_URL, org, migration_id, repo_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2658,8 +2793,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(MigrationsUnlockRepoForOrgError::Status404(github_response.to_json_async().await?)), - code => Err(MigrationsUnlockRepoForOrgError::Generic { code }), + 404 => Err(MigrationsUnlockRepoForOrgError::Status404(github_response.to_json_async().await?).into()), + code => Err(MigrationsUnlockRepoForOrgError::Generic { code }.into()), } } } @@ -2674,7 +2809,7 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn unlock_repo_for_org(&self, org: &str, migration_id: i32, repo_name: &str) -> Result<(), MigrationsUnlockRepoForOrgError> { + pub fn unlock_repo_for_org(&self, org: &str, migration_id: i32, repo_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/migrations/{}/repos/{}/lock", super::GITHUB_BASE_API_URL, org, migration_id, repo_name); @@ -2686,7 +2821,7 @@ impl<'api, C: Client> Migrations<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2698,8 +2833,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(MigrationsUnlockRepoForOrgError::Status404(github_response.to_json()?)), - code => Err(MigrationsUnlockRepoForOrgError::Generic { code }), + 404 => Err(MigrationsUnlockRepoForOrgError::Status404(github_response.to_json()?).into()), + code => Err(MigrationsUnlockRepoForOrgError::Generic { code }.into()), } } } @@ -2721,19 +2856,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// [GitHub API docs for update_import](https://docs.github.com/rest/migrations/source-imports#update-an-import) /// /// --- - pub async fn update_import_async(&self, owner: &str, repo: &str, body: PatchMigrationsUpdateImport) -> Result { + pub async fn update_import_async(&self, owner: &str, repo: &str, body: PatchMigrationsUpdateImport) -> Result { let request_uri = format!("{}/repos/{}/{}/import", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchMigrationsUpdateImport::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2745,8 +2880,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 503 => Err(MigrationsUpdateImportError::Status503(github_response.to_json_async().await?)), - code => Err(MigrationsUpdateImportError::Generic { code }), + 503 => Err(MigrationsUpdateImportError::Status503(github_response.to_json_async().await?).into()), + code => Err(MigrationsUpdateImportError::Generic { code }.into()), } } } @@ -2769,19 +2904,19 @@ impl<'api, C: Client> Migrations<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_import(&self, owner: &str, repo: &str, body: PatchMigrationsUpdateImport) -> Result { + pub fn update_import(&self, owner: &str, repo: &str, body: PatchMigrationsUpdateImport) -> Result { let request_uri = format!("{}/repos/{}/{}/import", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchMigrationsUpdateImport::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2793,8 +2928,8 @@ impl<'api, C: Client> Migrations<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 503 => Err(MigrationsUpdateImportError::Status503(github_response.to_json()?)), - code => Err(MigrationsUpdateImportError::Generic { code }), + 503 => Err(MigrationsUpdateImportError::Status503(github_response.to_json()?).into()), + code => Err(MigrationsUpdateImportError::Generic { code }.into()), } } } diff --git a/src/endpoints/mod.rs b/src/endpoints/mod.rs index 5046787..a534424 100644 --- a/src/endpoints/mod.rs +++ b/src/endpoints/mod.rs @@ -15,42 +15,42 @@ pub const GITHUB_BASE_API_URL: &str = if cfg!(feature = "mock") { "https://api.github.com" }; -pub mod actions; +pub mod meta; +pub mod issues; +pub mod licenses; +pub mod reactions; pub mod activity; +pub mod projects; +pub mod orgs; +pub mod users; pub mod apps; -pub mod billing; -pub mod checks; +pub mod rate_limit; +pub mod repos; +pub mod secret_scanning; +pub mod security_advisories; +pub mod packages; +pub mod search; pub mod classroom; -pub mod code_scanning; +pub mod teams; +pub mod oidc; +pub mod markdown; +pub mod actions; +pub mod migrations; +pub mod gists; pub mod code_security; -pub mod codes_of_conduct; -pub mod codespaces; +pub mod dependency_graph; pub mod copilot; pub mod dependabot; -pub mod dependency_graph; -pub mod emojis; -pub mod gists; +pub mod codes_of_conduct; +pub mod pulls; pub mod gitignore; pub mod git; +pub mod code_scanning; +pub mod checks; +pub mod billing; pub mod interactions; -pub mod issues; -pub mod licenses; -pub mod markdown; -pub mod meta; -pub mod migrations; -pub mod oidc; -pub mod orgs; -pub mod packages; -pub mod projects; -pub mod pulls; -pub mod rate_limit; -pub mod reactions; -pub mod repos; -pub mod search; -pub mod secret_scanning; -pub mod security_advisories; -pub mod teams; -pub mod users; +pub mod codespaces; +pub mod emojis; pub struct PerPage { per_page: u16, diff --git a/src/endpoints/oidc.rs b/src/endpoints/oidc.rs index e76fbfd..1d20226 100644 --- a/src/endpoints/oidc.rs +++ b/src/endpoints/oidc.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,44 +22,38 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Oidc<'api, C: Client> { +pub struct Oidc<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Oidc { +pub fn new(client: &C) -> Oidc where AdapterError: From<::Err> { Oidc { client } } /// Errors for the [Get the customization template for an OIDC subject claim for an organization](Oidc::get_oidc_custom_sub_template_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OidcGetOidcCustomSubTemplateForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: OidcGetOidcCustomSubTemplateForOrgError) -> Self { + let (description, status_code) = match err { + OidcGetOidcCustomSubTemplateForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set the customization template for an OIDC subject claim for an organization](Oidc::update_oidc_custom_sub_template_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OidcUpdateOidcCustomSubTemplateForOrgError { - #[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("Forbidden")] @@ -68,9 +62,25 @@ pub enum OidcUpdateOidcCustomSubTemplateForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OidcUpdateOidcCustomSubTemplateForOrgError) -> Self { + let (description, status_code) = match err { + OidcUpdateOidcCustomSubTemplateForOrgError::Status404(_) => (String::from("Resource not found"), 404), + OidcUpdateOidcCustomSubTemplateForOrgError::Status403(_) => (String::from("Forbidden"), 403), + OidcUpdateOidcCustomSubTemplateForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} -impl<'api, C: Client> Oidc<'api, C> { + +impl<'api, C: Client> Oidc<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Get the customization template for an OIDC subject claim for an organization @@ -82,19 +92,19 @@ impl<'api, C: Client> Oidc<'api, C> { /// [GitHub API docs for get_oidc_custom_sub_template_for_org](https://docs.github.com/rest/actions/oidc#get-the-customization-template-for-an-oidc-subject-claim-for-an-organization) /// /// --- - pub async fn get_oidc_custom_sub_template_for_org_async(&self, org: &str) -> Result { + pub async fn get_oidc_custom_sub_template_for_org_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/oidc/customization/sub", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -106,7 +116,7 @@ impl<'api, C: Client> Oidc<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OidcGetOidcCustomSubTemplateForOrgError::Generic { code }), + code => Err(OidcGetOidcCustomSubTemplateForOrgError::Generic { code }.into()), } } } @@ -123,7 +133,7 @@ impl<'api, C: Client> Oidc<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_oidc_custom_sub_template_for_org(&self, org: &str) -> Result { + pub fn get_oidc_custom_sub_template_for_org(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/actions/oidc/customization/sub", super::GITHUB_BASE_API_URL, org); @@ -135,7 +145,7 @@ impl<'api, C: Client> Oidc<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -147,7 +157,7 @@ impl<'api, C: Client> Oidc<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OidcGetOidcCustomSubTemplateForOrgError::Generic { code }), + code => Err(OidcGetOidcCustomSubTemplateForOrgError::Generic { code }.into()), } } } @@ -163,19 +173,19 @@ impl<'api, C: Client> Oidc<'api, C> { /// [GitHub API docs for update_oidc_custom_sub_template_for_org](https://docs.github.com/rest/actions/oidc#set-the-customization-template-for-an-oidc-subject-claim-for-an-organization) /// /// --- - pub async fn update_oidc_custom_sub_template_for_org_async(&self, org: &str, body: OidcCustomSub) -> Result { + pub async fn update_oidc_custom_sub_template_for_org_async(&self, org: &str, body: OidcCustomSub) -> Result { let request_uri = format!("{}/orgs/{}/actions/oidc/customization/sub", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(OidcCustomSub::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -187,9 +197,9 @@ impl<'api, C: Client> Oidc<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Status404(github_response.to_json_async().await?)), - 403 => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Status403(github_response.to_json_async().await?)), - code => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Generic { code }), + 404 => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Status403(github_response.to_json_async().await?).into()), + code => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Generic { code }.into()), } } } @@ -206,19 +216,19 @@ impl<'api, C: Client> Oidc<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_oidc_custom_sub_template_for_org(&self, org: &str, body: OidcCustomSub) -> Result { + pub fn update_oidc_custom_sub_template_for_org(&self, org: &str, body: OidcCustomSub) -> Result { let request_uri = format!("{}/orgs/{}/actions/oidc/customization/sub", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(OidcCustomSub::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -230,9 +240,9 @@ impl<'api, C: Client> Oidc<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Status404(github_response.to_json()?)), - 403 => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Status403(github_response.to_json()?)), - code => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Generic { code }), + 404 => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Status404(github_response.to_json()?).into()), + 403 => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Status403(github_response.to_json()?).into()), + code => Err(OidcUpdateOidcCustomSubTemplateForOrgError::Generic { code }.into()), } } } diff --git a/src/endpoints/orgs.rs b/src/endpoints/orgs.rs index 4f65064..9ce6db1 100644 --- a/src/endpoints/orgs.rs +++ b/src/endpoints/orgs.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,44 +22,38 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Orgs<'api, C: Client> { +pub struct Orgs<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Orgs { +pub fn new(client: &C) -> Orgs where AdapterError: From<::Err> { Orgs { client } } /// Errors for the [Add a security manager team](Orgs::add_security_manager_team_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsAddSecurityManagerTeamError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsAddSecurityManagerTeamError) -> Self { + let (description, status_code) = match err { + OrgsAddSecurityManagerTeamError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Assign an organization role to a team](Orgs::assign_team_to_org_role_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsAssignTeamToOrgRoleError { - #[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 the organization, team or role does not exist.")] Status404, #[error("Response if the organization roles feature is not enabled for the organization, or validation failed.")] @@ -68,19 +62,25 @@ pub enum OrgsAssignTeamToOrgRoleError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsAssignTeamToOrgRoleError) -> Self { + let (description, status_code) = match err { + OrgsAssignTeamToOrgRoleError::Status404 => (String::from("Response if the organization, team or role does not exist."), 404), + OrgsAssignTeamToOrgRoleError::Status422 => (String::from("Response if the organization roles feature is not enabled for the organization, or validation failed."), 422), + OrgsAssignTeamToOrgRoleError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Assign an organization role to a user](Orgs::assign_user_to_org_role_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsAssignUserToOrgRoleError { - #[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 the organization, user or role does not exist.")] Status404, #[error("Response if the organization roles feature is not enabled enabled for the organization, the validation failed, or the user is not an organization member.")] @@ -89,38 +89,49 @@ pub enum OrgsAssignUserToOrgRoleError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsAssignUserToOrgRoleError) -> Self { + let (description, status_code) = match err { + OrgsAssignUserToOrgRoleError::Status404 => (String::from("Response if the organization, user or role does not exist."), 404), + OrgsAssignUserToOrgRoleError::Status422 => (String::from("Response if the organization roles feature is not enabled enabled for the organization, the validation failed, or the user is not an organization member."), 422), + OrgsAssignUserToOrgRoleError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Block a user from an organization](Orgs::block_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsBlockUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsBlockUserError) -> Self { + let (description, status_code) = match err { + OrgsBlockUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsBlockUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Cancel an organization invitation](Orgs::cancel_invitation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsCancelInvitationError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -129,38 +140,49 @@ pub enum OrgsCancelInvitationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsCancelInvitationError) -> Self { + let (description, status_code) = match err { + OrgsCancelInvitationError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsCancelInvitationError::Status404(_) => (String::from("Resource not found"), 404), + OrgsCancelInvitationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check if a user is blocked by an organization](Orgs::check_blocked_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsCheckBlockedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("If the user is not blocked")] Status404(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsCheckBlockedUserError) -> Self { + let (description, status_code) = match err { + OrgsCheckBlockedUserError::Status404(_) => (String::from("If the user is not blocked"), 404), + OrgsCheckBlockedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check organization membership for a user](Orgs::check_membership_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsCheckMembershipForUserError { - #[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 requester is not an organization member")] Status302, #[error("Not Found if requester is an organization member and user is not a member")] @@ -169,38 +191,49 @@ pub enum OrgsCheckMembershipForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsCheckMembershipForUserError) -> Self { + let (description, status_code) = match err { + OrgsCheckMembershipForUserError::Status302 => (String::from("Response if requester is not an organization member"), 302), + OrgsCheckMembershipForUserError::Status404 => (String::from("Not Found if requester is an organization member and user is not a member"), 404), + OrgsCheckMembershipForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check public organization membership for a user](Orgs::check_public_membership_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsCheckPublicMembershipForUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if user is not a public member")] Status404, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsCheckPublicMembershipForUserError) -> Self { + let (description, status_code) = match err { + OrgsCheckPublicMembershipForUserError::Status404 => (String::from("Not Found if user is not a public member"), 404), + OrgsCheckPublicMembershipForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Convert an organization member to outside collaborator](Orgs::convert_member_to_outside_collaborator_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsConvertMemberToOutsideCollaboratorError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("User was converted")] Status204, #[error("Forbidden if user is the last owner of the organization, not a member of the organization, or if the enterprise enforces a policy for inviting outside collaborators. For more information, see \"[Enforcing repository management policies in your enterprise](https://docs.github.com/admin/policies/enforcing-policies-for-your-enterprise/enforcing-repository-management-policies-in-your-enterprise#enforcing-a-policy-for-inviting-outside-collaborators-to-repositories).\"")] @@ -211,19 +244,26 @@ pub enum OrgsConvertMemberToOutsideCollaboratorError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsConvertMemberToOutsideCollaboratorError) -> Self { + let (description, status_code) = match err { + OrgsConvertMemberToOutsideCollaboratorError::Status204 => (String::from("User was converted"), 204), + OrgsConvertMemberToOutsideCollaboratorError::Status403 => (String::from("Forbidden if user is the last owner of the organization, not a member of the organization, or if the enterprise enforces a policy for inviting outside collaborators. For more information, see \"[Enforcing repository management policies in your enterprise](https://docs.github.com/admin/policies/enforcing-policies-for-your-enterprise/enforcing-repository-management-policies-in-your-enterprise#enforcing-a-policy-for-inviting-outside-collaborators-to-repositories).\""), 403), + OrgsConvertMemberToOutsideCollaboratorError::Status404(_) => (String::from("Resource not found"), 404), + OrgsConvertMemberToOutsideCollaboratorError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an organization invitation](Orgs::create_invitation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsCreateInvitationError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -232,19 +272,25 @@ pub enum OrgsCreateInvitationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsCreateInvitationError) -> Self { + let (description, status_code) = match err { + OrgsCreateInvitationError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsCreateInvitationError::Status404(_) => (String::from("Resource not found"), 404), + OrgsCreateInvitationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update custom properties for an organization](Orgs::create_or_update_custom_properties_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsCreateOrUpdateCustomPropertiesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -253,19 +299,25 @@ pub enum OrgsCreateOrUpdateCustomPropertiesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsCreateOrUpdateCustomPropertiesError) -> Self { + let (description, status_code) = match err { + OrgsCreateOrUpdateCustomPropertiesError::Status403(_) => (String::from("Forbidden"), 403), + OrgsCreateOrUpdateCustomPropertiesError::Status404(_) => (String::from("Resource not found"), 404), + OrgsCreateOrUpdateCustomPropertiesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update custom property values for organization repositories](Orgs::create_or_update_custom_properties_values_for_repos_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsCreateOrUpdateCustomPropertiesValuesForReposError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -276,19 +328,26 @@ pub enum OrgsCreateOrUpdateCustomPropertiesValuesForReposError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsCreateOrUpdateCustomPropertiesValuesForReposError) -> Self { + let (description, status_code) = match err { + OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status403(_) => (String::from("Forbidden"), 403), + OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status404(_) => (String::from("Resource not found"), 404), + OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update a custom property for an organization](Orgs::create_or_update_custom_property_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsCreateOrUpdateCustomPropertyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -297,19 +356,25 @@ pub enum OrgsCreateOrUpdateCustomPropertyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsCreateOrUpdateCustomPropertyError) -> Self { + let (description, status_code) = match err { + OrgsCreateOrUpdateCustomPropertyError::Status403(_) => (String::from("Forbidden"), 403), + OrgsCreateOrUpdateCustomPropertyError::Status404(_) => (String::from("Resource not found"), 404), + OrgsCreateOrUpdateCustomPropertyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an organization webhook](Orgs::create_webhook_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsCreateWebhookError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -318,19 +383,25 @@ pub enum OrgsCreateWebhookError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsCreateWebhookError) -> Self { + let (description, status_code) = match err { + OrgsCreateWebhookError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsCreateWebhookError::Status404(_) => (String::from("Resource not found"), 404), + OrgsCreateWebhookError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an organization](Orgs::delete_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsDeleteError { - #[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("Forbidden")] @@ -339,76 +410,97 @@ pub enum OrgsDeleteError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsDeleteError) -> Self { + let (description, status_code) = match err { + OrgsDeleteError::Status404(_) => (String::from("Resource not found"), 404), + OrgsDeleteError::Status403(_) => (String::from("Forbidden"), 403), + OrgsDeleteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an organization webhook](Orgs::delete_webhook_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsDeleteWebhookError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsDeleteWebhookError) -> Self { + let (description, status_code) = match err { + OrgsDeleteWebhookError::Status404(_) => (String::from("Resource not found"), 404), + OrgsDeleteWebhookError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Enable or disable a security feature for an organization](Orgs::enable_or_disable_security_product_on_all_org_repos_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsEnableOrDisableSecurityProductOnAllOrgReposError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("The action could not be taken due to an in progress enablement, or a policy is preventing enablement")] Status422, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsEnableOrDisableSecurityProductOnAllOrgReposError) -> Self { + let (description, status_code) = match err { + OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Status422 => (String::from("The action could not be taken due to an in progress enablement, or a policy is preventing enablement"), 422), + OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization](Orgs::get_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsGetError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsGetError) -> Self { + let (description, status_code) = match err { + OrgsGetError::Status404(_) => (String::from("Resource not found"), 404), + OrgsGetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all custom properties for an organization](Orgs::get_all_custom_properties_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsGetAllCustomPropertiesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -417,19 +509,25 @@ pub enum OrgsGetAllCustomPropertiesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsGetAllCustomPropertiesError) -> Self { + let (description, status_code) = match err { + OrgsGetAllCustomPropertiesError::Status403(_) => (String::from("Forbidden"), 403), + OrgsGetAllCustomPropertiesError::Status404(_) => (String::from("Resource not found"), 404), + OrgsGetAllCustomPropertiesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a custom property for an organization](Orgs::get_custom_property_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsGetCustomPropertyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -438,19 +536,25 @@ pub enum OrgsGetCustomPropertyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsGetCustomPropertyError) -> Self { + let (description, status_code) = match err { + OrgsGetCustomPropertyError::Status403(_) => (String::from("Forbidden"), 403), + OrgsGetCustomPropertyError::Status404(_) => (String::from("Resource not found"), 404), + OrgsGetCustomPropertyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization membership for the authenticated user](Orgs::get_membership_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsGetMembershipForAuthenticatedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -459,19 +563,25 @@ pub enum OrgsGetMembershipForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsGetMembershipForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + OrgsGetMembershipForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + OrgsGetMembershipForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + OrgsGetMembershipForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get organization membership for a user](Orgs::get_membership_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsGetMembershipForUserError { - #[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("Forbidden")] @@ -480,19 +590,25 @@ pub enum OrgsGetMembershipForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsGetMembershipForUserError) -> Self { + let (description, status_code) = match err { + OrgsGetMembershipForUserError::Status404(_) => (String::from("Resource not found"), 404), + OrgsGetMembershipForUserError::Status403(_) => (String::from("Forbidden"), 403), + OrgsGetMembershipForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization role](Orgs::get_org_role_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsGetOrgRoleError { - #[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, or the endpoint has been spammed.")] @@ -501,55 +617,70 @@ pub enum OrgsGetOrgRoleError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsGetOrgRoleError) -> Self { + let (description, status_code) = match err { + OrgsGetOrgRoleError::Status404(_) => (String::from("Resource not found"), 404), + OrgsGetOrgRoleError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsGetOrgRoleError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization webhook](Orgs::get_webhook_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsGetWebhookError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsGetWebhookError) -> Self { + let (description, status_code) = match err { + OrgsGetWebhookError::Status404(_) => (String::from("Resource not found"), 404), + OrgsGetWebhookError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a webhook configuration for an organization](Orgs::get_webhook_config_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsGetWebhookConfigForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsGetWebhookConfigForOrgError) -> Self { + let (description, status_code) = match err { + OrgsGetWebhookConfigForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a webhook delivery for an organization webhook](Orgs::get_webhook_delivery_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsGetWebhookDeliveryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -558,89 +689,112 @@ pub enum OrgsGetWebhookDeliveryError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsGetWebhookDeliveryError) -> Self { + let (description, status_code) = match err { + OrgsGetWebhookDeliveryError::Status400(_) => (String::from("Bad Request"), 400), + OrgsGetWebhookDeliveryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsGetWebhookDeliveryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organizations](Orgs::list_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListError) -> Self { + let (description, status_code) = match err { + OrgsListError::Status304 => (String::from("Not modified"), 304), + OrgsListError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List app installations for an organization](Orgs::list_app_installations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListAppInstallationsError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsListAppInstallationsError) -> Self { + let (description, status_code) = match err { + OrgsListAppInstallationsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List attestations](Orgs::list_attestations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListAttestationsError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsListAttestationsError) -> Self { + let (description, status_code) = match err { + OrgsListAttestationsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List users blocked by an organization](Orgs::list_blocked_users_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListBlockedUsersError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsListBlockedUsersError) -> Self { + let (description, status_code) = match err { + OrgsListBlockedUsersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List custom property values for organization repositories](Orgs::list_custom_properties_values_for_repos_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListCustomPropertiesValuesForReposError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -649,38 +803,49 @@ pub enum OrgsListCustomPropertiesValuesForReposError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListCustomPropertiesValuesForReposError) -> Self { + let (description, status_code) = match err { + OrgsListCustomPropertiesValuesForReposError::Status403(_) => (String::from("Forbidden"), 403), + OrgsListCustomPropertiesValuesForReposError::Status404(_) => (String::from("Resource not found"), 404), + OrgsListCustomPropertiesValuesForReposError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List failed organization invitations](Orgs::list_failed_invitations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListFailedInvitationsError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsListFailedInvitationsError) -> Self { + let (description, status_code) = match err { + OrgsListFailedInvitationsError::Status404(_) => (String::from("Resource not found"), 404), + OrgsListFailedInvitationsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organizations for the authenticated user](Orgs::list_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListForAuthenticatedUserError { - #[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("Forbidden")] @@ -691,74 +856,95 @@ pub enum OrgsListForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + OrgsListForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + OrgsListForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + OrgsListForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + OrgsListForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organizations for a user](Orgs::list_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsListForUserError) -> Self { + let (description, status_code) = match err { + OrgsListForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization invitation teams](Orgs::list_invitation_teams_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListInvitationTeamsError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsListInvitationTeamsError) -> Self { + let (description, status_code) = match err { + OrgsListInvitationTeamsError::Status404(_) => (String::from("Resource not found"), 404), + OrgsListInvitationTeamsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization members](Orgs::list_members_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListMembersError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListMembersError) -> Self { + let (description, status_code) = match err { + OrgsListMembersError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsListMembersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization memberships for the authenticated user](Orgs::list_memberships_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListMembershipsForAuthenticatedUserError { - #[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("Forbidden")] @@ -771,19 +957,27 @@ pub enum OrgsListMembershipsForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListMembershipsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + OrgsListMembershipsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + OrgsListMembershipsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + OrgsListMembershipsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + OrgsListMembershipsForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsListMembershipsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List teams that are assigned to an organization role](Orgs::list_org_role_teams_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListOrgRoleTeamsError { - #[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 the organization or role does not exist.")] Status404, #[error("Response if the organization roles feature is not enabled or validation failed.")] @@ -792,19 +986,25 @@ pub enum OrgsListOrgRoleTeamsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListOrgRoleTeamsError) -> Self { + let (description, status_code) = match err { + OrgsListOrgRoleTeamsError::Status404 => (String::from("Response if the organization or role does not exist."), 404), + OrgsListOrgRoleTeamsError::Status422 => (String::from("Response if the organization roles feature is not enabled or validation failed."), 422), + OrgsListOrgRoleTeamsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List users that are assigned to an organization role](Orgs::list_org_role_users_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListOrgRoleUsersError { - #[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 the organization or role does not exist.")] Status404, #[error("Response if the organization roles feature is not enabled or validation failed.")] @@ -813,19 +1013,25 @@ pub enum OrgsListOrgRoleUsersError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListOrgRoleUsersError) -> Self { + let (description, status_code) = match err { + OrgsListOrgRoleUsersError::Status404 => (String::from("Response if the organization or role does not exist."), 404), + OrgsListOrgRoleUsersError::Status422 => (String::from("Response if the organization roles feature is not enabled or validation failed."), 422), + OrgsListOrgRoleUsersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all organization roles for an organization](Orgs::list_org_roles_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListOrgRolesError { - #[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, or the endpoint has been spammed.")] @@ -834,36 +1040,46 @@ pub enum OrgsListOrgRolesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListOrgRolesError) -> Self { + let (description, status_code) = match err { + OrgsListOrgRolesError::Status404(_) => (String::from("Resource not found"), 404), + OrgsListOrgRolesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsListOrgRolesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List outside collaborators for an organization](Orgs::list_outside_collaborators_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListOutsideCollaboratorsError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsListOutsideCollaboratorsError) -> Self { + let (description, status_code) = match err { + OrgsListOutsideCollaboratorsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories a fine-grained personal access token has access to](Orgs::list_pat_grant_repositories_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListPatGrantRepositoriesError { - #[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("Resource not found")] @@ -874,19 +1090,26 @@ pub enum OrgsListPatGrantRepositoriesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListPatGrantRepositoriesError) -> Self { + let (description, status_code) = match err { + OrgsListPatGrantRepositoriesError::Status500(_) => (String::from("Internal Error"), 500), + OrgsListPatGrantRepositoriesError::Status404(_) => (String::from("Resource not found"), 404), + OrgsListPatGrantRepositoriesError::Status403(_) => (String::from("Forbidden"), 403), + OrgsListPatGrantRepositoriesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories requested to be accessed by a fine-grained personal access token](Orgs::list_pat_grant_request_repositories_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListPatGrantRequestRepositoriesError { - #[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("Resource not found")] @@ -897,19 +1120,26 @@ pub enum OrgsListPatGrantRequestRepositoriesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListPatGrantRequestRepositoriesError) -> Self { + let (description, status_code) = match err { + OrgsListPatGrantRequestRepositoriesError::Status500(_) => (String::from("Internal Error"), 500), + OrgsListPatGrantRequestRepositoriesError::Status404(_) => (String::from("Resource not found"), 404), + OrgsListPatGrantRequestRepositoriesError::Status403(_) => (String::from("Forbidden"), 403), + OrgsListPatGrantRequestRepositoriesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List requests to access organization resources with fine-grained personal access tokens](Orgs::list_pat_grant_requests_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListPatGrantRequestsError { - #[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("Validation failed, or the endpoint has been spammed.")] @@ -922,19 +1152,27 @@ pub enum OrgsListPatGrantRequestsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListPatGrantRequestsError) -> Self { + let (description, status_code) = match err { + OrgsListPatGrantRequestsError::Status500(_) => (String::from("Internal Error"), 500), + OrgsListPatGrantRequestsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsListPatGrantRequestsError::Status404(_) => (String::from("Resource not found"), 404), + OrgsListPatGrantRequestsError::Status403(_) => (String::from("Forbidden"), 403), + OrgsListPatGrantRequestsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List fine-grained personal access tokens with access to organization resources](Orgs::list_pat_grants_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListPatGrantsError { - #[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("Validation failed, or the endpoint has been spammed.")] @@ -947,72 +1185,93 @@ pub enum OrgsListPatGrantsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListPatGrantsError) -> Self { + let (description, status_code) = match err { + OrgsListPatGrantsError::Status500(_) => (String::from("Internal Error"), 500), + OrgsListPatGrantsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsListPatGrantsError::Status404(_) => (String::from("Resource not found"), 404), + OrgsListPatGrantsError::Status403(_) => (String::from("Forbidden"), 403), + OrgsListPatGrantsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List pending organization invitations](Orgs::list_pending_invitations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListPendingInvitationsError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsListPendingInvitationsError) -> Self { + let (description, status_code) = match err { + OrgsListPendingInvitationsError::Status404(_) => (String::from("Resource not found"), 404), + OrgsListPendingInvitationsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List public organization members](Orgs::list_public_members_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListPublicMembersError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsListPublicMembersError) -> Self { + let (description, status_code) = match err { + OrgsListPublicMembersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List security manager teams](Orgs::list_security_manager_teams_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListSecurityManagerTeamsError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsListSecurityManagerTeamsError) -> Self { + let (description, status_code) = match err { + OrgsListSecurityManagerTeamsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List deliveries for an organization webhook](Orgs::list_webhook_deliveries_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListWebhookDeliveriesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -1021,57 +1280,73 @@ pub enum OrgsListWebhookDeliveriesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsListWebhookDeliveriesError) -> Self { + let (description, status_code) = match err { + OrgsListWebhookDeliveriesError::Status400(_) => (String::from("Bad Request"), 400), + OrgsListWebhookDeliveriesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsListWebhookDeliveriesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization webhooks](Orgs::list_webhooks_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsListWebhooksError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsListWebhooksError) -> Self { + let (description, status_code) = match err { + OrgsListWebhooksError::Status404(_) => (String::from("Resource not found"), 404), + OrgsListWebhooksError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Ping an organization webhook](Orgs::ping_webhook_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsPingWebhookError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsPingWebhookError) -> Self { + let (description, status_code) = match err { + OrgsPingWebhookError::Status404(_) => (String::from("Resource not found"), 404), + OrgsPingWebhookError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Redeliver a delivery for an organization webhook](Orgs::redeliver_webhook_delivery_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsRedeliverWebhookDeliveryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -1080,19 +1355,25 @@ pub enum OrgsRedeliverWebhookDeliveryError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsRedeliverWebhookDeliveryError) -> Self { + let (description, status_code) = match err { + OrgsRedeliverWebhookDeliveryError::Status400(_) => (String::from("Bad Request"), 400), + OrgsRedeliverWebhookDeliveryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsRedeliverWebhookDeliveryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove a custom property for an organization](Orgs::remove_custom_property_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsRemoveCustomPropertyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -1101,38 +1382,49 @@ pub enum OrgsRemoveCustomPropertyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsRemoveCustomPropertyError) -> Self { + let (description, status_code) = match err { + OrgsRemoveCustomPropertyError::Status403(_) => (String::from("Forbidden"), 403), + OrgsRemoveCustomPropertyError::Status404(_) => (String::from("Resource not found"), 404), + OrgsRemoveCustomPropertyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove an organization member](Orgs::remove_member_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsRemoveMemberError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsRemoveMemberError) -> Self { + let (description, status_code) = match err { + OrgsRemoveMemberError::Status403(_) => (String::from("Forbidden"), 403), + OrgsRemoveMemberError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove organization membership for a user](Orgs::remove_membership_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsRemoveMembershipForUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -1141,72 +1433,91 @@ pub enum OrgsRemoveMembershipForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsRemoveMembershipForUserError) -> Self { + let (description, status_code) = match err { + OrgsRemoveMembershipForUserError::Status403(_) => (String::from("Forbidden"), 403), + OrgsRemoveMembershipForUserError::Status404(_) => (String::from("Resource not found"), 404), + OrgsRemoveMembershipForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove outside collaborator from an organization](Orgs::remove_outside_collaborator_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsRemoveOutsideCollaboratorError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Unprocessable Entity if user is a member of the organization")] Status422(PutTeamsAddOrUpdateProjectPermissionsLegacyResponse403), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsRemoveOutsideCollaboratorError) -> Self { + let (description, status_code) = match err { + OrgsRemoveOutsideCollaboratorError::Status422(_) => (String::from("Unprocessable Entity if user is a member of the organization"), 422), + OrgsRemoveOutsideCollaboratorError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove public organization membership for the authenticated user](Orgs::remove_public_membership_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsRemovePublicMembershipForAuthenticatedUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsRemovePublicMembershipForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + OrgsRemovePublicMembershipForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove a security manager team](Orgs::remove_security_manager_team_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsRemoveSecurityManagerTeamError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsRemoveSecurityManagerTeamError) -> Self { + let (description, status_code) = match err { + OrgsRemoveSecurityManagerTeamError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Review a request to access organization resources with a fine-grained personal access token](Orgs::review_pat_grant_request_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsReviewPatGrantRequestError { - #[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("Validation failed, or the endpoint has been spammed.")] @@ -1219,19 +1530,27 @@ pub enum OrgsReviewPatGrantRequestError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsReviewPatGrantRequestError) -> Self { + let (description, status_code) = match err { + OrgsReviewPatGrantRequestError::Status500(_) => (String::from("Internal Error"), 500), + OrgsReviewPatGrantRequestError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsReviewPatGrantRequestError::Status404(_) => (String::from("Resource not found"), 404), + OrgsReviewPatGrantRequestError::Status403(_) => (String::from("Forbidden"), 403), + OrgsReviewPatGrantRequestError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Review requests to access organization resources with fine-grained personal access tokens](Orgs::review_pat_grant_requests_in_bulk_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsReviewPatGrantRequestsInBulkError { - #[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("Validation failed, or the endpoint has been spammed.")] @@ -1244,87 +1563,111 @@ pub enum OrgsReviewPatGrantRequestsInBulkError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsReviewPatGrantRequestsInBulkError) -> Self { + let (description, status_code) = match err { + OrgsReviewPatGrantRequestsInBulkError::Status500(_) => (String::from("Internal Error"), 500), + OrgsReviewPatGrantRequestsInBulkError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsReviewPatGrantRequestsInBulkError::Status404(_) => (String::from("Resource not found"), 404), + OrgsReviewPatGrantRequestsInBulkError::Status403(_) => (String::from("Forbidden"), 403), + OrgsReviewPatGrantRequestsInBulkError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove all organization roles for a team](Orgs::revoke_all_org_roles_team_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsRevokeAllOrgRolesTeamError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsRevokeAllOrgRolesTeamError) -> Self { + let (description, status_code) = match err { + OrgsRevokeAllOrgRolesTeamError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove all organization roles for a user](Orgs::revoke_all_org_roles_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsRevokeAllOrgRolesUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsRevokeAllOrgRolesUserError) -> Self { + let (description, status_code) = match err { + OrgsRevokeAllOrgRolesUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove an organization role from a team](Orgs::revoke_org_role_team_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsRevokeOrgRoleTeamError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsRevokeOrgRoleTeamError) -> Self { + let (description, status_code) = match err { + OrgsRevokeOrgRoleTeamError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove an organization role from a user](Orgs::revoke_org_role_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsRevokeOrgRoleUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsRevokeOrgRoleUserError) -> Self { + let (description, status_code) = match err { + OrgsRevokeOrgRoleUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set organization membership for a user](Orgs::set_membership_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsSetMembershipForUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Forbidden")] @@ -1333,55 +1676,70 @@ pub enum OrgsSetMembershipForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsSetMembershipForUserError) -> Self { + let (description, status_code) = match err { + OrgsSetMembershipForUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsSetMembershipForUserError::Status403(_) => (String::from("Forbidden"), 403), + OrgsSetMembershipForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set public organization membership for the authenticated user](Orgs::set_public_membership_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsSetPublicMembershipForAuthenticatedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsSetPublicMembershipForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + OrgsSetPublicMembershipForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + OrgsSetPublicMembershipForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Unblock a user from an organization](Orgs::unblock_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsUnblockUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsUnblockUserError) -> Self { + let (description, status_code) = match err { + OrgsUnblockUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update an organization](Orgs::update_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsUpdateError { - #[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(PostProjectsCreateCardResponse422), #[error("Conflict")] @@ -1390,19 +1748,25 @@ pub enum OrgsUpdateError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsUpdateError) -> Self { + let (description, status_code) = match err { + OrgsUpdateError::Status422(_) => (String::from("Validation failed"), 422), + OrgsUpdateError::Status409(_) => (String::from("Conflict"), 409), + OrgsUpdateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update an organization membership for the authenticated user](Orgs::update_membership_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsUpdateMembershipForAuthenticatedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -1413,19 +1777,26 @@ pub enum OrgsUpdateMembershipForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsUpdateMembershipForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + OrgsUpdateMembershipForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + OrgsUpdateMembershipForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + OrgsUpdateMembershipForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsUpdateMembershipForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update the access a fine-grained personal access token has to organization resources](Orgs::update_pat_access_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsUpdatePatAccessError { - #[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("Resource not found")] @@ -1438,19 +1809,27 @@ pub enum OrgsUpdatePatAccessError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsUpdatePatAccessError) -> Self { + let (description, status_code) = match err { + OrgsUpdatePatAccessError::Status500(_) => (String::from("Internal Error"), 500), + OrgsUpdatePatAccessError::Status404(_) => (String::from("Resource not found"), 404), + OrgsUpdatePatAccessError::Status403(_) => (String::from("Forbidden"), 403), + OrgsUpdatePatAccessError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsUpdatePatAccessError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update the access to organization resources via fine-grained personal access tokens](Orgs::update_pat_accesses_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsUpdatePatAccessesError { - #[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("Resource not found")] @@ -1463,19 +1842,27 @@ pub enum OrgsUpdatePatAccessesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsUpdatePatAccessesError) -> Self { + let (description, status_code) = match err { + OrgsUpdatePatAccessesError::Status500(_) => (String::from("Internal Error"), 500), + OrgsUpdatePatAccessesError::Status404(_) => (String::from("Resource not found"), 404), + OrgsUpdatePatAccessesError::Status403(_) => (String::from("Forbidden"), 403), + OrgsUpdatePatAccessesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsUpdatePatAccessesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update an organization webhook](Orgs::update_webhook_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsUpdateWebhookError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -1484,23 +1871,43 @@ pub enum OrgsUpdateWebhookError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: OrgsUpdateWebhookError) -> Self { + let (description, status_code) = match err { + OrgsUpdateWebhookError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + OrgsUpdateWebhookError::Status404(_) => (String::from("Resource not found"), 404), + OrgsUpdateWebhookError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a webhook configuration for an organization](Orgs::update_webhook_config_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum OrgsUpdateWebhookConfigForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: OrgsUpdateWebhookConfigForOrgError) -> Self { + let (description, status_code) = match err { + OrgsUpdateWebhookConfigForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List organizations](Orgs::list_async()) endpoint. #[derive(Default, Serialize)] @@ -2743,7 +3150,7 @@ impl<'enc> From<&'enc PerPage> for OrgsListWebhooksParams { } } -impl<'api, C: Client> Orgs<'api, C> { +impl<'api, C: Client> Orgs<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Add a security manager team @@ -2757,19 +3164,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for add_security_manager_team](https://docs.github.com/rest/orgs/security-managers#add-a-security-manager-team) /// /// --- - pub async fn add_security_manager_team_async(&self, org: &str, team_slug: &str) -> Result<(), OrgsAddSecurityManagerTeamError> { + pub async fn add_security_manager_team_async(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/security-managers/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2781,7 +3188,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsAddSecurityManagerTeamError::Generic { code }), + code => Err(OrgsAddSecurityManagerTeamError::Generic { code }.into()), } } } @@ -2800,7 +3207,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_security_manager_team(&self, org: &str, team_slug: &str) -> Result<(), OrgsAddSecurityManagerTeamError> { + pub fn add_security_manager_team(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/security-managers/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); @@ -2812,7 +3219,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2824,7 +3231,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsAddSecurityManagerTeamError::Generic { code }), + code => Err(OrgsAddSecurityManagerTeamError::Generic { code }.into()), } } } @@ -2842,19 +3249,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for assign_team_to_org_role](https://docs.github.com/rest/orgs/organization-roles#assign-an-organization-role-to-a-team) /// /// --- - pub async fn assign_team_to_org_role_async(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), OrgsAssignTeamToOrgRoleError> { + pub async fn assign_team_to_org_role_async(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/teams/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, role_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2866,9 +3273,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsAssignTeamToOrgRoleError::Status404), - 422 => Err(OrgsAssignTeamToOrgRoleError::Status422), - code => Err(OrgsAssignTeamToOrgRoleError::Generic { code }), + 404 => Err(OrgsAssignTeamToOrgRoleError::Status404.into()), + 422 => Err(OrgsAssignTeamToOrgRoleError::Status422.into()), + code => Err(OrgsAssignTeamToOrgRoleError::Generic { code }.into()), } } } @@ -2887,7 +3294,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn assign_team_to_org_role(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), OrgsAssignTeamToOrgRoleError> { + pub fn assign_team_to_org_role(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/teams/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, role_id); @@ -2899,7 +3306,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2911,9 +3318,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsAssignTeamToOrgRoleError::Status404), - 422 => Err(OrgsAssignTeamToOrgRoleError::Status422), - code => Err(OrgsAssignTeamToOrgRoleError::Generic { code }), + 404 => Err(OrgsAssignTeamToOrgRoleError::Status404.into()), + 422 => Err(OrgsAssignTeamToOrgRoleError::Status422.into()), + code => Err(OrgsAssignTeamToOrgRoleError::Generic { code }.into()), } } } @@ -2931,19 +3338,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for assign_user_to_org_role](https://docs.github.com/rest/orgs/organization-roles#assign-an-organization-role-to-a-user) /// /// --- - pub async fn assign_user_to_org_role_async(&self, org: &str, username: &str, role_id: i32) -> Result<(), OrgsAssignUserToOrgRoleError> { + pub async fn assign_user_to_org_role_async(&self, org: &str, username: &str, role_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/users/{}/{}", super::GITHUB_BASE_API_URL, org, username, role_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2955,9 +3362,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsAssignUserToOrgRoleError::Status404), - 422 => Err(OrgsAssignUserToOrgRoleError::Status422), - code => Err(OrgsAssignUserToOrgRoleError::Generic { code }), + 404 => Err(OrgsAssignUserToOrgRoleError::Status404.into()), + 422 => Err(OrgsAssignUserToOrgRoleError::Status422.into()), + code => Err(OrgsAssignUserToOrgRoleError::Generic { code }.into()), } } } @@ -2976,7 +3383,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn assign_user_to_org_role(&self, org: &str, username: &str, role_id: i32) -> Result<(), OrgsAssignUserToOrgRoleError> { + pub fn assign_user_to_org_role(&self, org: &str, username: &str, role_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/users/{}/{}", super::GITHUB_BASE_API_URL, org, username, role_id); @@ -2988,7 +3395,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3000,9 +3407,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsAssignUserToOrgRoleError::Status404), - 422 => Err(OrgsAssignUserToOrgRoleError::Status422), - code => Err(OrgsAssignUserToOrgRoleError::Generic { code }), + 404 => Err(OrgsAssignUserToOrgRoleError::Status404.into()), + 422 => Err(OrgsAssignUserToOrgRoleError::Status422.into()), + code => Err(OrgsAssignUserToOrgRoleError::Generic { code }.into()), } } } @@ -3016,19 +3423,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for block_user](https://docs.github.com/rest/orgs/blocking#block-a-user-from-an-organization) /// /// --- - pub async fn block_user_async(&self, org: &str, username: &str) -> Result<(), OrgsBlockUserError> { + pub async fn block_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3040,8 +3447,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(OrgsBlockUserError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsBlockUserError::Generic { code }), + 422 => Err(OrgsBlockUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsBlockUserError::Generic { code }.into()), } } } @@ -3056,7 +3463,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn block_user(&self, org: &str, username: &str) -> Result<(), OrgsBlockUserError> { + pub fn block_user(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, username); @@ -3068,7 +3475,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3080,8 +3487,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(OrgsBlockUserError::Status422(github_response.to_json()?)), - code => Err(OrgsBlockUserError::Generic { code }), + 422 => Err(OrgsBlockUserError::Status422(github_response.to_json()?).into()), + code => Err(OrgsBlockUserError::Generic { code }.into()), } } } @@ -3097,19 +3504,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for cancel_invitation](https://docs.github.com/rest/orgs/members#cancel-an-organization-invitation) /// /// --- - pub async fn cancel_invitation_async(&self, org: &str, invitation_id: i32) -> Result<(), OrgsCancelInvitationError> { + pub async fn cancel_invitation_async(&self, org: &str, invitation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/invitations/{}", super::GITHUB_BASE_API_URL, org, invitation_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3121,9 +3528,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(OrgsCancelInvitationError::Status422(github_response.to_json_async().await?)), - 404 => Err(OrgsCancelInvitationError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsCancelInvitationError::Generic { code }), + 422 => Err(OrgsCancelInvitationError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(OrgsCancelInvitationError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsCancelInvitationError::Generic { code }.into()), } } } @@ -3140,7 +3547,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn cancel_invitation(&self, org: &str, invitation_id: i32) -> Result<(), OrgsCancelInvitationError> { + pub fn cancel_invitation(&self, org: &str, invitation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/invitations/{}", super::GITHUB_BASE_API_URL, org, invitation_id); @@ -3152,7 +3559,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3164,9 +3571,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(OrgsCancelInvitationError::Status422(github_response.to_json()?)), - 404 => Err(OrgsCancelInvitationError::Status404(github_response.to_json()?)), - code => Err(OrgsCancelInvitationError::Generic { code }), + 422 => Err(OrgsCancelInvitationError::Status422(github_response.to_json()?).into()), + 404 => Err(OrgsCancelInvitationError::Status404(github_response.to_json()?).into()), + code => Err(OrgsCancelInvitationError::Generic { code }.into()), } } } @@ -3180,19 +3587,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for check_blocked_user](https://docs.github.com/rest/orgs/blocking#check-if-a-user-is-blocked-by-an-organization) /// /// --- - pub async fn check_blocked_user_async(&self, org: &str, username: &str) -> Result<(), OrgsCheckBlockedUserError> { + pub async fn check_blocked_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3204,8 +3611,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsCheckBlockedUserError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsCheckBlockedUserError::Generic { code }), + 404 => Err(OrgsCheckBlockedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsCheckBlockedUserError::Generic { code }.into()), } } } @@ -3220,7 +3627,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_blocked_user(&self, org: &str, username: &str) -> Result<(), OrgsCheckBlockedUserError> { + pub fn check_blocked_user(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, username); @@ -3232,7 +3639,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3244,8 +3651,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsCheckBlockedUserError::Status404(github_response.to_json()?)), - code => Err(OrgsCheckBlockedUserError::Generic { code }), + 404 => Err(OrgsCheckBlockedUserError::Status404(github_response.to_json()?).into()), + code => Err(OrgsCheckBlockedUserError::Generic { code }.into()), } } } @@ -3259,19 +3666,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for check_membership_for_user](https://docs.github.com/rest/orgs/members#check-organization-membership-for-a-user) /// /// --- - pub async fn check_membership_for_user_async(&self, org: &str, username: &str) -> Result<(), OrgsCheckMembershipForUserError> { + pub async fn check_membership_for_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/members/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3283,9 +3690,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 302 => Err(OrgsCheckMembershipForUserError::Status302), - 404 => Err(OrgsCheckMembershipForUserError::Status404), - code => Err(OrgsCheckMembershipForUserError::Generic { code }), + 302 => Err(OrgsCheckMembershipForUserError::Status302.into()), + 404 => Err(OrgsCheckMembershipForUserError::Status404.into()), + code => Err(OrgsCheckMembershipForUserError::Generic { code }.into()), } } } @@ -3300,7 +3707,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_membership_for_user(&self, org: &str, username: &str) -> Result<(), OrgsCheckMembershipForUserError> { + pub fn check_membership_for_user(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/members/{}", super::GITHUB_BASE_API_URL, org, username); @@ -3312,7 +3719,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3324,9 +3731,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 302 => Err(OrgsCheckMembershipForUserError::Status302), - 404 => Err(OrgsCheckMembershipForUserError::Status404), - code => Err(OrgsCheckMembershipForUserError::Generic { code }), + 302 => Err(OrgsCheckMembershipForUserError::Status302.into()), + 404 => Err(OrgsCheckMembershipForUserError::Status404.into()), + code => Err(OrgsCheckMembershipForUserError::Generic { code }.into()), } } } @@ -3340,19 +3747,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for check_public_membership_for_user](https://docs.github.com/rest/orgs/members#check-public-organization-membership-for-a-user) /// /// --- - pub async fn check_public_membership_for_user_async(&self, org: &str, username: &str) -> Result<(), OrgsCheckPublicMembershipForUserError> { + pub async fn check_public_membership_for_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3364,8 +3771,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsCheckPublicMembershipForUserError::Status404), - code => Err(OrgsCheckPublicMembershipForUserError::Generic { code }), + 404 => Err(OrgsCheckPublicMembershipForUserError::Status404.into()), + code => Err(OrgsCheckPublicMembershipForUserError::Generic { code }.into()), } } } @@ -3380,7 +3787,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_public_membership_for_user(&self, org: &str, username: &str) -> Result<(), OrgsCheckPublicMembershipForUserError> { + pub fn check_public_membership_for_user(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, username); @@ -3392,7 +3799,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3404,8 +3811,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsCheckPublicMembershipForUserError::Status404), - code => Err(OrgsCheckPublicMembershipForUserError::Generic { code }), + 404 => Err(OrgsCheckPublicMembershipForUserError::Status404.into()), + code => Err(OrgsCheckPublicMembershipForUserError::Generic { code }.into()), } } } @@ -3419,19 +3826,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for convert_member_to_outside_collaborator](https://docs.github.com/rest/orgs/outside-collaborators#convert-an-organization-member-to-outside-collaborator) /// /// --- - pub async fn convert_member_to_outside_collaborator_async(&self, org: &str, username: &str, body: PutOrgsConvertMemberToOutsideCollaborator) -> Result, OrgsConvertMemberToOutsideCollaboratorError> { + pub async fn convert_member_to_outside_collaborator_async(&self, org: &str, username: &str, body: PutOrgsConvertMemberToOutsideCollaborator) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/outside_collaborators/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutOrgsConvertMemberToOutsideCollaborator::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3443,10 +3850,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status204), - 403 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status403), - 404 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsConvertMemberToOutsideCollaboratorError::Generic { code }), + 204 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status204.into()), + 403 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status403.into()), + 404 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsConvertMemberToOutsideCollaboratorError::Generic { code }.into()), } } } @@ -3461,19 +3868,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn convert_member_to_outside_collaborator(&self, org: &str, username: &str, body: PutOrgsConvertMemberToOutsideCollaborator) -> Result, OrgsConvertMemberToOutsideCollaboratorError> { + pub fn convert_member_to_outside_collaborator(&self, org: &str, username: &str, body: PutOrgsConvertMemberToOutsideCollaborator) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/outside_collaborators/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutOrgsConvertMemberToOutsideCollaborator::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3485,10 +3892,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status204), - 403 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status403), - 404 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status404(github_response.to_json()?)), - code => Err(OrgsConvertMemberToOutsideCollaboratorError::Generic { code }), + 204 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status204.into()), + 403 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status403.into()), + 404 => Err(OrgsConvertMemberToOutsideCollaboratorError::Status404(github_response.to_json()?).into()), + code => Err(OrgsConvertMemberToOutsideCollaboratorError::Generic { code }.into()), } } } @@ -3505,19 +3912,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for create_invitation](https://docs.github.com/rest/orgs/members#create-an-organization-invitation) /// /// --- - pub async fn create_invitation_async(&self, org: &str, body: PostOrgsCreateInvitation) -> Result { + pub async fn create_invitation_async(&self, org: &str, body: PostOrgsCreateInvitation) -> Result { let request_uri = format!("{}/orgs/{}/invitations", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsCreateInvitation::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3529,9 +3936,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(OrgsCreateInvitationError::Status422(github_response.to_json_async().await?)), - 404 => Err(OrgsCreateInvitationError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsCreateInvitationError::Generic { code }), + 422 => Err(OrgsCreateInvitationError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(OrgsCreateInvitationError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsCreateInvitationError::Generic { code }.into()), } } } @@ -3549,19 +3956,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_invitation(&self, org: &str, body: PostOrgsCreateInvitation) -> Result { + pub fn create_invitation(&self, org: &str, body: PostOrgsCreateInvitation) -> Result { let request_uri = format!("{}/orgs/{}/invitations", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsCreateInvitation::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3573,9 +3980,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(OrgsCreateInvitationError::Status422(github_response.to_json()?)), - 404 => Err(OrgsCreateInvitationError::Status404(github_response.to_json()?)), - code => Err(OrgsCreateInvitationError::Generic { code }), + 422 => Err(OrgsCreateInvitationError::Status422(github_response.to_json()?).into()), + 404 => Err(OrgsCreateInvitationError::Status404(github_response.to_json()?).into()), + code => Err(OrgsCreateInvitationError::Generic { code }.into()), } } } @@ -3593,19 +4000,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for create_or_update_custom_properties](https://docs.github.com/rest/orgs/custom-properties#create-or-update-custom-properties-for-an-organization) /// /// --- - pub async fn create_or_update_custom_properties_async(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomProperties) -> Result, OrgsCreateOrUpdateCustomPropertiesError> { + pub async fn create_or_update_custom_properties_async(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomProperties) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/properties/schema", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsCreateOrUpdateCustomProperties::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3617,9 +4024,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status403(github_response.to_json_async().await?)), - 404 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsCreateOrUpdateCustomPropertiesError::Generic { code }), + 403 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsCreateOrUpdateCustomPropertiesError::Generic { code }.into()), } } } @@ -3638,19 +4045,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_custom_properties(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomProperties) -> Result, OrgsCreateOrUpdateCustomPropertiesError> { + pub fn create_or_update_custom_properties(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomProperties) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/properties/schema", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsCreateOrUpdateCustomProperties::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3662,9 +4069,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status403(github_response.to_json()?)), - 404 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status404(github_response.to_json()?)), - code => Err(OrgsCreateOrUpdateCustomPropertiesError::Generic { code }), + 403 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status403(github_response.to_json()?).into()), + 404 => Err(OrgsCreateOrUpdateCustomPropertiesError::Status404(github_response.to_json()?).into()), + code => Err(OrgsCreateOrUpdateCustomPropertiesError::Generic { code }.into()), } } } @@ -3687,19 +4094,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for create_or_update_custom_properties_values_for_repos](https://docs.github.com/rest/orgs/custom-properties#create-or-update-custom-property-values-for-organization-repositories) /// /// --- - pub async fn create_or_update_custom_properties_values_for_repos_async(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomPropertiesValuesForRepos) -> Result<(), OrgsCreateOrUpdateCustomPropertiesValuesForReposError> { + pub async fn create_or_update_custom_properties_values_for_repos_async(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomPropertiesValuesForRepos) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/properties/values", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsCreateOrUpdateCustomPropertiesValuesForRepos::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3711,10 +4118,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status403(github_response.to_json_async().await?)), - 404 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status404(github_response.to_json_async().await?)), - 422 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Generic { code }), + 403 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Generic { code }.into()), } } } @@ -3738,19 +4145,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_custom_properties_values_for_repos(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomPropertiesValuesForRepos) -> Result<(), OrgsCreateOrUpdateCustomPropertiesValuesForReposError> { + pub fn create_or_update_custom_properties_values_for_repos(&self, org: &str, body: PatchOrgsCreateOrUpdateCustomPropertiesValuesForRepos) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/properties/values", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsCreateOrUpdateCustomPropertiesValuesForRepos::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3762,10 +4169,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status403(github_response.to_json()?)), - 404 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status404(github_response.to_json()?)), - 422 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status422(github_response.to_json()?)), - code => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Generic { code }), + 403 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status403(github_response.to_json()?).into()), + 404 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status404(github_response.to_json()?).into()), + 422 => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Status422(github_response.to_json()?).into()), + code => Err(OrgsCreateOrUpdateCustomPropertiesValuesForReposError::Generic { code }.into()), } } } @@ -3783,19 +4190,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for create_or_update_custom_property](https://docs.github.com/rest/orgs/custom-properties#create-or-update-a-custom-property-for-an-organization) /// /// --- - pub async fn create_or_update_custom_property_async(&self, org: &str, custom_property_name: &str, body: PutOrgsCreateOrUpdateCustomProperty) -> Result { + pub async fn create_or_update_custom_property_async(&self, org: &str, custom_property_name: &str, body: PutOrgsCreateOrUpdateCustomProperty) -> Result { let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutOrgsCreateOrUpdateCustomProperty::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3807,9 +4214,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsCreateOrUpdateCustomPropertyError::Status403(github_response.to_json_async().await?)), - 404 => Err(OrgsCreateOrUpdateCustomPropertyError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsCreateOrUpdateCustomPropertyError::Generic { code }), + 403 => Err(OrgsCreateOrUpdateCustomPropertyError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(OrgsCreateOrUpdateCustomPropertyError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsCreateOrUpdateCustomPropertyError::Generic { code }.into()), } } } @@ -3828,19 +4235,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_custom_property(&self, org: &str, custom_property_name: &str, body: PutOrgsCreateOrUpdateCustomProperty) -> Result { + pub fn create_or_update_custom_property(&self, org: &str, custom_property_name: &str, body: PutOrgsCreateOrUpdateCustomProperty) -> Result { let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutOrgsCreateOrUpdateCustomProperty::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3852,9 +4259,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsCreateOrUpdateCustomPropertyError::Status403(github_response.to_json()?)), - 404 => Err(OrgsCreateOrUpdateCustomPropertyError::Status404(github_response.to_json()?)), - code => Err(OrgsCreateOrUpdateCustomPropertyError::Generic { code }), + 403 => Err(OrgsCreateOrUpdateCustomPropertyError::Status403(github_response.to_json()?).into()), + 404 => Err(OrgsCreateOrUpdateCustomPropertyError::Status404(github_response.to_json()?).into()), + code => Err(OrgsCreateOrUpdateCustomPropertyError::Generic { code }.into()), } } } @@ -3873,19 +4280,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for create_webhook](https://docs.github.com/rest/orgs/webhooks#create-an-organization-webhook) /// /// --- - pub async fn create_webhook_async(&self, org: &str, body: PostOrgsCreateWebhook) -> Result { + pub async fn create_webhook_async(&self, org: &str, body: PostOrgsCreateWebhook) -> Result { let request_uri = format!("{}/orgs/{}/hooks", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsCreateWebhook::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3897,9 +4304,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(OrgsCreateWebhookError::Status422(github_response.to_json_async().await?)), - 404 => Err(OrgsCreateWebhookError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsCreateWebhookError::Generic { code }), + 422 => Err(OrgsCreateWebhookError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(OrgsCreateWebhookError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsCreateWebhookError::Generic { code }.into()), } } } @@ -3919,19 +4326,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_webhook(&self, org: &str, body: PostOrgsCreateWebhook) -> Result { + pub fn create_webhook(&self, org: &str, body: PostOrgsCreateWebhook) -> Result { let request_uri = format!("{}/orgs/{}/hooks", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsCreateWebhook::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3943,9 +4350,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(OrgsCreateWebhookError::Status422(github_response.to_json()?)), - 404 => Err(OrgsCreateWebhookError::Status404(github_response.to_json()?)), - code => Err(OrgsCreateWebhookError::Generic { code }), + 422 => Err(OrgsCreateWebhookError::Status422(github_response.to_json()?).into()), + 404 => Err(OrgsCreateWebhookError::Status404(github_response.to_json()?).into()), + code => Err(OrgsCreateWebhookError::Generic { code }.into()), } } } @@ -3965,19 +4372,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for delete](https://docs.github.com/rest/orgs/orgs#delete-an-organization) /// /// --- - pub async fn delete_async(&self, org: &str) -> Result, OrgsDeleteError> { + pub async fn delete_async(&self, org: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3989,9 +4396,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsDeleteError::Status404(github_response.to_json_async().await?)), - 403 => Err(OrgsDeleteError::Status403(github_response.to_json_async().await?)), - code => Err(OrgsDeleteError::Generic { code }), + 404 => Err(OrgsDeleteError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(OrgsDeleteError::Status403(github_response.to_json_async().await?).into()), + code => Err(OrgsDeleteError::Generic { code }.into()), } } } @@ -4012,7 +4419,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete(&self, org: &str) -> Result, OrgsDeleteError> { + pub fn delete(&self, org: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org); @@ -4024,7 +4431,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4036,9 +4443,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsDeleteError::Status404(github_response.to_json()?)), - 403 => Err(OrgsDeleteError::Status403(github_response.to_json()?)), - code => Err(OrgsDeleteError::Generic { code }), + 404 => Err(OrgsDeleteError::Status404(github_response.to_json()?).into()), + 403 => Err(OrgsDeleteError::Status403(github_response.to_json()?).into()), + code => Err(OrgsDeleteError::Generic { code }.into()), } } } @@ -4055,19 +4462,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for delete_webhook](https://docs.github.com/rest/orgs/webhooks#delete-an-organization-webhook) /// /// --- - pub async fn delete_webhook_async(&self, org: &str, hook_id: i32) -> Result<(), OrgsDeleteWebhookError> { + pub async fn delete_webhook_async(&self, org: &str, hook_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4079,8 +4486,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsDeleteWebhookError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsDeleteWebhookError::Generic { code }), + 404 => Err(OrgsDeleteWebhookError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsDeleteWebhookError::Generic { code }.into()), } } } @@ -4098,7 +4505,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_webhook(&self, org: &str, hook_id: i32) -> Result<(), OrgsDeleteWebhookError> { + pub fn delete_webhook(&self, org: &str, hook_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_id); @@ -4110,7 +4517,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4122,8 +4529,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsDeleteWebhookError::Status404(github_response.to_json()?)), - code => Err(OrgsDeleteWebhookError::Generic { code }), + 404 => Err(OrgsDeleteWebhookError::Status404(github_response.to_json()?).into()), + code => Err(OrgsDeleteWebhookError::Generic { code }.into()), } } } @@ -4144,19 +4551,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for enable_or_disable_security_product_on_all_org_repos](https://docs.github.com/rest/orgs/orgs#enable-or-disable-a-security-feature-for-an-organization) /// /// --- - pub async fn enable_or_disable_security_product_on_all_org_repos_async(&self, org: &str, security_product: &str, enablement: &str, body: PostOrgsEnableOrDisableSecurityProductOnAllOrgRepos) -> Result<(), OrgsEnableOrDisableSecurityProductOnAllOrgReposError> { + pub async fn enable_or_disable_security_product_on_all_org_repos_async(&self, org: &str, security_product: &str, enablement: &str, body: PostOrgsEnableOrDisableSecurityProductOnAllOrgRepos) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/{}/{}", super::GITHUB_BASE_API_URL, org, security_product, enablement); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsEnableOrDisableSecurityProductOnAllOrgRepos::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4168,8 +4575,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Status422), - code => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Generic { code }), + 422 => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Status422.into()), + code => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Generic { code }.into()), } } } @@ -4191,19 +4598,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn enable_or_disable_security_product_on_all_org_repos(&self, org: &str, security_product: &str, enablement: &str, body: PostOrgsEnableOrDisableSecurityProductOnAllOrgRepos) -> Result<(), OrgsEnableOrDisableSecurityProductOnAllOrgReposError> { + pub fn enable_or_disable_security_product_on_all_org_repos(&self, org: &str, security_product: &str, enablement: &str, body: PostOrgsEnableOrDisableSecurityProductOnAllOrgRepos) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/{}/{}", super::GITHUB_BASE_API_URL, org, security_product, enablement); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsEnableOrDisableSecurityProductOnAllOrgRepos::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4215,8 +4622,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Status422), - code => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Generic { code }), + 422 => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Status422.into()), + code => Err(OrgsEnableOrDisableSecurityProductOnAllOrgReposError::Generic { code }.into()), } } } @@ -4238,19 +4645,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for get](https://docs.github.com/rest/orgs/orgs#get-an-organization) /// /// --- - pub async fn get_async(&self, org: &str) -> Result { + pub async fn get_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4262,8 +4669,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsGetError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsGetError::Generic { code }), + 404 => Err(OrgsGetError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsGetError::Generic { code }.into()), } } } @@ -4286,7 +4693,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get(&self, org: &str) -> Result { + pub fn get(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org); @@ -4298,7 +4705,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4310,8 +4717,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsGetError::Status404(github_response.to_json()?)), - code => Err(OrgsGetError::Generic { code }), + 404 => Err(OrgsGetError::Status404(github_response.to_json()?).into()), + code => Err(OrgsGetError::Generic { code }.into()), } } } @@ -4326,19 +4733,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for get_all_custom_properties](https://docs.github.com/rest/orgs/custom-properties#get-all-custom-properties-for-an-organization) /// /// --- - pub async fn get_all_custom_properties_async(&self, org: &str) -> Result, OrgsGetAllCustomPropertiesError> { + pub async fn get_all_custom_properties_async(&self, org: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/properties/schema", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4350,9 +4757,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsGetAllCustomPropertiesError::Status403(github_response.to_json_async().await?)), - 404 => Err(OrgsGetAllCustomPropertiesError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsGetAllCustomPropertiesError::Generic { code }), + 403 => Err(OrgsGetAllCustomPropertiesError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(OrgsGetAllCustomPropertiesError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsGetAllCustomPropertiesError::Generic { code }.into()), } } } @@ -4368,7 +4775,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_custom_properties(&self, org: &str) -> Result, OrgsGetAllCustomPropertiesError> { + pub fn get_all_custom_properties(&self, org: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/properties/schema", super::GITHUB_BASE_API_URL, org); @@ -4380,7 +4787,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4392,9 +4799,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsGetAllCustomPropertiesError::Status403(github_response.to_json()?)), - 404 => Err(OrgsGetAllCustomPropertiesError::Status404(github_response.to_json()?)), - code => Err(OrgsGetAllCustomPropertiesError::Generic { code }), + 403 => Err(OrgsGetAllCustomPropertiesError::Status403(github_response.to_json()?).into()), + 404 => Err(OrgsGetAllCustomPropertiesError::Status404(github_response.to_json()?).into()), + code => Err(OrgsGetAllCustomPropertiesError::Generic { code }.into()), } } } @@ -4409,19 +4816,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for get_custom_property](https://docs.github.com/rest/orgs/custom-properties#get-a-custom-property-for-an-organization) /// /// --- - pub async fn get_custom_property_async(&self, org: &str, custom_property_name: &str) -> Result { + pub async fn get_custom_property_async(&self, org: &str, custom_property_name: &str) -> Result { let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4433,9 +4840,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsGetCustomPropertyError::Status403(github_response.to_json_async().await?)), - 404 => Err(OrgsGetCustomPropertyError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsGetCustomPropertyError::Generic { code }), + 403 => Err(OrgsGetCustomPropertyError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(OrgsGetCustomPropertyError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsGetCustomPropertyError::Generic { code }.into()), } } } @@ -4451,7 +4858,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_custom_property(&self, org: &str, custom_property_name: &str) -> Result { + pub fn get_custom_property(&self, org: &str, custom_property_name: &str) -> Result { let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name); @@ -4463,7 +4870,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4475,9 +4882,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsGetCustomPropertyError::Status403(github_response.to_json()?)), - 404 => Err(OrgsGetCustomPropertyError::Status404(github_response.to_json()?)), - code => Err(OrgsGetCustomPropertyError::Generic { code }), + 403 => Err(OrgsGetCustomPropertyError::Status403(github_response.to_json()?).into()), + 404 => Err(OrgsGetCustomPropertyError::Status404(github_response.to_json()?).into()), + code => Err(OrgsGetCustomPropertyError::Generic { code }.into()), } } } @@ -4491,19 +4898,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for get_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#get-an-organization-membership-for-the-authenticated-user) /// /// --- - pub async fn get_membership_for_authenticated_user_async(&self, org: &str) -> Result { + pub async fn get_membership_for_authenticated_user_async(&self, org: &str) -> Result { let request_uri = format!("{}/user/memberships/orgs/{}", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4515,9 +4922,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsGetMembershipForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(OrgsGetMembershipForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsGetMembershipForAuthenticatedUserError::Generic { code }), + 403 => Err(OrgsGetMembershipForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(OrgsGetMembershipForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsGetMembershipForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4532,7 +4939,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_membership_for_authenticated_user(&self, org: &str) -> Result { + pub fn get_membership_for_authenticated_user(&self, org: &str) -> Result { let request_uri = format!("{}/user/memberships/orgs/{}", super::GITHUB_BASE_API_URL, org); @@ -4544,7 +4951,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4556,9 +4963,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsGetMembershipForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(OrgsGetMembershipForAuthenticatedUserError::Status404(github_response.to_json()?)), - code => Err(OrgsGetMembershipForAuthenticatedUserError::Generic { code }), + 403 => Err(OrgsGetMembershipForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(OrgsGetMembershipForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + code => Err(OrgsGetMembershipForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4572,19 +4979,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for get_membership_for_user](https://docs.github.com/rest/orgs/members#get-organization-membership-for-a-user) /// /// --- - pub async fn get_membership_for_user_async(&self, org: &str, username: &str) -> Result { + pub async fn get_membership_for_user_async(&self, org: &str, username: &str) -> Result { let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4596,9 +5003,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsGetMembershipForUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(OrgsGetMembershipForUserError::Status403(github_response.to_json_async().await?)), - code => Err(OrgsGetMembershipForUserError::Generic { code }), + 404 => Err(OrgsGetMembershipForUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(OrgsGetMembershipForUserError::Status403(github_response.to_json_async().await?).into()), + code => Err(OrgsGetMembershipForUserError::Generic { code }.into()), } } } @@ -4613,7 +5020,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_membership_for_user(&self, org: &str, username: &str) -> Result { + pub fn get_membership_for_user(&self, org: &str, username: &str) -> Result { let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, username); @@ -4625,7 +5032,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4637,9 +5044,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsGetMembershipForUserError::Status404(github_response.to_json()?)), - 403 => Err(OrgsGetMembershipForUserError::Status403(github_response.to_json()?)), - code => Err(OrgsGetMembershipForUserError::Generic { code }), + 404 => Err(OrgsGetMembershipForUserError::Status404(github_response.to_json()?).into()), + 403 => Err(OrgsGetMembershipForUserError::Status403(github_response.to_json()?).into()), + code => Err(OrgsGetMembershipForUserError::Generic { code }.into()), } } } @@ -4660,19 +5067,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for get_org_role](https://docs.github.com/rest/orgs/organization-roles#get-an-organization-role) /// /// --- - pub async fn get_org_role_async(&self, org: &str, role_id: i32) -> Result { + pub async fn get_org_role_async(&self, org: &str, role_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/organization-roles/{}", super::GITHUB_BASE_API_URL, org, role_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4684,9 +5091,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsGetOrgRoleError::Status404(github_response.to_json_async().await?)), - 422 => Err(OrgsGetOrgRoleError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsGetOrgRoleError::Generic { code }), + 404 => Err(OrgsGetOrgRoleError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(OrgsGetOrgRoleError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsGetOrgRoleError::Generic { code }.into()), } } } @@ -4708,7 +5115,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_role(&self, org: &str, role_id: i32) -> Result { + pub fn get_org_role(&self, org: &str, role_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/organization-roles/{}", super::GITHUB_BASE_API_URL, org, role_id); @@ -4720,7 +5127,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4732,9 +5139,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsGetOrgRoleError::Status404(github_response.to_json()?)), - 422 => Err(OrgsGetOrgRoleError::Status422(github_response.to_json()?)), - code => Err(OrgsGetOrgRoleError::Generic { code }), + 404 => Err(OrgsGetOrgRoleError::Status404(github_response.to_json()?).into()), + 422 => Err(OrgsGetOrgRoleError::Status422(github_response.to_json()?).into()), + code => Err(OrgsGetOrgRoleError::Generic { code }.into()), } } } @@ -4754,19 +5161,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for get_webhook](https://docs.github.com/rest/orgs/webhooks#get-an-organization-webhook) /// /// --- - pub async fn get_webhook_async(&self, org: &str, hook_id: i32) -> Result { + pub async fn get_webhook_async(&self, org: &str, hook_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4778,8 +5185,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsGetWebhookError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsGetWebhookError::Generic { code }), + 404 => Err(OrgsGetWebhookError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsGetWebhookError::Generic { code }.into()), } } } @@ -4800,7 +5207,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_webhook(&self, org: &str, hook_id: i32) -> Result { + pub fn get_webhook(&self, org: &str, hook_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_id); @@ -4812,7 +5219,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4824,8 +5231,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsGetWebhookError::Status404(github_response.to_json()?)), - code => Err(OrgsGetWebhookError::Generic { code }), + 404 => Err(OrgsGetWebhookError::Status404(github_response.to_json()?).into()), + code => Err(OrgsGetWebhookError::Generic { code }.into()), } } } @@ -4844,19 +5251,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for get_webhook_config_for_org](https://docs.github.com/rest/orgs/webhooks#get-a-webhook-configuration-for-an-organization) /// /// --- - pub async fn get_webhook_config_for_org_async(&self, org: &str, hook_id: i32) -> Result { + pub async fn get_webhook_config_for_org_async(&self, org: &str, hook_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, org, hook_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4868,7 +5275,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsGetWebhookConfigForOrgError::Generic { code }), + code => Err(OrgsGetWebhookConfigForOrgError::Generic { code }.into()), } } } @@ -4888,7 +5295,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_webhook_config_for_org(&self, org: &str, hook_id: i32) -> Result { + pub fn get_webhook_config_for_org(&self, org: &str, hook_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, org, hook_id); @@ -4900,7 +5307,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4912,7 +5319,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsGetWebhookConfigForOrgError::Generic { code }), + code => Err(OrgsGetWebhookConfigForOrgError::Generic { code }.into()), } } } @@ -4931,19 +5338,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for get_webhook_delivery](https://docs.github.com/rest/orgs/webhooks#get-a-webhook-delivery-for-an-organization-webhook) /// /// --- - pub async fn get_webhook_delivery_async(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result { + pub async fn get_webhook_delivery_async(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/hooks/{}/deliveries/{}", super::GITHUB_BASE_API_URL, org, hook_id, delivery_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4955,9 +5362,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(OrgsGetWebhookDeliveryError::Status400(github_response.to_json_async().await?)), - 422 => Err(OrgsGetWebhookDeliveryError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsGetWebhookDeliveryError::Generic { code }), + 400 => Err(OrgsGetWebhookDeliveryError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(OrgsGetWebhookDeliveryError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsGetWebhookDeliveryError::Generic { code }.into()), } } } @@ -4977,7 +5384,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_webhook_delivery(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result { + pub fn get_webhook_delivery(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/hooks/{}/deliveries/{}", super::GITHUB_BASE_API_URL, org, hook_id, delivery_id); @@ -4989,7 +5396,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5001,9 +5408,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(OrgsGetWebhookDeliveryError::Status400(github_response.to_json()?)), - 422 => Err(OrgsGetWebhookDeliveryError::Status422(github_response.to_json()?)), - code => Err(OrgsGetWebhookDeliveryError::Generic { code }), + 400 => Err(OrgsGetWebhookDeliveryError::Status400(github_response.to_json()?).into()), + 422 => Err(OrgsGetWebhookDeliveryError::Status422(github_response.to_json()?).into()), + code => Err(OrgsGetWebhookDeliveryError::Generic { code }.into()), } } } @@ -5020,7 +5427,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list](https://docs.github.com/rest/orgs/orgs#list-organizations) /// /// --- - pub async fn list_async(&self, query_params: Option>) -> Result, OrgsListError> { + pub async fn list_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/organizations", super::GITHUB_BASE_API_URL); @@ -5031,12 +5438,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5048,8 +5455,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(OrgsListError::Status304), - code => Err(OrgsListError::Generic { code }), + 304 => Err(OrgsListError::Status304.into()), + code => Err(OrgsListError::Generic { code }.into()), } } } @@ -5067,7 +5474,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list(&self, query_params: Option>) -> Result, OrgsListError> { + pub fn list(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/organizations", super::GITHUB_BASE_API_URL); @@ -5084,7 +5491,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5096,8 +5503,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(OrgsListError::Status304), - code => Err(OrgsListError::Generic { code }), + 304 => Err(OrgsListError::Status304.into()), + code => Err(OrgsListError::Generic { code }.into()), } } } @@ -5116,7 +5523,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_app_installations](https://docs.github.com/rest/orgs/orgs#list-app-installations-for-an-organization) /// /// --- - pub async fn list_app_installations_async(&self, org: &str, query_params: Option>) -> Result { + pub async fn list_app_installations_async(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/installations", super::GITHUB_BASE_API_URL, org); @@ -5127,12 +5534,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5144,7 +5551,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsListAppInstallationsError::Generic { code }), + code => Err(OrgsListAppInstallationsError::Generic { code }.into()), } } } @@ -5164,7 +5571,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_app_installations(&self, org: &str, query_params: Option>) -> Result { + pub fn list_app_installations(&self, org: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/orgs/{}/installations", super::GITHUB_BASE_API_URL, org); @@ -5181,7 +5588,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5193,7 +5600,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsListAppInstallationsError::Generic { code }), + code => Err(OrgsListAppInstallationsError::Generic { code }.into()), } } } @@ -5211,7 +5618,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_attestations](https://docs.github.com/rest/orgs/orgs#list-attestations) /// /// --- - pub async fn list_attestations_async(&self, org: &str, subject_digest: &str, query_params: Option>>) -> Result { + pub async fn list_attestations_async(&self, org: &str, subject_digest: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/orgs/{}/attestations/{}", super::GITHUB_BASE_API_URL, org, subject_digest); @@ -5222,12 +5629,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5239,7 +5646,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsListAttestationsError::Generic { code }), + code => Err(OrgsListAttestationsError::Generic { code }.into()), } } } @@ -5258,7 +5665,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_attestations(&self, org: &str, subject_digest: &str, query_params: Option>>) -> Result { + pub fn list_attestations(&self, org: &str, subject_digest: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/orgs/{}/attestations/{}", super::GITHUB_BASE_API_URL, org, subject_digest); @@ -5275,7 +5682,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5287,7 +5694,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsListAttestationsError::Generic { code }), + code => Err(OrgsListAttestationsError::Generic { code }.into()), } } } @@ -5301,7 +5708,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_blocked_users](https://docs.github.com/rest/orgs/blocking#list-users-blocked-by-an-organization) /// /// --- - pub async fn list_blocked_users_async(&self, org: &str, query_params: Option>) -> Result, OrgsListBlockedUsersError> { + pub async fn list_blocked_users_async(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/blocks", super::GITHUB_BASE_API_URL, org); @@ -5312,12 +5719,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5329,7 +5736,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsListBlockedUsersError::Generic { code }), + code => Err(OrgsListBlockedUsersError::Generic { code }.into()), } } } @@ -5344,7 +5751,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_blocked_users(&self, org: &str, query_params: Option>) -> Result, OrgsListBlockedUsersError> { + pub fn list_blocked_users(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/blocks", super::GITHUB_BASE_API_URL, org); @@ -5361,7 +5768,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5373,7 +5780,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsListBlockedUsersError::Generic { code }), + code => Err(OrgsListBlockedUsersError::Generic { code }.into()), } } } @@ -5388,7 +5795,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_custom_properties_values_for_repos](https://docs.github.com/rest/orgs/custom-properties#list-custom-property-values-for-organization-repositories) /// /// --- - pub async fn list_custom_properties_values_for_repos_async(&self, org: &str, query_params: Option>>) -> Result, OrgsListCustomPropertiesValuesForReposError> { + pub async fn list_custom_properties_values_for_repos_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/properties/values", super::GITHUB_BASE_API_URL, org); @@ -5399,12 +5806,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5416,9 +5823,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsListCustomPropertiesValuesForReposError::Status403(github_response.to_json_async().await?)), - 404 => Err(OrgsListCustomPropertiesValuesForReposError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsListCustomPropertiesValuesForReposError::Generic { code }), + 403 => Err(OrgsListCustomPropertiesValuesForReposError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(OrgsListCustomPropertiesValuesForReposError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsListCustomPropertiesValuesForReposError::Generic { code }.into()), } } } @@ -5434,7 +5841,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_custom_properties_values_for_repos(&self, org: &str, query_params: Option>>) -> Result, OrgsListCustomPropertiesValuesForReposError> { + pub fn list_custom_properties_values_for_repos(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/properties/values", super::GITHUB_BASE_API_URL, org); @@ -5451,7 +5858,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5463,9 +5870,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsListCustomPropertiesValuesForReposError::Status403(github_response.to_json()?)), - 404 => Err(OrgsListCustomPropertiesValuesForReposError::Status404(github_response.to_json()?)), - code => Err(OrgsListCustomPropertiesValuesForReposError::Generic { code }), + 403 => Err(OrgsListCustomPropertiesValuesForReposError::Status403(github_response.to_json()?).into()), + 404 => Err(OrgsListCustomPropertiesValuesForReposError::Status404(github_response.to_json()?).into()), + code => Err(OrgsListCustomPropertiesValuesForReposError::Generic { code }.into()), } } } @@ -5479,7 +5886,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_failed_invitations](https://docs.github.com/rest/orgs/members#list-failed-organization-invitations) /// /// --- - pub async fn list_failed_invitations_async(&self, org: &str, query_params: Option>) -> Result, OrgsListFailedInvitationsError> { + pub async fn list_failed_invitations_async(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/failed_invitations", super::GITHUB_BASE_API_URL, org); @@ -5490,12 +5897,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5507,8 +5914,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsListFailedInvitationsError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsListFailedInvitationsError::Generic { code }), + 404 => Err(OrgsListFailedInvitationsError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsListFailedInvitationsError::Generic { code }.into()), } } } @@ -5523,7 +5930,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_failed_invitations(&self, org: &str, query_params: Option>) -> Result, OrgsListFailedInvitationsError> { + pub fn list_failed_invitations(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/failed_invitations", super::GITHUB_BASE_API_URL, org); @@ -5540,7 +5947,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5552,8 +5959,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsListFailedInvitationsError::Status404(github_response.to_json()?)), - code => Err(OrgsListFailedInvitationsError::Generic { code }), + 404 => Err(OrgsListFailedInvitationsError::Status404(github_response.to_json()?).into()), + code => Err(OrgsListFailedInvitationsError::Generic { code }.into()), } } } @@ -5569,7 +5976,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/orgs/orgs#list-organizations-for-the-authenticated-user) /// /// --- - pub async fn list_for_authenticated_user_async(&self, query_params: Option>) -> Result, OrgsListForAuthenticatedUserError> { + pub async fn list_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/orgs", super::GITHUB_BASE_API_URL); @@ -5580,12 +5987,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5597,10 +6004,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(OrgsListForAuthenticatedUserError::Status304), - 403 => Err(OrgsListForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(OrgsListForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(OrgsListForAuthenticatedUserError::Generic { code }), + 304 => Err(OrgsListForAuthenticatedUserError::Status304.into()), + 403 => Err(OrgsListForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(OrgsListForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(OrgsListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5617,7 +6024,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_authenticated_user(&self, query_params: Option>) -> Result, OrgsListForAuthenticatedUserError> { + pub fn list_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/orgs", super::GITHUB_BASE_API_URL); @@ -5634,7 +6041,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5646,10 +6053,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(OrgsListForAuthenticatedUserError::Status304), - 403 => Err(OrgsListForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(OrgsListForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(OrgsListForAuthenticatedUserError::Generic { code }), + 304 => Err(OrgsListForAuthenticatedUserError::Status304.into()), + 403 => Err(OrgsListForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(OrgsListForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(OrgsListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5665,7 +6072,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_for_user](https://docs.github.com/rest/orgs/orgs#list-organizations-for-a-user) /// /// --- - pub async fn list_for_user_async(&self, username: &str, query_params: Option>) -> Result, OrgsListForUserError> { + pub async fn list_for_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/orgs", super::GITHUB_BASE_API_URL, username); @@ -5676,12 +6083,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5693,7 +6100,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsListForUserError::Generic { code }), + code => Err(OrgsListForUserError::Generic { code }.into()), } } } @@ -5710,7 +6117,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_user(&self, username: &str, query_params: Option>) -> Result, OrgsListForUserError> { + pub fn list_for_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/orgs", super::GITHUB_BASE_API_URL, username); @@ -5727,7 +6134,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5739,7 +6146,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsListForUserError::Generic { code }), + code => Err(OrgsListForUserError::Generic { code }.into()), } } } @@ -5753,7 +6160,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_invitation_teams](https://docs.github.com/rest/orgs/members#list-organization-invitation-teams) /// /// --- - pub async fn list_invitation_teams_async(&self, org: &str, invitation_id: i32, query_params: Option>) -> Result, OrgsListInvitationTeamsError> { + pub async fn list_invitation_teams_async(&self, org: &str, invitation_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/invitations/{}/teams", super::GITHUB_BASE_API_URL, org, invitation_id); @@ -5764,12 +6171,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5781,8 +6188,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsListInvitationTeamsError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsListInvitationTeamsError::Generic { code }), + 404 => Err(OrgsListInvitationTeamsError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsListInvitationTeamsError::Generic { code }.into()), } } } @@ -5797,7 +6204,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_invitation_teams(&self, org: &str, invitation_id: i32, query_params: Option>) -> Result, OrgsListInvitationTeamsError> { + pub fn list_invitation_teams(&self, org: &str, invitation_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/invitations/{}/teams", super::GITHUB_BASE_API_URL, org, invitation_id); @@ -5814,7 +6221,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5826,8 +6233,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsListInvitationTeamsError::Status404(github_response.to_json()?)), - code => Err(OrgsListInvitationTeamsError::Generic { code }), + 404 => Err(OrgsListInvitationTeamsError::Status404(github_response.to_json()?).into()), + code => Err(OrgsListInvitationTeamsError::Generic { code }.into()), } } } @@ -5841,7 +6248,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_members](https://docs.github.com/rest/orgs/members#list-organization-members) /// /// --- - pub async fn list_members_async(&self, org: &str, query_params: Option>>) -> Result, OrgsListMembersError> { + pub async fn list_members_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/members", super::GITHUB_BASE_API_URL, org); @@ -5852,12 +6259,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5869,8 +6276,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(OrgsListMembersError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsListMembersError::Generic { code }), + 422 => Err(OrgsListMembersError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsListMembersError::Generic { code }.into()), } } } @@ -5885,7 +6292,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_members(&self, org: &str, query_params: Option>>) -> Result, OrgsListMembersError> { + pub fn list_members(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/members", super::GITHUB_BASE_API_URL, org); @@ -5902,7 +6309,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5914,8 +6321,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(OrgsListMembersError::Status422(github_response.to_json()?)), - code => Err(OrgsListMembersError::Generic { code }), + 422 => Err(OrgsListMembersError::Status422(github_response.to_json()?).into()), + code => Err(OrgsListMembersError::Generic { code }.into()), } } } @@ -5929,7 +6336,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_memberships_for_authenticated_user](https://docs.github.com/rest/orgs/members#list-organization-memberships-for-the-authenticated-user) /// /// --- - pub async fn list_memberships_for_authenticated_user_async(&self, query_params: Option>>) -> Result, OrgsListMembershipsForAuthenticatedUserError> { + pub async fn list_memberships_for_authenticated_user_async(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/memberships/orgs", super::GITHUB_BASE_API_URL); @@ -5940,12 +6347,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5957,11 +6364,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(OrgsListMembershipsForAuthenticatedUserError::Status304), - 403 => Err(OrgsListMembershipsForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(OrgsListMembershipsForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 422 => Err(OrgsListMembershipsForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsListMembershipsForAuthenticatedUserError::Generic { code }), + 304 => Err(OrgsListMembershipsForAuthenticatedUserError::Status304.into()), + 403 => Err(OrgsListMembershipsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(OrgsListMembershipsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 422 => Err(OrgsListMembershipsForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsListMembershipsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5976,7 +6383,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_memberships_for_authenticated_user(&self, query_params: Option>>) -> Result, OrgsListMembershipsForAuthenticatedUserError> { + pub fn list_memberships_for_authenticated_user(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/memberships/orgs", super::GITHUB_BASE_API_URL); @@ -5993,7 +6400,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6005,11 +6412,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(OrgsListMembershipsForAuthenticatedUserError::Status304), - 403 => Err(OrgsListMembershipsForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(OrgsListMembershipsForAuthenticatedUserError::Status401(github_response.to_json()?)), - 422 => Err(OrgsListMembershipsForAuthenticatedUserError::Status422(github_response.to_json()?)), - code => Err(OrgsListMembershipsForAuthenticatedUserError::Generic { code }), + 304 => Err(OrgsListMembershipsForAuthenticatedUserError::Status304.into()), + 403 => Err(OrgsListMembershipsForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(OrgsListMembershipsForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 422 => Err(OrgsListMembershipsForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + code => Err(OrgsListMembershipsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -6027,7 +6434,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_org_role_teams](https://docs.github.com/rest/orgs/organization-roles#list-teams-that-are-assigned-to-an-organization-role) /// /// --- - pub async fn list_org_role_teams_async(&self, org: &str, role_id: i32, query_params: Option>) -> Result, OrgsListOrgRoleTeamsError> { + pub async fn list_org_role_teams_async(&self, org: &str, role_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/organization-roles/{}/teams", super::GITHUB_BASE_API_URL, org, role_id); @@ -6038,12 +6445,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6055,9 +6462,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsListOrgRoleTeamsError::Status404), - 422 => Err(OrgsListOrgRoleTeamsError::Status422), - code => Err(OrgsListOrgRoleTeamsError::Generic { code }), + 404 => Err(OrgsListOrgRoleTeamsError::Status404.into()), + 422 => Err(OrgsListOrgRoleTeamsError::Status422.into()), + code => Err(OrgsListOrgRoleTeamsError::Generic { code }.into()), } } } @@ -6076,7 +6483,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_org_role_teams(&self, org: &str, role_id: i32, query_params: Option>) -> Result, OrgsListOrgRoleTeamsError> { + pub fn list_org_role_teams(&self, org: &str, role_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/organization-roles/{}/teams", super::GITHUB_BASE_API_URL, org, role_id); @@ -6093,7 +6500,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6105,9 +6512,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsListOrgRoleTeamsError::Status404), - 422 => Err(OrgsListOrgRoleTeamsError::Status422), - code => Err(OrgsListOrgRoleTeamsError::Generic { code }), + 404 => Err(OrgsListOrgRoleTeamsError::Status404.into()), + 422 => Err(OrgsListOrgRoleTeamsError::Status422.into()), + code => Err(OrgsListOrgRoleTeamsError::Generic { code }.into()), } } } @@ -6125,7 +6532,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_org_role_users](https://docs.github.com/rest/orgs/organization-roles#list-users-that-are-assigned-to-an-organization-role) /// /// --- - pub async fn list_org_role_users_async(&self, org: &str, role_id: i32, query_params: Option>) -> Result, OrgsListOrgRoleUsersError> { + pub async fn list_org_role_users_async(&self, org: &str, role_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/organization-roles/{}/users", super::GITHUB_BASE_API_URL, org, role_id); @@ -6136,12 +6543,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6153,9 +6560,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsListOrgRoleUsersError::Status404), - 422 => Err(OrgsListOrgRoleUsersError::Status422), - code => Err(OrgsListOrgRoleUsersError::Generic { code }), + 404 => Err(OrgsListOrgRoleUsersError::Status404.into()), + 422 => Err(OrgsListOrgRoleUsersError::Status422.into()), + code => Err(OrgsListOrgRoleUsersError::Generic { code }.into()), } } } @@ -6174,7 +6581,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_org_role_users(&self, org: &str, role_id: i32, query_params: Option>) -> Result, OrgsListOrgRoleUsersError> { + pub fn list_org_role_users(&self, org: &str, role_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/organization-roles/{}/users", super::GITHUB_BASE_API_URL, org, role_id); @@ -6191,7 +6598,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6203,9 +6610,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsListOrgRoleUsersError::Status404), - 422 => Err(OrgsListOrgRoleUsersError::Status422), - code => Err(OrgsListOrgRoleUsersError::Generic { code }), + 404 => Err(OrgsListOrgRoleUsersError::Status404.into()), + 422 => Err(OrgsListOrgRoleUsersError::Status422.into()), + code => Err(OrgsListOrgRoleUsersError::Generic { code }.into()), } } } @@ -6226,19 +6633,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_org_roles](https://docs.github.com/rest/orgs/organization-roles#get-all-organization-roles-for-an-organization) /// /// --- - pub async fn list_org_roles_async(&self, org: &str) -> Result { + pub async fn list_org_roles_async(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/organization-roles", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6250,9 +6657,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsListOrgRolesError::Status404(github_response.to_json_async().await?)), - 422 => Err(OrgsListOrgRolesError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsListOrgRolesError::Generic { code }), + 404 => Err(OrgsListOrgRolesError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(OrgsListOrgRolesError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsListOrgRolesError::Generic { code }.into()), } } } @@ -6274,7 +6681,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_org_roles(&self, org: &str) -> Result { + pub fn list_org_roles(&self, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/organization-roles", super::GITHUB_BASE_API_URL, org); @@ -6286,7 +6693,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6298,9 +6705,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsListOrgRolesError::Status404(github_response.to_json()?)), - 422 => Err(OrgsListOrgRolesError::Status422(github_response.to_json()?)), - code => Err(OrgsListOrgRolesError::Generic { code }), + 404 => Err(OrgsListOrgRolesError::Status404(github_response.to_json()?).into()), + 422 => Err(OrgsListOrgRolesError::Status422(github_response.to_json()?).into()), + code => Err(OrgsListOrgRolesError::Generic { code }.into()), } } } @@ -6314,7 +6721,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_outside_collaborators](https://docs.github.com/rest/orgs/outside-collaborators#list-outside-collaborators-for-an-organization) /// /// --- - pub async fn list_outside_collaborators_async(&self, org: &str, query_params: Option>>) -> Result, OrgsListOutsideCollaboratorsError> { + pub async fn list_outside_collaborators_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/outside_collaborators", super::GITHUB_BASE_API_URL, org); @@ -6325,12 +6732,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6342,7 +6749,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsListOutsideCollaboratorsError::Generic { code }), + code => Err(OrgsListOutsideCollaboratorsError::Generic { code }.into()), } } } @@ -6357,7 +6764,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_outside_collaborators(&self, org: &str, query_params: Option>>) -> Result, OrgsListOutsideCollaboratorsError> { + pub fn list_outside_collaborators(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/outside_collaborators", super::GITHUB_BASE_API_URL, org); @@ -6374,7 +6781,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6386,7 +6793,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsListOutsideCollaboratorsError::Generic { code }), + code => Err(OrgsListOutsideCollaboratorsError::Generic { code }.into()), } } } @@ -6402,7 +6809,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_pat_grant_repositories](https://docs.github.com/rest/orgs/personal-access-tokens#list-repositories-a-fine-grained-personal-access-token-has-access-to) /// /// --- - pub async fn list_pat_grant_repositories_async(&self, org: &str, pat_id: i32, query_params: Option>) -> Result, OrgsListPatGrantRepositoriesError> { + pub async fn list_pat_grant_repositories_async(&self, org: &str, pat_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/personal-access-tokens/{}/repositories", super::GITHUB_BASE_API_URL, org, pat_id); @@ -6413,12 +6820,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6430,10 +6837,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(OrgsListPatGrantRepositoriesError::Status500(github_response.to_json_async().await?)), - 404 => Err(OrgsListPatGrantRepositoriesError::Status404(github_response.to_json_async().await?)), - 403 => Err(OrgsListPatGrantRepositoriesError::Status403(github_response.to_json_async().await?)), - code => Err(OrgsListPatGrantRepositoriesError::Generic { code }), + 500 => Err(OrgsListPatGrantRepositoriesError::Status500(github_response.to_json_async().await?).into()), + 404 => Err(OrgsListPatGrantRepositoriesError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(OrgsListPatGrantRepositoriesError::Status403(github_response.to_json_async().await?).into()), + code => Err(OrgsListPatGrantRepositoriesError::Generic { code }.into()), } } } @@ -6450,7 +6857,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_pat_grant_repositories(&self, org: &str, pat_id: i32, query_params: Option>) -> Result, OrgsListPatGrantRepositoriesError> { + pub fn list_pat_grant_repositories(&self, org: &str, pat_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/personal-access-tokens/{}/repositories", super::GITHUB_BASE_API_URL, org, pat_id); @@ -6467,7 +6874,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6479,10 +6886,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(OrgsListPatGrantRepositoriesError::Status500(github_response.to_json()?)), - 404 => Err(OrgsListPatGrantRepositoriesError::Status404(github_response.to_json()?)), - 403 => Err(OrgsListPatGrantRepositoriesError::Status403(github_response.to_json()?)), - code => Err(OrgsListPatGrantRepositoriesError::Generic { code }), + 500 => Err(OrgsListPatGrantRepositoriesError::Status500(github_response.to_json()?).into()), + 404 => Err(OrgsListPatGrantRepositoriesError::Status404(github_response.to_json()?).into()), + 403 => Err(OrgsListPatGrantRepositoriesError::Status403(github_response.to_json()?).into()), + code => Err(OrgsListPatGrantRepositoriesError::Generic { code }.into()), } } } @@ -6498,7 +6905,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_pat_grant_request_repositories](https://docs.github.com/rest/orgs/personal-access-tokens#list-repositories-requested-to-be-accessed-by-a-fine-grained-personal-access-token) /// /// --- - pub async fn list_pat_grant_request_repositories_async(&self, org: &str, pat_request_id: i32, query_params: Option>) -> Result, OrgsListPatGrantRequestRepositoriesError> { + pub async fn list_pat_grant_request_repositories_async(&self, org: &str, pat_request_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/personal-access-token-requests/{}/repositories", super::GITHUB_BASE_API_URL, org, pat_request_id); @@ -6509,12 +6916,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6526,10 +6933,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(OrgsListPatGrantRequestRepositoriesError::Status500(github_response.to_json_async().await?)), - 404 => Err(OrgsListPatGrantRequestRepositoriesError::Status404(github_response.to_json_async().await?)), - 403 => Err(OrgsListPatGrantRequestRepositoriesError::Status403(github_response.to_json_async().await?)), - code => Err(OrgsListPatGrantRequestRepositoriesError::Generic { code }), + 500 => Err(OrgsListPatGrantRequestRepositoriesError::Status500(github_response.to_json_async().await?).into()), + 404 => Err(OrgsListPatGrantRequestRepositoriesError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(OrgsListPatGrantRequestRepositoriesError::Status403(github_response.to_json_async().await?).into()), + code => Err(OrgsListPatGrantRequestRepositoriesError::Generic { code }.into()), } } } @@ -6546,7 +6953,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_pat_grant_request_repositories(&self, org: &str, pat_request_id: i32, query_params: Option>) -> Result, OrgsListPatGrantRequestRepositoriesError> { + pub fn list_pat_grant_request_repositories(&self, org: &str, pat_request_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/personal-access-token-requests/{}/repositories", super::GITHUB_BASE_API_URL, org, pat_request_id); @@ -6563,7 +6970,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6575,10 +6982,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(OrgsListPatGrantRequestRepositoriesError::Status500(github_response.to_json()?)), - 404 => Err(OrgsListPatGrantRequestRepositoriesError::Status404(github_response.to_json()?)), - 403 => Err(OrgsListPatGrantRequestRepositoriesError::Status403(github_response.to_json()?)), - code => Err(OrgsListPatGrantRequestRepositoriesError::Generic { code }), + 500 => Err(OrgsListPatGrantRequestRepositoriesError::Status500(github_response.to_json()?).into()), + 404 => Err(OrgsListPatGrantRequestRepositoriesError::Status404(github_response.to_json()?).into()), + 403 => Err(OrgsListPatGrantRequestRepositoriesError::Status403(github_response.to_json()?).into()), + code => Err(OrgsListPatGrantRequestRepositoriesError::Generic { code }.into()), } } } @@ -6594,7 +7001,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_pat_grant_requests](https://docs.github.com/rest/orgs/personal-access-tokens#list-requests-to-access-organization-resources-with-fine-grained-personal-access-tokens) /// /// --- - pub async fn list_pat_grant_requests_async(&self, org: &str, query_params: Option>>) -> Result, OrgsListPatGrantRequestsError> { + pub async fn list_pat_grant_requests_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/personal-access-token-requests", super::GITHUB_BASE_API_URL, org); @@ -6605,12 +7012,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6622,11 +7029,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(OrgsListPatGrantRequestsError::Status500(github_response.to_json_async().await?)), - 422 => Err(OrgsListPatGrantRequestsError::Status422(github_response.to_json_async().await?)), - 404 => Err(OrgsListPatGrantRequestsError::Status404(github_response.to_json_async().await?)), - 403 => Err(OrgsListPatGrantRequestsError::Status403(github_response.to_json_async().await?)), - code => Err(OrgsListPatGrantRequestsError::Generic { code }), + 500 => Err(OrgsListPatGrantRequestsError::Status500(github_response.to_json_async().await?).into()), + 422 => Err(OrgsListPatGrantRequestsError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(OrgsListPatGrantRequestsError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(OrgsListPatGrantRequestsError::Status403(github_response.to_json_async().await?).into()), + code => Err(OrgsListPatGrantRequestsError::Generic { code }.into()), } } } @@ -6643,7 +7050,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_pat_grant_requests(&self, org: &str, query_params: Option>>) -> Result, OrgsListPatGrantRequestsError> { + pub fn list_pat_grant_requests(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/personal-access-token-requests", super::GITHUB_BASE_API_URL, org); @@ -6660,7 +7067,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6672,11 +7079,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(OrgsListPatGrantRequestsError::Status500(github_response.to_json()?)), - 422 => Err(OrgsListPatGrantRequestsError::Status422(github_response.to_json()?)), - 404 => Err(OrgsListPatGrantRequestsError::Status404(github_response.to_json()?)), - 403 => Err(OrgsListPatGrantRequestsError::Status403(github_response.to_json()?)), - code => Err(OrgsListPatGrantRequestsError::Generic { code }), + 500 => Err(OrgsListPatGrantRequestsError::Status500(github_response.to_json()?).into()), + 422 => Err(OrgsListPatGrantRequestsError::Status422(github_response.to_json()?).into()), + 404 => Err(OrgsListPatGrantRequestsError::Status404(github_response.to_json()?).into()), + 403 => Err(OrgsListPatGrantRequestsError::Status403(github_response.to_json()?).into()), + code => Err(OrgsListPatGrantRequestsError::Generic { code }.into()), } } } @@ -6692,7 +7099,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_pat_grants](https://docs.github.com/rest/orgs/personal-access-tokens#list-fine-grained-personal-access-tokens-with-access-to-organization-resources) /// /// --- - pub async fn list_pat_grants_async(&self, org: &str, query_params: Option>>) -> Result, OrgsListPatGrantsError> { + pub async fn list_pat_grants_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/personal-access-tokens", super::GITHUB_BASE_API_URL, org); @@ -6703,12 +7110,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6720,11 +7127,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(OrgsListPatGrantsError::Status500(github_response.to_json_async().await?)), - 422 => Err(OrgsListPatGrantsError::Status422(github_response.to_json_async().await?)), - 404 => Err(OrgsListPatGrantsError::Status404(github_response.to_json_async().await?)), - 403 => Err(OrgsListPatGrantsError::Status403(github_response.to_json_async().await?)), - code => Err(OrgsListPatGrantsError::Generic { code }), + 500 => Err(OrgsListPatGrantsError::Status500(github_response.to_json_async().await?).into()), + 422 => Err(OrgsListPatGrantsError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(OrgsListPatGrantsError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(OrgsListPatGrantsError::Status403(github_response.to_json_async().await?).into()), + code => Err(OrgsListPatGrantsError::Generic { code }.into()), } } } @@ -6741,7 +7148,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_pat_grants(&self, org: &str, query_params: Option>>) -> Result, OrgsListPatGrantsError> { + pub fn list_pat_grants(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/personal-access-tokens", super::GITHUB_BASE_API_URL, org); @@ -6758,7 +7165,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6770,11 +7177,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(OrgsListPatGrantsError::Status500(github_response.to_json()?)), - 422 => Err(OrgsListPatGrantsError::Status422(github_response.to_json()?)), - 404 => Err(OrgsListPatGrantsError::Status404(github_response.to_json()?)), - 403 => Err(OrgsListPatGrantsError::Status403(github_response.to_json()?)), - code => Err(OrgsListPatGrantsError::Generic { code }), + 500 => Err(OrgsListPatGrantsError::Status500(github_response.to_json()?).into()), + 422 => Err(OrgsListPatGrantsError::Status422(github_response.to_json()?).into()), + 404 => Err(OrgsListPatGrantsError::Status404(github_response.to_json()?).into()), + 403 => Err(OrgsListPatGrantsError::Status403(github_response.to_json()?).into()), + code => Err(OrgsListPatGrantsError::Generic { code }.into()), } } } @@ -6791,7 +7198,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_pending_invitations](https://docs.github.com/rest/orgs/members#list-pending-organization-invitations) /// /// --- - pub async fn list_pending_invitations_async(&self, org: &str, query_params: Option>>) -> Result, OrgsListPendingInvitationsError> { + pub async fn list_pending_invitations_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/invitations", super::GITHUB_BASE_API_URL, org); @@ -6802,12 +7209,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6819,8 +7226,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsListPendingInvitationsError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsListPendingInvitationsError::Generic { code }), + 404 => Err(OrgsListPendingInvitationsError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsListPendingInvitationsError::Generic { code }.into()), } } } @@ -6838,7 +7245,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_pending_invitations(&self, org: &str, query_params: Option>>) -> Result, OrgsListPendingInvitationsError> { + pub fn list_pending_invitations(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/invitations", super::GITHUB_BASE_API_URL, org); @@ -6855,7 +7262,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6867,8 +7274,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsListPendingInvitationsError::Status404(github_response.to_json()?)), - code => Err(OrgsListPendingInvitationsError::Generic { code }), + 404 => Err(OrgsListPendingInvitationsError::Status404(github_response.to_json()?).into()), + code => Err(OrgsListPendingInvitationsError::Generic { code }.into()), } } } @@ -6882,7 +7289,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_public_members](https://docs.github.com/rest/orgs/members#list-public-organization-members) /// /// --- - pub async fn list_public_members_async(&self, org: &str, query_params: Option>) -> Result, OrgsListPublicMembersError> { + pub async fn list_public_members_async(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/public_members", super::GITHUB_BASE_API_URL, org); @@ -6893,12 +7300,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6910,7 +7317,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsListPublicMembersError::Generic { code }), + code => Err(OrgsListPublicMembersError::Generic { code }.into()), } } } @@ -6925,7 +7332,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_public_members(&self, org: &str, query_params: Option>) -> Result, OrgsListPublicMembersError> { + pub fn list_public_members(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/public_members", super::GITHUB_BASE_API_URL, org); @@ -6942,7 +7349,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6954,7 +7361,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsListPublicMembersError::Generic { code }), + code => Err(OrgsListPublicMembersError::Generic { code }.into()), } } } @@ -6972,19 +7379,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_security_manager_teams](https://docs.github.com/rest/orgs/security-managers#list-security-manager-teams) /// /// --- - pub async fn list_security_manager_teams_async(&self, org: &str) -> Result, OrgsListSecurityManagerTeamsError> { + pub async fn list_security_manager_teams_async(&self, org: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/security-managers", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6996,7 +7403,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsListSecurityManagerTeamsError::Generic { code }), + code => Err(OrgsListSecurityManagerTeamsError::Generic { code }.into()), } } } @@ -7015,7 +7422,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_security_manager_teams(&self, org: &str) -> Result, OrgsListSecurityManagerTeamsError> { + pub fn list_security_manager_teams(&self, org: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/security-managers", super::GITHUB_BASE_API_URL, org); @@ -7027,7 +7434,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7039,7 +7446,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsListSecurityManagerTeamsError::Generic { code }), + code => Err(OrgsListSecurityManagerTeamsError::Generic { code }.into()), } } } @@ -7058,7 +7465,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_webhook_deliveries](https://docs.github.com/rest/orgs/webhooks#list-deliveries-for-an-organization-webhook) /// /// --- - pub async fn list_webhook_deliveries_async(&self, org: &str, hook_id: i32, query_params: Option>>) -> Result, OrgsListWebhookDeliveriesError> { + pub async fn list_webhook_deliveries_async(&self, org: &str, hook_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/hooks/{}/deliveries", super::GITHUB_BASE_API_URL, org, hook_id); @@ -7069,12 +7476,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7086,9 +7493,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(OrgsListWebhookDeliveriesError::Status400(github_response.to_json_async().await?)), - 422 => Err(OrgsListWebhookDeliveriesError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsListWebhookDeliveriesError::Generic { code }), + 400 => Err(OrgsListWebhookDeliveriesError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(OrgsListWebhookDeliveriesError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsListWebhookDeliveriesError::Generic { code }.into()), } } } @@ -7108,7 +7515,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_webhook_deliveries(&self, org: &str, hook_id: i32, query_params: Option>>) -> Result, OrgsListWebhookDeliveriesError> { + pub fn list_webhook_deliveries(&self, org: &str, hook_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/hooks/{}/deliveries", super::GITHUB_BASE_API_URL, org, hook_id); @@ -7125,7 +7532,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7137,9 +7544,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(OrgsListWebhookDeliveriesError::Status400(github_response.to_json()?)), - 422 => Err(OrgsListWebhookDeliveriesError::Status422(github_response.to_json()?)), - code => Err(OrgsListWebhookDeliveriesError::Generic { code }), + 400 => Err(OrgsListWebhookDeliveriesError::Status400(github_response.to_json()?).into()), + 422 => Err(OrgsListWebhookDeliveriesError::Status422(github_response.to_json()?).into()), + code => Err(OrgsListWebhookDeliveriesError::Generic { code }.into()), } } } @@ -7156,7 +7563,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for list_webhooks](https://docs.github.com/rest/orgs/webhooks#list-organization-webhooks) /// /// --- - pub async fn list_webhooks_async(&self, org: &str, query_params: Option>) -> Result, OrgsListWebhooksError> { + pub async fn list_webhooks_async(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/hooks", super::GITHUB_BASE_API_URL, org); @@ -7167,12 +7574,12 @@ impl<'api, C: Client> Orgs<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7184,8 +7591,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsListWebhooksError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsListWebhooksError::Generic { code }), + 404 => Err(OrgsListWebhooksError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsListWebhooksError::Generic { code }.into()), } } } @@ -7203,7 +7610,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_webhooks(&self, org: &str, query_params: Option>) -> Result, OrgsListWebhooksError> { + pub fn list_webhooks(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/hooks", super::GITHUB_BASE_API_URL, org); @@ -7220,7 +7627,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7232,8 +7639,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsListWebhooksError::Status404(github_response.to_json()?)), - code => Err(OrgsListWebhooksError::Generic { code }), + 404 => Err(OrgsListWebhooksError::Status404(github_response.to_json()?).into()), + code => Err(OrgsListWebhooksError::Generic { code }.into()), } } } @@ -7253,19 +7660,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for ping_webhook](https://docs.github.com/rest/orgs/webhooks#ping-an-organization-webhook) /// /// --- - pub async fn ping_webhook_async(&self, org: &str, hook_id: i32) -> Result<(), OrgsPingWebhookError> { + pub async fn ping_webhook_async(&self, org: &str, hook_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/hooks/{}/pings", super::GITHUB_BASE_API_URL, org, hook_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7277,8 +7684,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(OrgsPingWebhookError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsPingWebhookError::Generic { code }), + 404 => Err(OrgsPingWebhookError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsPingWebhookError::Generic { code }.into()), } } } @@ -7299,7 +7706,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn ping_webhook(&self, org: &str, hook_id: i32) -> Result<(), OrgsPingWebhookError> { + pub fn ping_webhook(&self, org: &str, hook_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/hooks/{}/pings", super::GITHUB_BASE_API_URL, org, hook_id); @@ -7311,7 +7718,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7323,8 +7730,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(OrgsPingWebhookError::Status404(github_response.to_json()?)), - code => Err(OrgsPingWebhookError::Generic { code }), + 404 => Err(OrgsPingWebhookError::Status404(github_response.to_json()?).into()), + code => Err(OrgsPingWebhookError::Generic { code }.into()), } } } @@ -7343,19 +7750,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for redeliver_webhook_delivery](https://docs.github.com/rest/orgs/webhooks#redeliver-a-delivery-for-an-organization-webhook) /// /// --- - pub async fn redeliver_webhook_delivery_async(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result, OrgsRedeliverWebhookDeliveryError> { + pub async fn redeliver_webhook_delivery_async(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/hooks/{}/deliveries/{}/attempts", super::GITHUB_BASE_API_URL, org, hook_id, delivery_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7367,9 +7774,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(OrgsRedeliverWebhookDeliveryError::Status400(github_response.to_json_async().await?)), - 422 => Err(OrgsRedeliverWebhookDeliveryError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsRedeliverWebhookDeliveryError::Generic { code }), + 400 => Err(OrgsRedeliverWebhookDeliveryError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(OrgsRedeliverWebhookDeliveryError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsRedeliverWebhookDeliveryError::Generic { code }.into()), } } } @@ -7389,7 +7796,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn redeliver_webhook_delivery(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result, OrgsRedeliverWebhookDeliveryError> { + pub fn redeliver_webhook_delivery(&self, org: &str, hook_id: i32, delivery_id: i32) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/hooks/{}/deliveries/{}/attempts", super::GITHUB_BASE_API_URL, org, hook_id, delivery_id); @@ -7401,7 +7808,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7413,9 +7820,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(OrgsRedeliverWebhookDeliveryError::Status400(github_response.to_json()?)), - 422 => Err(OrgsRedeliverWebhookDeliveryError::Status422(github_response.to_json()?)), - code => Err(OrgsRedeliverWebhookDeliveryError::Generic { code }), + 400 => Err(OrgsRedeliverWebhookDeliveryError::Status400(github_response.to_json()?).into()), + 422 => Err(OrgsRedeliverWebhookDeliveryError::Status422(github_response.to_json()?).into()), + code => Err(OrgsRedeliverWebhookDeliveryError::Generic { code }.into()), } } } @@ -7433,19 +7840,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for remove_custom_property](https://docs.github.com/rest/orgs/custom-properties#remove-a-custom-property-for-an-organization) /// /// --- - pub async fn remove_custom_property_async(&self, org: &str, custom_property_name: &str) -> Result<(), OrgsRemoveCustomPropertyError> { + pub async fn remove_custom_property_async(&self, org: &str, custom_property_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7457,9 +7864,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsRemoveCustomPropertyError::Status403(github_response.to_json_async().await?)), - 404 => Err(OrgsRemoveCustomPropertyError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsRemoveCustomPropertyError::Generic { code }), + 403 => Err(OrgsRemoveCustomPropertyError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(OrgsRemoveCustomPropertyError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsRemoveCustomPropertyError::Generic { code }.into()), } } } @@ -7478,7 +7885,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_custom_property(&self, org: &str, custom_property_name: &str) -> Result<(), OrgsRemoveCustomPropertyError> { + pub fn remove_custom_property(&self, org: &str, custom_property_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/properties/schema/{}", super::GITHUB_BASE_API_URL, org, custom_property_name); @@ -7490,7 +7897,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7502,9 +7909,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsRemoveCustomPropertyError::Status403(github_response.to_json()?)), - 404 => Err(OrgsRemoveCustomPropertyError::Status404(github_response.to_json()?)), - code => Err(OrgsRemoveCustomPropertyError::Generic { code }), + 403 => Err(OrgsRemoveCustomPropertyError::Status403(github_response.to_json()?).into()), + 404 => Err(OrgsRemoveCustomPropertyError::Status404(github_response.to_json()?).into()), + code => Err(OrgsRemoveCustomPropertyError::Generic { code }.into()), } } } @@ -7518,19 +7925,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for remove_member](https://docs.github.com/rest/orgs/members#remove-an-organization-member) /// /// --- - pub async fn remove_member_async(&self, org: &str, username: &str) -> Result<(), OrgsRemoveMemberError> { + pub async fn remove_member_async(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/members/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7542,8 +7949,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsRemoveMemberError::Status403(github_response.to_json_async().await?)), - code => Err(OrgsRemoveMemberError::Generic { code }), + 403 => Err(OrgsRemoveMemberError::Status403(github_response.to_json_async().await?).into()), + code => Err(OrgsRemoveMemberError::Generic { code }.into()), } } } @@ -7558,7 +7965,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_member(&self, org: &str, username: &str) -> Result<(), OrgsRemoveMemberError> { + pub fn remove_member(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/members/{}", super::GITHUB_BASE_API_URL, org, username); @@ -7570,7 +7977,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7582,8 +7989,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsRemoveMemberError::Status403(github_response.to_json()?)), - code => Err(OrgsRemoveMemberError::Generic { code }), + 403 => Err(OrgsRemoveMemberError::Status403(github_response.to_json()?).into()), + code => Err(OrgsRemoveMemberError::Generic { code }.into()), } } } @@ -7599,19 +8006,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for remove_membership_for_user](https://docs.github.com/rest/orgs/members#remove-organization-membership-for-a-user) /// /// --- - pub async fn remove_membership_for_user_async(&self, org: &str, username: &str) -> Result<(), OrgsRemoveMembershipForUserError> { + pub async fn remove_membership_for_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7623,9 +8030,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsRemoveMembershipForUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(OrgsRemoveMembershipForUserError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsRemoveMembershipForUserError::Generic { code }), + 403 => Err(OrgsRemoveMembershipForUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(OrgsRemoveMembershipForUserError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsRemoveMembershipForUserError::Generic { code }.into()), } } } @@ -7642,7 +8049,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_membership_for_user(&self, org: &str, username: &str) -> Result<(), OrgsRemoveMembershipForUserError> { + pub fn remove_membership_for_user(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, username); @@ -7654,7 +8061,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7666,9 +8073,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsRemoveMembershipForUserError::Status403(github_response.to_json()?)), - 404 => Err(OrgsRemoveMembershipForUserError::Status404(github_response.to_json()?)), - code => Err(OrgsRemoveMembershipForUserError::Generic { code }), + 403 => Err(OrgsRemoveMembershipForUserError::Status403(github_response.to_json()?).into()), + 404 => Err(OrgsRemoveMembershipForUserError::Status404(github_response.to_json()?).into()), + code => Err(OrgsRemoveMembershipForUserError::Generic { code }.into()), } } } @@ -7682,19 +8089,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for remove_outside_collaborator](https://docs.github.com/rest/orgs/outside-collaborators#remove-outside-collaborator-from-an-organization) /// /// --- - pub async fn remove_outside_collaborator_async(&self, org: &str, username: &str) -> Result<(), OrgsRemoveOutsideCollaboratorError> { + pub async fn remove_outside_collaborator_async(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/outside_collaborators/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7706,8 +8113,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(OrgsRemoveOutsideCollaboratorError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsRemoveOutsideCollaboratorError::Generic { code }), + 422 => Err(OrgsRemoveOutsideCollaboratorError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsRemoveOutsideCollaboratorError::Generic { code }.into()), } } } @@ -7722,7 +8129,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_outside_collaborator(&self, org: &str, username: &str) -> Result<(), OrgsRemoveOutsideCollaboratorError> { + pub fn remove_outside_collaborator(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/outside_collaborators/{}", super::GITHUB_BASE_API_URL, org, username); @@ -7734,7 +8141,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7746,8 +8153,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(OrgsRemoveOutsideCollaboratorError::Status422(github_response.to_json()?)), - code => Err(OrgsRemoveOutsideCollaboratorError::Generic { code }), + 422 => Err(OrgsRemoveOutsideCollaboratorError::Status422(github_response.to_json()?).into()), + code => Err(OrgsRemoveOutsideCollaboratorError::Generic { code }.into()), } } } @@ -7761,19 +8168,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for remove_public_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#remove-public-organization-membership-for-the-authenticated-user) /// /// --- - pub async fn remove_public_membership_for_authenticated_user_async(&self, org: &str, username: &str) -> Result<(), OrgsRemovePublicMembershipForAuthenticatedUserError> { + pub async fn remove_public_membership_for_authenticated_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7785,7 +8192,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsRemovePublicMembershipForAuthenticatedUserError::Generic { code }), + code => Err(OrgsRemovePublicMembershipForAuthenticatedUserError::Generic { code }.into()), } } } @@ -7800,7 +8207,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_public_membership_for_authenticated_user(&self, org: &str, username: &str) -> Result<(), OrgsRemovePublicMembershipForAuthenticatedUserError> { + pub fn remove_public_membership_for_authenticated_user(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, username); @@ -7812,7 +8219,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7824,7 +8231,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsRemovePublicMembershipForAuthenticatedUserError::Generic { code }), + code => Err(OrgsRemovePublicMembershipForAuthenticatedUserError::Generic { code }.into()), } } } @@ -7842,19 +8249,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for remove_security_manager_team](https://docs.github.com/rest/orgs/security-managers#remove-a-security-manager-team) /// /// --- - pub async fn remove_security_manager_team_async(&self, org: &str, team_slug: &str) -> Result<(), OrgsRemoveSecurityManagerTeamError> { + pub async fn remove_security_manager_team_async(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/security-managers/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7866,7 +8273,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsRemoveSecurityManagerTeamError::Generic { code }), + code => Err(OrgsRemoveSecurityManagerTeamError::Generic { code }.into()), } } } @@ -7885,7 +8292,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_security_manager_team(&self, org: &str, team_slug: &str) -> Result<(), OrgsRemoveSecurityManagerTeamError> { + pub fn remove_security_manager_team(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/security-managers/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); @@ -7897,7 +8304,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7909,7 +8316,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsRemoveSecurityManagerTeamError::Generic { code }), + code => Err(OrgsRemoveSecurityManagerTeamError::Generic { code }.into()), } } } @@ -7925,19 +8332,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for review_pat_grant_request](https://docs.github.com/rest/orgs/personal-access-tokens#review-a-request-to-access-organization-resources-with-a-fine-grained-personal-access-token) /// /// --- - pub async fn review_pat_grant_request_async(&self, org: &str, pat_request_id: i32, body: PostOrgsReviewPatGrantRequest) -> Result<(), OrgsReviewPatGrantRequestError> { + pub async fn review_pat_grant_request_async(&self, org: &str, pat_request_id: i32, body: PostOrgsReviewPatGrantRequest) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/personal-access-token-requests/{}", super::GITHUB_BASE_API_URL, org, pat_request_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsReviewPatGrantRequest::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7949,11 +8356,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(OrgsReviewPatGrantRequestError::Status500(github_response.to_json_async().await?)), - 422 => Err(OrgsReviewPatGrantRequestError::Status422(github_response.to_json_async().await?)), - 404 => Err(OrgsReviewPatGrantRequestError::Status404(github_response.to_json_async().await?)), - 403 => Err(OrgsReviewPatGrantRequestError::Status403(github_response.to_json_async().await?)), - code => Err(OrgsReviewPatGrantRequestError::Generic { code }), + 500 => Err(OrgsReviewPatGrantRequestError::Status500(github_response.to_json_async().await?).into()), + 422 => Err(OrgsReviewPatGrantRequestError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(OrgsReviewPatGrantRequestError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(OrgsReviewPatGrantRequestError::Status403(github_response.to_json_async().await?).into()), + code => Err(OrgsReviewPatGrantRequestError::Generic { code }.into()), } } } @@ -7970,19 +8377,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn review_pat_grant_request(&self, org: &str, pat_request_id: i32, body: PostOrgsReviewPatGrantRequest) -> Result<(), OrgsReviewPatGrantRequestError> { + pub fn review_pat_grant_request(&self, org: &str, pat_request_id: i32, body: PostOrgsReviewPatGrantRequest) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/personal-access-token-requests/{}", super::GITHUB_BASE_API_URL, org, pat_request_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsReviewPatGrantRequest::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7994,11 +8401,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(OrgsReviewPatGrantRequestError::Status500(github_response.to_json()?)), - 422 => Err(OrgsReviewPatGrantRequestError::Status422(github_response.to_json()?)), - 404 => Err(OrgsReviewPatGrantRequestError::Status404(github_response.to_json()?)), - 403 => Err(OrgsReviewPatGrantRequestError::Status403(github_response.to_json()?)), - code => Err(OrgsReviewPatGrantRequestError::Generic { code }), + 500 => Err(OrgsReviewPatGrantRequestError::Status500(github_response.to_json()?).into()), + 422 => Err(OrgsReviewPatGrantRequestError::Status422(github_response.to_json()?).into()), + 404 => Err(OrgsReviewPatGrantRequestError::Status404(github_response.to_json()?).into()), + 403 => Err(OrgsReviewPatGrantRequestError::Status403(github_response.to_json()?).into()), + code => Err(OrgsReviewPatGrantRequestError::Generic { code }.into()), } } } @@ -8014,19 +8421,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for review_pat_grant_requests_in_bulk](https://docs.github.com/rest/orgs/personal-access-tokens#review-requests-to-access-organization-resources-with-fine-grained-personal-access-tokens) /// /// --- - pub async fn review_pat_grant_requests_in_bulk_async(&self, org: &str, body: PostOrgsReviewPatGrantRequestsInBulk) -> Result, OrgsReviewPatGrantRequestsInBulkError> { + pub async fn review_pat_grant_requests_in_bulk_async(&self, org: &str, body: PostOrgsReviewPatGrantRequestsInBulk) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/personal-access-token-requests", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsReviewPatGrantRequestsInBulk::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8038,11 +8445,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(OrgsReviewPatGrantRequestsInBulkError::Status500(github_response.to_json_async().await?)), - 422 => Err(OrgsReviewPatGrantRequestsInBulkError::Status422(github_response.to_json_async().await?)), - 404 => Err(OrgsReviewPatGrantRequestsInBulkError::Status404(github_response.to_json_async().await?)), - 403 => Err(OrgsReviewPatGrantRequestsInBulkError::Status403(github_response.to_json_async().await?)), - code => Err(OrgsReviewPatGrantRequestsInBulkError::Generic { code }), + 500 => Err(OrgsReviewPatGrantRequestsInBulkError::Status500(github_response.to_json_async().await?).into()), + 422 => Err(OrgsReviewPatGrantRequestsInBulkError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(OrgsReviewPatGrantRequestsInBulkError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(OrgsReviewPatGrantRequestsInBulkError::Status403(github_response.to_json_async().await?).into()), + code => Err(OrgsReviewPatGrantRequestsInBulkError::Generic { code }.into()), } } } @@ -8059,19 +8466,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn review_pat_grant_requests_in_bulk(&self, org: &str, body: PostOrgsReviewPatGrantRequestsInBulk) -> Result, OrgsReviewPatGrantRequestsInBulkError> { + pub fn review_pat_grant_requests_in_bulk(&self, org: &str, body: PostOrgsReviewPatGrantRequestsInBulk) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/personal-access-token-requests", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsReviewPatGrantRequestsInBulk::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8083,11 +8490,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(OrgsReviewPatGrantRequestsInBulkError::Status500(github_response.to_json()?)), - 422 => Err(OrgsReviewPatGrantRequestsInBulkError::Status422(github_response.to_json()?)), - 404 => Err(OrgsReviewPatGrantRequestsInBulkError::Status404(github_response.to_json()?)), - 403 => Err(OrgsReviewPatGrantRequestsInBulkError::Status403(github_response.to_json()?)), - code => Err(OrgsReviewPatGrantRequestsInBulkError::Generic { code }), + 500 => Err(OrgsReviewPatGrantRequestsInBulkError::Status500(github_response.to_json()?).into()), + 422 => Err(OrgsReviewPatGrantRequestsInBulkError::Status422(github_response.to_json()?).into()), + 404 => Err(OrgsReviewPatGrantRequestsInBulkError::Status404(github_response.to_json()?).into()), + 403 => Err(OrgsReviewPatGrantRequestsInBulkError::Status403(github_response.to_json()?).into()), + code => Err(OrgsReviewPatGrantRequestsInBulkError::Generic { code }.into()), } } } @@ -8105,19 +8512,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for revoke_all_org_roles_team](https://docs.github.com/rest/orgs/organization-roles#remove-all-organization-roles-for-a-team) /// /// --- - pub async fn revoke_all_org_roles_team_async(&self, org: &str, team_slug: &str) -> Result<(), OrgsRevokeAllOrgRolesTeamError> { + pub async fn revoke_all_org_roles_team_async(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8129,7 +8536,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsRevokeAllOrgRolesTeamError::Generic { code }), + code => Err(OrgsRevokeAllOrgRolesTeamError::Generic { code }.into()), } } } @@ -8148,7 +8555,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn revoke_all_org_roles_team(&self, org: &str, team_slug: &str) -> Result<(), OrgsRevokeAllOrgRolesTeamError> { + pub fn revoke_all_org_roles_team(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); @@ -8160,7 +8567,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8172,7 +8579,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsRevokeAllOrgRolesTeamError::Generic { code }), + code => Err(OrgsRevokeAllOrgRolesTeamError::Generic { code }.into()), } } } @@ -8190,19 +8597,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for revoke_all_org_roles_user](https://docs.github.com/rest/orgs/organization-roles#remove-all-organization-roles-for-a-user) /// /// --- - pub async fn revoke_all_org_roles_user_async(&self, org: &str, username: &str) -> Result<(), OrgsRevokeAllOrgRolesUserError> { + pub async fn revoke_all_org_roles_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/users/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8214,7 +8621,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsRevokeAllOrgRolesUserError::Generic { code }), + code => Err(OrgsRevokeAllOrgRolesUserError::Generic { code }.into()), } } } @@ -8233,7 +8640,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn revoke_all_org_roles_user(&self, org: &str, username: &str) -> Result<(), OrgsRevokeAllOrgRolesUserError> { + pub fn revoke_all_org_roles_user(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/users/{}", super::GITHUB_BASE_API_URL, org, username); @@ -8245,7 +8652,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8257,7 +8664,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsRevokeAllOrgRolesUserError::Generic { code }), + code => Err(OrgsRevokeAllOrgRolesUserError::Generic { code }.into()), } } } @@ -8275,19 +8682,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for revoke_org_role_team](https://docs.github.com/rest/orgs/organization-roles#remove-an-organization-role-from-a-team) /// /// --- - pub async fn revoke_org_role_team_async(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), OrgsRevokeOrgRoleTeamError> { + pub async fn revoke_org_role_team_async(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/teams/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, role_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8299,7 +8706,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsRevokeOrgRoleTeamError::Generic { code }), + code => Err(OrgsRevokeOrgRoleTeamError::Generic { code }.into()), } } } @@ -8318,7 +8725,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn revoke_org_role_team(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), OrgsRevokeOrgRoleTeamError> { + pub fn revoke_org_role_team(&self, org: &str, team_slug: &str, role_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/teams/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, role_id); @@ -8330,7 +8737,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8342,7 +8749,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsRevokeOrgRoleTeamError::Generic { code }), + code => Err(OrgsRevokeOrgRoleTeamError::Generic { code }.into()), } } } @@ -8360,19 +8767,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for revoke_org_role_user](https://docs.github.com/rest/orgs/organization-roles#remove-an-organization-role-from-a-user) /// /// --- - pub async fn revoke_org_role_user_async(&self, org: &str, username: &str, role_id: i32) -> Result<(), OrgsRevokeOrgRoleUserError> { + pub async fn revoke_org_role_user_async(&self, org: &str, username: &str, role_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/users/{}/{}", super::GITHUB_BASE_API_URL, org, username, role_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8384,7 +8791,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsRevokeOrgRoleUserError::Generic { code }), + code => Err(OrgsRevokeOrgRoleUserError::Generic { code }.into()), } } } @@ -8403,7 +8810,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn revoke_org_role_user(&self, org: &str, username: &str, role_id: i32) -> Result<(), OrgsRevokeOrgRoleUserError> { + pub fn revoke_org_role_user(&self, org: &str, username: &str, role_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/organization-roles/users/{}/{}", super::GITHUB_BASE_API_URL, org, username, role_id); @@ -8415,7 +8822,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8427,7 +8834,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsRevokeOrgRoleUserError::Generic { code }), + code => Err(OrgsRevokeOrgRoleUserError::Generic { code }.into()), } } } @@ -8449,19 +8856,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for set_membership_for_user](https://docs.github.com/rest/orgs/members#set-organization-membership-for-a-user) /// /// --- - pub async fn set_membership_for_user_async(&self, org: &str, username: &str, body: PutOrgsSetMembershipForUser) -> Result { + pub async fn set_membership_for_user_async(&self, org: &str, username: &str, body: PutOrgsSetMembershipForUser) -> Result { let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutOrgsSetMembershipForUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8473,9 +8880,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(OrgsSetMembershipForUserError::Status422(github_response.to_json_async().await?)), - 403 => Err(OrgsSetMembershipForUserError::Status403(github_response.to_json_async().await?)), - code => Err(OrgsSetMembershipForUserError::Generic { code }), + 422 => Err(OrgsSetMembershipForUserError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(OrgsSetMembershipForUserError::Status403(github_response.to_json_async().await?).into()), + code => Err(OrgsSetMembershipForUserError::Generic { code }.into()), } } } @@ -8498,19 +8905,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_membership_for_user(&self, org: &str, username: &str, body: PutOrgsSetMembershipForUser) -> Result { + pub fn set_membership_for_user(&self, org: &str, username: &str, body: PutOrgsSetMembershipForUser) -> Result { let request_uri = format!("{}/orgs/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutOrgsSetMembershipForUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8522,9 +8929,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(OrgsSetMembershipForUserError::Status422(github_response.to_json()?)), - 403 => Err(OrgsSetMembershipForUserError::Status403(github_response.to_json()?)), - code => Err(OrgsSetMembershipForUserError::Generic { code }), + 422 => Err(OrgsSetMembershipForUserError::Status422(github_response.to_json()?).into()), + 403 => Err(OrgsSetMembershipForUserError::Status403(github_response.to_json()?).into()), + code => Err(OrgsSetMembershipForUserError::Generic { code }.into()), } } } @@ -8540,19 +8947,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for set_public_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#set-public-organization-membership-for-the-authenticated-user) /// /// --- - pub async fn set_public_membership_for_authenticated_user_async(&self, org: &str, username: &str) -> Result<(), OrgsSetPublicMembershipForAuthenticatedUserError> { + pub async fn set_public_membership_for_authenticated_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8564,8 +8971,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - code => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Generic { code }), + 403 => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + code => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Generic { code }.into()), } } } @@ -8582,7 +8989,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_public_membership_for_authenticated_user(&self, org: &str, username: &str) -> Result<(), OrgsSetPublicMembershipForAuthenticatedUserError> { + pub fn set_public_membership_for_authenticated_user(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/public_members/{}", super::GITHUB_BASE_API_URL, org, username); @@ -8594,7 +9001,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8606,8 +9013,8 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Status403(github_response.to_json()?)), - code => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Generic { code }), + 403 => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + code => Err(OrgsSetPublicMembershipForAuthenticatedUserError::Generic { code }.into()), } } } @@ -8621,19 +9028,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for unblock_user](https://docs.github.com/rest/orgs/blocking#unblock-a-user-from-an-organization) /// /// --- - pub async fn unblock_user_async(&self, org: &str, username: &str) -> Result<(), OrgsUnblockUserError> { + pub async fn unblock_user_async(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8645,7 +9052,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsUnblockUserError::Generic { code }), + code => Err(OrgsUnblockUserError::Generic { code }.into()), } } } @@ -8660,7 +9067,7 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn unblock_user(&self, org: &str, username: &str) -> Result<(), OrgsUnblockUserError> { + pub fn unblock_user(&self, org: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/blocks/{}", super::GITHUB_BASE_API_URL, org, username); @@ -8672,7 +9079,7 @@ impl<'api, C: Client> Orgs<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8684,7 +9091,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsUnblockUserError::Generic { code }), + code => Err(OrgsUnblockUserError::Generic { code }.into()), } } } @@ -8708,19 +9115,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for update](https://docs.github.com/rest/orgs/orgs#update-an-organization) /// /// --- - pub async fn update_async(&self, org: &str, body: PatchOrgsUpdate) -> Result { + pub async fn update_async(&self, org: &str, body: PatchOrgsUpdate) -> Result { let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8732,9 +9139,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(OrgsUpdateError::Status422(github_response.to_json_async().await?)), - 409 => Err(OrgsUpdateError::Status409(github_response.to_json_async().await?)), - code => Err(OrgsUpdateError::Generic { code }), + 422 => Err(OrgsUpdateError::Status422(github_response.to_json_async().await?).into()), + 409 => Err(OrgsUpdateError::Status409(github_response.to_json_async().await?).into()), + code => Err(OrgsUpdateError::Generic { code }.into()), } } } @@ -8759,19 +9166,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update(&self, org: &str, body: PatchOrgsUpdate) -> Result { + pub fn update(&self, org: &str, body: PatchOrgsUpdate) -> Result { let request_uri = format!("{}/orgs/{}", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8783,9 +9190,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(OrgsUpdateError::Status422(github_response.to_json()?)), - 409 => Err(OrgsUpdateError::Status409(github_response.to_json()?)), - code => Err(OrgsUpdateError::Generic { code }), + 422 => Err(OrgsUpdateError::Status422(github_response.to_json()?).into()), + 409 => Err(OrgsUpdateError::Status409(github_response.to_json()?).into()), + code => Err(OrgsUpdateError::Generic { code }.into()), } } } @@ -8799,19 +9206,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for update_membership_for_authenticated_user](https://docs.github.com/rest/orgs/members#update-an-organization-membership-for-the-authenticated-user) /// /// --- - pub async fn update_membership_for_authenticated_user_async(&self, org: &str, body: PatchOrgsUpdateMembershipForAuthenticatedUser) -> Result { + pub async fn update_membership_for_authenticated_user_async(&self, org: &str, body: PatchOrgsUpdateMembershipForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/memberships/orgs/{}", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsUpdateMembershipForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8823,10 +9230,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 404 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 422 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsUpdateMembershipForAuthenticatedUserError::Generic { code }), + 403 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsUpdateMembershipForAuthenticatedUserError::Generic { code }.into()), } } } @@ -8841,19 +9248,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_membership_for_authenticated_user(&self, org: &str, body: PatchOrgsUpdateMembershipForAuthenticatedUser) -> Result { + pub fn update_membership_for_authenticated_user(&self, org: &str, body: PatchOrgsUpdateMembershipForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/memberships/orgs/{}", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsUpdateMembershipForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8865,10 +9272,10 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status403(github_response.to_json()?)), - 404 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status404(github_response.to_json()?)), - 422 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status422(github_response.to_json()?)), - code => Err(OrgsUpdateMembershipForAuthenticatedUserError::Generic { code }), + 403 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 404 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 422 => Err(OrgsUpdateMembershipForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + code => Err(OrgsUpdateMembershipForAuthenticatedUserError::Generic { code }.into()), } } } @@ -8884,19 +9291,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for update_pat_access](https://docs.github.com/rest/orgs/personal-access-tokens#update-the-access-a-fine-grained-personal-access-token-has-to-organization-resources) /// /// --- - pub async fn update_pat_access_async(&self, org: &str, pat_id: i32, body: PostOrgsUpdatePatAccess) -> Result<(), OrgsUpdatePatAccessError> { + pub async fn update_pat_access_async(&self, org: &str, pat_id: i32, body: PostOrgsUpdatePatAccess) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/personal-access-tokens/{}", super::GITHUB_BASE_API_URL, org, pat_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsUpdatePatAccess::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8908,11 +9315,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(OrgsUpdatePatAccessError::Status500(github_response.to_json_async().await?)), - 404 => Err(OrgsUpdatePatAccessError::Status404(github_response.to_json_async().await?)), - 403 => Err(OrgsUpdatePatAccessError::Status403(github_response.to_json_async().await?)), - 422 => Err(OrgsUpdatePatAccessError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsUpdatePatAccessError::Generic { code }), + 500 => Err(OrgsUpdatePatAccessError::Status500(github_response.to_json_async().await?).into()), + 404 => Err(OrgsUpdatePatAccessError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(OrgsUpdatePatAccessError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(OrgsUpdatePatAccessError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsUpdatePatAccessError::Generic { code }.into()), } } } @@ -8929,19 +9336,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_pat_access(&self, org: &str, pat_id: i32, body: PostOrgsUpdatePatAccess) -> Result<(), OrgsUpdatePatAccessError> { + pub fn update_pat_access(&self, org: &str, pat_id: i32, body: PostOrgsUpdatePatAccess) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/personal-access-tokens/{}", super::GITHUB_BASE_API_URL, org, pat_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsUpdatePatAccess::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8953,11 +9360,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(OrgsUpdatePatAccessError::Status500(github_response.to_json()?)), - 404 => Err(OrgsUpdatePatAccessError::Status404(github_response.to_json()?)), - 403 => Err(OrgsUpdatePatAccessError::Status403(github_response.to_json()?)), - 422 => Err(OrgsUpdatePatAccessError::Status422(github_response.to_json()?)), - code => Err(OrgsUpdatePatAccessError::Generic { code }), + 500 => Err(OrgsUpdatePatAccessError::Status500(github_response.to_json()?).into()), + 404 => Err(OrgsUpdatePatAccessError::Status404(github_response.to_json()?).into()), + 403 => Err(OrgsUpdatePatAccessError::Status403(github_response.to_json()?).into()), + 422 => Err(OrgsUpdatePatAccessError::Status422(github_response.to_json()?).into()), + code => Err(OrgsUpdatePatAccessError::Generic { code }.into()), } } } @@ -8973,19 +9380,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for update_pat_accesses](https://docs.github.com/rest/orgs/personal-access-tokens#update-the-access-to-organization-resources-via-fine-grained-personal-access-tokens) /// /// --- - pub async fn update_pat_accesses_async(&self, org: &str, body: PostOrgsUpdatePatAccesses) -> Result, OrgsUpdatePatAccessesError> { + pub async fn update_pat_accesses_async(&self, org: &str, body: PostOrgsUpdatePatAccesses) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/personal-access-tokens", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsUpdatePatAccesses::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8997,11 +9404,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(OrgsUpdatePatAccessesError::Status500(github_response.to_json_async().await?)), - 404 => Err(OrgsUpdatePatAccessesError::Status404(github_response.to_json_async().await?)), - 403 => Err(OrgsUpdatePatAccessesError::Status403(github_response.to_json_async().await?)), - 422 => Err(OrgsUpdatePatAccessesError::Status422(github_response.to_json_async().await?)), - code => Err(OrgsUpdatePatAccessesError::Generic { code }), + 500 => Err(OrgsUpdatePatAccessesError::Status500(github_response.to_json_async().await?).into()), + 404 => Err(OrgsUpdatePatAccessesError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(OrgsUpdatePatAccessesError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(OrgsUpdatePatAccessesError::Status422(github_response.to_json_async().await?).into()), + code => Err(OrgsUpdatePatAccessesError::Generic { code }.into()), } } } @@ -9018,19 +9425,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_pat_accesses(&self, org: &str, body: PostOrgsUpdatePatAccesses) -> Result, OrgsUpdatePatAccessesError> { + pub fn update_pat_accesses(&self, org: &str, body: PostOrgsUpdatePatAccesses) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/personal-access-tokens", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostOrgsUpdatePatAccesses::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9042,11 +9449,11 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(OrgsUpdatePatAccessesError::Status500(github_response.to_json()?)), - 404 => Err(OrgsUpdatePatAccessesError::Status404(github_response.to_json()?)), - 403 => Err(OrgsUpdatePatAccessesError::Status403(github_response.to_json()?)), - 422 => Err(OrgsUpdatePatAccessesError::Status422(github_response.to_json()?)), - code => Err(OrgsUpdatePatAccessesError::Generic { code }), + 500 => Err(OrgsUpdatePatAccessesError::Status500(github_response.to_json()?).into()), + 404 => Err(OrgsUpdatePatAccessesError::Status404(github_response.to_json()?).into()), + 403 => Err(OrgsUpdatePatAccessesError::Status403(github_response.to_json()?).into()), + 422 => Err(OrgsUpdatePatAccessesError::Status422(github_response.to_json()?).into()), + code => Err(OrgsUpdatePatAccessesError::Generic { code }.into()), } } } @@ -9069,19 +9476,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for update_webhook](https://docs.github.com/rest/orgs/webhooks#update-an-organization-webhook) /// /// --- - pub async fn update_webhook_async(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhook) -> Result { + pub async fn update_webhook_async(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhook) -> Result { let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsUpdateWebhook::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9093,9 +9500,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(OrgsUpdateWebhookError::Status422(github_response.to_json_async().await?)), - 404 => Err(OrgsUpdateWebhookError::Status404(github_response.to_json_async().await?)), - code => Err(OrgsUpdateWebhookError::Generic { code }), + 422 => Err(OrgsUpdateWebhookError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(OrgsUpdateWebhookError::Status404(github_response.to_json_async().await?).into()), + code => Err(OrgsUpdateWebhookError::Generic { code }.into()), } } } @@ -9119,19 +9526,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_webhook(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhook) -> Result { + pub fn update_webhook(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhook) -> Result { let request_uri = format!("{}/orgs/{}/hooks/{}", super::GITHUB_BASE_API_URL, org, hook_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsUpdateWebhook::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9143,9 +9550,9 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(OrgsUpdateWebhookError::Status422(github_response.to_json()?)), - 404 => Err(OrgsUpdateWebhookError::Status404(github_response.to_json()?)), - code => Err(OrgsUpdateWebhookError::Generic { code }), + 422 => Err(OrgsUpdateWebhookError::Status422(github_response.to_json()?).into()), + 404 => Err(OrgsUpdateWebhookError::Status404(github_response.to_json()?).into()), + code => Err(OrgsUpdateWebhookError::Generic { code }.into()), } } } @@ -9164,19 +9571,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// [GitHub API docs for update_webhook_config_for_org](https://docs.github.com/rest/orgs/webhooks#update-a-webhook-configuration-for-an-organization) /// /// --- - pub async fn update_webhook_config_for_org_async(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhookConfigForOrg) -> Result { + pub async fn update_webhook_config_for_org_async(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhookConfigForOrg) -> Result { let request_uri = format!("{}/orgs/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, org, hook_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsUpdateWebhookConfigForOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9188,7 +9595,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(OrgsUpdateWebhookConfigForOrgError::Generic { code }), + code => Err(OrgsUpdateWebhookConfigForOrgError::Generic { code }.into()), } } } @@ -9208,19 +9615,19 @@ impl<'api, C: Client> Orgs<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_webhook_config_for_org(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhookConfigForOrg) -> Result { + pub fn update_webhook_config_for_org(&self, org: &str, hook_id: i32, body: PatchOrgsUpdateWebhookConfigForOrg) -> Result { let request_uri = format!("{}/orgs/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, org, hook_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchOrgsUpdateWebhookConfigForOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9232,7 +9639,7 @@ impl<'api, C: Client> Orgs<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(OrgsUpdateWebhookConfigForOrgError::Generic { code }), + code => Err(OrgsUpdateWebhookConfigForOrgError::Generic { code }.into()), } } } diff --git a/src/endpoints/packages.rs b/src/endpoints/packages.rs index 3a0fd26..2073a49 100644 --- a/src/endpoints/packages.rs +++ b/src/endpoints/packages.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Packages<'api, C: Client> { +pub struct Packages<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Packages { +pub fn new(client: &C) -> Packages where AdapterError: From<::Err> { Packages { client } } /// Errors for the [Delete a package for the authenticated user](Packages::delete_package_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesDeletePackageForAuthenticatedUserError { - #[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("Forbidden")] @@ -53,19 +43,26 @@ pub enum PackagesDeletePackageForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesDeletePackageForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + PackagesDeletePackageForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + PackagesDeletePackageForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesDeletePackageForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesDeletePackageForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a package for an organization](Packages::delete_package_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesDeletePackageForOrgError { - #[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("Forbidden")] @@ -76,19 +73,26 @@ pub enum PackagesDeletePackageForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesDeletePackageForOrgError) -> Self { + let (description, status_code) = match err { + PackagesDeletePackageForOrgError::Status404(_) => (String::from("Resource not found"), 404), + PackagesDeletePackageForOrgError::Status403(_) => (String::from("Forbidden"), 403), + PackagesDeletePackageForOrgError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesDeletePackageForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a package for a user](Packages::delete_package_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesDeletePackageForUserError { - #[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("Forbidden")] @@ -99,19 +103,26 @@ pub enum PackagesDeletePackageForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesDeletePackageForUserError) -> Self { + let (description, status_code) = match err { + PackagesDeletePackageForUserError::Status404(_) => (String::from("Resource not found"), 404), + PackagesDeletePackageForUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesDeletePackageForUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesDeletePackageForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a package version for the authenticated user](Packages::delete_package_version_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesDeletePackageVersionForAuthenticatedUserError { - #[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("Forbidden")] @@ -122,19 +133,26 @@ pub enum PackagesDeletePackageVersionForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesDeletePackageVersionForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + PackagesDeletePackageVersionForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + PackagesDeletePackageVersionForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesDeletePackageVersionForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesDeletePackageVersionForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete package version for an organization](Packages::delete_package_version_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesDeletePackageVersionForOrgError { - #[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("Forbidden")] @@ -145,19 +163,26 @@ pub enum PackagesDeletePackageVersionForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesDeletePackageVersionForOrgError) -> Self { + let (description, status_code) = match err { + PackagesDeletePackageVersionForOrgError::Status404(_) => (String::from("Resource not found"), 404), + PackagesDeletePackageVersionForOrgError::Status403(_) => (String::from("Forbidden"), 403), + PackagesDeletePackageVersionForOrgError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesDeletePackageVersionForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete package version for a user](Packages::delete_package_version_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesDeletePackageVersionForUserError { - #[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("Forbidden")] @@ -168,19 +193,26 @@ pub enum PackagesDeletePackageVersionForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesDeletePackageVersionForUserError) -> Self { + let (description, status_code) = match err { + PackagesDeletePackageVersionForUserError::Status404(_) => (String::from("Resource not found"), 404), + PackagesDeletePackageVersionForUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesDeletePackageVersionForUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesDeletePackageVersionForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List package versions for a package owned by the authenticated user](Packages::get_all_package_versions_for_package_owned_by_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError { - #[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("Forbidden")] @@ -191,19 +223,26 @@ pub enum PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List package versions for a package owned by an organization](Packages::get_all_package_versions_for_package_owned_by_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesGetAllPackageVersionsForPackageOwnedByOrgError { - #[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("Forbidden")] @@ -214,19 +253,26 @@ pub enum PackagesGetAllPackageVersionsForPackageOwnedByOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesGetAllPackageVersionsForPackageOwnedByOrgError) -> Self { + let (description, status_code) = match err { + PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status404(_) => (String::from("Resource not found"), 404), + PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status403(_) => (String::from("Forbidden"), 403), + PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List package versions for a package owned by a user](Packages::get_all_package_versions_for_package_owned_by_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesGetAllPackageVersionsForPackageOwnedByUserError { - #[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("Forbidden")] @@ -237,138 +283,173 @@ pub enum PackagesGetAllPackageVersionsForPackageOwnedByUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesGetAllPackageVersionsForPackageOwnedByUserError) -> Self { + let (description, status_code) = match err { + PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status404(_) => (String::from("Resource not found"), 404), + PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesGetAllPackageVersionsForPackageOwnedByUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a package for the authenticated user](Packages::get_package_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesGetPackageForAuthenticatedUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: PackagesGetPackageForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + PackagesGetPackageForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a package for an organization](Packages::get_package_for_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesGetPackageForOrganizationError { - #[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 }, } +impl From for AdapterError { + fn from(err: PackagesGetPackageForOrganizationError) -> Self { + let (description, status_code) = match err { + PackagesGetPackageForOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a package for a user](Packages::get_package_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesGetPackageForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: PackagesGetPackageForUserError) -> Self { + let (description, status_code) = match err { + PackagesGetPackageForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a package version for the authenticated user](Packages::get_package_version_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesGetPackageVersionForAuthenticatedUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: PackagesGetPackageVersionForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + PackagesGetPackageVersionForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a package version for an organization](Packages::get_package_version_for_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesGetPackageVersionForOrganizationError { - #[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 }, } +impl From for AdapterError { + fn from(err: PackagesGetPackageVersionForOrganizationError) -> Self { + let (description, status_code) = match err { + PackagesGetPackageVersionForOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a package version for a user](Packages::get_package_version_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesGetPackageVersionForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: PackagesGetPackageVersionForUserError) -> Self { + let (description, status_code) = match err { + PackagesGetPackageVersionForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get list of conflicting packages during Docker migration for authenticated-user](Packages::list_docker_migration_conflicting_packages_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get list of conflicting packages during Docker migration for organization](Packages::list_docker_migration_conflicting_packages_for_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesListDockerMigrationConflictingPackagesForOrganizationError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Requires authentication")] @@ -377,19 +458,25 @@ pub enum PackagesListDockerMigrationConflictingPackagesForOrganizationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesListDockerMigrationConflictingPackagesForOrganizationError) -> Self { + let (description, status_code) = match err { + PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status403(_) => (String::from("Forbidden"), 403), + PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesListDockerMigrationConflictingPackagesForOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get list of conflicting packages during Docker migration for user](Packages::list_docker_migration_conflicting_packages_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesListDockerMigrationConflictingPackagesForUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Requires authentication")] @@ -398,38 +485,49 @@ pub enum PackagesListDockerMigrationConflictingPackagesForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesListDockerMigrationConflictingPackagesForUserError) -> Self { + let (description, status_code) = match err { + PackagesListDockerMigrationConflictingPackagesForUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesListDockerMigrationConflictingPackagesForUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesListDockerMigrationConflictingPackagesForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List packages for the authenticated user's namespace](Packages::list_packages_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesListPackagesForAuthenticatedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("The value of `per_page` multiplied by `page` cannot be greater than 10000.")] Status400, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesListPackagesForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + PackagesListPackagesForAuthenticatedUserError::Status400 => (String::from("The value of `per_page` multiplied by `page` cannot be greater than 10000."), 400), + PackagesListPackagesForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List packages for an organization](Packages::list_packages_for_organization_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesListPackagesForOrganizationError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Requires authentication")] @@ -440,19 +538,26 @@ pub enum PackagesListPackagesForOrganizationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesListPackagesForOrganizationError) -> Self { + let (description, status_code) = match err { + PackagesListPackagesForOrganizationError::Status403(_) => (String::from("Forbidden"), 403), + PackagesListPackagesForOrganizationError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesListPackagesForOrganizationError::Status400 => (String::from("The value of `per_page` multiplied by `page` cannot be greater than 10000."), 400), + PackagesListPackagesForOrganizationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List packages for a user](Packages::list_packages_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesListPackagesForUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Requires authentication")] @@ -463,19 +568,26 @@ pub enum PackagesListPackagesForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesListPackagesForUserError) -> Self { + let (description, status_code) = match err { + PackagesListPackagesForUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesListPackagesForUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesListPackagesForUserError::Status400 => (String::from("The value of `per_page` multiplied by `page` cannot be greater than 10000."), 400), + PackagesListPackagesForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Restore a package for the authenticated user](Packages::restore_package_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesRestorePackageForAuthenticatedUserError { - #[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("Forbidden")] @@ -486,19 +598,26 @@ pub enum PackagesRestorePackageForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesRestorePackageForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + PackagesRestorePackageForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + PackagesRestorePackageForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesRestorePackageForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesRestorePackageForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Restore a package for an organization](Packages::restore_package_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesRestorePackageForOrgError { - #[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("Forbidden")] @@ -509,19 +628,26 @@ pub enum PackagesRestorePackageForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesRestorePackageForOrgError) -> Self { + let (description, status_code) = match err { + PackagesRestorePackageForOrgError::Status404(_) => (String::from("Resource not found"), 404), + PackagesRestorePackageForOrgError::Status403(_) => (String::from("Forbidden"), 403), + PackagesRestorePackageForOrgError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesRestorePackageForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Restore a package for a user](Packages::restore_package_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesRestorePackageForUserError { - #[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("Forbidden")] @@ -532,19 +658,26 @@ pub enum PackagesRestorePackageForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesRestorePackageForUserError) -> Self { + let (description, status_code) = match err { + PackagesRestorePackageForUserError::Status404(_) => (String::from("Resource not found"), 404), + PackagesRestorePackageForUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesRestorePackageForUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesRestorePackageForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Restore a package version for the authenticated user](Packages::restore_package_version_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesRestorePackageVersionForAuthenticatedUserError { - #[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("Forbidden")] @@ -555,19 +688,26 @@ pub enum PackagesRestorePackageVersionForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesRestorePackageVersionForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + PackagesRestorePackageVersionForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + PackagesRestorePackageVersionForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesRestorePackageVersionForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesRestorePackageVersionForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Restore package version for an organization](Packages::restore_package_version_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesRestorePackageVersionForOrgError { - #[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("Forbidden")] @@ -578,19 +718,26 @@ pub enum PackagesRestorePackageVersionForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesRestorePackageVersionForOrgError) -> Self { + let (description, status_code) = match err { + PackagesRestorePackageVersionForOrgError::Status404(_) => (String::from("Resource not found"), 404), + PackagesRestorePackageVersionForOrgError::Status403(_) => (String::from("Forbidden"), 403), + PackagesRestorePackageVersionForOrgError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesRestorePackageVersionForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Restore package version for a user](Packages::restore_package_version_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PackagesRestorePackageVersionForUserError { - #[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("Forbidden")] @@ -601,6 +748,23 @@ pub enum PackagesRestorePackageVersionForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PackagesRestorePackageVersionForUserError) -> Self { + let (description, status_code) = match err { + PackagesRestorePackageVersionForUserError::Status404(_) => (String::from("Resource not found"), 404), + PackagesRestorePackageVersionForUserError::Status403(_) => (String::from("Forbidden"), 403), + PackagesRestorePackageVersionForUserError::Status401(_) => (String::from("Requires authentication"), 401), + PackagesRestorePackageVersionForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List package versions for a package owned by the authenticated user](Packages::get_all_package_versions_for_package_owned_by_authenticated_user_async()) endpoint. #[derive(Default, Serialize)] @@ -973,7 +1137,7 @@ impl<'req> PackagesRestorePackageForUserParams<'req> { } -impl<'api, C: Client> Packages<'api, C> { +impl<'api, C: Client> Packages<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Delete a package for the authenticated user @@ -985,19 +1149,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for delete_package_for_authenticated_user](https://docs.github.com/rest/packages/packages#delete-a-package-for-the-authenticated-user) /// /// --- - pub async fn delete_package_for_authenticated_user_async(&self, package_type: &str, package_name: &str) -> Result<(), PackagesDeletePackageForAuthenticatedUserError> { + pub async fn delete_package_for_authenticated_user_async(&self, package_type: &str, package_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1009,10 +1173,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesDeletePackageForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesDeletePackageForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesDeletePackageForAuthenticatedUserError::Generic { code }), + 404 => Err(PackagesDeletePackageForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesDeletePackageForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesDeletePackageForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesDeletePackageForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1029,7 +1193,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_package_for_authenticated_user(&self, package_type: &str, package_name: &str) -> Result<(), PackagesDeletePackageForAuthenticatedUserError> { + pub fn delete_package_for_authenticated_user(&self, package_type: &str, package_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name); @@ -1041,7 +1205,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1053,10 +1217,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(PackagesDeletePackageForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesDeletePackageForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(PackagesDeletePackageForAuthenticatedUserError::Generic { code }), + 404 => Err(PackagesDeletePackageForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesDeletePackageForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesDeletePackageForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(PackagesDeletePackageForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1074,19 +1238,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for delete_package_for_org](https://docs.github.com/rest/packages/packages#delete-a-package-for-an-organization) /// /// --- - pub async fn delete_package_for_org_async(&self, package_type: &str, package_name: &str, org: &str) -> Result<(), PackagesDeletePackageForOrgError> { + pub async fn delete_package_for_org_async(&self, package_type: &str, package_name: &str, org: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1098,10 +1262,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageForOrgError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesDeletePackageForOrgError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesDeletePackageForOrgError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesDeletePackageForOrgError::Generic { code }), + 404 => Err(PackagesDeletePackageForOrgError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesDeletePackageForOrgError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesDeletePackageForOrgError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesDeletePackageForOrgError::Generic { code }.into()), } } } @@ -1120,7 +1284,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_package_for_org(&self, package_type: &str, package_name: &str, org: &str) -> Result<(), PackagesDeletePackageForOrgError> { + pub fn delete_package_for_org(&self, package_type: &str, package_name: &str, org: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org); @@ -1132,7 +1296,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1144,10 +1308,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageForOrgError::Status404(github_response.to_json()?)), - 403 => Err(PackagesDeletePackageForOrgError::Status403(github_response.to_json()?)), - 401 => Err(PackagesDeletePackageForOrgError::Status401(github_response.to_json()?)), - code => Err(PackagesDeletePackageForOrgError::Generic { code }), + 404 => Err(PackagesDeletePackageForOrgError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesDeletePackageForOrgError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesDeletePackageForOrgError::Status401(github_response.to_json()?).into()), + code => Err(PackagesDeletePackageForOrgError::Generic { code }.into()), } } } @@ -1165,19 +1329,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for delete_package_for_user](https://docs.github.com/rest/packages/packages#delete-a-package-for-a-user) /// /// --- - pub async fn delete_package_for_user_async(&self, package_type: &str, package_name: &str, username: &str) -> Result<(), PackagesDeletePackageForUserError> { + pub async fn delete_package_for_user_async(&self, package_type: &str, package_name: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/users/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1189,10 +1353,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageForUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesDeletePackageForUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesDeletePackageForUserError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesDeletePackageForUserError::Generic { code }), + 404 => Err(PackagesDeletePackageForUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesDeletePackageForUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesDeletePackageForUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesDeletePackageForUserError::Generic { code }.into()), } } } @@ -1211,7 +1375,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_package_for_user(&self, package_type: &str, package_name: &str, username: &str) -> Result<(), PackagesDeletePackageForUserError> { + pub fn delete_package_for_user(&self, package_type: &str, package_name: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/users/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, username); @@ -1223,7 +1387,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1235,10 +1399,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageForUserError::Status404(github_response.to_json()?)), - 403 => Err(PackagesDeletePackageForUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesDeletePackageForUserError::Status401(github_response.to_json()?)), - code => Err(PackagesDeletePackageForUserError::Generic { code }), + 404 => Err(PackagesDeletePackageForUserError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesDeletePackageForUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesDeletePackageForUserError::Status401(github_response.to_json()?).into()), + code => Err(PackagesDeletePackageForUserError::Generic { code }.into()), } } } @@ -1256,19 +1420,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for delete_package_version_for_authenticated_user](https://docs.github.com/rest/packages/packages#delete-a-package-version-for-the-authenticated-user) /// /// --- - pub async fn delete_package_version_for_authenticated_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), PackagesDeletePackageVersionForAuthenticatedUserError> { + pub async fn delete_package_version_for_authenticated_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1280,10 +1444,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Generic { code }), + 404 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1302,7 +1466,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_package_version_for_authenticated_user(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), PackagesDeletePackageVersionForAuthenticatedUserError> { + pub fn delete_package_version_for_authenticated_user(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_id); @@ -1314,7 +1478,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1326,10 +1490,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Generic { code }), + 404 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(PackagesDeletePackageVersionForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1347,19 +1511,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for delete_package_version_for_org](https://docs.github.com/rest/packages/packages#delete-package-version-for-an-organization) /// /// --- - pub async fn delete_package_version_for_org_async(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), PackagesDeletePackageVersionForOrgError> { + pub async fn delete_package_version_for_org_async(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_version_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1371,10 +1535,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageVersionForOrgError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesDeletePackageVersionForOrgError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesDeletePackageVersionForOrgError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesDeletePackageVersionForOrgError::Generic { code }), + 404 => Err(PackagesDeletePackageVersionForOrgError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesDeletePackageVersionForOrgError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesDeletePackageVersionForOrgError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesDeletePackageVersionForOrgError::Generic { code }.into()), } } } @@ -1393,7 +1557,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_package_version_for_org(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), PackagesDeletePackageVersionForOrgError> { + pub fn delete_package_version_for_org(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_version_id); @@ -1405,7 +1569,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1417,10 +1581,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageVersionForOrgError::Status404(github_response.to_json()?)), - 403 => Err(PackagesDeletePackageVersionForOrgError::Status403(github_response.to_json()?)), - 401 => Err(PackagesDeletePackageVersionForOrgError::Status401(github_response.to_json()?)), - code => Err(PackagesDeletePackageVersionForOrgError::Generic { code }), + 404 => Err(PackagesDeletePackageVersionForOrgError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesDeletePackageVersionForOrgError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesDeletePackageVersionForOrgError::Status401(github_response.to_json()?).into()), + code => Err(PackagesDeletePackageVersionForOrgError::Generic { code }.into()), } } } @@ -1438,19 +1602,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for delete_package_version_for_user](https://docs.github.com/rest/packages/packages#delete-package-version-for-a-user) /// /// --- - pub async fn delete_package_version_for_user_async(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), PackagesDeletePackageVersionForUserError> { + pub async fn delete_package_version_for_user_async(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, username, package_version_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1462,10 +1626,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageVersionForUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesDeletePackageVersionForUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesDeletePackageVersionForUserError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesDeletePackageVersionForUserError::Generic { code }), + 404 => Err(PackagesDeletePackageVersionForUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesDeletePackageVersionForUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesDeletePackageVersionForUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesDeletePackageVersionForUserError::Generic { code }.into()), } } } @@ -1484,7 +1648,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_package_version_for_user(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), PackagesDeletePackageVersionForUserError> { + pub fn delete_package_version_for_user(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, username, package_version_id); @@ -1496,7 +1660,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1508,10 +1672,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesDeletePackageVersionForUserError::Status404(github_response.to_json()?)), - 403 => Err(PackagesDeletePackageVersionForUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesDeletePackageVersionForUserError::Status401(github_response.to_json()?)), - code => Err(PackagesDeletePackageVersionForUserError::Generic { code }), + 404 => Err(PackagesDeletePackageVersionForUserError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesDeletePackageVersionForUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesDeletePackageVersionForUserError::Status401(github_response.to_json()?).into()), + code => Err(PackagesDeletePackageVersionForUserError::Generic { code }.into()), } } } @@ -1527,7 +1691,7 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for get_all_package_versions_for_package_owned_by_authenticated_user](https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-the-authenticated-user) /// /// --- - pub async fn get_all_package_versions_for_package_owned_by_authenticated_user_async(&self, package_type: &str, package_name: &str, query_params: Option>>) -> Result, PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError> { + pub async fn get_all_package_versions_for_package_owned_by_authenticated_user_async(&self, package_type: &str, package_name: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_name); @@ -1538,12 +1702,12 @@ impl<'api, C: Client> Packages<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1555,10 +1719,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Generic { code }), + 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Generic { code }.into()), } } } @@ -1575,7 +1739,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_package_versions_for_package_owned_by_authenticated_user(&self, package_type: &str, package_name: &str, query_params: Option>>) -> Result, PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError> { + pub fn get_all_package_versions_for_package_owned_by_authenticated_user(&self, package_type: &str, package_name: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_name); @@ -1592,7 +1756,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1604,10 +1768,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Generic { code }), + 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(PackagesGetAllPackageVersionsForPackageOwnedByAuthenticatedUserError::Generic { code }.into()), } } } @@ -1623,7 +1787,7 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for get_all_package_versions_for_package_owned_by_org](https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-an-organization) /// /// --- - pub async fn get_all_package_versions_for_package_owned_by_org_async(&self, package_type: &str, package_name: &str, org: &str, query_params: Option>>) -> Result, PackagesGetAllPackageVersionsForPackageOwnedByOrgError> { + pub async fn get_all_package_versions_for_package_owned_by_org_async(&self, package_type: &str, package_name: &str, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_name, org); @@ -1634,12 +1798,12 @@ impl<'api, C: Client> Packages<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1651,10 +1815,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Generic { code }), + 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Generic { code }.into()), } } } @@ -1671,7 +1835,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_package_versions_for_package_owned_by_org(&self, package_type: &str, package_name: &str, org: &str, query_params: Option>>) -> Result, PackagesGetAllPackageVersionsForPackageOwnedByOrgError> { + pub fn get_all_package_versions_for_package_owned_by_org(&self, package_type: &str, package_name: &str, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_name, org); @@ -1688,7 +1852,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1700,10 +1864,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status404(github_response.to_json()?)), - 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status403(github_response.to_json()?)), - 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status401(github_response.to_json()?)), - code => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Generic { code }), + 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Status401(github_response.to_json()?).into()), + code => Err(PackagesGetAllPackageVersionsForPackageOwnedByOrgError::Generic { code }.into()), } } } @@ -1719,19 +1883,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for get_all_package_versions_for_package_owned_by_user](https://docs.github.com/rest/packages/packages#list-package-versions-for-a-package-owned-by-a-user) /// /// --- - pub async fn get_all_package_versions_for_package_owned_by_user_async(&self, package_type: &str, package_name: &str, username: &str) -> Result, PackagesGetAllPackageVersionsForPackageOwnedByUserError> { + pub async fn get_all_package_versions_for_package_owned_by_user_async(&self, package_type: &str, package_name: &str, username: &str) -> Result, AdapterError> { let request_uri = format!("{}/users/{}/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_name, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1743,10 +1907,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Generic { code }), + 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Generic { code }.into()), } } } @@ -1763,7 +1927,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_package_versions_for_package_owned_by_user(&self, package_type: &str, package_name: &str, username: &str) -> Result, PackagesGetAllPackageVersionsForPackageOwnedByUserError> { + pub fn get_all_package_versions_for_package_owned_by_user(&self, package_type: &str, package_name: &str, username: &str) -> Result, AdapterError> { let request_uri = format!("{}/users/{}/packages/{}/{}/versions", super::GITHUB_BASE_API_URL, package_type, package_name, username); @@ -1775,7 +1939,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1787,10 +1951,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status404(github_response.to_json()?)), - 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status401(github_response.to_json()?)), - code => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Generic { code }), + 404 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Status401(github_response.to_json()?).into()), + code => Err(PackagesGetAllPackageVersionsForPackageOwnedByUserError::Generic { code }.into()), } } } @@ -1806,19 +1970,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for get_package_for_authenticated_user](https://docs.github.com/rest/packages/packages#get-a-package-for-the-authenticated-user) /// /// --- - pub async fn get_package_for_authenticated_user_async(&self, package_type: &str, package_name: &str) -> Result { + pub async fn get_package_for_authenticated_user_async(&self, package_type: &str, package_name: &str) -> Result { let request_uri = format!("{}/user/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1830,7 +1994,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageForAuthenticatedUserError::Generic { code }), + code => Err(PackagesGetPackageForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1847,7 +2011,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_package_for_authenticated_user(&self, package_type: &str, package_name: &str) -> Result { + pub fn get_package_for_authenticated_user(&self, package_type: &str, package_name: &str) -> Result { let request_uri = format!("{}/user/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name); @@ -1859,7 +2023,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1871,7 +2035,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageForAuthenticatedUserError::Generic { code }), + code => Err(PackagesGetPackageForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1887,19 +2051,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for get_package_for_organization](https://docs.github.com/rest/packages/packages#get-a-package-for-an-organization) /// /// --- - pub async fn get_package_for_organization_async(&self, package_type: &str, package_name: &str, org: &str) -> Result { + pub async fn get_package_for_organization_async(&self, package_type: &str, package_name: &str, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1911,7 +2075,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageForOrganizationError::Generic { code }), + code => Err(PackagesGetPackageForOrganizationError::Generic { code }.into()), } } } @@ -1928,7 +2092,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_package_for_organization(&self, package_type: &str, package_name: &str, org: &str) -> Result { + pub fn get_package_for_organization(&self, package_type: &str, package_name: &str, org: &str) -> Result { let request_uri = format!("{}/orgs/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org); @@ -1940,7 +2104,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1952,7 +2116,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageForOrganizationError::Generic { code }), + code => Err(PackagesGetPackageForOrganizationError::Generic { code }.into()), } } } @@ -1968,19 +2132,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for get_package_for_user](https://docs.github.com/rest/packages/packages#get-a-package-for-a-user) /// /// --- - pub async fn get_package_for_user_async(&self, package_type: &str, package_name: &str, username: &str) -> Result { + pub async fn get_package_for_user_async(&self, package_type: &str, package_name: &str, username: &str) -> Result { let request_uri = format!("{}/users/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1992,7 +2156,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageForUserError::Generic { code }), + code => Err(PackagesGetPackageForUserError::Generic { code }.into()), } } } @@ -2009,7 +2173,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_package_for_user(&self, package_type: &str, package_name: &str, username: &str) -> Result { + pub fn get_package_for_user(&self, package_type: &str, package_name: &str, username: &str) -> Result { let request_uri = format!("{}/users/{}/packages/{}/{}", super::GITHUB_BASE_API_URL, package_type, package_name, username); @@ -2021,7 +2185,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2033,7 +2197,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageForUserError::Generic { code }), + code => Err(PackagesGetPackageForUserError::Generic { code }.into()), } } } @@ -2049,19 +2213,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for get_package_version_for_authenticated_user](https://docs.github.com/rest/packages/packages#get-a-package-version-for-the-authenticated-user) /// /// --- - pub async fn get_package_version_for_authenticated_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result { + pub async fn get_package_version_for_authenticated_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result { let request_uri = format!("{}/user/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2073,7 +2237,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageVersionForAuthenticatedUserError::Generic { code }), + code => Err(PackagesGetPackageVersionForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2090,7 +2254,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_package_version_for_authenticated_user(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result { + pub fn get_package_version_for_authenticated_user(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result { let request_uri = format!("{}/user/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_id); @@ -2102,7 +2266,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2114,7 +2278,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageVersionForAuthenticatedUserError::Generic { code }), + code => Err(PackagesGetPackageVersionForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2130,19 +2294,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for get_package_version_for_organization](https://docs.github.com/rest/packages/packages#get-a-package-version-for-an-organization) /// /// --- - pub async fn get_package_version_for_organization_async(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result { + pub async fn get_package_version_for_organization_async(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_version_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2154,7 +2318,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageVersionForOrganizationError::Generic { code }), + code => Err(PackagesGetPackageVersionForOrganizationError::Generic { code }.into()), } } } @@ -2171,7 +2335,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_package_version_for_organization(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result { + pub fn get_package_version_for_organization(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_version_id); @@ -2183,7 +2347,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2195,7 +2359,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageVersionForOrganizationError::Generic { code }), + code => Err(PackagesGetPackageVersionForOrganizationError::Generic { code }.into()), } } } @@ -2211,19 +2375,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for get_package_version_for_user](https://docs.github.com/rest/packages/packages#get-a-package-version-for-a-user) /// /// --- - pub async fn get_package_version_for_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32, username: &str) -> Result { + pub async fn get_package_version_for_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32, username: &str) -> Result { let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_id, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2235,7 +2399,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageVersionForUserError::Generic { code }), + code => Err(PackagesGetPackageVersionForUserError::Generic { code }.into()), } } } @@ -2252,7 +2416,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_package_version_for_user(&self, package_type: &str, package_name: &str, package_version_id: i32, username: &str) -> Result { + pub fn get_package_version_for_user(&self, package_type: &str, package_name: &str, package_version_id: i32, username: &str) -> Result { let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_id, username); @@ -2264,7 +2428,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2276,7 +2440,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PackagesGetPackageVersionForUserError::Generic { code }), + code => Err(PackagesGetPackageVersionForUserError::Generic { code }.into()), } } } @@ -2292,19 +2456,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for list_docker_migration_conflicting_packages_for_authenticated_user](https://docs.github.com/rest/packages/packages#get-list-of-conflicting-packages-during-docker-migration-for-authenticated-user) /// /// --- - pub async fn list_docker_migration_conflicting_packages_for_authenticated_user_async(&self) -> Result, PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError> { + pub async fn list_docker_migration_conflicting_packages_for_authenticated_user_async(&self) -> Result, AdapterError> { let request_uri = format!("{}/user/docker/conflicts", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2316,7 +2480,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError::Generic { code }), + code => Err(PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2333,7 +2497,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_docker_migration_conflicting_packages_for_authenticated_user(&self) -> Result, PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError> { + pub fn list_docker_migration_conflicting_packages_for_authenticated_user(&self) -> Result, AdapterError> { let request_uri = format!("{}/user/docker/conflicts", super::GITHUB_BASE_API_URL); @@ -2345,7 +2509,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2357,7 +2521,7 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError::Generic { code }), + code => Err(PackagesListDockerMigrationConflictingPackagesForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2373,19 +2537,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for list_docker_migration_conflicting_packages_for_organization](https://docs.github.com/rest/packages/packages#get-list-of-conflicting-packages-during-docker-migration-for-organization) /// /// --- - pub async fn list_docker_migration_conflicting_packages_for_organization_async(&self, org: &str) -> Result, PackagesListDockerMigrationConflictingPackagesForOrganizationError> { + pub async fn list_docker_migration_conflicting_packages_for_organization_async(&self, org: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/docker/conflicts", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2397,9 +2561,9 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Generic { code }), + 403 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Generic { code }.into()), } } } @@ -2416,7 +2580,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_docker_migration_conflicting_packages_for_organization(&self, org: &str) -> Result, PackagesListDockerMigrationConflictingPackagesForOrganizationError> { + pub fn list_docker_migration_conflicting_packages_for_organization(&self, org: &str) -> Result, AdapterError> { let request_uri = format!("{}/orgs/{}/docker/conflicts", super::GITHUB_BASE_API_URL, org); @@ -2428,7 +2592,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2440,9 +2604,9 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status403(github_response.to_json()?)), - 401 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status401(github_response.to_json()?)), - code => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Generic { code }), + 403 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Status401(github_response.to_json()?).into()), + code => Err(PackagesListDockerMigrationConflictingPackagesForOrganizationError::Generic { code }.into()), } } } @@ -2458,19 +2622,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for list_docker_migration_conflicting_packages_for_user](https://docs.github.com/rest/packages/packages#get-list-of-conflicting-packages-during-docker-migration-for-user) /// /// --- - pub async fn list_docker_migration_conflicting_packages_for_user_async(&self, username: &str) -> Result, PackagesListDockerMigrationConflictingPackagesForUserError> { + pub async fn list_docker_migration_conflicting_packages_for_user_async(&self, username: &str) -> Result, AdapterError> { let request_uri = format!("{}/users/{}/docker/conflicts", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2482,9 +2646,9 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Generic { code }), + 403 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Generic { code }.into()), } } } @@ -2501,7 +2665,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_docker_migration_conflicting_packages_for_user(&self, username: &str) -> Result, PackagesListDockerMigrationConflictingPackagesForUserError> { + pub fn list_docker_migration_conflicting_packages_for_user(&self, username: &str) -> Result, AdapterError> { let request_uri = format!("{}/users/{}/docker/conflicts", super::GITHUB_BASE_API_URL, username); @@ -2513,7 +2677,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2525,9 +2689,9 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status401(github_response.to_json()?)), - code => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Generic { code }), + 403 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Status401(github_response.to_json()?).into()), + code => Err(PackagesListDockerMigrationConflictingPackagesForUserError::Generic { code }.into()), } } } @@ -2543,7 +2707,7 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for list_packages_for_authenticated_user](https://docs.github.com/rest/packages/packages#list-packages-for-the-authenticated-users-namespace) /// /// --- - pub async fn list_packages_for_authenticated_user_async(&self, query_params: impl Into>) -> Result, PackagesListPackagesForAuthenticatedUserError> { + pub async fn list_packages_for_authenticated_user_async(&self, query_params: impl Into>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/packages", super::GITHUB_BASE_API_URL); @@ -2552,12 +2716,12 @@ impl<'api, C: Client> Packages<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2569,8 +2733,8 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(PackagesListPackagesForAuthenticatedUserError::Status400), - code => Err(PackagesListPackagesForAuthenticatedUserError::Generic { code }), + 400 => Err(PackagesListPackagesForAuthenticatedUserError::Status400.into()), + code => Err(PackagesListPackagesForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2587,7 +2751,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_packages_for_authenticated_user(&self, query_params: impl Into>) -> Result, PackagesListPackagesForAuthenticatedUserError> { + pub fn list_packages_for_authenticated_user(&self, query_params: impl Into>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/packages", super::GITHUB_BASE_API_URL); @@ -2602,7 +2766,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2614,8 +2778,8 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(PackagesListPackagesForAuthenticatedUserError::Status400), - code => Err(PackagesListPackagesForAuthenticatedUserError::Generic { code }), + 400 => Err(PackagesListPackagesForAuthenticatedUserError::Status400.into()), + code => Err(PackagesListPackagesForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2631,7 +2795,7 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for list_packages_for_organization](https://docs.github.com/rest/packages/packages#list-packages-for-an-organization) /// /// --- - pub async fn list_packages_for_organization_async(&self, org: &str, query_params: impl Into>) -> Result, PackagesListPackagesForOrganizationError> { + pub async fn list_packages_for_organization_async(&self, org: &str, query_params: impl Into>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/packages", super::GITHUB_BASE_API_URL, org); @@ -2640,12 +2804,12 @@ impl<'api, C: Client> Packages<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2657,10 +2821,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(PackagesListPackagesForOrganizationError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesListPackagesForOrganizationError::Status401(github_response.to_json_async().await?)), - 400 => Err(PackagesListPackagesForOrganizationError::Status400), - code => Err(PackagesListPackagesForOrganizationError::Generic { code }), + 403 => Err(PackagesListPackagesForOrganizationError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesListPackagesForOrganizationError::Status401(github_response.to_json_async().await?).into()), + 400 => Err(PackagesListPackagesForOrganizationError::Status400.into()), + code => Err(PackagesListPackagesForOrganizationError::Generic { code }.into()), } } } @@ -2677,7 +2841,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_packages_for_organization(&self, org: &str, query_params: impl Into>) -> Result, PackagesListPackagesForOrganizationError> { + pub fn list_packages_for_organization(&self, org: &str, query_params: impl Into>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/packages", super::GITHUB_BASE_API_URL, org); @@ -2692,7 +2856,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2704,10 +2868,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(PackagesListPackagesForOrganizationError::Status403(github_response.to_json()?)), - 401 => Err(PackagesListPackagesForOrganizationError::Status401(github_response.to_json()?)), - 400 => Err(PackagesListPackagesForOrganizationError::Status400), - code => Err(PackagesListPackagesForOrganizationError::Generic { code }), + 403 => Err(PackagesListPackagesForOrganizationError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesListPackagesForOrganizationError::Status401(github_response.to_json()?).into()), + 400 => Err(PackagesListPackagesForOrganizationError::Status400.into()), + code => Err(PackagesListPackagesForOrganizationError::Generic { code }.into()), } } } @@ -2723,7 +2887,7 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for list_packages_for_user](https://docs.github.com/rest/packages/packages#list-packages-for-a-user) /// /// --- - pub async fn list_packages_for_user_async(&self, username: &str, query_params: impl Into>) -> Result, PackagesListPackagesForUserError> { + pub async fn list_packages_for_user_async(&self, username: &str, query_params: impl Into>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/packages", super::GITHUB_BASE_API_URL, username); @@ -2732,12 +2896,12 @@ impl<'api, C: Client> Packages<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2749,10 +2913,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(PackagesListPackagesForUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesListPackagesForUserError::Status401(github_response.to_json_async().await?)), - 400 => Err(PackagesListPackagesForUserError::Status400), - code => Err(PackagesListPackagesForUserError::Generic { code }), + 403 => Err(PackagesListPackagesForUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesListPackagesForUserError::Status401(github_response.to_json_async().await?).into()), + 400 => Err(PackagesListPackagesForUserError::Status400.into()), + code => Err(PackagesListPackagesForUserError::Generic { code }.into()), } } } @@ -2769,7 +2933,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_packages_for_user(&self, username: &str, query_params: impl Into>) -> Result, PackagesListPackagesForUserError> { + pub fn list_packages_for_user(&self, username: &str, query_params: impl Into>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/packages", super::GITHUB_BASE_API_URL, username); @@ -2784,7 +2948,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2796,10 +2960,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(PackagesListPackagesForUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesListPackagesForUserError::Status401(github_response.to_json()?)), - 400 => Err(PackagesListPackagesForUserError::Status400), - code => Err(PackagesListPackagesForUserError::Generic { code }), + 403 => Err(PackagesListPackagesForUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesListPackagesForUserError::Status401(github_response.to_json()?).into()), + 400 => Err(PackagesListPackagesForUserError::Status400.into()), + code => Err(PackagesListPackagesForUserError::Generic { code }.into()), } } } @@ -2819,7 +2983,7 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for restore_package_for_authenticated_user](https://docs.github.com/rest/packages/packages#restore-a-package-for-the-authenticated-user) /// /// --- - pub async fn restore_package_for_authenticated_user_async(&self, package_type: &str, package_name: &str, query_params: Option>>) -> Result<(), PackagesRestorePackageForAuthenticatedUserError> { + pub async fn restore_package_for_authenticated_user_async(&self, package_type: &str, package_name: &str, query_params: Option>>) -> Result<(), AdapterError> { let mut request_uri = format!("{}/user/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name); @@ -2830,12 +2994,12 @@ impl<'api, C: Client> Packages<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2847,10 +3011,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesRestorePackageForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesRestorePackageForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesRestorePackageForAuthenticatedUserError::Generic { code }), + 404 => Err(PackagesRestorePackageForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesRestorePackageForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesRestorePackageForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesRestorePackageForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2871,7 +3035,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn restore_package_for_authenticated_user(&self, package_type: &str, package_name: &str, query_params: Option>>) -> Result<(), PackagesRestorePackageForAuthenticatedUserError> { + pub fn restore_package_for_authenticated_user(&self, package_type: &str, package_name: &str, query_params: Option>>) -> Result<(), AdapterError> { let mut request_uri = format!("{}/user/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name); @@ -2888,7 +3052,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2900,10 +3064,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(PackagesRestorePackageForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesRestorePackageForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(PackagesRestorePackageForAuthenticatedUserError::Generic { code }), + 404 => Err(PackagesRestorePackageForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesRestorePackageForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesRestorePackageForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(PackagesRestorePackageForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2925,7 +3089,7 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for restore_package_for_org](https://docs.github.com/rest/packages/packages#restore-a-package-for-an-organization) /// /// --- - pub async fn restore_package_for_org_async(&self, package_type: &str, package_name: &str, org: &str, query_params: Option>>) -> Result<(), PackagesRestorePackageForOrgError> { + pub async fn restore_package_for_org_async(&self, package_type: &str, package_name: &str, org: &str, query_params: Option>>) -> Result<(), AdapterError> { let mut request_uri = format!("{}/orgs/{}/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, org); @@ -2936,12 +3100,12 @@ impl<'api, C: Client> Packages<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2953,10 +3117,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageForOrgError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesRestorePackageForOrgError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesRestorePackageForOrgError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesRestorePackageForOrgError::Generic { code }), + 404 => Err(PackagesRestorePackageForOrgError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesRestorePackageForOrgError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesRestorePackageForOrgError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesRestorePackageForOrgError::Generic { code }.into()), } } } @@ -2979,7 +3143,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn restore_package_for_org(&self, package_type: &str, package_name: &str, org: &str, query_params: Option>>) -> Result<(), PackagesRestorePackageForOrgError> { + pub fn restore_package_for_org(&self, package_type: &str, package_name: &str, org: &str, query_params: Option>>) -> Result<(), AdapterError> { let mut request_uri = format!("{}/orgs/{}/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, org); @@ -2996,7 +3160,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3008,10 +3172,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageForOrgError::Status404(github_response.to_json()?)), - 403 => Err(PackagesRestorePackageForOrgError::Status403(github_response.to_json()?)), - 401 => Err(PackagesRestorePackageForOrgError::Status401(github_response.to_json()?)), - code => Err(PackagesRestorePackageForOrgError::Generic { code }), + 404 => Err(PackagesRestorePackageForOrgError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesRestorePackageForOrgError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesRestorePackageForOrgError::Status401(github_response.to_json()?).into()), + code => Err(PackagesRestorePackageForOrgError::Generic { code }.into()), } } } @@ -3033,7 +3197,7 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for restore_package_for_user](https://docs.github.com/rest/packages/packages#restore-a-package-for-a-user) /// /// --- - pub async fn restore_package_for_user_async(&self, package_type: &str, package_name: &str, username: &str, query_params: Option>>) -> Result<(), PackagesRestorePackageForUserError> { + pub async fn restore_package_for_user_async(&self, package_type: &str, package_name: &str, username: &str, query_params: Option>>) -> Result<(), AdapterError> { let mut request_uri = format!("{}/users/{}/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, username); @@ -3044,12 +3208,12 @@ impl<'api, C: Client> Packages<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3061,10 +3225,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageForUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesRestorePackageForUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesRestorePackageForUserError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesRestorePackageForUserError::Generic { code }), + 404 => Err(PackagesRestorePackageForUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesRestorePackageForUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesRestorePackageForUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesRestorePackageForUserError::Generic { code }.into()), } } } @@ -3087,7 +3251,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn restore_package_for_user(&self, package_type: &str, package_name: &str, username: &str, query_params: Option>>) -> Result<(), PackagesRestorePackageForUserError> { + pub fn restore_package_for_user(&self, package_type: &str, package_name: &str, username: &str, query_params: Option>>) -> Result<(), AdapterError> { let mut request_uri = format!("{}/users/{}/packages/{}/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, username); @@ -3104,7 +3268,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3116,10 +3280,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageForUserError::Status404(github_response.to_json()?)), - 403 => Err(PackagesRestorePackageForUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesRestorePackageForUserError::Status401(github_response.to_json()?)), - code => Err(PackagesRestorePackageForUserError::Generic { code }), + 404 => Err(PackagesRestorePackageForUserError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesRestorePackageForUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesRestorePackageForUserError::Status401(github_response.to_json()?).into()), + code => Err(PackagesRestorePackageForUserError::Generic { code }.into()), } } } @@ -3139,19 +3303,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for restore_package_version_for_authenticated_user](https://docs.github.com/rest/packages/packages#restore-a-package-version-for-the-authenticated-user) /// /// --- - pub async fn restore_package_version_for_authenticated_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), PackagesRestorePackageVersionForAuthenticatedUserError> { + pub async fn restore_package_version_for_authenticated_user_async(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3163,10 +3327,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Generic { code }), + 404 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3187,7 +3351,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn restore_package_version_for_authenticated_user(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), PackagesRestorePackageVersionForAuthenticatedUserError> { + pub fn restore_package_version_for_authenticated_user(&self, package_type: &str, package_name: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, package_version_id); @@ -3199,7 +3363,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3211,10 +3375,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Generic { code }), + 404 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(PackagesRestorePackageVersionForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3236,19 +3400,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for restore_package_version_for_org](https://docs.github.com/rest/packages/packages#restore-package-version-for-an-organization) /// /// --- - pub async fn restore_package_version_for_org_async(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), PackagesRestorePackageVersionForOrgError> { + pub async fn restore_package_version_for_org_async(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_version_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3260,10 +3424,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageVersionForOrgError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesRestorePackageVersionForOrgError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesRestorePackageVersionForOrgError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesRestorePackageVersionForOrgError::Generic { code }), + 404 => Err(PackagesRestorePackageVersionForOrgError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesRestorePackageVersionForOrgError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesRestorePackageVersionForOrgError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesRestorePackageVersionForOrgError::Generic { code }.into()), } } } @@ -3286,7 +3450,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn restore_package_version_for_org(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), PackagesRestorePackageVersionForOrgError> { + pub fn restore_package_version_for_org(&self, package_type: &str, package_name: &str, org: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, org, package_version_id); @@ -3298,7 +3462,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3310,10 +3474,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageVersionForOrgError::Status404(github_response.to_json()?)), - 403 => Err(PackagesRestorePackageVersionForOrgError::Status403(github_response.to_json()?)), - 401 => Err(PackagesRestorePackageVersionForOrgError::Status401(github_response.to_json()?)), - code => Err(PackagesRestorePackageVersionForOrgError::Generic { code }), + 404 => Err(PackagesRestorePackageVersionForOrgError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesRestorePackageVersionForOrgError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesRestorePackageVersionForOrgError::Status401(github_response.to_json()?).into()), + code => Err(PackagesRestorePackageVersionForOrgError::Generic { code }.into()), } } } @@ -3335,19 +3499,19 @@ impl<'api, C: Client> Packages<'api, C> { /// [GitHub API docs for restore_package_version_for_user](https://docs.github.com/rest/packages/packages#restore-package-version-for-a-user) /// /// --- - pub async fn restore_package_version_for_user_async(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), PackagesRestorePackageVersionForUserError> { + pub async fn restore_package_version_for_user_async(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, username, package_version_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3359,10 +3523,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageVersionForUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(PackagesRestorePackageVersionForUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(PackagesRestorePackageVersionForUserError::Status401(github_response.to_json_async().await?)), - code => Err(PackagesRestorePackageVersionForUserError::Generic { code }), + 404 => Err(PackagesRestorePackageVersionForUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(PackagesRestorePackageVersionForUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(PackagesRestorePackageVersionForUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(PackagesRestorePackageVersionForUserError::Generic { code }.into()), } } } @@ -3385,7 +3549,7 @@ impl<'api, C: Client> Packages<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn restore_package_version_for_user(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), PackagesRestorePackageVersionForUserError> { + pub fn restore_package_version_for_user(&self, package_type: &str, package_name: &str, username: &str, package_version_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/users/{}/packages/{}/{}/versions/{}/restore", super::GITHUB_BASE_API_URL, package_type, package_name, username, package_version_id); @@ -3397,7 +3561,7 @@ impl<'api, C: Client> Packages<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3409,10 +3573,10 @@ impl<'api, C: Client> Packages<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PackagesRestorePackageVersionForUserError::Status404(github_response.to_json()?)), - 403 => Err(PackagesRestorePackageVersionForUserError::Status403(github_response.to_json()?)), - 401 => Err(PackagesRestorePackageVersionForUserError::Status401(github_response.to_json()?)), - code => Err(PackagesRestorePackageVersionForUserError::Generic { code }), + 404 => Err(PackagesRestorePackageVersionForUserError::Status404(github_response.to_json()?).into()), + 403 => Err(PackagesRestorePackageVersionForUserError::Status403(github_response.to_json()?).into()), + 401 => Err(PackagesRestorePackageVersionForUserError::Status401(github_response.to_json()?).into()), + code => Err(PackagesRestorePackageVersionForUserError::Generic { code }.into()), } } } diff --git a/src/endpoints/projects.rs b/src/endpoints/projects.rs index 29383b6..61c1428 100644 --- a/src/endpoints/projects.rs +++ b/src/endpoints/projects.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Projects<'api, C: Client> { +pub struct Projects<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Projects { +pub fn new(client: &C) -> Projects where AdapterError: From<::Err> { Projects { client } } /// Errors for the [Add project collaborator](Projects::add_collaborator_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsAddCollaboratorError { - #[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, or the endpoint has been spammed.")] @@ -57,19 +47,28 @@ pub enum ProjectsAddCollaboratorError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsAddCollaboratorError) -> Self { + let (description, status_code) = match err { + ProjectsAddCollaboratorError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsAddCollaboratorError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsAddCollaboratorError::Status304 => (String::from("Not modified"), 304), + ProjectsAddCollaboratorError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsAddCollaboratorError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsAddCollaboratorError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a project card](Projects::create_card_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsCreateCardError { - #[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("Forbidden")] @@ -84,19 +83,28 @@ pub enum ProjectsCreateCardError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsCreateCardError) -> Self { + let (description, status_code) = match err { + ProjectsCreateCardError::Status304 => (String::from("Not modified"), 304), + ProjectsCreateCardError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsCreateCardError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsCreateCardError::Status422(_) => (String::from("Validation failed"), 422), + ProjectsCreateCardError::Status503(_) => (String::from("Response"), 503), + ProjectsCreateCardError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a project column](Projects::create_column_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsCreateColumnError { - #[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("Forbidden")] @@ -109,19 +117,27 @@ pub enum ProjectsCreateColumnError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsCreateColumnError) -> Self { + let (description, status_code) = match err { + ProjectsCreateColumnError::Status304 => (String::from("Not modified"), 304), + ProjectsCreateColumnError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsCreateColumnError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsCreateColumnError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsCreateColumnError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a user project](Projects::create_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsCreateForAuthenticatedUserError { - #[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("Forbidden")] @@ -134,19 +150,27 @@ pub enum ProjectsCreateForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsCreateForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ProjectsCreateForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ProjectsCreateForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsCreateForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsCreateForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsCreateForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an organization project](Projects::create_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsCreateForOrgError { - #[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")] @@ -161,19 +185,28 @@ pub enum ProjectsCreateForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsCreateForOrgError) -> Self { + let (description, status_code) = match err { + ProjectsCreateForOrgError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsCreateForOrgError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsCreateForOrgError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsCreateForOrgError::Status410(_) => (String::from("Gone"), 410), + ProjectsCreateForOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsCreateForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a repository project](Projects::create_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsCreateForRepoError { - #[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")] @@ -188,19 +221,28 @@ pub enum ProjectsCreateForRepoError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsCreateForRepoError) -> Self { + let (description, status_code) = match err { + ProjectsCreateForRepoError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsCreateForRepoError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsCreateForRepoError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsCreateForRepoError::Status410(_) => (String::from("Gone"), 410), + ProjectsCreateForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsCreateForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a project](Projects::delete_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsDeleteError { - #[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("Forbidden")] @@ -215,19 +257,28 @@ pub enum ProjectsDeleteError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsDeleteError) -> Self { + let (description, status_code) = match err { + ProjectsDeleteError::Status304 => (String::from("Not modified"), 304), + ProjectsDeleteError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsDeleteError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsDeleteError::Status410(_) => (String::from("Gone"), 410), + ProjectsDeleteError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsDeleteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a project card](Projects::delete_card_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsDeleteCardError { - #[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("Forbidden")] @@ -240,19 +291,27 @@ pub enum ProjectsDeleteCardError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsDeleteCardError) -> Self { + let (description, status_code) = match err { + ProjectsDeleteCardError::Status304 => (String::from("Not modified"), 304), + ProjectsDeleteCardError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsDeleteCardError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsDeleteCardError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsDeleteCardError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a project column](Projects::delete_column_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsDeleteColumnError { - #[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("Forbidden")] @@ -263,19 +322,26 @@ pub enum ProjectsDeleteColumnError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsDeleteColumnError) -> Self { + let (description, status_code) = match err { + ProjectsDeleteColumnError::Status304 => (String::from("Not modified"), 304), + ProjectsDeleteColumnError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsDeleteColumnError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsDeleteColumnError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a project](Projects::get_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsGetError { - #[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("Forbidden")] @@ -286,19 +352,26 @@ pub enum ProjectsGetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsGetError) -> Self { + let (description, status_code) = match err { + ProjectsGetError::Status304 => (String::from("Not modified"), 304), + ProjectsGetError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsGetError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsGetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a project card](Projects::get_card_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsGetCardError { - #[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("Forbidden")] @@ -311,19 +384,27 @@ pub enum ProjectsGetCardError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsGetCardError) -> Self { + let (description, status_code) = match err { + ProjectsGetCardError::Status304 => (String::from("Not modified"), 304), + ProjectsGetCardError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsGetCardError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsGetCardError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsGetCardError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a project column](Projects::get_column_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsGetColumnError { - #[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("Forbidden")] @@ -336,19 +417,27 @@ pub enum ProjectsGetColumnError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsGetColumnError) -> Self { + let (description, status_code) = match err { + ProjectsGetColumnError::Status304 => (String::from("Not modified"), 304), + ProjectsGetColumnError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsGetColumnError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsGetColumnError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsGetColumnError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get project permission for a user](Projects::get_permission_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsGetPermissionForUserError { - #[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, or the endpoint has been spammed.")] @@ -363,19 +452,28 @@ pub enum ProjectsGetPermissionForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsGetPermissionForUserError) -> Self { + let (description, status_code) = match err { + ProjectsGetPermissionForUserError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsGetPermissionForUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsGetPermissionForUserError::Status304 => (String::from("Not modified"), 304), + ProjectsGetPermissionForUserError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsGetPermissionForUserError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsGetPermissionForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List project cards](Projects::list_cards_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsListCardsError { - #[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("Forbidden")] @@ -386,19 +484,26 @@ pub enum ProjectsListCardsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsListCardsError) -> Self { + let (description, status_code) = match err { + ProjectsListCardsError::Status304 => (String::from("Not modified"), 304), + ProjectsListCardsError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsListCardsError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsListCardsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List project collaborators](Projects::list_collaborators_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsListCollaboratorsError { - #[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, or the endpoint has been spammed.")] @@ -413,19 +518,28 @@ pub enum ProjectsListCollaboratorsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsListCollaboratorsError) -> Self { + let (description, status_code) = match err { + ProjectsListCollaboratorsError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsListCollaboratorsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsListCollaboratorsError::Status304 => (String::from("Not modified"), 304), + ProjectsListCollaboratorsError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsListCollaboratorsError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsListCollaboratorsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List project columns](Projects::list_columns_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsListColumnsError { - #[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("Forbidden")] @@ -436,38 +550,50 @@ pub enum ProjectsListColumnsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsListColumnsError) -> Self { + let (description, status_code) = match err { + ProjectsListColumnsError::Status304 => (String::from("Not modified"), 304), + ProjectsListColumnsError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsListColumnsError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsListColumnsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization projects](Projects::list_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsListForOrgError { - #[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, or the endpoint has been spammed.")] Status422(ValidationErrorSimple), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsListForOrgError) -> Self { + let (description, status_code) = match err { + ProjectsListForOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsListForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository projects](Projects::list_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsListForRepoError { - #[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")] @@ -482,38 +608,52 @@ pub enum ProjectsListForRepoError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsListForRepoError) -> Self { + let (description, status_code) = match err { + ProjectsListForRepoError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsListForRepoError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsListForRepoError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsListForRepoError::Status410(_) => (String::from("Gone"), 410), + ProjectsListForRepoError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsListForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List user projects](Projects::list_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsListForUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsListForUserError) -> Self { + let (description, status_code) = match err { + ProjectsListForUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsListForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Move a project card](Projects::move_card_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsMoveCardError { - #[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("Forbidden")] @@ -528,19 +668,28 @@ pub enum ProjectsMoveCardError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsMoveCardError) -> Self { + let (description, status_code) = match err { + ProjectsMoveCardError::Status304 => (String::from("Not modified"), 304), + ProjectsMoveCardError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsMoveCardError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsMoveCardError::Status503(_) => (String::from("Response"), 503), + ProjectsMoveCardError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsMoveCardError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Move a project column](Projects::move_column_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsMoveColumnError { - #[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("Forbidden")] @@ -553,19 +702,27 @@ pub enum ProjectsMoveColumnError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsMoveColumnError) -> Self { + let (description, status_code) = match err { + ProjectsMoveColumnError::Status304 => (String::from("Not modified"), 304), + ProjectsMoveColumnError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsMoveColumnError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsMoveColumnError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsMoveColumnError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove user as a collaborator](Projects::remove_collaborator_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsRemoveCollaboratorError { - #[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("Resource not found")] @@ -580,19 +737,28 @@ pub enum ProjectsRemoveCollaboratorError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsRemoveCollaboratorError) -> Self { + let (description, status_code) = match err { + ProjectsRemoveCollaboratorError::Status304 => (String::from("Not modified"), 304), + ProjectsRemoveCollaboratorError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsRemoveCollaboratorError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsRemoveCollaboratorError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsRemoveCollaboratorError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsRemoveCollaboratorError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a project](Projects::update_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsUpdateError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if the authenticated user does not have access to the project")] Status404, #[error("Not modified")] @@ -609,19 +775,29 @@ pub enum ProjectsUpdateError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsUpdateError) -> Self { + let (description, status_code) = match err { + ProjectsUpdateError::Status404 => (String::from("Not Found if the authenticated user does not have access to the project"), 404), + ProjectsUpdateError::Status304 => (String::from("Not modified"), 304), + ProjectsUpdateError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsUpdateError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsUpdateError::Status410(_) => (String::from("Gone"), 410), + ProjectsUpdateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsUpdateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update an existing project card](Projects::update_card_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsUpdateCardError { - #[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("Forbidden")] @@ -636,19 +812,28 @@ pub enum ProjectsUpdateCardError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsUpdateCardError) -> Self { + let (description, status_code) = match err { + ProjectsUpdateCardError::Status304 => (String::from("Not modified"), 304), + ProjectsUpdateCardError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsUpdateCardError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsUpdateCardError::Status404(_) => (String::from("Resource not found"), 404), + ProjectsUpdateCardError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ProjectsUpdateCardError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update an existing project column](Projects::update_column_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ProjectsUpdateColumnError { - #[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("Forbidden")] @@ -659,6 +844,23 @@ pub enum ProjectsUpdateColumnError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ProjectsUpdateColumnError) -> Self { + let (description, status_code) = match err { + ProjectsUpdateColumnError::Status304 => (String::from("Not modified"), 304), + ProjectsUpdateColumnError::Status403(_) => (String::from("Forbidden"), 403), + ProjectsUpdateColumnError::Status401(_) => (String::from("Requires authentication"), 401), + ProjectsUpdateColumnError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List project cards](Projects::list_cards_async()) endpoint. #[derive(Default, Serialize)] @@ -966,7 +1168,7 @@ impl<'enc> From<&'enc PerPage> for ProjectsListForUserParams<'enc> { } } -impl<'api, C: Client> Projects<'api, C> { +impl<'api, C: Client> Projects<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Add project collaborator @@ -976,19 +1178,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for add_collaborator](https://docs.github.com/rest/projects/collaborators#add-project-collaborator) /// /// --- - pub async fn add_collaborator_async(&self, project_id: i32, username: &str, body: PutProjectsAddCollaborator) -> Result<(), ProjectsAddCollaboratorError> { + pub async fn add_collaborator_async(&self, project_id: i32, username: &str, body: PutProjectsAddCollaborator) -> Result<(), AdapterError> { let request_uri = format!("{}/projects/{}/collaborators/{}", super::GITHUB_BASE_API_URL, project_id, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutProjectsAddCollaborator::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1000,12 +1202,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ProjectsAddCollaboratorError::Status404(github_response.to_json_async().await?)), - 422 => Err(ProjectsAddCollaboratorError::Status422(github_response.to_json_async().await?)), - 304 => Err(ProjectsAddCollaboratorError::Status304), - 403 => Err(ProjectsAddCollaboratorError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsAddCollaboratorError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsAddCollaboratorError::Generic { code }), + 404 => Err(ProjectsAddCollaboratorError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsAddCollaboratorError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(ProjectsAddCollaboratorError::Status304.into()), + 403 => Err(ProjectsAddCollaboratorError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsAddCollaboratorError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsAddCollaboratorError::Generic { code }.into()), } } } @@ -1020,19 +1222,19 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_collaborator(&self, project_id: i32, username: &str, body: PutProjectsAddCollaborator) -> Result<(), ProjectsAddCollaboratorError> { + pub fn add_collaborator(&self, project_id: i32, username: &str, body: PutProjectsAddCollaborator) -> Result<(), AdapterError> { let request_uri = format!("{}/projects/{}/collaborators/{}", super::GITHUB_BASE_API_URL, project_id, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutProjectsAddCollaborator::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1044,12 +1246,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ProjectsAddCollaboratorError::Status404(github_response.to_json()?)), - 422 => Err(ProjectsAddCollaboratorError::Status422(github_response.to_json()?)), - 304 => Err(ProjectsAddCollaboratorError::Status304), - 403 => Err(ProjectsAddCollaboratorError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsAddCollaboratorError::Status401(github_response.to_json()?)), - code => Err(ProjectsAddCollaboratorError::Generic { code }), + 404 => Err(ProjectsAddCollaboratorError::Status404(github_response.to_json()?).into()), + 422 => Err(ProjectsAddCollaboratorError::Status422(github_response.to_json()?).into()), + 304 => Err(ProjectsAddCollaboratorError::Status304.into()), + 403 => Err(ProjectsAddCollaboratorError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsAddCollaboratorError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsAddCollaboratorError::Generic { code }.into()), } } } @@ -1061,19 +1263,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for create_card](https://docs.github.com/rest/projects/cards#create-a-project-card) /// /// --- - pub async fn create_card_async(&self, column_id: i32, body: PostProjectsCreateCard) -> Result { + pub async fn create_card_async(&self, column_id: i32, body: PostProjectsCreateCard) -> Result { let request_uri = format!("{}/projects/columns/{}/cards", super::GITHUB_BASE_API_URL, column_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsCreateCard::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1085,12 +1287,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsCreateCardError::Status304), - 403 => Err(ProjectsCreateCardError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsCreateCardError::Status401(github_response.to_json_async().await?)), - 422 => Err(ProjectsCreateCardError::Status422(github_response.to_json_async().await?)), - 503 => Err(ProjectsCreateCardError::Status503(github_response.to_json_async().await?)), - code => Err(ProjectsCreateCardError::Generic { code }), + 304 => Err(ProjectsCreateCardError::Status304.into()), + 403 => Err(ProjectsCreateCardError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsCreateCardError::Status401(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsCreateCardError::Status422(github_response.to_json_async().await?).into()), + 503 => Err(ProjectsCreateCardError::Status503(github_response.to_json_async().await?).into()), + code => Err(ProjectsCreateCardError::Generic { code }.into()), } } } @@ -1103,19 +1305,19 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_card(&self, column_id: i32, body: PostProjectsCreateCard) -> Result { + pub fn create_card(&self, column_id: i32, body: PostProjectsCreateCard) -> Result { let request_uri = format!("{}/projects/columns/{}/cards", super::GITHUB_BASE_API_URL, column_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsCreateCard::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1127,12 +1329,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsCreateCardError::Status304), - 403 => Err(ProjectsCreateCardError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsCreateCardError::Status401(github_response.to_json()?)), - 422 => Err(ProjectsCreateCardError::Status422(github_response.to_json()?)), - 503 => Err(ProjectsCreateCardError::Status503(github_response.to_json()?)), - code => Err(ProjectsCreateCardError::Generic { code }), + 304 => Err(ProjectsCreateCardError::Status304.into()), + 403 => Err(ProjectsCreateCardError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsCreateCardError::Status401(github_response.to_json()?).into()), + 422 => Err(ProjectsCreateCardError::Status422(github_response.to_json()?).into()), + 503 => Err(ProjectsCreateCardError::Status503(github_response.to_json()?).into()), + code => Err(ProjectsCreateCardError::Generic { code }.into()), } } } @@ -1146,19 +1348,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for create_column](https://docs.github.com/rest/projects/columns#create-a-project-column) /// /// --- - pub async fn create_column_async(&self, project_id: i32, body: PostProjectsCreateColumn) -> Result { + pub async fn create_column_async(&self, project_id: i32, body: PostProjectsCreateColumn) -> Result { let request_uri = format!("{}/projects/{}/columns", super::GITHUB_BASE_API_URL, project_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsCreateColumn::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1170,11 +1372,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsCreateColumnError::Status304), - 403 => Err(ProjectsCreateColumnError::Status403(github_response.to_json_async().await?)), - 422 => Err(ProjectsCreateColumnError::Status422(github_response.to_json_async().await?)), - 401 => Err(ProjectsCreateColumnError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsCreateColumnError::Generic { code }), + 304 => Err(ProjectsCreateColumnError::Status304.into()), + 403 => Err(ProjectsCreateColumnError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsCreateColumnError::Status422(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsCreateColumnError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsCreateColumnError::Generic { code }.into()), } } } @@ -1189,19 +1391,19 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_column(&self, project_id: i32, body: PostProjectsCreateColumn) -> Result { + pub fn create_column(&self, project_id: i32, body: PostProjectsCreateColumn) -> Result { let request_uri = format!("{}/projects/{}/columns", super::GITHUB_BASE_API_URL, project_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsCreateColumn::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1213,11 +1415,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsCreateColumnError::Status304), - 403 => Err(ProjectsCreateColumnError::Status403(github_response.to_json()?)), - 422 => Err(ProjectsCreateColumnError::Status422(github_response.to_json()?)), - 401 => Err(ProjectsCreateColumnError::Status401(github_response.to_json()?)), - code => Err(ProjectsCreateColumnError::Generic { code }), + 304 => Err(ProjectsCreateColumnError::Status304.into()), + 403 => Err(ProjectsCreateColumnError::Status403(github_response.to_json()?).into()), + 422 => Err(ProjectsCreateColumnError::Status422(github_response.to_json()?).into()), + 401 => Err(ProjectsCreateColumnError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsCreateColumnError::Generic { code }.into()), } } } @@ -1231,19 +1433,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for create_for_authenticated_user](https://docs.github.com/rest/projects/projects#create-a-user-project) /// /// --- - pub async fn create_for_authenticated_user_async(&self, body: PostProjectsCreateForAuthenticatedUser) -> Result { + pub async fn create_for_authenticated_user_async(&self, body: PostProjectsCreateForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/projects", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsCreateForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1255,11 +1457,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsCreateForAuthenticatedUserError::Status304), - 403 => Err(ProjectsCreateForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsCreateForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 422 => Err(ProjectsCreateForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - code => Err(ProjectsCreateForAuthenticatedUserError::Generic { code }), + 304 => Err(ProjectsCreateForAuthenticatedUserError::Status304.into()), + 403 => Err(ProjectsCreateForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsCreateForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsCreateForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(ProjectsCreateForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1274,19 +1476,19 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_authenticated_user(&self, body: PostProjectsCreateForAuthenticatedUser) -> Result { + pub fn create_for_authenticated_user(&self, body: PostProjectsCreateForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/projects", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsCreateForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1298,11 +1500,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsCreateForAuthenticatedUserError::Status304), - 403 => Err(ProjectsCreateForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsCreateForAuthenticatedUserError::Status401(github_response.to_json()?)), - 422 => Err(ProjectsCreateForAuthenticatedUserError::Status422(github_response.to_json()?)), - code => Err(ProjectsCreateForAuthenticatedUserError::Generic { code }), + 304 => Err(ProjectsCreateForAuthenticatedUserError::Status304.into()), + 403 => Err(ProjectsCreateForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsCreateForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 422 => Err(ProjectsCreateForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + code => Err(ProjectsCreateForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1316,19 +1518,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for create_for_org](https://docs.github.com/rest/projects/projects#create-an-organization-project) /// /// --- - pub async fn create_for_org_async(&self, org: &str, body: PostProjectsCreateForOrg) -> Result { + pub async fn create_for_org_async(&self, org: &str, body: PostProjectsCreateForOrg) -> Result { let request_uri = format!("{}/orgs/{}/projects", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsCreateForOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1340,12 +1542,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(ProjectsCreateForOrgError::Status401(github_response.to_json_async().await?)), - 403 => Err(ProjectsCreateForOrgError::Status403(github_response.to_json_async().await?)), - 404 => Err(ProjectsCreateForOrgError::Status404(github_response.to_json_async().await?)), - 410 => Err(ProjectsCreateForOrgError::Status410(github_response.to_json_async().await?)), - 422 => Err(ProjectsCreateForOrgError::Status422(github_response.to_json_async().await?)), - code => Err(ProjectsCreateForOrgError::Generic { code }), + 401 => Err(ProjectsCreateForOrgError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(ProjectsCreateForOrgError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ProjectsCreateForOrgError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(ProjectsCreateForOrgError::Status410(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsCreateForOrgError::Status422(github_response.to_json_async().await?).into()), + code => Err(ProjectsCreateForOrgError::Generic { code }.into()), } } } @@ -1360,19 +1562,19 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_org(&self, org: &str, body: PostProjectsCreateForOrg) -> Result { + pub fn create_for_org(&self, org: &str, body: PostProjectsCreateForOrg) -> Result { let request_uri = format!("{}/orgs/{}/projects", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsCreateForOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1384,12 +1586,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(ProjectsCreateForOrgError::Status401(github_response.to_json()?)), - 403 => Err(ProjectsCreateForOrgError::Status403(github_response.to_json()?)), - 404 => Err(ProjectsCreateForOrgError::Status404(github_response.to_json()?)), - 410 => Err(ProjectsCreateForOrgError::Status410(github_response.to_json()?)), - 422 => Err(ProjectsCreateForOrgError::Status422(github_response.to_json()?)), - code => Err(ProjectsCreateForOrgError::Generic { code }), + 401 => Err(ProjectsCreateForOrgError::Status401(github_response.to_json()?).into()), + 403 => Err(ProjectsCreateForOrgError::Status403(github_response.to_json()?).into()), + 404 => Err(ProjectsCreateForOrgError::Status404(github_response.to_json()?).into()), + 410 => Err(ProjectsCreateForOrgError::Status410(github_response.to_json()?).into()), + 422 => Err(ProjectsCreateForOrgError::Status422(github_response.to_json()?).into()), + code => Err(ProjectsCreateForOrgError::Generic { code }.into()), } } } @@ -1403,19 +1605,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for create_for_repo](https://docs.github.com/rest/projects/projects#create-a-repository-project) /// /// --- - pub async fn create_for_repo_async(&self, owner: &str, repo: &str, body: PostProjectsCreateForRepo) -> Result { + pub async fn create_for_repo_async(&self, owner: &str, repo: &str, body: PostProjectsCreateForRepo) -> Result { let request_uri = format!("{}/repos/{}/{}/projects", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsCreateForRepo::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1427,12 +1629,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(ProjectsCreateForRepoError::Status401(github_response.to_json_async().await?)), - 403 => Err(ProjectsCreateForRepoError::Status403(github_response.to_json_async().await?)), - 404 => Err(ProjectsCreateForRepoError::Status404(github_response.to_json_async().await?)), - 410 => Err(ProjectsCreateForRepoError::Status410(github_response.to_json_async().await?)), - 422 => Err(ProjectsCreateForRepoError::Status422(github_response.to_json_async().await?)), - code => Err(ProjectsCreateForRepoError::Generic { code }), + 401 => Err(ProjectsCreateForRepoError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(ProjectsCreateForRepoError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ProjectsCreateForRepoError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(ProjectsCreateForRepoError::Status410(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsCreateForRepoError::Status422(github_response.to_json_async().await?).into()), + code => Err(ProjectsCreateForRepoError::Generic { code }.into()), } } } @@ -1447,19 +1649,19 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_repo(&self, owner: &str, repo: &str, body: PostProjectsCreateForRepo) -> Result { + pub fn create_for_repo(&self, owner: &str, repo: &str, body: PostProjectsCreateForRepo) -> Result { let request_uri = format!("{}/repos/{}/{}/projects", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsCreateForRepo::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1471,12 +1673,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(ProjectsCreateForRepoError::Status401(github_response.to_json()?)), - 403 => Err(ProjectsCreateForRepoError::Status403(github_response.to_json()?)), - 404 => Err(ProjectsCreateForRepoError::Status404(github_response.to_json()?)), - 410 => Err(ProjectsCreateForRepoError::Status410(github_response.to_json()?)), - 422 => Err(ProjectsCreateForRepoError::Status422(github_response.to_json()?)), - code => Err(ProjectsCreateForRepoError::Generic { code }), + 401 => Err(ProjectsCreateForRepoError::Status401(github_response.to_json()?).into()), + 403 => Err(ProjectsCreateForRepoError::Status403(github_response.to_json()?).into()), + 404 => Err(ProjectsCreateForRepoError::Status404(github_response.to_json()?).into()), + 410 => Err(ProjectsCreateForRepoError::Status410(github_response.to_json()?).into()), + 422 => Err(ProjectsCreateForRepoError::Status422(github_response.to_json()?).into()), + code => Err(ProjectsCreateForRepoError::Generic { code }.into()), } } } @@ -1490,19 +1692,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for delete](https://docs.github.com/rest/projects/projects#delete-a-project) /// /// --- - pub async fn delete_async(&self, project_id: i32) -> Result<(), ProjectsDeleteError> { + pub async fn delete_async(&self, project_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/projects/{}", super::GITHUB_BASE_API_URL, project_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1514,12 +1716,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsDeleteError::Status304), - 403 => Err(ProjectsDeleteError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsDeleteError::Status401(github_response.to_json_async().await?)), - 410 => Err(ProjectsDeleteError::Status410(github_response.to_json_async().await?)), - 404 => Err(ProjectsDeleteError::Status404(github_response.to_json_async().await?)), - code => Err(ProjectsDeleteError::Generic { code }), + 304 => Err(ProjectsDeleteError::Status304.into()), + 403 => Err(ProjectsDeleteError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsDeleteError::Status401(github_response.to_json_async().await?).into()), + 410 => Err(ProjectsDeleteError::Status410(github_response.to_json_async().await?).into()), + 404 => Err(ProjectsDeleteError::Status404(github_response.to_json_async().await?).into()), + code => Err(ProjectsDeleteError::Generic { code }.into()), } } } @@ -1534,7 +1736,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete(&self, project_id: i32) -> Result<(), ProjectsDeleteError> { + pub fn delete(&self, project_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/projects/{}", super::GITHUB_BASE_API_URL, project_id); @@ -1546,7 +1748,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1558,12 +1760,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsDeleteError::Status304), - 403 => Err(ProjectsDeleteError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsDeleteError::Status401(github_response.to_json()?)), - 410 => Err(ProjectsDeleteError::Status410(github_response.to_json()?)), - 404 => Err(ProjectsDeleteError::Status404(github_response.to_json()?)), - code => Err(ProjectsDeleteError::Generic { code }), + 304 => Err(ProjectsDeleteError::Status304.into()), + 403 => Err(ProjectsDeleteError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsDeleteError::Status401(github_response.to_json()?).into()), + 410 => Err(ProjectsDeleteError::Status410(github_response.to_json()?).into()), + 404 => Err(ProjectsDeleteError::Status404(github_response.to_json()?).into()), + code => Err(ProjectsDeleteError::Generic { code }.into()), } } } @@ -1577,19 +1779,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for delete_card](https://docs.github.com/rest/projects/cards#delete-a-project-card) /// /// --- - pub async fn delete_card_async(&self, card_id: i32) -> Result<(), ProjectsDeleteCardError> { + pub async fn delete_card_async(&self, card_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/projects/columns/cards/{}", super::GITHUB_BASE_API_URL, card_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1601,11 +1803,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsDeleteCardError::Status304), - 403 => Err(ProjectsDeleteCardError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsDeleteCardError::Status401(github_response.to_json_async().await?)), - 404 => Err(ProjectsDeleteCardError::Status404(github_response.to_json_async().await?)), - code => Err(ProjectsDeleteCardError::Generic { code }), + 304 => Err(ProjectsDeleteCardError::Status304.into()), + 403 => Err(ProjectsDeleteCardError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsDeleteCardError::Status401(github_response.to_json_async().await?).into()), + 404 => Err(ProjectsDeleteCardError::Status404(github_response.to_json_async().await?).into()), + code => Err(ProjectsDeleteCardError::Generic { code }.into()), } } } @@ -1620,7 +1822,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_card(&self, card_id: i32) -> Result<(), ProjectsDeleteCardError> { + pub fn delete_card(&self, card_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/projects/columns/cards/{}", super::GITHUB_BASE_API_URL, card_id); @@ -1632,7 +1834,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1644,11 +1846,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsDeleteCardError::Status304), - 403 => Err(ProjectsDeleteCardError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsDeleteCardError::Status401(github_response.to_json()?)), - 404 => Err(ProjectsDeleteCardError::Status404(github_response.to_json()?)), - code => Err(ProjectsDeleteCardError::Generic { code }), + 304 => Err(ProjectsDeleteCardError::Status304.into()), + 403 => Err(ProjectsDeleteCardError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsDeleteCardError::Status401(github_response.to_json()?).into()), + 404 => Err(ProjectsDeleteCardError::Status404(github_response.to_json()?).into()), + code => Err(ProjectsDeleteCardError::Generic { code }.into()), } } } @@ -1662,19 +1864,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for delete_column](https://docs.github.com/rest/projects/columns#delete-a-project-column) /// /// --- - pub async fn delete_column_async(&self, column_id: i32) -> Result<(), ProjectsDeleteColumnError> { + pub async fn delete_column_async(&self, column_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/projects/columns/{}", super::GITHUB_BASE_API_URL, column_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1686,10 +1888,10 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsDeleteColumnError::Status304), - 403 => Err(ProjectsDeleteColumnError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsDeleteColumnError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsDeleteColumnError::Generic { code }), + 304 => Err(ProjectsDeleteColumnError::Status304.into()), + 403 => Err(ProjectsDeleteColumnError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsDeleteColumnError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsDeleteColumnError::Generic { code }.into()), } } } @@ -1704,7 +1906,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_column(&self, column_id: i32) -> Result<(), ProjectsDeleteColumnError> { + pub fn delete_column(&self, column_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/projects/columns/{}", super::GITHUB_BASE_API_URL, column_id); @@ -1716,7 +1918,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1728,10 +1930,10 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsDeleteColumnError::Status304), - 403 => Err(ProjectsDeleteColumnError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsDeleteColumnError::Status401(github_response.to_json()?)), - code => Err(ProjectsDeleteColumnError::Generic { code }), + 304 => Err(ProjectsDeleteColumnError::Status304.into()), + 403 => Err(ProjectsDeleteColumnError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsDeleteColumnError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsDeleteColumnError::Generic { code }.into()), } } } @@ -1745,19 +1947,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for get](https://docs.github.com/rest/projects/projects#get-a-project) /// /// --- - pub async fn get_async(&self, project_id: i32) -> Result { + pub async fn get_async(&self, project_id: i32) -> Result { let request_uri = format!("{}/projects/{}", super::GITHUB_BASE_API_URL, project_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1769,10 +1971,10 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsGetError::Status304), - 403 => Err(ProjectsGetError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsGetError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsGetError::Generic { code }), + 304 => Err(ProjectsGetError::Status304.into()), + 403 => Err(ProjectsGetError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsGetError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsGetError::Generic { code }.into()), } } } @@ -1787,7 +1989,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get(&self, project_id: i32) -> Result { + pub fn get(&self, project_id: i32) -> Result { let request_uri = format!("{}/projects/{}", super::GITHUB_BASE_API_URL, project_id); @@ -1799,7 +2001,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1811,10 +2013,10 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsGetError::Status304), - 403 => Err(ProjectsGetError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsGetError::Status401(github_response.to_json()?)), - code => Err(ProjectsGetError::Generic { code }), + 304 => Err(ProjectsGetError::Status304.into()), + 403 => Err(ProjectsGetError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsGetError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsGetError::Generic { code }.into()), } } } @@ -1828,19 +2030,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for get_card](https://docs.github.com/rest/projects/cards#get-a-project-card) /// /// --- - pub async fn get_card_async(&self, card_id: i32) -> Result { + pub async fn get_card_async(&self, card_id: i32) -> Result { let request_uri = format!("{}/projects/columns/cards/{}", super::GITHUB_BASE_API_URL, card_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1852,11 +2054,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsGetCardError::Status304), - 403 => Err(ProjectsGetCardError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsGetCardError::Status401(github_response.to_json_async().await?)), - 404 => Err(ProjectsGetCardError::Status404(github_response.to_json_async().await?)), - code => Err(ProjectsGetCardError::Generic { code }), + 304 => Err(ProjectsGetCardError::Status304.into()), + 403 => Err(ProjectsGetCardError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsGetCardError::Status401(github_response.to_json_async().await?).into()), + 404 => Err(ProjectsGetCardError::Status404(github_response.to_json_async().await?).into()), + code => Err(ProjectsGetCardError::Generic { code }.into()), } } } @@ -1871,7 +2073,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_card(&self, card_id: i32) -> Result { + pub fn get_card(&self, card_id: i32) -> Result { let request_uri = format!("{}/projects/columns/cards/{}", super::GITHUB_BASE_API_URL, card_id); @@ -1883,7 +2085,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1895,11 +2097,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsGetCardError::Status304), - 403 => Err(ProjectsGetCardError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsGetCardError::Status401(github_response.to_json()?)), - 404 => Err(ProjectsGetCardError::Status404(github_response.to_json()?)), - code => Err(ProjectsGetCardError::Generic { code }), + 304 => Err(ProjectsGetCardError::Status304.into()), + 403 => Err(ProjectsGetCardError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsGetCardError::Status401(github_response.to_json()?).into()), + 404 => Err(ProjectsGetCardError::Status404(github_response.to_json()?).into()), + code => Err(ProjectsGetCardError::Generic { code }.into()), } } } @@ -1913,19 +2115,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for get_column](https://docs.github.com/rest/projects/columns#get-a-project-column) /// /// --- - pub async fn get_column_async(&self, column_id: i32) -> Result { + pub async fn get_column_async(&self, column_id: i32) -> Result { let request_uri = format!("{}/projects/columns/{}", super::GITHUB_BASE_API_URL, column_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1937,11 +2139,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsGetColumnError::Status304), - 403 => Err(ProjectsGetColumnError::Status403(github_response.to_json_async().await?)), - 404 => Err(ProjectsGetColumnError::Status404(github_response.to_json_async().await?)), - 401 => Err(ProjectsGetColumnError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsGetColumnError::Generic { code }), + 304 => Err(ProjectsGetColumnError::Status304.into()), + 403 => Err(ProjectsGetColumnError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ProjectsGetColumnError::Status404(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsGetColumnError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsGetColumnError::Generic { code }.into()), } } } @@ -1956,7 +2158,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_column(&self, column_id: i32) -> Result { + pub fn get_column(&self, column_id: i32) -> Result { let request_uri = format!("{}/projects/columns/{}", super::GITHUB_BASE_API_URL, column_id); @@ -1968,7 +2170,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1980,11 +2182,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsGetColumnError::Status304), - 403 => Err(ProjectsGetColumnError::Status403(github_response.to_json()?)), - 404 => Err(ProjectsGetColumnError::Status404(github_response.to_json()?)), - 401 => Err(ProjectsGetColumnError::Status401(github_response.to_json()?)), - code => Err(ProjectsGetColumnError::Generic { code }), + 304 => Err(ProjectsGetColumnError::Status304.into()), + 403 => Err(ProjectsGetColumnError::Status403(github_response.to_json()?).into()), + 404 => Err(ProjectsGetColumnError::Status404(github_response.to_json()?).into()), + 401 => Err(ProjectsGetColumnError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsGetColumnError::Generic { code }.into()), } } } @@ -1998,19 +2200,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for get_permission_for_user](https://docs.github.com/rest/projects/collaborators#get-project-permission-for-a-user) /// /// --- - pub async fn get_permission_for_user_async(&self, project_id: i32, username: &str) -> Result { + pub async fn get_permission_for_user_async(&self, project_id: i32, username: &str) -> Result { let request_uri = format!("{}/projects/{}/collaborators/{}/permission", super::GITHUB_BASE_API_URL, project_id, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2022,12 +2224,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ProjectsGetPermissionForUserError::Status404(github_response.to_json_async().await?)), - 422 => Err(ProjectsGetPermissionForUserError::Status422(github_response.to_json_async().await?)), - 304 => Err(ProjectsGetPermissionForUserError::Status304), - 403 => Err(ProjectsGetPermissionForUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsGetPermissionForUserError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsGetPermissionForUserError::Generic { code }), + 404 => Err(ProjectsGetPermissionForUserError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsGetPermissionForUserError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(ProjectsGetPermissionForUserError::Status304.into()), + 403 => Err(ProjectsGetPermissionForUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsGetPermissionForUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsGetPermissionForUserError::Generic { code }.into()), } } } @@ -2042,7 +2244,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_permission_for_user(&self, project_id: i32, username: &str) -> Result { + pub fn get_permission_for_user(&self, project_id: i32, username: &str) -> Result { let request_uri = format!("{}/projects/{}/collaborators/{}/permission", super::GITHUB_BASE_API_URL, project_id, username); @@ -2054,7 +2256,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2066,12 +2268,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ProjectsGetPermissionForUserError::Status404(github_response.to_json()?)), - 422 => Err(ProjectsGetPermissionForUserError::Status422(github_response.to_json()?)), - 304 => Err(ProjectsGetPermissionForUserError::Status304), - 403 => Err(ProjectsGetPermissionForUserError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsGetPermissionForUserError::Status401(github_response.to_json()?)), - code => Err(ProjectsGetPermissionForUserError::Generic { code }), + 404 => Err(ProjectsGetPermissionForUserError::Status404(github_response.to_json()?).into()), + 422 => Err(ProjectsGetPermissionForUserError::Status422(github_response.to_json()?).into()), + 304 => Err(ProjectsGetPermissionForUserError::Status304.into()), + 403 => Err(ProjectsGetPermissionForUserError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsGetPermissionForUserError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsGetPermissionForUserError::Generic { code }.into()), } } } @@ -2085,7 +2287,7 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for list_cards](https://docs.github.com/rest/projects/cards#list-project-cards) /// /// --- - pub async fn list_cards_async(&self, column_id: i32, query_params: Option>>) -> Result, ProjectsListCardsError> { + pub async fn list_cards_async(&self, column_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/projects/columns/{}/cards", super::GITHUB_BASE_API_URL, column_id); @@ -2096,12 +2298,12 @@ impl<'api, C: Client> Projects<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2113,10 +2315,10 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsListCardsError::Status304), - 403 => Err(ProjectsListCardsError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsListCardsError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsListCardsError::Generic { code }), + 304 => Err(ProjectsListCardsError::Status304.into()), + 403 => Err(ProjectsListCardsError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsListCardsError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsListCardsError::Generic { code }.into()), } } } @@ -2131,7 +2333,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_cards(&self, column_id: i32, query_params: Option>>) -> Result, ProjectsListCardsError> { + pub fn list_cards(&self, column_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/projects/columns/{}/cards", super::GITHUB_BASE_API_URL, column_id); @@ -2148,7 +2350,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2160,10 +2362,10 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsListCardsError::Status304), - 403 => Err(ProjectsListCardsError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsListCardsError::Status401(github_response.to_json()?)), - code => Err(ProjectsListCardsError::Generic { code }), + 304 => Err(ProjectsListCardsError::Status304.into()), + 403 => Err(ProjectsListCardsError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsListCardsError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsListCardsError::Generic { code }.into()), } } } @@ -2177,7 +2379,7 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for list_collaborators](https://docs.github.com/rest/projects/collaborators#list-project-collaborators) /// /// --- - pub async fn list_collaborators_async(&self, project_id: i32, query_params: Option>>) -> Result, ProjectsListCollaboratorsError> { + pub async fn list_collaborators_async(&self, project_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/projects/{}/collaborators", super::GITHUB_BASE_API_URL, project_id); @@ -2188,12 +2390,12 @@ impl<'api, C: Client> Projects<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2205,12 +2407,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ProjectsListCollaboratorsError::Status404(github_response.to_json_async().await?)), - 422 => Err(ProjectsListCollaboratorsError::Status422(github_response.to_json_async().await?)), - 304 => Err(ProjectsListCollaboratorsError::Status304), - 403 => Err(ProjectsListCollaboratorsError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsListCollaboratorsError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsListCollaboratorsError::Generic { code }), + 404 => Err(ProjectsListCollaboratorsError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsListCollaboratorsError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(ProjectsListCollaboratorsError::Status304.into()), + 403 => Err(ProjectsListCollaboratorsError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsListCollaboratorsError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsListCollaboratorsError::Generic { code }.into()), } } } @@ -2225,7 +2427,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_collaborators(&self, project_id: i32, query_params: Option>>) -> Result, ProjectsListCollaboratorsError> { + pub fn list_collaborators(&self, project_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/projects/{}/collaborators", super::GITHUB_BASE_API_URL, project_id); @@ -2242,7 +2444,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2254,12 +2456,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ProjectsListCollaboratorsError::Status404(github_response.to_json()?)), - 422 => Err(ProjectsListCollaboratorsError::Status422(github_response.to_json()?)), - 304 => Err(ProjectsListCollaboratorsError::Status304), - 403 => Err(ProjectsListCollaboratorsError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsListCollaboratorsError::Status401(github_response.to_json()?)), - code => Err(ProjectsListCollaboratorsError::Generic { code }), + 404 => Err(ProjectsListCollaboratorsError::Status404(github_response.to_json()?).into()), + 422 => Err(ProjectsListCollaboratorsError::Status422(github_response.to_json()?).into()), + 304 => Err(ProjectsListCollaboratorsError::Status304.into()), + 403 => Err(ProjectsListCollaboratorsError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsListCollaboratorsError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsListCollaboratorsError::Generic { code }.into()), } } } @@ -2273,7 +2475,7 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for list_columns](https://docs.github.com/rest/projects/columns#list-project-columns) /// /// --- - pub async fn list_columns_async(&self, project_id: i32, query_params: Option>) -> Result, ProjectsListColumnsError> { + pub async fn list_columns_async(&self, project_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/projects/{}/columns", super::GITHUB_BASE_API_URL, project_id); @@ -2284,12 +2486,12 @@ impl<'api, C: Client> Projects<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2301,10 +2503,10 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsListColumnsError::Status304), - 403 => Err(ProjectsListColumnsError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsListColumnsError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsListColumnsError::Generic { code }), + 304 => Err(ProjectsListColumnsError::Status304.into()), + 403 => Err(ProjectsListColumnsError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsListColumnsError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsListColumnsError::Generic { code }.into()), } } } @@ -2319,7 +2521,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_columns(&self, project_id: i32, query_params: Option>) -> Result, ProjectsListColumnsError> { + pub fn list_columns(&self, project_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/projects/{}/columns", super::GITHUB_BASE_API_URL, project_id); @@ -2336,7 +2538,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2348,10 +2550,10 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsListColumnsError::Status304), - 403 => Err(ProjectsListColumnsError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsListColumnsError::Status401(github_response.to_json()?)), - code => Err(ProjectsListColumnsError::Generic { code }), + 304 => Err(ProjectsListColumnsError::Status304.into()), + 403 => Err(ProjectsListColumnsError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsListColumnsError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsListColumnsError::Generic { code }.into()), } } } @@ -2365,7 +2567,7 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for list_for_org](https://docs.github.com/rest/projects/projects#list-organization-projects) /// /// --- - pub async fn list_for_org_async(&self, org: &str, query_params: Option>>) -> Result, ProjectsListForOrgError> { + pub async fn list_for_org_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/projects", super::GITHUB_BASE_API_URL, org); @@ -2376,12 +2578,12 @@ impl<'api, C: Client> Projects<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2393,8 +2595,8 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ProjectsListForOrgError::Status422(github_response.to_json_async().await?)), - code => Err(ProjectsListForOrgError::Generic { code }), + 422 => Err(ProjectsListForOrgError::Status422(github_response.to_json_async().await?).into()), + code => Err(ProjectsListForOrgError::Generic { code }.into()), } } } @@ -2409,7 +2611,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_org(&self, org: &str, query_params: Option>>) -> Result, ProjectsListForOrgError> { + pub fn list_for_org(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/projects", super::GITHUB_BASE_API_URL, org); @@ -2426,7 +2628,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2438,8 +2640,8 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ProjectsListForOrgError::Status422(github_response.to_json()?)), - code => Err(ProjectsListForOrgError::Generic { code }), + 422 => Err(ProjectsListForOrgError::Status422(github_response.to_json()?).into()), + code => Err(ProjectsListForOrgError::Generic { code }.into()), } } } @@ -2453,7 +2655,7 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for list_for_repo](https://docs.github.com/rest/projects/projects#list-repository-projects) /// /// --- - pub async fn list_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ProjectsListForRepoError> { + pub async fn list_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/projects", super::GITHUB_BASE_API_URL, owner, repo); @@ -2464,12 +2666,12 @@ impl<'api, C: Client> Projects<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2481,12 +2683,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(ProjectsListForRepoError::Status401(github_response.to_json_async().await?)), - 403 => Err(ProjectsListForRepoError::Status403(github_response.to_json_async().await?)), - 404 => Err(ProjectsListForRepoError::Status404(github_response.to_json_async().await?)), - 410 => Err(ProjectsListForRepoError::Status410(github_response.to_json_async().await?)), - 422 => Err(ProjectsListForRepoError::Status422(github_response.to_json_async().await?)), - code => Err(ProjectsListForRepoError::Generic { code }), + 401 => Err(ProjectsListForRepoError::Status401(github_response.to_json_async().await?).into()), + 403 => Err(ProjectsListForRepoError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ProjectsListForRepoError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(ProjectsListForRepoError::Status410(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsListForRepoError::Status422(github_response.to_json_async().await?).into()), + code => Err(ProjectsListForRepoError::Generic { code }.into()), } } } @@ -2501,7 +2703,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ProjectsListForRepoError> { + pub fn list_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/projects", super::GITHUB_BASE_API_URL, owner, repo); @@ -2518,7 +2720,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2530,12 +2732,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(ProjectsListForRepoError::Status401(github_response.to_json()?)), - 403 => Err(ProjectsListForRepoError::Status403(github_response.to_json()?)), - 404 => Err(ProjectsListForRepoError::Status404(github_response.to_json()?)), - 410 => Err(ProjectsListForRepoError::Status410(github_response.to_json()?)), - 422 => Err(ProjectsListForRepoError::Status422(github_response.to_json()?)), - code => Err(ProjectsListForRepoError::Generic { code }), + 401 => Err(ProjectsListForRepoError::Status401(github_response.to_json()?).into()), + 403 => Err(ProjectsListForRepoError::Status403(github_response.to_json()?).into()), + 404 => Err(ProjectsListForRepoError::Status404(github_response.to_json()?).into()), + 410 => Err(ProjectsListForRepoError::Status410(github_response.to_json()?).into()), + 422 => Err(ProjectsListForRepoError::Status422(github_response.to_json()?).into()), + code => Err(ProjectsListForRepoError::Generic { code }.into()), } } } @@ -2549,7 +2751,7 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for list_for_user](https://docs.github.com/rest/projects/projects#list-user-projects) /// /// --- - pub async fn list_for_user_async(&self, username: &str, query_params: Option>>) -> Result, ProjectsListForUserError> { + pub async fn list_for_user_async(&self, username: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/projects", super::GITHUB_BASE_API_URL, username); @@ -2560,12 +2762,12 @@ impl<'api, C: Client> Projects<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2577,8 +2779,8 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ProjectsListForUserError::Status422(github_response.to_json_async().await?)), - code => Err(ProjectsListForUserError::Generic { code }), + 422 => Err(ProjectsListForUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(ProjectsListForUserError::Generic { code }.into()), } } } @@ -2593,7 +2795,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_user(&self, username: &str, query_params: Option>>) -> Result, ProjectsListForUserError> { + pub fn list_for_user(&self, username: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/projects", super::GITHUB_BASE_API_URL, username); @@ -2610,7 +2812,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2622,8 +2824,8 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ProjectsListForUserError::Status422(github_response.to_json()?)), - code => Err(ProjectsListForUserError::Generic { code }), + 422 => Err(ProjectsListForUserError::Status422(github_response.to_json()?).into()), + code => Err(ProjectsListForUserError::Generic { code }.into()), } } } @@ -2635,19 +2837,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for move_card](https://docs.github.com/rest/projects/cards#move-a-project-card) /// /// --- - pub async fn move_card_async(&self, card_id: i32, body: PostProjectsMoveCard) -> Result, ProjectsMoveCardError> { + pub async fn move_card_async(&self, card_id: i32, body: PostProjectsMoveCard) -> Result, AdapterError> { let request_uri = format!("{}/projects/columns/cards/{}/moves", super::GITHUB_BASE_API_URL, card_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsMoveCard::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2659,12 +2861,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsMoveCardError::Status304), - 403 => Err(ProjectsMoveCardError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsMoveCardError::Status401(github_response.to_json_async().await?)), - 503 => Err(ProjectsMoveCardError::Status503(github_response.to_json_async().await?)), - 422 => Err(ProjectsMoveCardError::Status422(github_response.to_json_async().await?)), - code => Err(ProjectsMoveCardError::Generic { code }), + 304 => Err(ProjectsMoveCardError::Status304.into()), + 403 => Err(ProjectsMoveCardError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsMoveCardError::Status401(github_response.to_json_async().await?).into()), + 503 => Err(ProjectsMoveCardError::Status503(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsMoveCardError::Status422(github_response.to_json_async().await?).into()), + code => Err(ProjectsMoveCardError::Generic { code }.into()), } } } @@ -2677,19 +2879,19 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn move_card(&self, card_id: i32, body: PostProjectsMoveCard) -> Result, ProjectsMoveCardError> { + pub fn move_card(&self, card_id: i32, body: PostProjectsMoveCard) -> Result, AdapterError> { let request_uri = format!("{}/projects/columns/cards/{}/moves", super::GITHUB_BASE_API_URL, card_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsMoveCard::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2701,12 +2903,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsMoveCardError::Status304), - 403 => Err(ProjectsMoveCardError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsMoveCardError::Status401(github_response.to_json()?)), - 503 => Err(ProjectsMoveCardError::Status503(github_response.to_json()?)), - 422 => Err(ProjectsMoveCardError::Status422(github_response.to_json()?)), - code => Err(ProjectsMoveCardError::Generic { code }), + 304 => Err(ProjectsMoveCardError::Status304.into()), + 403 => Err(ProjectsMoveCardError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsMoveCardError::Status401(github_response.to_json()?).into()), + 503 => Err(ProjectsMoveCardError::Status503(github_response.to_json()?).into()), + 422 => Err(ProjectsMoveCardError::Status422(github_response.to_json()?).into()), + code => Err(ProjectsMoveCardError::Generic { code }.into()), } } } @@ -2718,19 +2920,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for move_column](https://docs.github.com/rest/projects/columns#move-a-project-column) /// /// --- - pub async fn move_column_async(&self, column_id: i32, body: PostProjectsMoveColumn) -> Result, ProjectsMoveColumnError> { + pub async fn move_column_async(&self, column_id: i32, body: PostProjectsMoveColumn) -> Result, AdapterError> { let request_uri = format!("{}/projects/columns/{}/moves", super::GITHUB_BASE_API_URL, column_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsMoveColumn::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2742,11 +2944,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsMoveColumnError::Status304), - 403 => Err(ProjectsMoveColumnError::Status403(github_response.to_json_async().await?)), - 422 => Err(ProjectsMoveColumnError::Status422(github_response.to_json_async().await?)), - 401 => Err(ProjectsMoveColumnError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsMoveColumnError::Generic { code }), + 304 => Err(ProjectsMoveColumnError::Status304.into()), + 403 => Err(ProjectsMoveColumnError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsMoveColumnError::Status422(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsMoveColumnError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsMoveColumnError::Generic { code }.into()), } } } @@ -2759,19 +2961,19 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn move_column(&self, column_id: i32, body: PostProjectsMoveColumn) -> Result, ProjectsMoveColumnError> { + pub fn move_column(&self, column_id: i32, body: PostProjectsMoveColumn) -> Result, AdapterError> { let request_uri = format!("{}/projects/columns/{}/moves", super::GITHUB_BASE_API_URL, column_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostProjectsMoveColumn::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2783,11 +2985,11 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsMoveColumnError::Status304), - 403 => Err(ProjectsMoveColumnError::Status403(github_response.to_json()?)), - 422 => Err(ProjectsMoveColumnError::Status422(github_response.to_json()?)), - 401 => Err(ProjectsMoveColumnError::Status401(github_response.to_json()?)), - code => Err(ProjectsMoveColumnError::Generic { code }), + 304 => Err(ProjectsMoveColumnError::Status304.into()), + 403 => Err(ProjectsMoveColumnError::Status403(github_response.to_json()?).into()), + 422 => Err(ProjectsMoveColumnError::Status422(github_response.to_json()?).into()), + 401 => Err(ProjectsMoveColumnError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsMoveColumnError::Generic { code }.into()), } } } @@ -2801,19 +3003,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for remove_collaborator](https://docs.github.com/rest/projects/collaborators#remove-user-as-a-collaborator) /// /// --- - pub async fn remove_collaborator_async(&self, project_id: i32, username: &str) -> Result<(), ProjectsRemoveCollaboratorError> { + pub async fn remove_collaborator_async(&self, project_id: i32, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/projects/{}/collaborators/{}", super::GITHUB_BASE_API_URL, project_id, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2825,12 +3027,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsRemoveCollaboratorError::Status304), - 404 => Err(ProjectsRemoveCollaboratorError::Status404(github_response.to_json_async().await?)), - 403 => Err(ProjectsRemoveCollaboratorError::Status403(github_response.to_json_async().await?)), - 422 => Err(ProjectsRemoveCollaboratorError::Status422(github_response.to_json_async().await?)), - 401 => Err(ProjectsRemoveCollaboratorError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsRemoveCollaboratorError::Generic { code }), + 304 => Err(ProjectsRemoveCollaboratorError::Status304.into()), + 404 => Err(ProjectsRemoveCollaboratorError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(ProjectsRemoveCollaboratorError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsRemoveCollaboratorError::Status422(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsRemoveCollaboratorError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsRemoveCollaboratorError::Generic { code }.into()), } } } @@ -2845,7 +3047,7 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_collaborator(&self, project_id: i32, username: &str) -> Result<(), ProjectsRemoveCollaboratorError> { + pub fn remove_collaborator(&self, project_id: i32, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/projects/{}/collaborators/{}", super::GITHUB_BASE_API_URL, project_id, username); @@ -2857,7 +3059,7 @@ impl<'api, C: Client> Projects<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2869,12 +3071,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsRemoveCollaboratorError::Status304), - 404 => Err(ProjectsRemoveCollaboratorError::Status404(github_response.to_json()?)), - 403 => Err(ProjectsRemoveCollaboratorError::Status403(github_response.to_json()?)), - 422 => Err(ProjectsRemoveCollaboratorError::Status422(github_response.to_json()?)), - 401 => Err(ProjectsRemoveCollaboratorError::Status401(github_response.to_json()?)), - code => Err(ProjectsRemoveCollaboratorError::Generic { code }), + 304 => Err(ProjectsRemoveCollaboratorError::Status304.into()), + 404 => Err(ProjectsRemoveCollaboratorError::Status404(github_response.to_json()?).into()), + 403 => Err(ProjectsRemoveCollaboratorError::Status403(github_response.to_json()?).into()), + 422 => Err(ProjectsRemoveCollaboratorError::Status422(github_response.to_json()?).into()), + 401 => Err(ProjectsRemoveCollaboratorError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsRemoveCollaboratorError::Generic { code }.into()), } } } @@ -2888,19 +3090,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for update](https://docs.github.com/rest/projects/projects#update-a-project) /// /// --- - pub async fn update_async(&self, project_id: i32, body: PatchProjectsUpdate) -> Result { + pub async fn update_async(&self, project_id: i32, body: PatchProjectsUpdate) -> Result { let request_uri = format!("{}/projects/{}", super::GITHUB_BASE_API_URL, project_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchProjectsUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2912,13 +3114,13 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ProjectsUpdateError::Status404), - 304 => Err(ProjectsUpdateError::Status304), - 403 => Err(ProjectsUpdateError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsUpdateError::Status401(github_response.to_json_async().await?)), - 410 => Err(ProjectsUpdateError::Status410(github_response.to_json_async().await?)), - 422 => Err(ProjectsUpdateError::Status422(github_response.to_json_async().await?)), - code => Err(ProjectsUpdateError::Generic { code }), + 404 => Err(ProjectsUpdateError::Status404.into()), + 304 => Err(ProjectsUpdateError::Status304.into()), + 403 => Err(ProjectsUpdateError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsUpdateError::Status401(github_response.to_json_async().await?).into()), + 410 => Err(ProjectsUpdateError::Status410(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsUpdateError::Status422(github_response.to_json_async().await?).into()), + code => Err(ProjectsUpdateError::Generic { code }.into()), } } } @@ -2933,19 +3135,19 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update(&self, project_id: i32, body: PatchProjectsUpdate) -> Result { + pub fn update(&self, project_id: i32, body: PatchProjectsUpdate) -> Result { let request_uri = format!("{}/projects/{}", super::GITHUB_BASE_API_URL, project_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchProjectsUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2957,13 +3159,13 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ProjectsUpdateError::Status404), - 304 => Err(ProjectsUpdateError::Status304), - 403 => Err(ProjectsUpdateError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsUpdateError::Status401(github_response.to_json()?)), - 410 => Err(ProjectsUpdateError::Status410(github_response.to_json()?)), - 422 => Err(ProjectsUpdateError::Status422(github_response.to_json()?)), - code => Err(ProjectsUpdateError::Generic { code }), + 404 => Err(ProjectsUpdateError::Status404.into()), + 304 => Err(ProjectsUpdateError::Status304.into()), + 403 => Err(ProjectsUpdateError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsUpdateError::Status401(github_response.to_json()?).into()), + 410 => Err(ProjectsUpdateError::Status410(github_response.to_json()?).into()), + 422 => Err(ProjectsUpdateError::Status422(github_response.to_json()?).into()), + code => Err(ProjectsUpdateError::Generic { code }.into()), } } } @@ -2975,19 +3177,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for update_card](https://docs.github.com/rest/projects/cards#update-an-existing-project-card) /// /// --- - pub async fn update_card_async(&self, card_id: i32, body: PatchProjectsUpdateCard) -> Result { + pub async fn update_card_async(&self, card_id: i32, body: PatchProjectsUpdateCard) -> Result { let request_uri = format!("{}/projects/columns/cards/{}", super::GITHUB_BASE_API_URL, card_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchProjectsUpdateCard::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2999,12 +3201,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsUpdateCardError::Status304), - 403 => Err(ProjectsUpdateCardError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsUpdateCardError::Status401(github_response.to_json_async().await?)), - 404 => Err(ProjectsUpdateCardError::Status404(github_response.to_json_async().await?)), - 422 => Err(ProjectsUpdateCardError::Status422(github_response.to_json_async().await?)), - code => Err(ProjectsUpdateCardError::Generic { code }), + 304 => Err(ProjectsUpdateCardError::Status304.into()), + 403 => Err(ProjectsUpdateCardError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsUpdateCardError::Status401(github_response.to_json_async().await?).into()), + 404 => Err(ProjectsUpdateCardError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ProjectsUpdateCardError::Status422(github_response.to_json_async().await?).into()), + code => Err(ProjectsUpdateCardError::Generic { code }.into()), } } } @@ -3017,19 +3219,19 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_card(&self, card_id: i32, body: PatchProjectsUpdateCard) -> Result { + pub fn update_card(&self, card_id: i32, body: PatchProjectsUpdateCard) -> Result { let request_uri = format!("{}/projects/columns/cards/{}", super::GITHUB_BASE_API_URL, card_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchProjectsUpdateCard::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3041,12 +3243,12 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsUpdateCardError::Status304), - 403 => Err(ProjectsUpdateCardError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsUpdateCardError::Status401(github_response.to_json()?)), - 404 => Err(ProjectsUpdateCardError::Status404(github_response.to_json()?)), - 422 => Err(ProjectsUpdateCardError::Status422(github_response.to_json()?)), - code => Err(ProjectsUpdateCardError::Generic { code }), + 304 => Err(ProjectsUpdateCardError::Status304.into()), + 403 => Err(ProjectsUpdateCardError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsUpdateCardError::Status401(github_response.to_json()?).into()), + 404 => Err(ProjectsUpdateCardError::Status404(github_response.to_json()?).into()), + 422 => Err(ProjectsUpdateCardError::Status422(github_response.to_json()?).into()), + code => Err(ProjectsUpdateCardError::Generic { code }.into()), } } } @@ -3058,19 +3260,19 @@ impl<'api, C: Client> Projects<'api, C> { /// [GitHub API docs for update_column](https://docs.github.com/rest/projects/columns#update-an-existing-project-column) /// /// --- - pub async fn update_column_async(&self, column_id: i32, body: PatchProjectsUpdateColumn) -> Result { + pub async fn update_column_async(&self, column_id: i32, body: PatchProjectsUpdateColumn) -> Result { let request_uri = format!("{}/projects/columns/{}", super::GITHUB_BASE_API_URL, column_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchProjectsUpdateColumn::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3082,10 +3284,10 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ProjectsUpdateColumnError::Status304), - 403 => Err(ProjectsUpdateColumnError::Status403(github_response.to_json_async().await?)), - 401 => Err(ProjectsUpdateColumnError::Status401(github_response.to_json_async().await?)), - code => Err(ProjectsUpdateColumnError::Generic { code }), + 304 => Err(ProjectsUpdateColumnError::Status304.into()), + 403 => Err(ProjectsUpdateColumnError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ProjectsUpdateColumnError::Status401(github_response.to_json_async().await?).into()), + code => Err(ProjectsUpdateColumnError::Generic { code }.into()), } } } @@ -3098,19 +3300,19 @@ impl<'api, C: Client> Projects<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_column(&self, column_id: i32, body: PatchProjectsUpdateColumn) -> Result { + pub fn update_column(&self, column_id: i32, body: PatchProjectsUpdateColumn) -> Result { let request_uri = format!("{}/projects/columns/{}", super::GITHUB_BASE_API_URL, column_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchProjectsUpdateColumn::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3122,10 +3324,10 @@ impl<'api, C: Client> Projects<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ProjectsUpdateColumnError::Status304), - 403 => Err(ProjectsUpdateColumnError::Status403(github_response.to_json()?)), - 401 => Err(ProjectsUpdateColumnError::Status401(github_response.to_json()?)), - code => Err(ProjectsUpdateColumnError::Generic { code }), + 304 => Err(ProjectsUpdateColumnError::Status304.into()), + 403 => Err(ProjectsUpdateColumnError::Status403(github_response.to_json()?).into()), + 401 => Err(ProjectsUpdateColumnError::Status401(github_response.to_json()?).into()), + code => Err(ProjectsUpdateColumnError::Generic { code }.into()), } } } diff --git a/src/endpoints/pulls.rs b/src/endpoints/pulls.rs index f5bc634..637a512 100644 --- a/src/endpoints/pulls.rs +++ b/src/endpoints/pulls.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,46 +22,41 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Pulls<'api, C: Client> { +pub struct Pulls<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Pulls { +pub fn new(client: &C) -> Pulls where AdapterError: From<::Err> { Pulls { client } } /// Errors for the [Check if a pull request has been merged](Pulls::check_if_merged_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsCheckIfMergedError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if pull request has not been merged")] Status404, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsCheckIfMergedError) -> Self { + let (description, status_code) = match err { + PullsCheckIfMergedError::Status404 => (String::from("Not Found if pull request has not been merged"), 404), + PullsCheckIfMergedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a pull request](Pulls::create_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsCreateError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -70,38 +65,49 @@ pub enum PullsCreateError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsCreateError) -> Self { + let (description, status_code) = match err { + PullsCreateError::Status403(_) => (String::from("Forbidden"), 403), + PullsCreateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsCreateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a reply for a review comment](Pulls::create_reply_for_review_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsCreateReplyForReviewCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: PullsCreateReplyForReviewCommentError) -> Self { + let (description, status_code) = match err { + PullsCreateReplyForReviewCommentError::Status404(_) => (String::from("Resource not found"), 404), + PullsCreateReplyForReviewCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a review for a pull request](Pulls::create_review_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsCreateReviewError { - #[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, or the endpoint has been spammed.")] Status422(ValidationErrorSimple), #[error("Forbidden")] @@ -110,19 +116,25 @@ pub enum PullsCreateReviewError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsCreateReviewError) -> Self { + let (description, status_code) = match err { + PullsCreateReviewError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsCreateReviewError::Status403(_) => (String::from("Forbidden"), 403), + PullsCreateReviewError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a review comment for a pull request](Pulls::create_review_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsCreateReviewCommentError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Forbidden")] @@ -131,19 +143,25 @@ pub enum PullsCreateReviewCommentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsCreateReviewCommentError) -> Self { + let (description, status_code) = match err { + PullsCreateReviewCommentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsCreateReviewCommentError::Status403(_) => (String::from("Forbidden"), 403), + PullsCreateReviewCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a pending review for a pull request](Pulls::delete_pending_review_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsDeletePendingReviewError { - #[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, or the endpoint has been spammed.")] Status422(ValidationErrorSimple), #[error("Resource not found")] @@ -152,38 +170,49 @@ pub enum PullsDeletePendingReviewError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsDeletePendingReviewError) -> Self { + let (description, status_code) = match err { + PullsDeletePendingReviewError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsDeletePendingReviewError::Status404(_) => (String::from("Resource not found"), 404), + PullsDeletePendingReviewError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a review comment for a pull request](Pulls::delete_review_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsDeleteReviewCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: PullsDeleteReviewCommentError) -> Self { + let (description, status_code) = match err { + PullsDeleteReviewCommentError::Status404(_) => (String::from("Resource not found"), 404), + PullsDeleteReviewCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Dismiss a review for a pull request](Pulls::dismiss_review_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsDismissReviewError { - #[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, or the endpoint has been spammed.")] @@ -192,19 +221,25 @@ pub enum PullsDismissReviewError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsDismissReviewError) -> Self { + let (description, status_code) = match err { + PullsDismissReviewError::Status404(_) => (String::from("Resource not found"), 404), + PullsDismissReviewError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsDismissReviewError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a pull request](Pulls::get_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsGetError { - #[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("Resource not found")] @@ -219,57 +254,76 @@ pub enum PullsGetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsGetError) -> Self { + let (description, status_code) = match err { + PullsGetError::Status304 => (String::from("Not modified"), 304), + PullsGetError::Status404(_) => (String::from("Resource not found"), 404), + PullsGetError::Status406(_) => (String::from("Unacceptable"), 406), + PullsGetError::Status500(_) => (String::from("Internal Error"), 500), + PullsGetError::Status503(_) => (String::from("Service unavailable"), 503), + PullsGetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a review for a pull request](Pulls::get_review_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsGetReviewError { - #[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 }, } +impl From for AdapterError { + fn from(err: PullsGetReviewError) -> Self { + let (description, status_code) = match err { + PullsGetReviewError::Status404(_) => (String::from("Resource not found"), 404), + PullsGetReviewError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a review comment for a pull request](Pulls::get_review_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsGetReviewCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: PullsGetReviewCommentError) -> Self { + let (description, status_code) = match err { + PullsGetReviewCommentError::Status404(_) => (String::from("Resource not found"), 404), + PullsGetReviewCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List pull requests](Pulls::list_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsListError { - #[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("Validation failed, or the endpoint has been spammed.")] @@ -278,55 +332,70 @@ pub enum PullsListError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsListError) -> Self { + let (description, status_code) = match err { + PullsListError::Status304 => (String::from("Not modified"), 304), + PullsListError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsListError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List comments for a pull request review](Pulls::list_comments_for_review_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsListCommentsForReviewError { - #[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 }, } +impl From for AdapterError { + fn from(err: PullsListCommentsForReviewError) -> Self { + let (description, status_code) = match err { + PullsListCommentsForReviewError::Status404(_) => (String::from("Resource not found"), 404), + PullsListCommentsForReviewError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List commits on a pull request](Pulls::list_commits_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsListCommitsError { - #[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 }, } +impl From for AdapterError { + fn from(err: PullsListCommitsError) -> Self { + let (description, status_code) = match err { + PullsListCommitsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List pull requests files](Pulls::list_files_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsListFilesError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Internal Error")] @@ -337,87 +406,110 @@ pub enum PullsListFilesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsListFilesError) -> Self { + let (description, status_code) = match err { + PullsListFilesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsListFilesError::Status500(_) => (String::from("Internal Error"), 500), + PullsListFilesError::Status503(_) => (String::from("Service unavailable"), 503), + PullsListFilesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all requested reviewers for a pull request](Pulls::list_requested_reviewers_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsListRequestedReviewersError { - #[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 }, } +impl From for AdapterError { + fn from(err: PullsListRequestedReviewersError) -> Self { + let (description, status_code) = match err { + PullsListRequestedReviewersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List review comments on a pull request](Pulls::list_review_comments_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsListReviewCommentsError { - #[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 }, } +impl From for AdapterError { + fn from(err: PullsListReviewCommentsError) -> Self { + let (description, status_code) = match err { + PullsListReviewCommentsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List review comments in a repository](Pulls::list_review_comments_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsListReviewCommentsForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: PullsListReviewCommentsForRepoError) -> Self { + let (description, status_code) = match err { + PullsListReviewCommentsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List reviews for a pull request](Pulls::list_reviews_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsListReviewsError { - #[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 }, } +impl From for AdapterError { + fn from(err: PullsListReviewsError) -> Self { + let (description, status_code) = match err { + PullsListReviewsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Merge a pull request](Pulls::merge_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsMergeError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Method Not Allowed if merge cannot be performed")] Status405(PutTeamsAddOrUpdateProjectPermissionsLegacyResponse403), #[error("Conflict if sha was provided and pull request head did not match")] @@ -432,38 +524,52 @@ pub enum PullsMergeError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsMergeError) -> Self { + let (description, status_code) = match err { + PullsMergeError::Status405(_) => (String::from("Method Not Allowed if merge cannot be performed"), 405), + PullsMergeError::Status409(_) => (String::from("Conflict if sha was provided and pull request head did not match"), 409), + PullsMergeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsMergeError::Status403(_) => (String::from("Forbidden"), 403), + PullsMergeError::Status404(_) => (String::from("Resource not found"), 404), + PullsMergeError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove requested reviewers from a pull request](Pulls::remove_requested_reviewers_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsRemoveRequestedReviewersError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsRemoveRequestedReviewersError) -> Self { + let (description, status_code) = match err { + PullsRemoveRequestedReviewersError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsRemoveRequestedReviewersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Request reviewers for a pull request](Pulls::request_reviewers_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsRequestReviewersError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Unprocessable Entity if user is not a collaborator")] Status422, #[error("Forbidden")] @@ -472,19 +578,25 @@ pub enum PullsRequestReviewersError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsRequestReviewersError) -> Self { + let (description, status_code) = match err { + PullsRequestReviewersError::Status422 => (String::from("Unprocessable Entity if user is not a collaborator"), 422), + PullsRequestReviewersError::Status403(_) => (String::from("Forbidden"), 403), + PullsRequestReviewersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Submit a review for a pull request](Pulls::submit_review_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsSubmitReviewError { - #[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, or the endpoint has been spammed.")] @@ -495,19 +607,26 @@ pub enum PullsSubmitReviewError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsSubmitReviewError) -> Self { + let (description, status_code) = match err { + PullsSubmitReviewError::Status404(_) => (String::from("Resource not found"), 404), + PullsSubmitReviewError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsSubmitReviewError::Status403(_) => (String::from("Forbidden"), 403), + PullsSubmitReviewError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a pull request](Pulls::update_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsUpdateError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Forbidden")] @@ -516,19 +635,25 @@ pub enum PullsUpdateError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsUpdateError) -> Self { + let (description, status_code) = match err { + PullsUpdateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsUpdateError::Status403(_) => (String::from("Forbidden"), 403), + PullsUpdateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a pull request branch](Pulls::update_branch_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsUpdateBranchError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Forbidden")] @@ -537,42 +662,67 @@ pub enum PullsUpdateBranchError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsUpdateBranchError) -> Self { + let (description, status_code) = match err { + PullsUpdateBranchError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsUpdateBranchError::Status403(_) => (String::from("Forbidden"), 403), + PullsUpdateBranchError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a review for a pull request](Pulls::update_review_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsUpdateReviewError { - #[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, or the endpoint has been spammed.")] Status422(ValidationErrorSimple), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: PullsUpdateReviewError) -> Self { + let (description, status_code) = match err { + PullsUpdateReviewError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + PullsUpdateReviewError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a review comment for a pull request](Pulls::update_review_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum PullsUpdateReviewCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: PullsUpdateReviewCommentError) -> Self { + let (description, status_code) = match err { + PullsUpdateReviewCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List pull requests](Pulls::list_async()) endpoint. #[derive(Default, Serialize)] @@ -1030,7 +1180,7 @@ impl<'enc> From<&'enc PerPage> for PullsListReviewsParams { } } -impl<'api, C: Client> Pulls<'api, C> { +impl<'api, C: Client> Pulls<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Check if a pull request has been merged @@ -1040,19 +1190,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for check_if_merged](https://docs.github.com/rest/pulls/pulls#check-if-a-pull-request-has-been-merged) /// /// --- - pub async fn check_if_merged_async(&self, owner: &str, repo: &str, pull_number: i32) -> Result<(), PullsCheckIfMergedError> { + pub async fn check_if_merged_async(&self, owner: &str, repo: &str, pull_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pulls/{}/merge", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1064,8 +1214,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PullsCheckIfMergedError::Status404), - code => Err(PullsCheckIfMergedError::Generic { code }), + 404 => Err(PullsCheckIfMergedError::Status404.into()), + code => Err(PullsCheckIfMergedError::Generic { code }.into()), } } } @@ -1080,7 +1230,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_if_merged(&self, owner: &str, repo: &str, pull_number: i32) -> Result<(), PullsCheckIfMergedError> { + pub fn check_if_merged(&self, owner: &str, repo: &str, pull_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pulls/{}/merge", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -1092,7 +1242,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1104,8 +1254,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PullsCheckIfMergedError::Status404), - code => Err(PullsCheckIfMergedError::Generic { code }), + 404 => Err(PullsCheckIfMergedError::Status404.into()), + code => Err(PullsCheckIfMergedError::Generic { code }.into()), } } } @@ -1130,19 +1280,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for create](https://docs.github.com/rest/pulls/pulls#create-a-pull-request) /// /// --- - pub async fn create_async(&self, owner: &str, repo: &str, body: PostPullsCreate) -> Result { + pub async fn create_async(&self, owner: &str, repo: &str, body: PostPullsCreate) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsCreate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1154,9 +1304,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(PullsCreateError::Status403(github_response.to_json_async().await?)), - 422 => Err(PullsCreateError::Status422(github_response.to_json_async().await?)), - code => Err(PullsCreateError::Generic { code }), + 403 => Err(PullsCreateError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(PullsCreateError::Status422(github_response.to_json_async().await?).into()), + code => Err(PullsCreateError::Generic { code }.into()), } } } @@ -1182,19 +1332,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create(&self, owner: &str, repo: &str, body: PostPullsCreate) -> Result { + pub fn create(&self, owner: &str, repo: &str, body: PostPullsCreate) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsCreate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1206,9 +1356,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(PullsCreateError::Status403(github_response.to_json()?)), - 422 => Err(PullsCreateError::Status422(github_response.to_json()?)), - code => Err(PullsCreateError::Generic { code }), + 403 => Err(PullsCreateError::Status403(github_response.to_json()?).into()), + 422 => Err(PullsCreateError::Status422(github_response.to_json()?).into()), + code => Err(PullsCreateError::Generic { code }.into()), } } } @@ -1232,19 +1382,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for create_reply_for_review_comment](https://docs.github.com/rest/pulls/comments#create-a-reply-for-a-review-comment) /// /// --- - pub async fn create_reply_for_review_comment_async(&self, owner: &str, repo: &str, pull_number: i32, comment_id: i64, body: PostPullsCreateReplyForReviewComment) -> Result { + pub async fn create_reply_for_review_comment_async(&self, owner: &str, repo: &str, pull_number: i32, comment_id: i64, body: PostPullsCreateReplyForReviewComment) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/comments/{}/replies", super::GITHUB_BASE_API_URL, owner, repo, pull_number, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsCreateReplyForReviewComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1256,8 +1406,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PullsCreateReplyForReviewCommentError::Status404(github_response.to_json_async().await?)), - code => Err(PullsCreateReplyForReviewCommentError::Generic { code }), + 404 => Err(PullsCreateReplyForReviewCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(PullsCreateReplyForReviewCommentError::Generic { code }.into()), } } } @@ -1282,19 +1432,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_reply_for_review_comment(&self, owner: &str, repo: &str, pull_number: i32, comment_id: i64, body: PostPullsCreateReplyForReviewComment) -> Result { + pub fn create_reply_for_review_comment(&self, owner: &str, repo: &str, pull_number: i32, comment_id: i64, body: PostPullsCreateReplyForReviewComment) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/comments/{}/replies", super::GITHUB_BASE_API_URL, owner, repo, pull_number, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsCreateReplyForReviewComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1306,8 +1456,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PullsCreateReplyForReviewCommentError::Status404(github_response.to_json()?)), - code => Err(PullsCreateReplyForReviewCommentError::Generic { code }), + 404 => Err(PullsCreateReplyForReviewCommentError::Status404(github_response.to_json()?).into()), + code => Err(PullsCreateReplyForReviewCommentError::Generic { code }.into()), } } } @@ -1337,19 +1487,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for create_review](https://docs.github.com/rest/pulls/reviews#create-a-review-for-a-pull-request) /// /// --- - pub async fn create_review_async(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReview) -> Result { + pub async fn create_review_async(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReview) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsCreateReview::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1361,9 +1511,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(PullsCreateReviewError::Status422(github_response.to_json_async().await?)), - 403 => Err(PullsCreateReviewError::Status403(github_response.to_json_async().await?)), - code => Err(PullsCreateReviewError::Generic { code }), + 422 => Err(PullsCreateReviewError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(PullsCreateReviewError::Status403(github_response.to_json_async().await?).into()), + code => Err(PullsCreateReviewError::Generic { code }.into()), } } } @@ -1394,19 +1544,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_review(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReview) -> Result { + pub fn create_review(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReview) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsCreateReview::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1418,9 +1568,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(PullsCreateReviewError::Status422(github_response.to_json()?)), - 403 => Err(PullsCreateReviewError::Status403(github_response.to_json()?)), - code => Err(PullsCreateReviewError::Generic { code }), + 422 => Err(PullsCreateReviewError::Status422(github_response.to_json()?).into()), + 403 => Err(PullsCreateReviewError::Status403(github_response.to_json()?).into()), + code => Err(PullsCreateReviewError::Generic { code }.into()), } } } @@ -1448,19 +1598,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for create_review_comment](https://docs.github.com/rest/pulls/comments#create-a-review-comment-for-a-pull-request) /// /// --- - pub async fn create_review_comment_async(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReviewComment) -> Result { + 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); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsCreateReviewComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1472,9 +1622,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(PullsCreateReviewCommentError::Status422(github_response.to_json_async().await?)), - 403 => Err(PullsCreateReviewCommentError::Status403(github_response.to_json_async().await?)), - code => Err(PullsCreateReviewCommentError::Generic { code }), + 422 => Err(PullsCreateReviewCommentError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(PullsCreateReviewCommentError::Status403(github_response.to_json_async().await?).into()), + code => Err(PullsCreateReviewCommentError::Generic { code }.into()), } } } @@ -1503,19 +1653,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_review_comment(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsCreateReviewComment) -> Result { + 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); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsCreateReviewComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1527,9 +1677,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(PullsCreateReviewCommentError::Status422(github_response.to_json()?)), - 403 => Err(PullsCreateReviewCommentError::Status403(github_response.to_json()?)), - code => Err(PullsCreateReviewCommentError::Generic { code }), + 422 => Err(PullsCreateReviewCommentError::Status422(github_response.to_json()?).into()), + 403 => Err(PullsCreateReviewCommentError::Status403(github_response.to_json()?).into()), + code => Err(PullsCreateReviewCommentError::Generic { code }.into()), } } } @@ -1550,19 +1700,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for delete_pending_review](https://docs.github.com/rest/pulls/reviews#delete-a-pending-review-for-a-pull-request) /// /// --- - pub async fn delete_pending_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result { + pub async fn delete_pending_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1574,9 +1724,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(PullsDeletePendingReviewError::Status422(github_response.to_json_async().await?)), - 404 => Err(PullsDeletePendingReviewError::Status404(github_response.to_json_async().await?)), - code => Err(PullsDeletePendingReviewError::Generic { code }), + 422 => Err(PullsDeletePendingReviewError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(PullsDeletePendingReviewError::Status404(github_response.to_json_async().await?).into()), + code => Err(PullsDeletePendingReviewError::Generic { code }.into()), } } } @@ -1598,7 +1748,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_pending_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result { + pub fn delete_pending_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); @@ -1610,7 +1760,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1622,9 +1772,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(PullsDeletePendingReviewError::Status422(github_response.to_json()?)), - 404 => Err(PullsDeletePendingReviewError::Status404(github_response.to_json()?)), - code => Err(PullsDeletePendingReviewError::Generic { code }), + 422 => Err(PullsDeletePendingReviewError::Status422(github_response.to_json()?).into()), + 404 => Err(PullsDeletePendingReviewError::Status404(github_response.to_json()?).into()), + code => Err(PullsDeletePendingReviewError::Generic { code }.into()), } } } @@ -1638,19 +1788,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for delete_review_comment](https://docs.github.com/rest/pulls/comments#delete-a-review-comment-for-a-pull-request) /// /// --- - pub async fn delete_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), PullsDeleteReviewCommentError> { + pub async fn delete_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1662,8 +1812,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PullsDeleteReviewCommentError::Status404(github_response.to_json_async().await?)), - code => Err(PullsDeleteReviewCommentError::Generic { code }), + 404 => Err(PullsDeleteReviewCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(PullsDeleteReviewCommentError::Generic { code }.into()), } } } @@ -1678,7 +1828,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_review_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), PullsDeleteReviewCommentError> { + pub fn delete_review_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -1690,7 +1840,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1702,8 +1852,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PullsDeleteReviewCommentError::Status404(github_response.to_json()?)), - code => Err(PullsDeleteReviewCommentError::Generic { code }), + 404 => Err(PullsDeleteReviewCommentError::Status404(github_response.to_json()?).into()), + code => Err(PullsDeleteReviewCommentError::Generic { code }.into()), } } } @@ -1727,19 +1877,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for dismiss_review](https://docs.github.com/rest/pulls/reviews#dismiss-a-review-for-a-pull-request) /// /// --- - pub async fn dismiss_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsDismissReview) -> Result { + pub async fn dismiss_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsDismissReview) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/dismissals", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutPullsDismissReview::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1751,9 +1901,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PullsDismissReviewError::Status404(github_response.to_json_async().await?)), - 422 => Err(PullsDismissReviewError::Status422(github_response.to_json_async().await?)), - code => Err(PullsDismissReviewError::Generic { code }), + 404 => Err(PullsDismissReviewError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(PullsDismissReviewError::Status422(github_response.to_json_async().await?).into()), + code => Err(PullsDismissReviewError::Generic { code }.into()), } } } @@ -1778,19 +1928,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn dismiss_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsDismissReview) -> Result { + pub fn dismiss_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsDismissReview) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/dismissals", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutPullsDismissReview::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1802,9 +1952,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PullsDismissReviewError::Status404(github_response.to_json()?)), - 422 => Err(PullsDismissReviewError::Status422(github_response.to_json()?)), - code => Err(PullsDismissReviewError::Generic { code }), + 404 => Err(PullsDismissReviewError::Status404(github_response.to_json()?).into()), + 422 => Err(PullsDismissReviewError::Status422(github_response.to_json()?).into()), + code => Err(PullsDismissReviewError::Generic { code }.into()), } } } @@ -1840,19 +1990,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for get](https://docs.github.com/rest/pulls/pulls#get-a-pull-request) /// /// --- - pub async fn get_async(&self, owner: &str, repo: &str, pull_number: i32) -> Result { + pub async fn get_async(&self, owner: &str, repo: &str, pull_number: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1864,12 +2014,12 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(PullsGetError::Status304), - 404 => Err(PullsGetError::Status404(github_response.to_json_async().await?)), - 406 => Err(PullsGetError::Status406(github_response.to_json_async().await?)), - 500 => Err(PullsGetError::Status500(github_response.to_json_async().await?)), - 503 => Err(PullsGetError::Status503(github_response.to_json_async().await?)), - code => Err(PullsGetError::Generic { code }), + 304 => Err(PullsGetError::Status304.into()), + 404 => Err(PullsGetError::Status404(github_response.to_json_async().await?).into()), + 406 => Err(PullsGetError::Status406(github_response.to_json_async().await?).into()), + 500 => Err(PullsGetError::Status500(github_response.to_json_async().await?).into()), + 503 => Err(PullsGetError::Status503(github_response.to_json_async().await?).into()), + code => Err(PullsGetError::Generic { code }.into()), } } } @@ -1906,7 +2056,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get(&self, owner: &str, repo: &str, pull_number: i32) -> Result { + pub fn get(&self, owner: &str, repo: &str, pull_number: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -1918,7 +2068,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1930,12 +2080,12 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(PullsGetError::Status304), - 404 => Err(PullsGetError::Status404(github_response.to_json()?)), - 406 => Err(PullsGetError::Status406(github_response.to_json()?)), - 500 => Err(PullsGetError::Status500(github_response.to_json()?)), - 503 => Err(PullsGetError::Status503(github_response.to_json()?)), - code => Err(PullsGetError::Generic { code }), + 304 => Err(PullsGetError::Status304.into()), + 404 => Err(PullsGetError::Status404(github_response.to_json()?).into()), + 406 => Err(PullsGetError::Status406(github_response.to_json()?).into()), + 500 => Err(PullsGetError::Status500(github_response.to_json()?).into()), + 503 => Err(PullsGetError::Status503(github_response.to_json()?).into()), + code => Err(PullsGetError::Generic { code }.into()), } } } @@ -1956,19 +2106,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for get_review](https://docs.github.com/rest/pulls/reviews#get-a-review-for-a-pull-request) /// /// --- - pub async fn get_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result { + pub async fn get_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1980,8 +2130,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PullsGetReviewError::Status404(github_response.to_json_async().await?)), - code => Err(PullsGetReviewError::Generic { code }), + 404 => Err(PullsGetReviewError::Status404(github_response.to_json_async().await?).into()), + code => Err(PullsGetReviewError::Generic { code }.into()), } } } @@ -2003,7 +2153,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result { + pub fn get_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); @@ -2015,7 +2165,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2027,8 +2177,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PullsGetReviewError::Status404(github_response.to_json()?)), - code => Err(PullsGetReviewError::Generic { code }), + 404 => Err(PullsGetReviewError::Status404(github_response.to_json()?).into()), + code => Err(PullsGetReviewError::Generic { code }.into()), } } } @@ -2049,19 +2199,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for get_review_comment](https://docs.github.com/rest/pulls/comments#get-a-review-comment-for-a-pull-request) /// /// --- - pub async fn get_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result { + pub async fn get_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2073,8 +2223,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PullsGetReviewCommentError::Status404(github_response.to_json_async().await?)), - code => Err(PullsGetReviewCommentError::Generic { code }), + 404 => Err(PullsGetReviewCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(PullsGetReviewCommentError::Generic { code }.into()), } } } @@ -2096,7 +2246,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_review_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result { + pub fn get_review_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -2108,7 +2258,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2120,8 +2270,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PullsGetReviewCommentError::Status404(github_response.to_json()?)), - code => Err(PullsGetReviewCommentError::Generic { code }), + 404 => Err(PullsGetReviewCommentError::Status404(github_response.to_json()?).into()), + code => Err(PullsGetReviewCommentError::Generic { code }.into()), } } } @@ -2148,7 +2298,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for list](https://docs.github.com/rest/pulls/pulls#list-pull-requests) /// /// --- - pub async fn list_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, PullsListError> { + pub async fn list_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo); @@ -2159,12 +2309,12 @@ impl<'api, C: Client> Pulls<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2176,9 +2326,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(PullsListError::Status304), - 422 => Err(PullsListError::Status422(github_response.to_json_async().await?)), - code => Err(PullsListError::Generic { code }), + 304 => Err(PullsListError::Status304.into()), + 422 => Err(PullsListError::Status422(github_response.to_json_async().await?).into()), + code => Err(PullsListError::Generic { code }.into()), } } } @@ -2206,7 +2356,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, PullsListError> { + pub fn list(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo); @@ -2223,7 +2373,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2235,9 +2385,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(PullsListError::Status304), - 422 => Err(PullsListError::Status422(github_response.to_json()?)), - code => Err(PullsListError::Generic { code }), + 304 => Err(PullsListError::Status304.into()), + 422 => Err(PullsListError::Status422(github_response.to_json()?).into()), + code => Err(PullsListError::Generic { code }.into()), } } } @@ -2258,7 +2408,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for list_comments_for_review](https://docs.github.com/rest/pulls/reviews#list-comments-for-a-pull-request-review) /// /// --- - pub async fn list_comments_for_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, query_params: Option>) -> Result, PullsListCommentsForReviewError> { + pub async fn list_comments_for_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); @@ -2269,12 +2419,12 @@ impl<'api, C: Client> Pulls<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2286,8 +2436,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PullsListCommentsForReviewError::Status404(github_response.to_json_async().await?)), - code => Err(PullsListCommentsForReviewError::Generic { code }), + 404 => Err(PullsListCommentsForReviewError::Status404(github_response.to_json_async().await?).into()), + code => Err(PullsListCommentsForReviewError::Generic { code }.into()), } } } @@ -2309,7 +2459,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_comments_for_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, query_params: Option>) -> Result, PullsListCommentsForReviewError> { + pub fn list_comments_for_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); @@ -2326,7 +2476,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2338,8 +2488,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PullsListCommentsForReviewError::Status404(github_response.to_json()?)), - code => Err(PullsListCommentsForReviewError::Generic { code }), + 404 => Err(PullsListCommentsForReviewError::Status404(github_response.to_json()?).into()), + code => Err(PullsListCommentsForReviewError::Generic { code }.into()), } } } @@ -2362,7 +2512,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for list_commits](https://docs.github.com/rest/pulls/pulls#list-commits-on-a-pull-request) /// /// --- - pub async fn list_commits_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, PullsListCommitsError> { + pub async fn list_commits_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/commits", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -2373,12 +2523,12 @@ impl<'api, C: Client> Pulls<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2390,7 +2540,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PullsListCommitsError::Generic { code }), + code => Err(PullsListCommitsError::Generic { code }.into()), } } } @@ -2414,7 +2564,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_commits(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, PullsListCommitsError> { + pub fn list_commits(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/commits", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -2431,7 +2581,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2443,7 +2593,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PullsListCommitsError::Generic { code }), + code => Err(PullsListCommitsError::Generic { code }.into()), } } } @@ -2467,7 +2617,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for list_files](https://docs.github.com/rest/pulls/pulls#list-pull-requests-files) /// /// --- - pub async fn list_files_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, PullsListFilesError> { + pub async fn list_files_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/files", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -2478,12 +2628,12 @@ impl<'api, C: Client> Pulls<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2495,10 +2645,10 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(PullsListFilesError::Status422(github_response.to_json_async().await?)), - 500 => Err(PullsListFilesError::Status500(github_response.to_json_async().await?)), - 503 => Err(PullsListFilesError::Status503(github_response.to_json_async().await?)), - code => Err(PullsListFilesError::Generic { code }), + 422 => Err(PullsListFilesError::Status422(github_response.to_json_async().await?).into()), + 500 => Err(PullsListFilesError::Status500(github_response.to_json_async().await?).into()), + 503 => Err(PullsListFilesError::Status503(github_response.to_json_async().await?).into()), + code => Err(PullsListFilesError::Generic { code }.into()), } } } @@ -2523,7 +2673,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_files(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, PullsListFilesError> { + pub fn list_files(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/files", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -2540,7 +2690,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2552,10 +2702,10 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(PullsListFilesError::Status422(github_response.to_json()?)), - 500 => Err(PullsListFilesError::Status500(github_response.to_json()?)), - 503 => Err(PullsListFilesError::Status503(github_response.to_json()?)), - code => Err(PullsListFilesError::Generic { code }), + 422 => Err(PullsListFilesError::Status422(github_response.to_json()?).into()), + 500 => Err(PullsListFilesError::Status500(github_response.to_json()?).into()), + 503 => Err(PullsListFilesError::Status503(github_response.to_json()?).into()), + code => Err(PullsListFilesError::Generic { code }.into()), } } } @@ -2569,19 +2719,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for list_requested_reviewers](https://docs.github.com/rest/pulls/review-requests#get-all-requested-reviewers-for-a-pull-request) /// /// --- - pub async fn list_requested_reviewers_async(&self, owner: &str, repo: &str, pull_number: i32) -> Result { + pub async fn list_requested_reviewers_async(&self, owner: &str, repo: &str, pull_number: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2593,7 +2743,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PullsListRequestedReviewersError::Generic { code }), + code => Err(PullsListRequestedReviewersError::Generic { code }.into()), } } } @@ -2608,7 +2758,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_requested_reviewers(&self, owner: &str, repo: &str, pull_number: i32) -> Result { + pub fn list_requested_reviewers(&self, owner: &str, repo: &str, pull_number: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -2620,7 +2770,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2632,7 +2782,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PullsListRequestedReviewersError::Generic { code }), + code => Err(PullsListRequestedReviewersError::Generic { code }.into()), } } } @@ -2654,7 +2804,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for list_review_comments](https://docs.github.com/rest/pulls/comments#list-review-comments-on-a-pull-request) /// /// --- - pub async fn list_review_comments_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>>) -> Result, PullsListReviewCommentsError> { + pub async fn list_review_comments_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -2665,12 +2815,12 @@ impl<'api, C: Client> Pulls<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2682,7 +2832,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PullsListReviewCommentsError::Generic { code }), + code => Err(PullsListReviewCommentsError::Generic { code }.into()), } } } @@ -2705,7 +2855,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_review_comments(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>>) -> Result, PullsListReviewCommentsError> { + pub fn list_review_comments(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -2722,7 +2872,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2734,7 +2884,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PullsListReviewCommentsError::Generic { code }), + code => Err(PullsListReviewCommentsError::Generic { code }.into()), } } } @@ -2756,7 +2906,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for list_review_comments_for_repo](https://docs.github.com/rest/pulls/comments#list-review-comments-in-a-repository) /// /// --- - pub async fn list_review_comments_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, PullsListReviewCommentsForRepoError> { + pub async fn list_review_comments_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/comments", super::GITHUB_BASE_API_URL, owner, repo); @@ -2767,12 +2917,12 @@ impl<'api, C: Client> Pulls<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2784,7 +2934,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PullsListReviewCommentsForRepoError::Generic { code }), + code => Err(PullsListReviewCommentsForRepoError::Generic { code }.into()), } } } @@ -2807,7 +2957,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_review_comments_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, PullsListReviewCommentsForRepoError> { + pub fn list_review_comments_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/comments", super::GITHUB_BASE_API_URL, owner, repo); @@ -2824,7 +2974,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2836,7 +2986,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PullsListReviewCommentsForRepoError::Generic { code }), + code => Err(PullsListReviewCommentsForRepoError::Generic { code }.into()), } } } @@ -2857,7 +3007,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for list_reviews](https://docs.github.com/rest/pulls/reviews#list-reviews-for-a-pull-request) /// /// --- - pub async fn list_reviews_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, PullsListReviewsError> { + pub async fn list_reviews_async(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -2868,12 +3018,12 @@ impl<'api, C: Client> Pulls<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2885,7 +3035,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PullsListReviewsError::Generic { code }), + code => Err(PullsListReviewsError::Generic { code }.into()), } } } @@ -2907,7 +3057,7 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_reviews(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, PullsListReviewsError> { + pub fn list_reviews(&self, owner: &str, repo: &str, pull_number: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews", super::GITHUB_BASE_API_URL, owner, repo, pull_number); @@ -2924,7 +3074,7 @@ impl<'api, C: Client> Pulls<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2936,7 +3086,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PullsListReviewsError::Generic { code }), + code => Err(PullsListReviewsError::Generic { code }.into()), } } } @@ -2951,19 +3101,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for merge](https://docs.github.com/rest/pulls/pulls#merge-a-pull-request) /// /// --- - pub async fn merge_async(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsMerge) -> Result { + pub async fn merge_async(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsMerge) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/merge", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(PutPullsMerge::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2975,12 +3125,12 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 405 => Err(PullsMergeError::Status405(github_response.to_json_async().await?)), - 409 => Err(PullsMergeError::Status409(github_response.to_json_async().await?)), - 422 => Err(PullsMergeError::Status422(github_response.to_json_async().await?)), - 403 => Err(PullsMergeError::Status403(github_response.to_json_async().await?)), - 404 => Err(PullsMergeError::Status404(github_response.to_json_async().await?)), - code => Err(PullsMergeError::Generic { code }), + 405 => Err(PullsMergeError::Status405(github_response.to_json_async().await?).into()), + 409 => Err(PullsMergeError::Status409(github_response.to_json_async().await?).into()), + 422 => Err(PullsMergeError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(PullsMergeError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(PullsMergeError::Status404(github_response.to_json_async().await?).into()), + code => Err(PullsMergeError::Generic { code }.into()), } } } @@ -2996,19 +3146,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn merge(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsMerge) -> Result { + pub fn merge(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsMerge) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/merge", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(PutPullsMerge::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3020,12 +3170,12 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 405 => Err(PullsMergeError::Status405(github_response.to_json()?)), - 409 => Err(PullsMergeError::Status409(github_response.to_json()?)), - 422 => Err(PullsMergeError::Status422(github_response.to_json()?)), - 403 => Err(PullsMergeError::Status403(github_response.to_json()?)), - 404 => Err(PullsMergeError::Status404(github_response.to_json()?)), - code => Err(PullsMergeError::Generic { code }), + 405 => Err(PullsMergeError::Status405(github_response.to_json()?).into()), + 409 => Err(PullsMergeError::Status409(github_response.to_json()?).into()), + 422 => Err(PullsMergeError::Status422(github_response.to_json()?).into()), + 403 => Err(PullsMergeError::Status403(github_response.to_json()?).into()), + 404 => Err(PullsMergeError::Status404(github_response.to_json()?).into()), + code => Err(PullsMergeError::Generic { code }.into()), } } } @@ -3039,19 +3189,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for remove_requested_reviewers](https://docs.github.com/rest/pulls/review-requests#remove-requested-reviewers-from-a-pull-request) /// /// --- - pub async fn remove_requested_reviewers_async(&self, owner: &str, repo: &str, pull_number: i32, body: DeletePullsRemoveRequestedReviewers) -> Result { + pub async fn remove_requested_reviewers_async(&self, owner: &str, repo: &str, pull_number: i32, body: DeletePullsRemoveRequestedReviewers) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(DeletePullsRemoveRequestedReviewers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3063,8 +3213,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(PullsRemoveRequestedReviewersError::Status422(github_response.to_json_async().await?)), - code => Err(PullsRemoveRequestedReviewersError::Generic { code }), + 422 => Err(PullsRemoveRequestedReviewersError::Status422(github_response.to_json_async().await?).into()), + code => Err(PullsRemoveRequestedReviewersError::Generic { code }.into()), } } } @@ -3079,19 +3229,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_requested_reviewers(&self, owner: &str, repo: &str, pull_number: i32, body: DeletePullsRemoveRequestedReviewers) -> Result { + pub fn remove_requested_reviewers(&self, owner: &str, repo: &str, pull_number: i32, body: DeletePullsRemoveRequestedReviewers) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(DeletePullsRemoveRequestedReviewers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3103,8 +3253,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(PullsRemoveRequestedReviewersError::Status422(github_response.to_json()?)), - code => Err(PullsRemoveRequestedReviewersError::Generic { code }), + 422 => Err(PullsRemoveRequestedReviewersError::Status422(github_response.to_json()?).into()), + code => Err(PullsRemoveRequestedReviewersError::Generic { code }.into()), } } } @@ -3119,19 +3269,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for request_reviewers](https://docs.github.com/rest/pulls/review-requests#request-reviewers-for-a-pull-request) /// /// --- - pub async fn request_reviewers_async(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsRequestReviewers) -> Result { + pub async fn request_reviewers_async(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsRequestReviewers) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsRequestReviewers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3143,9 +3293,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(PullsRequestReviewersError::Status422), - 403 => Err(PullsRequestReviewersError::Status403(github_response.to_json_async().await?)), - code => Err(PullsRequestReviewersError::Generic { code }), + 422 => Err(PullsRequestReviewersError::Status422.into()), + 403 => Err(PullsRequestReviewersError::Status403(github_response.to_json_async().await?).into()), + code => Err(PullsRequestReviewersError::Generic { code }.into()), } } } @@ -3161,19 +3311,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn request_reviewers(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsRequestReviewers) -> Result { + pub fn request_reviewers(&self, owner: &str, repo: &str, pull_number: i32, body: PostPullsRequestReviewers) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/requested_reviewers", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsRequestReviewers::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3185,9 +3335,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(PullsRequestReviewersError::Status422), - 403 => Err(PullsRequestReviewersError::Status403(github_response.to_json()?)), - code => Err(PullsRequestReviewersError::Generic { code }), + 422 => Err(PullsRequestReviewersError::Status422.into()), + 403 => Err(PullsRequestReviewersError::Status403(github_response.to_json()?).into()), + code => Err(PullsRequestReviewersError::Generic { code }.into()), } } } @@ -3208,19 +3358,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for submit_review](https://docs.github.com/rest/pulls/reviews#submit-a-review-for-a-pull-request) /// /// --- - pub async fn submit_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PostPullsSubmitReview) -> Result { + pub async fn submit_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PostPullsSubmitReview) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/events", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsSubmitReview::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3232,10 +3382,10 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(PullsSubmitReviewError::Status404(github_response.to_json_async().await?)), - 422 => Err(PullsSubmitReviewError::Status422(github_response.to_json_async().await?)), - 403 => Err(PullsSubmitReviewError::Status403(github_response.to_json_async().await?)), - code => Err(PullsSubmitReviewError::Generic { code }), + 404 => Err(PullsSubmitReviewError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(PullsSubmitReviewError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(PullsSubmitReviewError::Status403(github_response.to_json_async().await?).into()), + code => Err(PullsSubmitReviewError::Generic { code }.into()), } } } @@ -3257,19 +3407,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn submit_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PostPullsSubmitReview) -> Result { + pub fn submit_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PostPullsSubmitReview) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}/events", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostPullsSubmitReview::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3281,10 +3431,10 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(PullsSubmitReviewError::Status404(github_response.to_json()?)), - 422 => Err(PullsSubmitReviewError::Status422(github_response.to_json()?)), - 403 => Err(PullsSubmitReviewError::Status403(github_response.to_json()?)), - code => Err(PullsSubmitReviewError::Generic { code }), + 404 => Err(PullsSubmitReviewError::Status404(github_response.to_json()?).into()), + 422 => Err(PullsSubmitReviewError::Status422(github_response.to_json()?).into()), + 403 => Err(PullsSubmitReviewError::Status403(github_response.to_json()?).into()), + code => Err(PullsSubmitReviewError::Generic { code }.into()), } } } @@ -3307,19 +3457,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for update](https://docs.github.com/rest/pulls/pulls#update-a-pull-request) /// /// --- - pub async fn update_async(&self, owner: &str, repo: &str, pull_number: i32, body: PatchPullsUpdate) -> Result { + pub async fn update_async(&self, owner: &str, repo: &str, pull_number: i32, body: PatchPullsUpdate) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchPullsUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3331,9 +3481,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(PullsUpdateError::Status422(github_response.to_json_async().await?)), - 403 => Err(PullsUpdateError::Status403(github_response.to_json_async().await?)), - code => Err(PullsUpdateError::Generic { code }), + 422 => Err(PullsUpdateError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(PullsUpdateError::Status403(github_response.to_json_async().await?).into()), + code => Err(PullsUpdateError::Generic { code }.into()), } } } @@ -3357,19 +3507,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update(&self, owner: &str, repo: &str, pull_number: i32, body: PatchPullsUpdate) -> Result { + pub fn update(&self, owner: &str, repo: &str, pull_number: i32, body: PatchPullsUpdate) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchPullsUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3381,9 +3531,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(PullsUpdateError::Status422(github_response.to_json()?)), - 403 => Err(PullsUpdateError::Status403(github_response.to_json()?)), - code => Err(PullsUpdateError::Generic { code }), + 422 => Err(PullsUpdateError::Status422(github_response.to_json()?).into()), + 403 => Err(PullsUpdateError::Status403(github_response.to_json()?).into()), + code => Err(PullsUpdateError::Generic { code }.into()), } } } @@ -3398,19 +3548,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for update_branch](https://docs.github.com/rest/pulls/pulls#update-a-pull-request-branch) /// /// --- - pub async fn update_branch_async(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsUpdateBranch) -> Result { + pub async fn update_branch_async(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsUpdateBranch) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/update-branch", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(PutPullsUpdateBranch::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3422,9 +3572,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(PullsUpdateBranchError::Status422(github_response.to_json_async().await?)), - 403 => Err(PullsUpdateBranchError::Status403(github_response.to_json_async().await?)), - code => Err(PullsUpdateBranchError::Generic { code }), + 422 => Err(PullsUpdateBranchError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(PullsUpdateBranchError::Status403(github_response.to_json_async().await?).into()), + code => Err(PullsUpdateBranchError::Generic { code }.into()), } } } @@ -3440,19 +3590,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_branch(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsUpdateBranch) -> Result { + pub fn update_branch(&self, owner: &str, repo: &str, pull_number: i32, body: PutPullsUpdateBranch) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/update-branch", super::GITHUB_BASE_API_URL, owner, repo, pull_number); let req = GitHubRequest { uri: request_uri, - body: Some(PutPullsUpdateBranch::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3464,9 +3614,9 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(PullsUpdateBranchError::Status422(github_response.to_json()?)), - 403 => Err(PullsUpdateBranchError::Status403(github_response.to_json()?)), - code => Err(PullsUpdateBranchError::Generic { code }), + 422 => Err(PullsUpdateBranchError::Status422(github_response.to_json()?).into()), + 403 => Err(PullsUpdateBranchError::Status403(github_response.to_json()?).into()), + code => Err(PullsUpdateBranchError::Generic { code }.into()), } } } @@ -3487,19 +3637,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for update_review](https://docs.github.com/rest/pulls/reviews#update-a-review-for-a-pull-request) /// /// --- - pub async fn update_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsUpdateReview) -> Result { + pub async fn update_review_async(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsUpdateReview) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutPullsUpdateReview::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3511,8 +3661,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(PullsUpdateReviewError::Status422(github_response.to_json_async().await?)), - code => Err(PullsUpdateReviewError::Generic { code }), + 422 => Err(PullsUpdateReviewError::Status422(github_response.to_json_async().await?).into()), + code => Err(PullsUpdateReviewError::Generic { code }.into()), } } } @@ -3534,19 +3684,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsUpdateReview) -> Result { + pub fn update_review(&self, owner: &str, repo: &str, pull_number: i32, review_id: i32, body: PutPullsUpdateReview) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/{}/reviews/{}", super::GITHUB_BASE_API_URL, owner, repo, pull_number, review_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutPullsUpdateReview::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3558,8 +3708,8 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(PullsUpdateReviewError::Status422(github_response.to_json()?)), - code => Err(PullsUpdateReviewError::Generic { code }), + 422 => Err(PullsUpdateReviewError::Status422(github_response.to_json()?).into()), + code => Err(PullsUpdateReviewError::Generic { code }.into()), } } } @@ -3580,19 +3730,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// [GitHub API docs for update_review_comment](https://docs.github.com/rest/pulls/comments#update-a-review-comment-for-a-pull-request) /// /// --- - pub async fn update_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PatchPullsUpdateReviewComment) -> Result { + pub async fn update_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PatchPullsUpdateReviewComment) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchPullsUpdateReviewComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3604,7 +3754,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(PullsUpdateReviewCommentError::Generic { code }), + code => Err(PullsUpdateReviewCommentError::Generic { code }.into()), } } } @@ -3626,19 +3776,19 @@ impl<'api, C: Client> Pulls<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_review_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PatchPullsUpdateReviewComment) -> Result { + pub fn update_review_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PatchPullsUpdateReviewComment) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchPullsUpdateReviewComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3650,7 +3800,7 @@ impl<'api, C: Client> Pulls<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(PullsUpdateReviewCommentError::Generic { code }), + code => Err(PullsUpdateReviewCommentError::Generic { code }.into()), } } } diff --git a/src/endpoints/rate_limit.rs b/src/endpoints/rate_limit.rs index b3e9e92..f8e3647 100644 --- a/src/endpoints/rate_limit.rs +++ b/src/endpoints/rate_limit.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct RateLimit<'api, C: Client> { +pub struct RateLimit<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> RateLimit { +pub fn new(client: &C) -> RateLimit where AdapterError: From<::Err> { RateLimit { client } } /// Errors for the [Get rate limit status for the authenticated user](RateLimit::get_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum RateLimitGetError { - #[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("Resource not found")] @@ -51,9 +41,25 @@ pub enum RateLimitGetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: RateLimitGetError) -> Self { + let (description, status_code) = match err { + RateLimitGetError::Status304 => (String::from("Not modified"), 304), + RateLimitGetError::Status404(_) => (String::from("Resource not found"), 404), + RateLimitGetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + -impl<'api, C: Client> RateLimit<'api, C> { +impl<'api, C: Client> RateLimit<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Get rate limit status for the authenticated user @@ -78,19 +84,19 @@ impl<'api, C: Client> RateLimit<'api, C> { /// [GitHub API docs for get](https://docs.github.com/rest/rate-limit/rate-limit#get-rate-limit-status-for-the-authenticated-user) /// /// --- - pub async fn get_async(&self) -> Result { + pub async fn get_async(&self) -> Result { let request_uri = format!("{}/rate_limit", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -102,9 +108,9 @@ impl<'api, C: Client> RateLimit<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(RateLimitGetError::Status304), - 404 => Err(RateLimitGetError::Status404(github_response.to_json_async().await?)), - code => Err(RateLimitGetError::Generic { code }), + 304 => Err(RateLimitGetError::Status304.into()), + 404 => Err(RateLimitGetError::Status404(github_response.to_json_async().await?).into()), + code => Err(RateLimitGetError::Generic { code }.into()), } } } @@ -134,7 +140,7 @@ impl<'api, C: Client> RateLimit<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get(&self) -> Result { + pub fn get(&self) -> Result { let request_uri = format!("{}/rate_limit", super::GITHUB_BASE_API_URL); @@ -146,7 +152,7 @@ impl<'api, C: Client> RateLimit<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -158,9 +164,9 @@ impl<'api, C: Client> RateLimit<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(RateLimitGetError::Status304), - 404 => Err(RateLimitGetError::Status404(github_response.to_json()?)), - code => Err(RateLimitGetError::Generic { code }), + 304 => Err(RateLimitGetError::Status304.into()), + 404 => Err(RateLimitGetError::Status404(github_response.to_json()?).into()), + code => Err(RateLimitGetError::Generic { code }.into()), } } } diff --git a/src/endpoints/reactions.rs b/src/endpoints/reactions.rs index 074deed..0120f31 100644 --- a/src/endpoints/reactions.rs +++ b/src/endpoints/reactions.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Reactions<'api, C: Client> { +pub struct Reactions<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Reactions { +pub fn new(client: &C) -> Reactions where AdapterError: From<::Err> { Reactions { client } } /// Errors for the [Create reaction for a commit comment](Reactions::create_for_commit_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsCreateForCommitCommentError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Reaction created")] Status201(Reaction), #[error("Validation failed, or the endpoint has been spammed.")] @@ -51,19 +41,25 @@ pub enum ReactionsCreateForCommitCommentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReactionsCreateForCommitCommentError) -> Self { + let (description, status_code) = match err { + ReactionsCreateForCommitCommentError::Status201(_) => (String::from("Reaction created"), 201), + ReactionsCreateForCommitCommentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReactionsCreateForCommitCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create reaction for an issue](Reactions::create_for_issue_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsCreateForIssueError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status201(Reaction), #[error("Validation failed, or the endpoint has been spammed.")] @@ -72,19 +68,25 @@ pub enum ReactionsCreateForIssueError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReactionsCreateForIssueError) -> Self { + let (description, status_code) = match err { + ReactionsCreateForIssueError::Status201(_) => (String::from("Response"), 201), + ReactionsCreateForIssueError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReactionsCreateForIssueError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create reaction for an issue comment](Reactions::create_for_issue_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsCreateForIssueCommentError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Reaction created")] Status201(Reaction), #[error("Validation failed, or the endpoint has been spammed.")] @@ -93,19 +95,25 @@ pub enum ReactionsCreateForIssueCommentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReactionsCreateForIssueCommentError) -> Self { + let (description, status_code) = match err { + ReactionsCreateForIssueCommentError::Status201(_) => (String::from("Reaction created"), 201), + ReactionsCreateForIssueCommentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReactionsCreateForIssueCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create reaction for a pull request review comment](Reactions::create_for_pull_request_review_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsCreateForPullRequestReviewCommentError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Reaction created")] Status201(Reaction), #[error("Validation failed, or the endpoint has been spammed.")] @@ -114,19 +122,25 @@ pub enum ReactionsCreateForPullRequestReviewCommentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReactionsCreateForPullRequestReviewCommentError) -> Self { + let (description, status_code) = match err { + ReactionsCreateForPullRequestReviewCommentError::Status201(_) => (String::from("Reaction created"), 201), + ReactionsCreateForPullRequestReviewCommentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReactionsCreateForPullRequestReviewCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create reaction for a release](Reactions::create_for_release_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsCreateForReleaseError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Reaction created")] Status201(Reaction), #[error("Validation failed, or the endpoint has been spammed.")] @@ -135,229 +149,286 @@ pub enum ReactionsCreateForReleaseError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReactionsCreateForReleaseError) -> Self { + let (description, status_code) = match err { + ReactionsCreateForReleaseError::Status201(_) => (String::from("Reaction created"), 201), + ReactionsCreateForReleaseError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReactionsCreateForReleaseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create reaction for a team discussion comment](Reactions::create_for_team_discussion_comment_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsCreateForTeamDiscussionCommentInOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status201(Reaction), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReactionsCreateForTeamDiscussionCommentInOrgError) -> Self { + let (description, status_code) = match err { + ReactionsCreateForTeamDiscussionCommentInOrgError::Status201(_) => (String::from("Response"), 201), + ReactionsCreateForTeamDiscussionCommentInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create reaction for a team discussion comment (Legacy)](Reactions::create_for_team_discussion_comment_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsCreateForTeamDiscussionCommentLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsCreateForTeamDiscussionCommentLegacyError) -> Self { + let (description, status_code) = match err { + ReactionsCreateForTeamDiscussionCommentLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create reaction for a team discussion](Reactions::create_for_team_discussion_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsCreateForTeamDiscussionInOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status201(Reaction), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReactionsCreateForTeamDiscussionInOrgError) -> Self { + let (description, status_code) = match err { + ReactionsCreateForTeamDiscussionInOrgError::Status201(_) => (String::from("Response"), 201), + ReactionsCreateForTeamDiscussionInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create reaction for a team discussion (Legacy)](Reactions::create_for_team_discussion_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsCreateForTeamDiscussionLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsCreateForTeamDiscussionLegacyError) -> Self { + let (description, status_code) = match err { + ReactionsCreateForTeamDiscussionLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a commit comment reaction](Reactions::delete_for_commit_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsDeleteForCommitCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsDeleteForCommitCommentError) -> Self { + let (description, status_code) = match err { + ReactionsDeleteForCommitCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an issue reaction](Reactions::delete_for_issue_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsDeleteForIssueError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsDeleteForIssueError) -> Self { + let (description, status_code) = match err { + ReactionsDeleteForIssueError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an issue comment reaction](Reactions::delete_for_issue_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsDeleteForIssueCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsDeleteForIssueCommentError) -> Self { + let (description, status_code) = match err { + ReactionsDeleteForIssueCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a pull request comment reaction](Reactions::delete_for_pull_request_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsDeleteForPullRequestCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsDeleteForPullRequestCommentError) -> Self { + let (description, status_code) = match err { + ReactionsDeleteForPullRequestCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a release reaction](Reactions::delete_for_release_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsDeleteForReleaseError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsDeleteForReleaseError) -> Self { + let (description, status_code) = match err { + ReactionsDeleteForReleaseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete team discussion reaction](Reactions::delete_for_team_discussion_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsDeleteForTeamDiscussionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsDeleteForTeamDiscussionError) -> Self { + let (description, status_code) = match err { + ReactionsDeleteForTeamDiscussionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete team discussion comment reaction](Reactions::delete_for_team_discussion_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsDeleteForTeamDiscussionCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsDeleteForTeamDiscussionCommentError) -> Self { + let (description, status_code) = match err { + ReactionsDeleteForTeamDiscussionCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List reactions for a commit comment](Reactions::list_for_commit_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsListForCommitCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsListForCommitCommentError) -> Self { + let (description, status_code) = match err { + ReactionsListForCommitCommentError::Status404(_) => (String::from("Resource not found"), 404), + ReactionsListForCommitCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List reactions for an issue](Reactions::list_for_issue_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsListForIssueError { - #[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("Gone")] @@ -366,131 +437,178 @@ pub enum ReactionsListForIssueError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReactionsListForIssueError) -> Self { + let (description, status_code) = match err { + ReactionsListForIssueError::Status404(_) => (String::from("Resource not found"), 404), + ReactionsListForIssueError::Status410(_) => (String::from("Gone"), 410), + ReactionsListForIssueError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List reactions for an issue comment](Reactions::list_for_issue_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsListForIssueCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsListForIssueCommentError) -> Self { + let (description, status_code) = match err { + ReactionsListForIssueCommentError::Status404(_) => (String::from("Resource not found"), 404), + ReactionsListForIssueCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List reactions for a pull request review comment](Reactions::list_for_pull_request_review_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsListForPullRequestReviewCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsListForPullRequestReviewCommentError) -> Self { + let (description, status_code) = match err { + ReactionsListForPullRequestReviewCommentError::Status404(_) => (String::from("Resource not found"), 404), + ReactionsListForPullRequestReviewCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List reactions for a release](Reactions::list_for_release_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsListForReleaseError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsListForReleaseError) -> Self { + let (description, status_code) = match err { + ReactionsListForReleaseError::Status404(_) => (String::from("Resource not found"), 404), + ReactionsListForReleaseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List reactions for a team discussion comment](Reactions::list_for_team_discussion_comment_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsListForTeamDiscussionCommentInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsListForTeamDiscussionCommentInOrgError) -> Self { + let (description, status_code) = match err { + ReactionsListForTeamDiscussionCommentInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List reactions for a team discussion comment (Legacy)](Reactions::list_for_team_discussion_comment_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsListForTeamDiscussionCommentLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsListForTeamDiscussionCommentLegacyError) -> Self { + let (description, status_code) = match err { + ReactionsListForTeamDiscussionCommentLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List reactions for a team discussion](Reactions::list_for_team_discussion_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsListForTeamDiscussionInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsListForTeamDiscussionInOrgError) -> Self { + let (description, status_code) = match err { + ReactionsListForTeamDiscussionInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List reactions for a team discussion (Legacy)](Reactions::list_for_team_discussion_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReactionsListForTeamDiscussionLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReactionsListForTeamDiscussionLegacyError) -> Self { + let (description, status_code) = match err { + ReactionsListForTeamDiscussionLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List reactions for a commit comment](Reactions::list_for_commit_comment_async()) endpoint. #[derive(Default, Serialize)] @@ -970,7 +1088,7 @@ impl<'enc> From<&'enc PerPage> for ReactionsListForTeamDiscussionLegacyParams<'e } } -impl<'api, C: Client> Reactions<'api, C> { +impl<'api, C: Client> Reactions<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Create reaction for a commit comment @@ -980,19 +1098,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for create_for_commit_comment](https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-commit-comment) /// /// --- - pub async fn create_for_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForCommitComment) -> Result { + pub async fn create_for_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForCommitComment) -> Result { let request_uri = format!("{}/repos/{}/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForCommitComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1004,9 +1122,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForCommitCommentError::Status201(github_response.to_json_async().await?)), - 422 => Err(ReactionsCreateForCommitCommentError::Status422(github_response.to_json_async().await?)), - code => Err(ReactionsCreateForCommitCommentError::Generic { code }), + 201 => Err(ReactionsCreateForCommitCommentError::Status201(github_response.to_json_async().await?).into()), + 422 => Err(ReactionsCreateForCommitCommentError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReactionsCreateForCommitCommentError::Generic { code }.into()), } } } @@ -1021,19 +1139,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_commit_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForCommitComment) -> Result { + pub fn create_for_commit_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForCommitComment) -> Result { let request_uri = format!("{}/repos/{}/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForCommitComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1045,9 +1163,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForCommitCommentError::Status201(github_response.to_json()?)), - 422 => Err(ReactionsCreateForCommitCommentError::Status422(github_response.to_json()?)), - code => Err(ReactionsCreateForCommitCommentError::Generic { code }), + 201 => Err(ReactionsCreateForCommitCommentError::Status201(github_response.to_json()?).into()), + 422 => Err(ReactionsCreateForCommitCommentError::Status422(github_response.to_json()?).into()), + code => Err(ReactionsCreateForCommitCommentError::Generic { code }.into()), } } } @@ -1061,19 +1179,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for create_for_issue](https://docs.github.com/rest/reactions/reactions#create-reaction-for-an-issue) /// /// --- - pub async fn create_for_issue_async(&self, owner: &str, repo: &str, issue_number: i32, body: PostReactionsCreateForIssue) -> Result { + pub async fn create_for_issue_async(&self, owner: &str, repo: &str, issue_number: i32, body: PostReactionsCreateForIssue) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForIssue::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1085,9 +1203,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForIssueError::Status201(github_response.to_json_async().await?)), - 422 => Err(ReactionsCreateForIssueError::Status422(github_response.to_json_async().await?)), - code => Err(ReactionsCreateForIssueError::Generic { code }), + 201 => Err(ReactionsCreateForIssueError::Status201(github_response.to_json_async().await?).into()), + 422 => Err(ReactionsCreateForIssueError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReactionsCreateForIssueError::Generic { code }.into()), } } } @@ -1102,19 +1220,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_issue(&self, owner: &str, repo: &str, issue_number: i32, body: PostReactionsCreateForIssue) -> Result { + pub fn create_for_issue(&self, owner: &str, repo: &str, issue_number: i32, body: PostReactionsCreateForIssue) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, issue_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForIssue::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1126,9 +1244,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForIssueError::Status201(github_response.to_json()?)), - 422 => Err(ReactionsCreateForIssueError::Status422(github_response.to_json()?)), - code => Err(ReactionsCreateForIssueError::Generic { code }), + 201 => Err(ReactionsCreateForIssueError::Status201(github_response.to_json()?).into()), + 422 => Err(ReactionsCreateForIssueError::Status422(github_response.to_json()?).into()), + code => Err(ReactionsCreateForIssueError::Generic { code }.into()), } } } @@ -1142,19 +1260,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for create_for_issue_comment](https://docs.github.com/rest/reactions/reactions#create-reaction-for-an-issue-comment) /// /// --- - pub async fn create_for_issue_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForIssueComment) -> Result { + pub async fn create_for_issue_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForIssueComment) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForIssueComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1166,9 +1284,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForIssueCommentError::Status201(github_response.to_json_async().await?)), - 422 => Err(ReactionsCreateForIssueCommentError::Status422(github_response.to_json_async().await?)), - code => Err(ReactionsCreateForIssueCommentError::Generic { code }), + 201 => Err(ReactionsCreateForIssueCommentError::Status201(github_response.to_json_async().await?).into()), + 422 => Err(ReactionsCreateForIssueCommentError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReactionsCreateForIssueCommentError::Generic { code }.into()), } } } @@ -1183,19 +1301,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_issue_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForIssueComment) -> Result { + pub fn create_for_issue_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForIssueComment) -> Result { let request_uri = format!("{}/repos/{}/{}/issues/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForIssueComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1207,9 +1325,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForIssueCommentError::Status201(github_response.to_json()?)), - 422 => Err(ReactionsCreateForIssueCommentError::Status422(github_response.to_json()?)), - code => Err(ReactionsCreateForIssueCommentError::Generic { code }), + 201 => Err(ReactionsCreateForIssueCommentError::Status201(github_response.to_json()?).into()), + 422 => Err(ReactionsCreateForIssueCommentError::Status422(github_response.to_json()?).into()), + code => Err(ReactionsCreateForIssueCommentError::Generic { code }.into()), } } } @@ -1223,19 +1341,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for create_for_pull_request_review_comment](https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-pull-request-review-comment) /// /// --- - pub async fn create_for_pull_request_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForPullRequestReviewComment) -> Result { + pub async fn create_for_pull_request_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForPullRequestReviewComment) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForPullRequestReviewComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1247,9 +1365,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForPullRequestReviewCommentError::Status201(github_response.to_json_async().await?)), - 422 => Err(ReactionsCreateForPullRequestReviewCommentError::Status422(github_response.to_json_async().await?)), - code => Err(ReactionsCreateForPullRequestReviewCommentError::Generic { code }), + 201 => Err(ReactionsCreateForPullRequestReviewCommentError::Status201(github_response.to_json_async().await?).into()), + 422 => Err(ReactionsCreateForPullRequestReviewCommentError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReactionsCreateForPullRequestReviewCommentError::Generic { code }.into()), } } } @@ -1264,19 +1382,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_pull_request_review_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForPullRequestReviewComment) -> Result { + pub fn create_for_pull_request_review_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PostReactionsCreateForPullRequestReviewComment) -> Result { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForPullRequestReviewComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1288,9 +1406,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForPullRequestReviewCommentError::Status201(github_response.to_json()?)), - 422 => Err(ReactionsCreateForPullRequestReviewCommentError::Status422(github_response.to_json()?)), - code => Err(ReactionsCreateForPullRequestReviewCommentError::Generic { code }), + 201 => Err(ReactionsCreateForPullRequestReviewCommentError::Status201(github_response.to_json()?).into()), + 422 => Err(ReactionsCreateForPullRequestReviewCommentError::Status422(github_response.to_json()?).into()), + code => Err(ReactionsCreateForPullRequestReviewCommentError::Generic { code }.into()), } } } @@ -1304,19 +1422,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for create_for_release](https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-release) /// /// --- - pub async fn create_for_release_async(&self, owner: &str, repo: &str, release_id: i32, body: PostReactionsCreateForRelease) -> Result { + pub async fn create_for_release_async(&self, owner: &str, repo: &str, release_id: i32, body: PostReactionsCreateForRelease) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, release_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForRelease::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1328,9 +1446,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForReleaseError::Status201(github_response.to_json_async().await?)), - 422 => Err(ReactionsCreateForReleaseError::Status422(github_response.to_json_async().await?)), - code => Err(ReactionsCreateForReleaseError::Generic { code }), + 201 => Err(ReactionsCreateForReleaseError::Status201(github_response.to_json_async().await?).into()), + 422 => Err(ReactionsCreateForReleaseError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReactionsCreateForReleaseError::Generic { code }.into()), } } } @@ -1345,19 +1463,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_release(&self, owner: &str, repo: &str, release_id: i32, body: PostReactionsCreateForRelease) -> Result { + pub fn create_for_release(&self, owner: &str, repo: &str, release_id: i32, body: PostReactionsCreateForRelease) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, release_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForRelease::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1369,9 +1487,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForReleaseError::Status201(github_response.to_json()?)), - 422 => Err(ReactionsCreateForReleaseError::Status422(github_response.to_json()?)), - code => Err(ReactionsCreateForReleaseError::Generic { code }), + 201 => Err(ReactionsCreateForReleaseError::Status201(github_response.to_json()?).into()), + 422 => Err(ReactionsCreateForReleaseError::Status422(github_response.to_json()?).into()), + code => Err(ReactionsCreateForReleaseError::Generic { code }.into()), } } } @@ -1392,19 +1510,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for create_for_team_discussion_comment_in_org](https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-team-discussion-comment) /// /// --- - pub async fn create_for_team_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, body: PostReactionsCreateForTeamDiscussionCommentInOrg) -> Result { + pub async fn create_for_team_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, body: PostReactionsCreateForTeamDiscussionCommentInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForTeamDiscussionCommentInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1416,8 +1534,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForTeamDiscussionCommentInOrgError::Status201(github_response.to_json_async().await?)), - code => Err(ReactionsCreateForTeamDiscussionCommentInOrgError::Generic { code }), + 201 => Err(ReactionsCreateForTeamDiscussionCommentInOrgError::Status201(github_response.to_json_async().await?).into()), + code => Err(ReactionsCreateForTeamDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -1439,19 +1557,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_team_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, body: PostReactionsCreateForTeamDiscussionCommentInOrg) -> Result { + pub fn create_for_team_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, body: PostReactionsCreateForTeamDiscussionCommentInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForTeamDiscussionCommentInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1463,8 +1581,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForTeamDiscussionCommentInOrgError::Status201(github_response.to_json()?)), - code => Err(ReactionsCreateForTeamDiscussionCommentInOrgError::Generic { code }), + 201 => Err(ReactionsCreateForTeamDiscussionCommentInOrgError::Status201(github_response.to_json()?).into()), + code => Err(ReactionsCreateForTeamDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -1485,19 +1603,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for create_for_team_discussion_comment_legacy](https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-team-discussion-comment-legacy) /// /// --- - pub async fn create_for_team_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32, body: PostReactionsCreateForTeamDiscussionCommentLegacy) -> Result { + pub async fn create_for_team_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32, body: PostReactionsCreateForTeamDiscussionCommentLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForTeamDiscussionCommentLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1509,7 +1627,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsCreateForTeamDiscussionCommentLegacyError::Generic { code }), + code => Err(ReactionsCreateForTeamDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -1531,19 +1649,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_team_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32, body: PostReactionsCreateForTeamDiscussionCommentLegacy) -> Result { + pub fn create_for_team_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32, body: PostReactionsCreateForTeamDiscussionCommentLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForTeamDiscussionCommentLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1555,7 +1673,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsCreateForTeamDiscussionCommentLegacyError::Generic { code }), + code => Err(ReactionsCreateForTeamDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -1576,19 +1694,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for create_for_team_discussion_in_org](https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-team-discussion) /// /// --- - pub async fn create_for_team_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, body: PostReactionsCreateForTeamDiscussionInOrg) -> Result { + pub async fn create_for_team_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, body: PostReactionsCreateForTeamDiscussionInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/reactions", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForTeamDiscussionInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1600,8 +1718,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForTeamDiscussionInOrgError::Status201(github_response.to_json_async().await?)), - code => Err(ReactionsCreateForTeamDiscussionInOrgError::Generic { code }), + 201 => Err(ReactionsCreateForTeamDiscussionInOrgError::Status201(github_response.to_json_async().await?).into()), + code => Err(ReactionsCreateForTeamDiscussionInOrgError::Generic { code }.into()), } } } @@ -1623,19 +1741,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_team_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, body: PostReactionsCreateForTeamDiscussionInOrg) -> Result { + pub fn create_for_team_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, body: PostReactionsCreateForTeamDiscussionInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/reactions", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForTeamDiscussionInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1647,8 +1765,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(ReactionsCreateForTeamDiscussionInOrgError::Status201(github_response.to_json()?)), - code => Err(ReactionsCreateForTeamDiscussionInOrgError::Generic { code }), + 201 => Err(ReactionsCreateForTeamDiscussionInOrgError::Status201(github_response.to_json()?).into()), + code => Err(ReactionsCreateForTeamDiscussionInOrgError::Generic { code }.into()), } } } @@ -1669,19 +1787,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for create_for_team_discussion_legacy](https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-team-discussion-legacy) /// /// --- - pub async fn create_for_team_discussion_legacy_async(&self, team_id: i32, discussion_number: i32, body: PostReactionsCreateForTeamDiscussionLegacy) -> Result { + pub async fn create_for_team_discussion_legacy_async(&self, team_id: i32, discussion_number: i32, body: PostReactionsCreateForTeamDiscussionLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}/reactions", super::GITHUB_BASE_API_URL, team_id, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForTeamDiscussionLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1693,7 +1811,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsCreateForTeamDiscussionLegacyError::Generic { code }), + code => Err(ReactionsCreateForTeamDiscussionLegacyError::Generic { code }.into()), } } } @@ -1715,19 +1833,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_team_discussion_legacy(&self, team_id: i32, discussion_number: i32, body: PostReactionsCreateForTeamDiscussionLegacy) -> Result { + pub fn create_for_team_discussion_legacy(&self, team_id: i32, discussion_number: i32, body: PostReactionsCreateForTeamDiscussionLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}/reactions", super::GITHUB_BASE_API_URL, team_id, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostReactionsCreateForTeamDiscussionLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1739,7 +1857,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsCreateForTeamDiscussionLegacyError::Generic { code }), + code => Err(ReactionsCreateForTeamDiscussionLegacyError::Generic { code }.into()), } } } @@ -1756,19 +1874,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for delete_for_commit_comment](https://docs.github.com/rest/reactions/reactions#delete-a-commit-comment-reaction) /// /// --- - pub async fn delete_for_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), ReactionsDeleteForCommitCommentError> { + pub async fn delete_for_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/comments/{}/reactions/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id, reaction_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1780,7 +1898,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForCommitCommentError::Generic { code }), + code => Err(ReactionsDeleteForCommitCommentError::Generic { code }.into()), } } } @@ -1798,7 +1916,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_for_commit_comment(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), ReactionsDeleteForCommitCommentError> { + pub fn delete_for_commit_comment(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/comments/{}/reactions/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id, reaction_id); @@ -1810,7 +1928,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1822,7 +1940,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForCommitCommentError::Generic { code }), + code => Err(ReactionsDeleteForCommitCommentError::Generic { code }.into()), } } } @@ -1839,19 +1957,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for delete_for_issue](https://docs.github.com/rest/reactions/reactions#delete-an-issue-reaction) /// /// --- - pub async fn delete_for_issue_async(&self, owner: &str, repo: &str, issue_number: i32, reaction_id: i32) -> Result<(), ReactionsDeleteForIssueError> { + pub async fn delete_for_issue_async(&self, owner: &str, repo: &str, issue_number: i32, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/reactions/{}", super::GITHUB_BASE_API_URL, owner, repo, issue_number, reaction_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1863,7 +1981,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForIssueError::Generic { code }), + code => Err(ReactionsDeleteForIssueError::Generic { code }.into()), } } } @@ -1881,7 +1999,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_for_issue(&self, owner: &str, repo: &str, issue_number: i32, reaction_id: i32) -> Result<(), ReactionsDeleteForIssueError> { + pub fn delete_for_issue(&self, owner: &str, repo: &str, issue_number: i32, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/{}/reactions/{}", super::GITHUB_BASE_API_URL, owner, repo, issue_number, reaction_id); @@ -1893,7 +2011,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1905,7 +2023,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForIssueError::Generic { code }), + code => Err(ReactionsDeleteForIssueError::Generic { code }.into()), } } } @@ -1922,19 +2040,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for delete_for_issue_comment](https://docs.github.com/rest/reactions/reactions#delete-an-issue-comment-reaction) /// /// --- - pub async fn delete_for_issue_comment_async(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), ReactionsDeleteForIssueCommentError> { + pub async fn delete_for_issue_comment_async(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/comments/{}/reactions/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id, reaction_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1946,7 +2064,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForIssueCommentError::Generic { code }), + code => Err(ReactionsDeleteForIssueCommentError::Generic { code }.into()), } } } @@ -1964,7 +2082,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_for_issue_comment(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), ReactionsDeleteForIssueCommentError> { + pub fn delete_for_issue_comment(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/issues/comments/{}/reactions/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id, reaction_id); @@ -1976,7 +2094,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1988,7 +2106,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForIssueCommentError::Generic { code }), + code => Err(ReactionsDeleteForIssueCommentError::Generic { code }.into()), } } } @@ -2005,19 +2123,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for delete_for_pull_request_comment](https://docs.github.com/rest/reactions/reactions#delete-a-pull-request-comment-reaction) /// /// --- - pub async fn delete_for_pull_request_comment_async(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), ReactionsDeleteForPullRequestCommentError> { + pub async fn delete_for_pull_request_comment_async(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}/reactions/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id, reaction_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2029,7 +2147,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForPullRequestCommentError::Generic { code }), + code => Err(ReactionsDeleteForPullRequestCommentError::Generic { code }.into()), } } } @@ -2047,7 +2165,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_for_pull_request_comment(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), ReactionsDeleteForPullRequestCommentError> { + pub fn delete_for_pull_request_comment(&self, owner: &str, repo: &str, comment_id: i64, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pulls/comments/{}/reactions/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id, reaction_id); @@ -2059,7 +2177,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2071,7 +2189,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForPullRequestCommentError::Generic { code }), + code => Err(ReactionsDeleteForPullRequestCommentError::Generic { code }.into()), } } } @@ -2088,19 +2206,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for delete_for_release](https://docs.github.com/rest/reactions/reactions#delete-a-release-reaction) /// /// --- - pub async fn delete_for_release_async(&self, owner: &str, repo: &str, release_id: i32, reaction_id: i32) -> Result<(), ReactionsDeleteForReleaseError> { + pub async fn delete_for_release_async(&self, owner: &str, repo: &str, release_id: i32, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/releases/{}/reactions/{}", super::GITHUB_BASE_API_URL, owner, repo, release_id, reaction_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2112,7 +2230,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForReleaseError::Generic { code }), + code => Err(ReactionsDeleteForReleaseError::Generic { code }.into()), } } } @@ -2130,7 +2248,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_for_release(&self, owner: &str, repo: &str, release_id: i32, reaction_id: i32) -> Result<(), ReactionsDeleteForReleaseError> { + pub fn delete_for_release(&self, owner: &str, repo: &str, release_id: i32, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/releases/{}/reactions/{}", super::GITHUB_BASE_API_URL, owner, repo, release_id, reaction_id); @@ -2142,7 +2260,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2154,7 +2272,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForReleaseError::Generic { code }), + code => Err(ReactionsDeleteForReleaseError::Generic { code }.into()), } } } @@ -2173,19 +2291,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for delete_for_team_discussion](https://docs.github.com/rest/reactions/reactions#delete-team-discussion-reaction) /// /// --- - pub async fn delete_for_team_discussion_async(&self, org: &str, team_slug: &str, discussion_number: i32, reaction_id: i32) -> Result<(), ReactionsDeleteForTeamDiscussionError> { + pub async fn delete_for_team_discussion_async(&self, org: &str, team_slug: &str, discussion_number: i32, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/reactions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, reaction_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2197,7 +2315,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForTeamDiscussionError::Generic { code }), + code => Err(ReactionsDeleteForTeamDiscussionError::Generic { code }.into()), } } } @@ -2217,7 +2335,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_for_team_discussion(&self, org: &str, team_slug: &str, discussion_number: i32, reaction_id: i32) -> Result<(), ReactionsDeleteForTeamDiscussionError> { + pub fn delete_for_team_discussion(&self, org: &str, team_slug: &str, discussion_number: i32, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/reactions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, reaction_id); @@ -2229,7 +2347,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2241,7 +2359,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForTeamDiscussionError::Generic { code }), + code => Err(ReactionsDeleteForTeamDiscussionError::Generic { code }.into()), } } } @@ -2260,19 +2378,19 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for delete_for_team_discussion_comment](https://docs.github.com/rest/reactions/reactions#delete-team-discussion-comment-reaction) /// /// --- - pub async fn delete_for_team_discussion_comment_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, reaction_id: i32) -> Result<(), ReactionsDeleteForTeamDiscussionCommentError> { + pub async fn delete_for_team_discussion_comment_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}/reactions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number, reaction_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2284,7 +2402,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForTeamDiscussionCommentError::Generic { code }), + code => Err(ReactionsDeleteForTeamDiscussionCommentError::Generic { code }.into()), } } } @@ -2304,7 +2422,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_for_team_discussion_comment(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, reaction_id: i32) -> Result<(), ReactionsDeleteForTeamDiscussionCommentError> { + pub fn delete_for_team_discussion_comment(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, reaction_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}/reactions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number, reaction_id); @@ -2316,7 +2434,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2328,7 +2446,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsDeleteForTeamDiscussionCommentError::Generic { code }), + code => Err(ReactionsDeleteForTeamDiscussionCommentError::Generic { code }.into()), } } } @@ -2342,7 +2460,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for list_for_commit_comment](https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-commit-comment) /// /// --- - pub async fn list_for_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, ReactionsListForCommitCommentError> { + pub async fn list_for_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -2353,12 +2471,12 @@ impl<'api, C: Client> Reactions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2370,8 +2488,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReactionsListForCommitCommentError::Status404(github_response.to_json_async().await?)), - code => Err(ReactionsListForCommitCommentError::Generic { code }), + 404 => Err(ReactionsListForCommitCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReactionsListForCommitCommentError::Generic { code }.into()), } } } @@ -2386,7 +2504,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_commit_comment(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, ReactionsListForCommitCommentError> { + pub fn list_for_commit_comment(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -2403,7 +2521,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2415,8 +2533,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReactionsListForCommitCommentError::Status404(github_response.to_json()?)), - code => Err(ReactionsListForCommitCommentError::Generic { code }), + 404 => Err(ReactionsListForCommitCommentError::Status404(github_response.to_json()?).into()), + code => Err(ReactionsListForCommitCommentError::Generic { code }.into()), } } } @@ -2430,7 +2548,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for list_for_issue](https://docs.github.com/rest/reactions/reactions#list-reactions-for-an-issue) /// /// --- - pub async fn list_for_issue_async(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>>) -> Result, ReactionsListForIssueError> { + pub async fn list_for_issue_async(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -2441,12 +2559,12 @@ impl<'api, C: Client> Reactions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2458,9 +2576,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReactionsListForIssueError::Status404(github_response.to_json_async().await?)), - 410 => Err(ReactionsListForIssueError::Status410(github_response.to_json_async().await?)), - code => Err(ReactionsListForIssueError::Generic { code }), + 404 => Err(ReactionsListForIssueError::Status404(github_response.to_json_async().await?).into()), + 410 => Err(ReactionsListForIssueError::Status410(github_response.to_json_async().await?).into()), + code => Err(ReactionsListForIssueError::Generic { code }.into()), } } } @@ -2475,7 +2593,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_issue(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>>) -> Result, ReactionsListForIssueError> { + pub fn list_for_issue(&self, owner: &str, repo: &str, issue_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, issue_number); @@ -2492,7 +2610,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2504,9 +2622,9 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReactionsListForIssueError::Status404(github_response.to_json()?)), - 410 => Err(ReactionsListForIssueError::Status410(github_response.to_json()?)), - code => Err(ReactionsListForIssueError::Generic { code }), + 404 => Err(ReactionsListForIssueError::Status404(github_response.to_json()?).into()), + 410 => Err(ReactionsListForIssueError::Status410(github_response.to_json()?).into()), + code => Err(ReactionsListForIssueError::Generic { code }.into()), } } } @@ -2520,7 +2638,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for list_for_issue_comment](https://docs.github.com/rest/reactions/reactions#list-reactions-for-an-issue-comment) /// /// --- - pub async fn list_for_issue_comment_async(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, ReactionsListForIssueCommentError> { + pub async fn list_for_issue_comment_async(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -2531,12 +2649,12 @@ impl<'api, C: Client> Reactions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2548,8 +2666,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReactionsListForIssueCommentError::Status404(github_response.to_json_async().await?)), - code => Err(ReactionsListForIssueCommentError::Generic { code }), + 404 => Err(ReactionsListForIssueCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReactionsListForIssueCommentError::Generic { code }.into()), } } } @@ -2564,7 +2682,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_issue_comment(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, ReactionsListForIssueCommentError> { + pub fn list_for_issue_comment(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/issues/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -2581,7 +2699,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2593,8 +2711,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReactionsListForIssueCommentError::Status404(github_response.to_json()?)), - code => Err(ReactionsListForIssueCommentError::Generic { code }), + 404 => Err(ReactionsListForIssueCommentError::Status404(github_response.to_json()?).into()), + code => Err(ReactionsListForIssueCommentError::Generic { code }.into()), } } } @@ -2608,7 +2726,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for list_for_pull_request_review_comment](https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-pull-request-review-comment) /// /// --- - pub async fn list_for_pull_request_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, ReactionsListForPullRequestReviewCommentError> { + pub async fn list_for_pull_request_review_comment_async(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -2619,12 +2737,12 @@ impl<'api, C: Client> Reactions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2636,8 +2754,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReactionsListForPullRequestReviewCommentError::Status404(github_response.to_json_async().await?)), - code => Err(ReactionsListForPullRequestReviewCommentError::Generic { code }), + 404 => Err(ReactionsListForPullRequestReviewCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReactionsListForPullRequestReviewCommentError::Generic { code }.into()), } } } @@ -2652,7 +2770,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_pull_request_review_comment(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, ReactionsListForPullRequestReviewCommentError> { + pub fn list_for_pull_request_review_comment(&self, owner: &str, repo: &str, comment_id: i64, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pulls/comments/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -2669,7 +2787,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2681,8 +2799,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReactionsListForPullRequestReviewCommentError::Status404(github_response.to_json()?)), - code => Err(ReactionsListForPullRequestReviewCommentError::Generic { code }), + 404 => Err(ReactionsListForPullRequestReviewCommentError::Status404(github_response.to_json()?).into()), + code => Err(ReactionsListForPullRequestReviewCommentError::Generic { code }.into()), } } } @@ -2696,7 +2814,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for list_for_release](https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-release) /// /// --- - pub async fn list_for_release_async(&self, owner: &str, repo: &str, release_id: i32, query_params: Option>>) -> Result, ReactionsListForReleaseError> { + pub async fn list_for_release_async(&self, owner: &str, repo: &str, release_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/releases/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, release_id); @@ -2707,12 +2825,12 @@ impl<'api, C: Client> Reactions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2724,8 +2842,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReactionsListForReleaseError::Status404(github_response.to_json_async().await?)), - code => Err(ReactionsListForReleaseError::Generic { code }), + 404 => Err(ReactionsListForReleaseError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReactionsListForReleaseError::Generic { code }.into()), } } } @@ -2740,7 +2858,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_release(&self, owner: &str, repo: &str, release_id: i32, query_params: Option>>) -> Result, ReactionsListForReleaseError> { + pub fn list_for_release(&self, owner: &str, repo: &str, release_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/releases/{}/reactions", super::GITHUB_BASE_API_URL, owner, repo, release_id); @@ -2757,7 +2875,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2769,8 +2887,8 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReactionsListForReleaseError::Status404(github_response.to_json()?)), - code => Err(ReactionsListForReleaseError::Generic { code }), + 404 => Err(ReactionsListForReleaseError::Status404(github_response.to_json()?).into()), + code => Err(ReactionsListForReleaseError::Generic { code }.into()), } } } @@ -2789,7 +2907,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for list_for_team_discussion_comment_in_org](https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-team-discussion-comment) /// /// --- - pub async fn list_for_team_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, query_params: Option>>) -> Result, ReactionsListForTeamDiscussionCommentInOrgError> { + pub async fn list_for_team_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number); @@ -2800,12 +2918,12 @@ impl<'api, C: Client> Reactions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2817,7 +2935,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsListForTeamDiscussionCommentInOrgError::Generic { code }), + code => Err(ReactionsListForTeamDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -2837,7 +2955,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_team_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, query_params: Option>>) -> Result, ReactionsListForTeamDiscussionCommentInOrgError> { + pub fn list_for_team_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number); @@ -2854,7 +2972,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2866,7 +2984,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsListForTeamDiscussionCommentInOrgError::Generic { code }), + code => Err(ReactionsListForTeamDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -2885,7 +3003,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for list_for_team_discussion_comment_legacy](https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-team-discussion-comment-legacy) /// /// --- - pub async fn list_for_team_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32, query_params: Option>>) -> Result, ReactionsListForTeamDiscussionCommentLegacyError> { + pub async fn list_for_team_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/discussions/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number); @@ -2896,12 +3014,12 @@ impl<'api, C: Client> Reactions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2913,7 +3031,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsListForTeamDiscussionCommentLegacyError::Generic { code }), + code => Err(ReactionsListForTeamDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -2933,7 +3051,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_team_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32, query_params: Option>>) -> Result, ReactionsListForTeamDiscussionCommentLegacyError> { + pub fn list_for_team_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/discussions/{}/comments/{}/reactions", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number); @@ -2950,7 +3068,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2962,7 +3080,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsListForTeamDiscussionCommentLegacyError::Generic { code }), + code => Err(ReactionsListForTeamDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -2981,7 +3099,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for list_for_team_discussion_in_org](https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-team-discussion) /// /// --- - pub async fn list_for_team_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, query_params: Option>>) -> Result, ReactionsListForTeamDiscussionInOrgError> { + pub async fn list_for_team_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/reactions", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); @@ -2992,12 +3110,12 @@ impl<'api, C: Client> Reactions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3009,7 +3127,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsListForTeamDiscussionInOrgError::Generic { code }), + code => Err(ReactionsListForTeamDiscussionInOrgError::Generic { code }.into()), } } } @@ -3029,7 +3147,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_team_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, query_params: Option>>) -> Result, ReactionsListForTeamDiscussionInOrgError> { + pub fn list_for_team_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/reactions", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); @@ -3046,7 +3164,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3058,7 +3176,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsListForTeamDiscussionInOrgError::Generic { code }), + code => Err(ReactionsListForTeamDiscussionInOrgError::Generic { code }.into()), } } } @@ -3077,7 +3195,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// [GitHub API docs for list_for_team_discussion_legacy](https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-team-discussion-legacy) /// /// --- - pub async fn list_for_team_discussion_legacy_async(&self, team_id: i32, discussion_number: i32, query_params: Option>>) -> Result, ReactionsListForTeamDiscussionLegacyError> { + pub async fn list_for_team_discussion_legacy_async(&self, team_id: i32, discussion_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/discussions/{}/reactions", super::GITHUB_BASE_API_URL, team_id, discussion_number); @@ -3088,12 +3206,12 @@ impl<'api, C: Client> Reactions<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3105,7 +3223,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReactionsListForTeamDiscussionLegacyError::Generic { code }), + code => Err(ReactionsListForTeamDiscussionLegacyError::Generic { code }.into()), } } } @@ -3125,7 +3243,7 @@ impl<'api, C: Client> Reactions<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_team_discussion_legacy(&self, team_id: i32, discussion_number: i32, query_params: Option>>) -> Result, ReactionsListForTeamDiscussionLegacyError> { + pub fn list_for_team_discussion_legacy(&self, team_id: i32, discussion_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/discussions/{}/reactions", super::GITHUB_BASE_API_URL, team_id, discussion_number); @@ -3142,7 +3260,7 @@ impl<'api, C: Client> Reactions<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3154,7 +3272,7 @@ impl<'api, C: Client> Reactions<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReactionsListForTeamDiscussionLegacyError::Generic { code }), + code => Err(ReactionsListForTeamDiscussionLegacyError::Generic { code }.into()), } } } diff --git a/src/endpoints/repos.rs b/src/endpoints/repos.rs index 9eadda6..2926f31 100644 --- a/src/endpoints/repos.rs +++ b/src/endpoints/repos.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Repos<'api, C: Client> { +pub struct Repos<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Repos { +pub fn new(client: &C) -> Repos where AdapterError: From<::Err> { Repos { client } } /// Errors for the [Accept a repository invitation](Repos::accept_invitation_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposAcceptInvitationForAuthenticatedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Conflict")] @@ -55,38 +45,51 @@ pub enum ReposAcceptInvitationForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposAcceptInvitationForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ReposAcceptInvitationForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ReposAcceptInvitationForAuthenticatedUserError::Status409(_) => (String::from("Conflict"), 409), + ReposAcceptInvitationForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + ReposAcceptInvitationForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ReposAcceptInvitationForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add app access restrictions](Repos::add_app_access_restrictions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposAddAppAccessRestrictionsError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposAddAppAccessRestrictionsError) -> Self { + let (description, status_code) = match err { + ReposAddAppAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposAddAppAccessRestrictionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add a repository collaborator](Repos::add_collaborator_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposAddCollaboratorError { - #[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: - an existing collaborator is added as a collaborator - an organization member is added as an individual collaborator - an existing team member (whose team is also a repository collaborator) is added as an individual collaborator")] Status204, #[error("Validation failed, or the endpoint has been spammed.")] @@ -97,19 +100,26 @@ pub enum ReposAddCollaboratorError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposAddCollaboratorError) -> Self { + let (description, status_code) = match err { + ReposAddCollaboratorError::Status204 => (String::from("Response when: - an existing collaborator is added as a collaborator - an organization member is added as an individual collaborator - an existing team member (whose team is also a repository collaborator) is added as an individual collaborator"), 204), + ReposAddCollaboratorError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposAddCollaboratorError::Status403(_) => (String::from("Forbidden"), 403), + ReposAddCollaboratorError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add status check contexts](Repos::add_status_check_contexts_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposAddStatusCheckContextsError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Forbidden")] @@ -120,171 +130,218 @@ pub enum ReposAddStatusCheckContextsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposAddStatusCheckContextsError) -> Self { + let (description, status_code) = match err { + ReposAddStatusCheckContextsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposAddStatusCheckContextsError::Status403(_) => (String::from("Forbidden"), 403), + ReposAddStatusCheckContextsError::Status404(_) => (String::from("Resource not found"), 404), + ReposAddStatusCheckContextsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add team access restrictions](Repos::add_team_access_restrictions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposAddTeamAccessRestrictionsError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposAddTeamAccessRestrictionsError) -> Self { + let (description, status_code) = match err { + ReposAddTeamAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposAddTeamAccessRestrictionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add user access restrictions](Repos::add_user_access_restrictions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposAddUserAccessRestrictionsError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposAddUserAccessRestrictionsError) -> Self { + let (description, status_code) = match err { + ReposAddUserAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposAddUserAccessRestrictionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Cancel a GitHub Pages deployment](Repos::cancel_pages_deployment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCancelPagesDeploymentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposCancelPagesDeploymentError) -> Self { + let (description, status_code) = match err { + ReposCancelPagesDeploymentError::Status404(_) => (String::from("Resource not found"), 404), + ReposCancelPagesDeploymentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check if automated security fixes are enabled for a repository](Repos::check_automated_security_fixes_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCheckAutomatedSecurityFixesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if Dependabot is not enabled for the repository")] Status404, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCheckAutomatedSecurityFixesError) -> Self { + let (description, status_code) = match err { + ReposCheckAutomatedSecurityFixesError::Status404 => (String::from("Not Found if Dependabot is not enabled for the repository"), 404), + ReposCheckAutomatedSecurityFixesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check if a user is a repository collaborator](Repos::check_collaborator_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCheckCollaboratorError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if user is not a collaborator")] Status404, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCheckCollaboratorError) -> Self { + let (description, status_code) = match err { + ReposCheckCollaboratorError::Status404 => (String::from("Not Found if user is not a collaborator"), 404), + ReposCheckCollaboratorError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check if private vulnerability reporting is enabled for a repository](Repos::check_private_vulnerability_reporting_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCheckPrivateVulnerabilityReportingError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status422(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCheckPrivateVulnerabilityReportingError) -> Self { + let (description, status_code) = match err { + ReposCheckPrivateVulnerabilityReportingError::Status422(_) => (String::from("Bad Request"), 422), + ReposCheckPrivateVulnerabilityReportingError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check if vulnerability alerts are enabled for a repository](Repos::check_vulnerability_alerts_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCheckVulnerabilityAlertsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if repository is not enabled with vulnerability alerts")] Status404, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCheckVulnerabilityAlertsError) -> Self { + let (description, status_code) = match err { + ReposCheckVulnerabilityAlertsError::Status404 => (String::from("Not Found if repository is not enabled with vulnerability alerts"), 404), + ReposCheckVulnerabilityAlertsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List CODEOWNERS errors](Repos::codeowners_errors_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCodeownersErrorsError { - #[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, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCodeownersErrorsError) -> Self { + let (description, status_code) = match err { + ReposCodeownersErrorsError::Status404 => (String::from("Resource not found"), 404), + ReposCodeownersErrorsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Compare two commits](Repos::compare_commits_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCompareCommitsError { - #[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("Internal Error")] @@ -295,19 +352,26 @@ pub enum ReposCompareCommitsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCompareCommitsError) -> Self { + let (description, status_code) = match err { + ReposCompareCommitsError::Status404(_) => (String::from("Resource not found"), 404), + ReposCompareCommitsError::Status500(_) => (String::from("Internal Error"), 500), + ReposCompareCommitsError::Status503(_) => (String::from("Service unavailable"), 503), + ReposCompareCommitsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an attestation](Repos::create_attestation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateAttestationError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -316,38 +380,49 @@ pub enum ReposCreateAttestationError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateAttestationError) -> Self { + let (description, status_code) = match err { + ReposCreateAttestationError::Status403(_) => (String::from("Forbidden"), 403), + ReposCreateAttestationError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateAttestationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an autolink reference for a repository](Repos::create_autolink_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateAutolinkError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateAutolinkError) -> Self { + let (description, status_code) = match err { + ReposCreateAutolinkError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateAutolinkError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a commit comment](Repos::create_commit_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateCommitCommentError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -356,74 +431,94 @@ pub enum ReposCreateCommitCommentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateCommitCommentError) -> Self { + let (description, status_code) = match err { + ReposCreateCommitCommentError::Status403(_) => (String::from("Forbidden"), 403), + ReposCreateCommitCommentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateCommitCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create commit signature protection](Repos::create_commit_signature_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateCommitSignatureProtectionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposCreateCommitSignatureProtectionError) -> Self { + let (description, status_code) = match err { + ReposCreateCommitSignatureProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposCreateCommitSignatureProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a commit status](Repos::create_commit_status_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateCommitStatusError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposCreateCommitStatusError) -> Self { + let (description, status_code) = match err { + ReposCreateCommitStatusError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a deploy key](Repos::create_deploy_key_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateDeployKeyError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateDeployKeyError) -> Self { + let (description, status_code) = match err { + ReposCreateDeployKeyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateDeployKeyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a deployment](Repos::create_deployment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateDeploymentError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Merged branch response")] Status202(PostReposCreateDeploymentResponse202), #[error("Conflict when there is a merge conflict or the commit's status checks failed")] @@ -434,19 +529,26 @@ pub enum ReposCreateDeploymentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateDeploymentError) -> Self { + let (description, status_code) = match err { + ReposCreateDeploymentError::Status202(_) => (String::from("Merged branch response"), 202), + ReposCreateDeploymentError::Status409 => (String::from("Conflict when there is a merge conflict or the commit's status checks failed"), 409), + ReposCreateDeploymentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateDeploymentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a deployment branch policy](Repos::create_deployment_branch_policy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateDeploymentBranchPolicyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found or `deployment_branch_policy.custom_branch_policies` property for the environment is set to false")] Status404, #[error("Response if the same branch name pattern already exists")] @@ -455,55 +557,70 @@ pub enum ReposCreateDeploymentBranchPolicyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateDeploymentBranchPolicyError) -> Self { + let (description, status_code) = match err { + ReposCreateDeploymentBranchPolicyError::Status404 => (String::from("Not Found or `deployment_branch_policy.custom_branch_policies` property for the environment is set to false"), 404), + ReposCreateDeploymentBranchPolicyError::Status303 => (String::from("Response if the same branch name pattern already exists"), 303), + ReposCreateDeploymentBranchPolicyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a custom deployment protection rule on an environment](Repos::create_deployment_protection_rule_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateDeploymentProtectionRuleError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposCreateDeploymentProtectionRuleError) -> Self { + let (description, status_code) = match err { + ReposCreateDeploymentProtectionRuleError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a deployment status](Repos::create_deployment_status_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateDeploymentStatusError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateDeploymentStatusError) -> Self { + let (description, status_code) = match err { + ReposCreateDeploymentStatusError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateDeploymentStatusError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a repository dispatch event](Repos::create_dispatch_event_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateDispatchEventError { - #[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, or the endpoint has been spammed.")] @@ -512,19 +629,25 @@ pub enum ReposCreateDispatchEventError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateDispatchEventError) -> Self { + let (description, status_code) = match err { + ReposCreateDispatchEventError::Status404(_) => (String::from("Resource not found"), 404), + ReposCreateDispatchEventError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateDispatchEventError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a repository for the authenticated user](Repos::create_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateForAuthenticatedUserError { - #[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("Not modified")] @@ -541,19 +664,29 @@ pub enum ReposCreateForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ReposCreateForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + ReposCreateForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ReposCreateForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + ReposCreateForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ReposCreateForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateForAuthenticatedUserError::Status400(_) => (String::from("Bad Request"), 400), + ReposCreateForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a fork](Repos::create_fork_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateForkError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -566,19 +699,27 @@ pub enum ReposCreateForkError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateForkError) -> Self { + let (description, status_code) = match err { + ReposCreateForkError::Status400(_) => (String::from("Bad Request"), 400), + ReposCreateForkError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateForkError::Status403(_) => (String::from("Forbidden"), 403), + ReposCreateForkError::Status404(_) => (String::from("Resource not found"), 404), + ReposCreateForkError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an organization repository](Repos::create_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateInOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -587,19 +728,25 @@ pub enum ReposCreateInOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateInOrgError) -> Self { + let (description, status_code) = match err { + ReposCreateInOrgError::Status403(_) => (String::from("Forbidden"), 403), + ReposCreateInOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update custom property values for a repository](Repos::create_or_update_custom_properties_values_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateOrUpdateCustomPropertiesValuesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -610,38 +757,50 @@ pub enum ReposCreateOrUpdateCustomPropertiesValuesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateOrUpdateCustomPropertiesValuesError) -> Self { + let (description, status_code) = match err { + ReposCreateOrUpdateCustomPropertiesValuesError::Status403(_) => (String::from("Forbidden"), 403), + ReposCreateOrUpdateCustomPropertiesValuesError::Status404(_) => (String::from("Resource not found"), 404), + ReposCreateOrUpdateCustomPropertiesValuesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateOrUpdateCustomPropertiesValuesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create or update an environment](Repos::create_or_update_environment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateOrUpdateEnvironmentError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Validation error when the environment name is invalid or when `protected_branches` and `custom_branch_policies` in `deployment_branch_policy` are set to the same value")] Status422(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } -/// Errors for the [Create or update file contents](Repos::create_or_update_file_contents_async()) endpoint. -#[derive(Debug, thiserror::Error)] -pub enum ReposCreateOrUpdateFileContentsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - +impl From for AdapterError { + fn from(err: ReposCreateOrUpdateEnvironmentError) -> Self { + let (description, status_code) = match err { + ReposCreateOrUpdateEnvironmentError::Status422(_) => (String::from("Validation error when the environment name is invalid or when `protected_branches` and `custom_branch_policies` in `deployment_branch_policy` are set to the same value"), 422), + ReposCreateOrUpdateEnvironmentError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Create or update file contents](Repos::create_or_update_file_contents_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ReposCreateOrUpdateFileContentsError { #[error("Response")] Status201(FileCommit), #[error("Resource not found")] @@ -654,19 +813,27 @@ pub enum ReposCreateOrUpdateFileContentsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateOrUpdateFileContentsError) -> Self { + let (description, status_code) = match err { + ReposCreateOrUpdateFileContentsError::Status201(_) => (String::from("Response"), 201), + ReposCreateOrUpdateFileContentsError::Status404(_) => (String::from("Resource not found"), 404), + ReposCreateOrUpdateFileContentsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateOrUpdateFileContentsError::Status409(_) => (String::from("Conflict"), 409), + ReposCreateOrUpdateFileContentsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create an organization repository ruleset](Repos::create_org_ruleset_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateOrgRulesetError { - #[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("Internal Error")] @@ -675,19 +842,25 @@ pub enum ReposCreateOrgRulesetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateOrgRulesetError) -> Self { + let (description, status_code) = match err { + ReposCreateOrgRulesetError::Status404(_) => (String::from("Resource not found"), 404), + ReposCreateOrgRulesetError::Status500(_) => (String::from("Internal Error"), 500), + ReposCreateOrgRulesetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a GitHub Pages deployment](Repos::create_pages_deployment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreatePagesDeploymentError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -698,19 +871,26 @@ pub enum ReposCreatePagesDeploymentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreatePagesDeploymentError) -> Self { + let (description, status_code) = match err { + ReposCreatePagesDeploymentError::Status400(_) => (String::from("Bad Request"), 400), + ReposCreatePagesDeploymentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreatePagesDeploymentError::Status404(_) => (String::from("Resource not found"), 404), + ReposCreatePagesDeploymentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a GitHub Pages site](Repos::create_pages_site_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreatePagesSiteError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Conflict")] @@ -719,19 +899,25 @@ pub enum ReposCreatePagesSiteError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreatePagesSiteError) -> Self { + let (description, status_code) = match err { + ReposCreatePagesSiteError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreatePagesSiteError::Status409(_) => (String::from("Conflict"), 409), + ReposCreatePagesSiteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a release](Repos::create_release_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateReleaseError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if the discussion category name is invalid")] Status404(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -740,19 +926,25 @@ pub enum ReposCreateReleaseError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateReleaseError) -> Self { + let (description, status_code) = match err { + ReposCreateReleaseError::Status404(_) => (String::from("Not Found if the discussion category name is invalid"), 404), + ReposCreateReleaseError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateReleaseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a repository ruleset](Repos::create_repo_ruleset_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateRepoRulesetError { - #[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("Internal Error")] @@ -761,19 +953,25 @@ pub enum ReposCreateRepoRulesetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateRepoRulesetError) -> Self { + let (description, status_code) = match err { + ReposCreateRepoRulesetError::Status404(_) => (String::from("Resource not found"), 404), + ReposCreateRepoRulesetError::Status500(_) => (String::from("Internal Error"), 500), + ReposCreateRepoRulesetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Deprecated - Create a tag protection state for a repository](Repos::create_tag_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateTagProtectionError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -782,36 +980,46 @@ pub enum ReposCreateTagProtectionError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateTagProtectionError) -> Self { + let (description, status_code) = match err { + ReposCreateTagProtectionError::Status403(_) => (String::from("Forbidden"), 403), + ReposCreateTagProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposCreateTagProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a repository using a template](Repos::create_using_template_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateUsingTemplateError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposCreateUsingTemplateError) -> Self { + let (description, status_code) = match err { + ReposCreateUsingTemplateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a repository webhook](Repos::create_webhook_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposCreateWebhookError { - #[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, or the endpoint has been spammed.")] @@ -822,19 +1030,26 @@ pub enum ReposCreateWebhookError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposCreateWebhookError) -> Self { + let (description, status_code) = match err { + ReposCreateWebhookError::Status404(_) => (String::from("Resource not found"), 404), + ReposCreateWebhookError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposCreateWebhookError::Status403(_) => (String::from("Forbidden"), 403), + ReposCreateWebhookError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Decline a repository invitation](Repos::decline_invitation_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeclineInvitationForAuthenticatedUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Conflict")] Status409(BasicError), #[error("Not modified")] @@ -847,19 +1062,27 @@ pub enum ReposDeclineInvitationForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDeclineInvitationForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ReposDeclineInvitationForAuthenticatedUserError::Status409(_) => (String::from("Conflict"), 409), + ReposDeclineInvitationForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ReposDeclineInvitationForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeclineInvitationForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ReposDeclineInvitationForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a repository](Repos::delete_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("If an organization owner has configured the organization to prevent members from deleting organization-owned repositories, a member will get this response:")] Status403(PutTeamsAddOrUpdateProjectPermissionsLegacyResponse403), #[error("Temporary Redirect")] @@ -870,165 +1093,209 @@ pub enum ReposDeleteError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDeleteError) -> Self { + let (description, status_code) = match err { + ReposDeleteError::Status403(_) => (String::from("If an organization owner has configured the organization to prevent members from deleting organization-owned repositories, a member will get this response:"), 403), + ReposDeleteError::Status307(_) => (String::from("Temporary Redirect"), 307), + ReposDeleteError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeleteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete access restrictions](Repos::delete_access_restrictions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteAccessRestrictionsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeleteAccessRestrictionsError) -> Self { + let (description, status_code) = match err { + ReposDeleteAccessRestrictionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete admin branch protection](Repos::delete_admin_branch_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteAdminBranchProtectionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeleteAdminBranchProtectionError) -> Self { + let (description, status_code) = match err { + ReposDeleteAdminBranchProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeleteAdminBranchProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an environment](Repos::delete_an_environment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteAnEnvironmentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeleteAnEnvironmentError) -> Self { + let (description, status_code) = match err { + ReposDeleteAnEnvironmentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an autolink reference from a repository](Repos::delete_autolink_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteAutolinkError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeleteAutolinkError) -> Self { + let (description, status_code) = match err { + ReposDeleteAutolinkError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeleteAutolinkError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete branch protection](Repos::delete_branch_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteBranchProtectionError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDeleteBranchProtectionError) -> Self { + let (description, status_code) = match err { + ReposDeleteBranchProtectionError::Status403(_) => (String::from("Forbidden"), 403), + ReposDeleteBranchProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a commit comment](Repos::delete_commit_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteCommitCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeleteCommitCommentError) -> Self { + let (description, status_code) = match err { + ReposDeleteCommitCommentError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeleteCommitCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete commit signature protection](Repos::delete_commit_signature_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteCommitSignatureProtectionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeleteCommitSignatureProtectionError) -> Self { + let (description, status_code) = match err { + ReposDeleteCommitSignatureProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeleteCommitSignatureProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a deploy key](Repos::delete_deploy_key_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteDeployKeyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeleteDeployKeyError) -> Self { + let (description, status_code) = match err { + ReposDeleteDeployKeyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a deployment](Repos::delete_deployment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteDeploymentError { - #[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, or the endpoint has been spammed.")] @@ -1037,36 +1304,46 @@ pub enum ReposDeleteDeploymentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDeleteDeploymentError) -> Self { + let (description, status_code) = match err { + ReposDeleteDeploymentError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeleteDeploymentError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposDeleteDeploymentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a deployment branch policy](Repos::delete_deployment_branch_policy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteDeploymentBranchPolicyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeleteDeploymentBranchPolicyError) -> Self { + let (description, status_code) = match err { + ReposDeleteDeploymentBranchPolicyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a file](Repos::delete_file_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteFileError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -1079,36 +1356,48 @@ pub enum ReposDeleteFileError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDeleteFileError) -> Self { + let (description, status_code) = match err { + ReposDeleteFileError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposDeleteFileError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeleteFileError::Status409(_) => (String::from("Conflict"), 409), + ReposDeleteFileError::Status503(_) => (String::from("Service unavailable"), 503), + ReposDeleteFileError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a repository invitation](Repos::delete_invitation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteInvitationError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeleteInvitationError) -> Self { + let (description, status_code) = match err { + ReposDeleteInvitationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an organization repository ruleset](Repos::delete_org_ruleset_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteOrgRulesetError { - #[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("Internal Error")] @@ -1117,19 +1406,25 @@ pub enum ReposDeleteOrgRulesetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDeleteOrgRulesetError) -> Self { + let (description, status_code) = match err { + ReposDeleteOrgRulesetError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeleteOrgRulesetError::Status500(_) => (String::from("Internal Error"), 500), + ReposDeleteOrgRulesetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a GitHub Pages site](Repos::delete_pages_site_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeletePagesSiteError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -1140,72 +1435,92 @@ pub enum ReposDeletePagesSiteError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDeletePagesSiteError) -> Self { + let (description, status_code) = match err { + ReposDeletePagesSiteError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposDeletePagesSiteError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeletePagesSiteError::Status409(_) => (String::from("Conflict"), 409), + ReposDeletePagesSiteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete pull request review protection](Repos::delete_pull_request_review_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeletePullRequestReviewProtectionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeletePullRequestReviewProtectionError) -> Self { + let (description, status_code) = match err { + ReposDeletePullRequestReviewProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeletePullRequestReviewProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a release](Repos::delete_release_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteReleaseError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeleteReleaseError) -> Self { + let (description, status_code) = match err { + ReposDeleteReleaseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a release asset](Repos::delete_release_asset_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteReleaseAssetError { - #[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 [Delete a repository ruleset](Repos::delete_repo_ruleset_async()) endpoint. -#[derive(Debug, thiserror::Error)] -pub enum ReposDeleteRepoRulesetError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - +impl From for AdapterError { + fn from(err: ReposDeleteReleaseAssetError) -> Self { + let (description, status_code) = match err { + ReposDeleteReleaseAssetError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Delete a repository ruleset](Repos::delete_repo_ruleset_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ReposDeleteRepoRulesetError { #[error("Resource not found")] Status404(BasicError), #[error("Internal Error")] @@ -1214,19 +1529,25 @@ pub enum ReposDeleteRepoRulesetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDeleteRepoRulesetError) -> Self { + let (description, status_code) = match err { + ReposDeleteRepoRulesetError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeleteRepoRulesetError::Status500(_) => (String::from("Internal Error"), 500), + ReposDeleteRepoRulesetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Deprecated - Delete a tag protection state for a repository](Repos::delete_tag_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteTagProtectionError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -1235,218 +1556,274 @@ pub enum ReposDeleteTagProtectionError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDeleteTagProtectionError) -> Self { + let (description, status_code) = match err { + ReposDeleteTagProtectionError::Status403(_) => (String::from("Forbidden"), 403), + ReposDeleteTagProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeleteTagProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a repository webhook](Repos::delete_webhook_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDeleteWebhookError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDeleteWebhookError) -> Self { + let (description, status_code) = match err { + ReposDeleteWebhookError::Status404(_) => (String::from("Resource not found"), 404), + ReposDeleteWebhookError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Disable automated security fixes](Repos::disable_automated_security_fixes_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDisableAutomatedSecurityFixesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDisableAutomatedSecurityFixesError) -> Self { + let (description, status_code) = match err { + ReposDisableAutomatedSecurityFixesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Disable a custom protection rule for an environment](Repos::disable_deployment_protection_rule_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDisableDeploymentProtectionRuleError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDisableDeploymentProtectionRuleError) -> Self { + let (description, status_code) = match err { + ReposDisableDeploymentProtectionRuleError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Disable private vulnerability reporting for a repository](Repos::disable_private_vulnerability_reporting_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDisablePrivateVulnerabilityReportingError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status422(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDisablePrivateVulnerabilityReportingError) -> Self { + let (description, status_code) = match err { + ReposDisablePrivateVulnerabilityReportingError::Status422(_) => (String::from("Bad Request"), 422), + ReposDisablePrivateVulnerabilityReportingError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Disable vulnerability alerts](Repos::disable_vulnerability_alerts_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDisableVulnerabilityAlertsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposDisableVulnerabilityAlertsError) -> Self { + let (description, status_code) = match err { + ReposDisableVulnerabilityAlertsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Download a repository archive (tar)](Repos::download_tarball_archive_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDownloadTarballArchiveError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status302, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDownloadTarballArchiveError) -> Self { + let (description, status_code) = match err { + ReposDownloadTarballArchiveError::Status302 => (String::from("Response"), 302), + ReposDownloadTarballArchiveError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Download a repository archive (zip)](Repos::download_zipball_archive_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposDownloadZipballArchiveError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status302, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposDownloadZipballArchiveError) -> Self { + let (description, status_code) = match err { + ReposDownloadZipballArchiveError::Status302 => (String::from("Response"), 302), + ReposDownloadZipballArchiveError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Enable automated security fixes](Repos::enable_automated_security_fixes_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposEnableAutomatedSecurityFixesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposEnableAutomatedSecurityFixesError) -> Self { + let (description, status_code) = match err { + ReposEnableAutomatedSecurityFixesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Enable private vulnerability reporting for a repository](Repos::enable_private_vulnerability_reporting_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposEnablePrivateVulnerabilityReportingError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status422(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposEnablePrivateVulnerabilityReportingError) -> Self { + let (description, status_code) = match err { + ReposEnablePrivateVulnerabilityReportingError::Status422(_) => (String::from("Bad Request"), 422), + ReposEnablePrivateVulnerabilityReportingError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Enable vulnerability alerts](Repos::enable_vulnerability_alerts_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposEnableVulnerabilityAlertsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposEnableVulnerabilityAlertsError) -> Self { + let (description, status_code) = match err { + ReposEnableVulnerabilityAlertsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Generate release notes content for a release](Repos::generate_release_notes_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGenerateReleaseNotesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGenerateReleaseNotesError) -> Self { + let (description, status_code) = match err { + ReposGenerateReleaseNotesError::Status404(_) => (String::from("Resource not found"), 404), + ReposGenerateReleaseNotesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository](Repos::get_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -1457,165 +1834,209 @@ pub enum ReposGetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetError) -> Self { + let (description, status_code) = match err { + ReposGetError::Status403(_) => (String::from("Forbidden"), 403), + ReposGetError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetError::Status301(_) => (String::from("Moved permanently"), 301), + ReposGetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get access restrictions](Repos::get_access_restrictions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetAccessRestrictionsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetAccessRestrictionsError) -> Self { + let (description, status_code) = match err { + ReposGetAccessRestrictionsError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetAccessRestrictionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get admin branch protection](Repos::get_admin_branch_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetAdminBranchProtectionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetAdminBranchProtectionError) -> Self { + let (description, status_code) = match err { + ReposGetAdminBranchProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all deployment protection rules for an environment](Repos::get_all_deployment_protection_rules_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetAllDeploymentProtectionRulesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetAllDeploymentProtectionRulesError) -> Self { + let (description, status_code) = match err { + ReposGetAllDeploymentProtectionRulesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List environments](Repos::get_all_environments_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetAllEnvironmentsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetAllEnvironmentsError) -> Self { + let (description, status_code) = match err { + ReposGetAllEnvironmentsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all status check contexts](Repos::get_all_status_check_contexts_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetAllStatusCheckContextsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetAllStatusCheckContextsError) -> Self { + let (description, status_code) = match err { + ReposGetAllStatusCheckContextsError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetAllStatusCheckContextsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all repository topics](Repos::get_all_topics_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetAllTopicsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetAllTopicsError) -> Self { + let (description, status_code) = match err { + ReposGetAllTopicsError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetAllTopicsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get apps with access to the protected branch](Repos::get_apps_with_access_to_protected_branch_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetAppsWithAccessToProtectedBranchError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetAppsWithAccessToProtectedBranchError) -> Self { + let (description, status_code) = match err { + ReposGetAppsWithAccessToProtectedBranchError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetAppsWithAccessToProtectedBranchError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an autolink reference of a repository](Repos::get_autolink_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetAutolinkError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetAutolinkError) -> Self { + let (description, status_code) = match err { + ReposGetAutolinkError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetAutolinkError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a branch](Repos::get_branch_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetBranchError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Moved permanently")] Status301(BasicError), #[error("Resource not found")] @@ -1624,74 +2045,94 @@ pub enum ReposGetBranchError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetBranchError) -> Self { + let (description, status_code) = match err { + ReposGetBranchError::Status301(_) => (String::from("Moved permanently"), 301), + ReposGetBranchError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetBranchError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get branch protection](Repos::get_branch_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetBranchProtectionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetBranchProtectionError) -> Self { + let (description, status_code) = match err { + ReposGetBranchProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetBranchProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get rules for a branch](Repos::get_branch_rules_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetBranchRulesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetBranchRulesError) -> Self { + let (description, status_code) = match err { + ReposGetBranchRulesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get repository clones](Repos::get_clones_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetClonesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetClonesError) -> Self { + let (description, status_code) = match err { + ReposGetClonesError::Status403(_) => (String::from("Forbidden"), 403), + ReposGetClonesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the weekly commit activity](Repos::get_code_frequency_stats_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetCodeFrequencyStatsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Accepted")] Status202(HashMap), #[error("A header with no content is returned.")] @@ -1702,57 +2143,74 @@ pub enum ReposGetCodeFrequencyStatsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetCodeFrequencyStatsError) -> Self { + let (description, status_code) = match err { + ReposGetCodeFrequencyStatsError::Status202(_) => (String::from("Accepted"), 202), + ReposGetCodeFrequencyStatsError::Status204 => (String::from("A header with no content is returned."), 204), + ReposGetCodeFrequencyStatsError::Status422 => (String::from("Repository contains more than 10,000 commits"), 422), + ReposGetCodeFrequencyStatsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get repository permissions for a user](Repos::get_collaborator_permission_level_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetCollaboratorPermissionLevelError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetCollaboratorPermissionLevelError) -> Self { + let (description, status_code) = match err { + ReposGetCollaboratorPermissionLevelError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetCollaboratorPermissionLevelError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the combined status for a specific reference](Repos::get_combined_status_for_ref_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetCombinedStatusForRefError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetCombinedStatusForRefError) -> Self { + let (description, status_code) = match err { + ReposGetCombinedStatusForRefError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetCombinedStatusForRefError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a commit](Repos::get_commit_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetCommitError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -1767,19 +2225,28 @@ pub enum ReposGetCommitError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetCommitError) -> Self { + let (description, status_code) = match err { + ReposGetCommitError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposGetCommitError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetCommitError::Status500(_) => (String::from("Internal Error"), 500), + ReposGetCommitError::Status503(_) => (String::from("Service unavailable"), 503), + ReposGetCommitError::Status409(_) => (String::from("Conflict"), 409), + ReposGetCommitError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the last year of commit activity](Repos::get_commit_activity_stats_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetCommitActivityStatsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Accepted")] Status202(HashMap), #[error("A header with no content is returned.")] @@ -1788,74 +2255,94 @@ pub enum ReposGetCommitActivityStatsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetCommitActivityStatsError) -> Self { + let (description, status_code) = match err { + ReposGetCommitActivityStatsError::Status202(_) => (String::from("Accepted"), 202), + ReposGetCommitActivityStatsError::Status204 => (String::from("A header with no content is returned."), 204), + ReposGetCommitActivityStatsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a commit comment](Repos::get_commit_comment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetCommitCommentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetCommitCommentError) -> Self { + let (description, status_code) = match err { + ReposGetCommitCommentError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetCommitCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get commit signature protection](Repos::get_commit_signature_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetCommitSignatureProtectionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetCommitSignatureProtectionError) -> Self { + let (description, status_code) = match err { + ReposGetCommitSignatureProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetCommitSignatureProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get community profile metrics](Repos::get_community_profile_metrics_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetCommunityProfileMetricsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetCommunityProfileMetricsError) -> Self { + let (description, status_code) = match err { + ReposGetCommunityProfileMetricsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get repository content](Repos::get_content_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetContentError { - #[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("Forbidden")] @@ -1868,19 +2355,27 @@ pub enum ReposGetContentError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetContentError) -> Self { + let (description, status_code) = match err { + ReposGetContentError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetContentError::Status403(_) => (String::from("Forbidden"), 403), + ReposGetContentError::Status302 => (String::from("Found"), 302), + ReposGetContentError::Status304 => (String::from("Not modified"), 304), + ReposGetContentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all contributor commit activity](Repos::get_contributors_stats_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetContributorsStatsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Accepted")] Status202(HashMap), #[error("A header with no content is returned.")] @@ -1889,36 +2384,46 @@ pub enum ReposGetContributorsStatsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetContributorsStatsError) -> Self { + let (description, status_code) = match err { + ReposGetContributorsStatsError::Status202(_) => (String::from("Accepted"), 202), + ReposGetContributorsStatsError::Status204 => (String::from("A header with no content is returned."), 204), + ReposGetContributorsStatsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a custom deployment protection rule](Repos::get_custom_deployment_protection_rule_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetCustomDeploymentProtectionRuleError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetCustomDeploymentProtectionRuleError) -> Self { + let (description, status_code) = match err { + ReposGetCustomDeploymentProtectionRuleError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all custom property values for a repository](Repos::get_custom_properties_values_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetCustomPropertiesValuesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -1927,144 +2432,181 @@ pub enum ReposGetCustomPropertiesValuesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetCustomPropertiesValuesError) -> Self { + let (description, status_code) = match err { + ReposGetCustomPropertiesValuesError::Status403(_) => (String::from("Forbidden"), 403), + ReposGetCustomPropertiesValuesError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetCustomPropertiesValuesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a deploy key](Repos::get_deploy_key_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetDeployKeyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetDeployKeyError) -> Self { + let (description, status_code) = match err { + ReposGetDeployKeyError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetDeployKeyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a deployment](Repos::get_deployment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetDeploymentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetDeploymentError) -> Self { + let (description, status_code) = match err { + ReposGetDeploymentError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetDeploymentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a deployment branch policy](Repos::get_deployment_branch_policy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetDeploymentBranchPolicyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetDeploymentBranchPolicyError) -> Self { + let (description, status_code) = match err { + ReposGetDeploymentBranchPolicyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a deployment status](Repos::get_deployment_status_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetDeploymentStatusError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetDeploymentStatusError) -> Self { + let (description, status_code) = match err { + ReposGetDeploymentStatusError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetDeploymentStatusError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an environment](Repos::get_environment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetEnvironmentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetEnvironmentError) -> Self { + let (description, status_code) = match err { + ReposGetEnvironmentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get latest Pages build](Repos::get_latest_pages_build_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetLatestPagesBuildError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetLatestPagesBuildError) -> Self { + let (description, status_code) = match err { + ReposGetLatestPagesBuildError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the latest release](Repos::get_latest_release_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetLatestReleaseError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetLatestReleaseError) -> Self { + let (description, status_code) = match err { + ReposGetLatestReleaseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization rule suite](Repos::get_org_rule_suite_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetOrgRuleSuiteError { - #[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("Internal Error")] @@ -2073,19 +2615,25 @@ pub enum ReposGetOrgRuleSuiteError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetOrgRuleSuiteError) -> Self { + let (description, status_code) = match err { + ReposGetOrgRuleSuiteError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetOrgRuleSuiteError::Status500(_) => (String::from("Internal Error"), 500), + ReposGetOrgRuleSuiteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization rule suites](Repos::get_org_rule_suites_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetOrgRuleSuitesError { - #[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("Internal Error")] @@ -2094,19 +2642,25 @@ pub enum ReposGetOrgRuleSuitesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetOrgRuleSuitesError) -> Self { + let (description, status_code) = match err { + ReposGetOrgRuleSuitesError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetOrgRuleSuitesError::Status500(_) => (String::from("Internal Error"), 500), + ReposGetOrgRuleSuitesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an organization repository ruleset](Repos::get_org_ruleset_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetOrgRulesetError { - #[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("Internal Error")] @@ -2115,19 +2669,25 @@ pub enum ReposGetOrgRulesetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetOrgRulesetError) -> Self { + let (description, status_code) = match err { + ReposGetOrgRulesetError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetOrgRulesetError::Status500(_) => (String::from("Internal Error"), 500), + ReposGetOrgRulesetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all organization repository rulesets](Repos::get_org_rulesets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetOrgRulesetsError { - #[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("Internal Error")] @@ -2136,74 +2696,94 @@ pub enum ReposGetOrgRulesetsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetOrgRulesetsError) -> Self { + let (description, status_code) = match err { + ReposGetOrgRulesetsError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetOrgRulesetsError::Status500(_) => (String::from("Internal Error"), 500), + ReposGetOrgRulesetsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a GitHub Pages site](Repos::get_pages_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetPagesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetPagesError) -> Self { + let (description, status_code) = match err { + ReposGetPagesError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetPagesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get GitHub Pages build](Repos::get_pages_build_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetPagesBuildError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetPagesBuildError) -> Self { + let (description, status_code) = match err { + ReposGetPagesBuildError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the status of a GitHub Pages deployment](Repos::get_pages_deployment_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetPagesDeploymentError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetPagesDeploymentError) -> Self { + let (description, status_code) = match err { + ReposGetPagesDeploymentError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetPagesDeploymentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a DNS health check for GitHub Pages](Repos::get_pages_health_check_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetPagesHealthCheckError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Empty response")] Status202(EmptyObject), #[error("Custom domains are not available for GitHub Pages")] @@ -2216,74 +2796,96 @@ pub enum ReposGetPagesHealthCheckError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetPagesHealthCheckError) -> Self { + let (description, status_code) = match err { + ReposGetPagesHealthCheckError::Status202(_) => (String::from("Empty response"), 202), + ReposGetPagesHealthCheckError::Status400 => (String::from("Custom domains are not available for GitHub Pages"), 400), + ReposGetPagesHealthCheckError::Status422 => (String::from("There isn't a CNAME for this page"), 422), + ReposGetPagesHealthCheckError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetPagesHealthCheckError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the weekly commit count](Repos::get_participation_stats_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetParticipationStatsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetParticipationStatsError) -> Self { + let (description, status_code) = match err { + ReposGetParticipationStatsError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetParticipationStatsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get pull request review protection](Repos::get_pull_request_review_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetPullRequestReviewProtectionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetPullRequestReviewProtectionError) -> Self { + let (description, status_code) = match err { + ReposGetPullRequestReviewProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the hourly commit count for each day](Repos::get_punch_card_stats_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetPunchCardStatsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("A header with no content is returned.")] Status204, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetPunchCardStatsError) -> Self { + let (description, status_code) = match err { + ReposGetPunchCardStatsError::Status204 => (String::from("A header with no content is returned."), 204), + ReposGetPunchCardStatsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository README](Repos::get_readme_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetReadmeError { - #[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("Resource not found")] @@ -2294,19 +2896,26 @@ pub enum ReposGetReadmeError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetReadmeError) -> Self { + let (description, status_code) = match err { + ReposGetReadmeError::Status304 => (String::from("Not modified"), 304), + ReposGetReadmeError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetReadmeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposGetReadmeError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository README for a directory](Repos::get_readme_in_directory_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetReadmeInDirectoryError { - #[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, or the endpoint has been spammed.")] @@ -2315,38 +2924,49 @@ pub enum ReposGetReadmeInDirectoryError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetReadmeInDirectoryError) -> Self { + let (description, status_code) = match err { + ReposGetReadmeInDirectoryError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetReadmeInDirectoryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposGetReadmeInDirectoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a release](Repos::get_release_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetReleaseError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Unauthorized")] Status401, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetReleaseError) -> Self { + let (description, status_code) = match err { + ReposGetReleaseError::Status401 => (String::from("Unauthorized"), 401), + ReposGetReleaseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a release asset](Repos::get_release_asset_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetReleaseAssetError { - #[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("Found")] @@ -2355,38 +2975,49 @@ pub enum ReposGetReleaseAssetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetReleaseAssetError) -> Self { + let (description, status_code) = match err { + ReposGetReleaseAssetError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetReleaseAssetError::Status302 => (String::from("Found"), 302), + ReposGetReleaseAssetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a release by tag name](Repos::get_release_by_tag_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetReleaseByTagError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetReleaseByTagError) -> Self { + let (description, status_code) = match err { + ReposGetReleaseByTagError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetReleaseByTagError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository rule suite](Repos::get_repo_rule_suite_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetRepoRuleSuiteError { - #[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("Internal Error")] @@ -2395,19 +3026,25 @@ pub enum ReposGetRepoRuleSuiteError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetRepoRuleSuiteError) -> Self { + let (description, status_code) = match err { + ReposGetRepoRuleSuiteError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetRepoRuleSuiteError::Status500(_) => (String::from("Internal Error"), 500), + ReposGetRepoRuleSuiteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository rule suites](Repos::get_repo_rule_suites_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetRepoRuleSuitesError { - #[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("Internal Error")] @@ -2416,19 +3053,25 @@ pub enum ReposGetRepoRuleSuitesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetRepoRuleSuitesError) -> Self { + let (description, status_code) = match err { + ReposGetRepoRuleSuitesError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetRepoRuleSuitesError::Status500(_) => (String::from("Internal Error"), 500), + ReposGetRepoRuleSuitesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository ruleset](Repos::get_repo_ruleset_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetRepoRulesetError { - #[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("Internal Error")] @@ -2437,19 +3080,25 @@ pub enum ReposGetRepoRulesetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetRepoRulesetError) -> Self { + let (description, status_code) = match err { + ReposGetRepoRulesetError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetRepoRulesetError::Status500(_) => (String::from("Internal Error"), 500), + ReposGetRepoRulesetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all repository rulesets](Repos::get_repo_rulesets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetRepoRulesetsError { - #[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("Internal Error")] @@ -2458,169 +3107,214 @@ pub enum ReposGetRepoRulesetsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetRepoRulesetsError) -> Self { + let (description, status_code) = match err { + ReposGetRepoRulesetsError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetRepoRulesetsError::Status500(_) => (String::from("Internal Error"), 500), + ReposGetRepoRulesetsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get status checks protection](Repos::get_status_checks_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetStatusChecksProtectionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetStatusChecksProtectionError) -> Self { + let (description, status_code) = match err { + ReposGetStatusChecksProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetStatusChecksProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get teams with access to the protected branch](Repos::get_teams_with_access_to_protected_branch_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetTeamsWithAccessToProtectedBranchError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetTeamsWithAccessToProtectedBranchError) -> Self { + let (description, status_code) = match err { + ReposGetTeamsWithAccessToProtectedBranchError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetTeamsWithAccessToProtectedBranchError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get top referral paths](Repos::get_top_paths_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetTopPathsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetTopPathsError) -> Self { + let (description, status_code) = match err { + ReposGetTopPathsError::Status403(_) => (String::from("Forbidden"), 403), + ReposGetTopPathsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get top referral sources](Repos::get_top_referrers_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetTopReferrersError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetTopReferrersError) -> Self { + let (description, status_code) = match err { + ReposGetTopReferrersError::Status403(_) => (String::from("Forbidden"), 403), + ReposGetTopReferrersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get users with access to the protected branch](Repos::get_users_with_access_to_protected_branch_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetUsersWithAccessToProtectedBranchError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetUsersWithAccessToProtectedBranchError) -> Self { + let (description, status_code) = match err { + ReposGetUsersWithAccessToProtectedBranchError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetUsersWithAccessToProtectedBranchError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get page views](Repos::get_views_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetViewsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetViewsError) -> Self { + let (description, status_code) = match err { + ReposGetViewsError::Status403(_) => (String::from("Forbidden"), 403), + ReposGetViewsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository webhook](Repos::get_webhook_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetWebhookError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposGetWebhookError) -> Self { + let (description, status_code) = match err { + ReposGetWebhookError::Status404(_) => (String::from("Resource not found"), 404), + ReposGetWebhookError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a webhook configuration for a repository](Repos::get_webhook_config_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetWebhookConfigForRepoError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - + #[error("Status code: {}", code)] + Generic { code: u16 }, +} - // -- endpoint errors +impl From for AdapterError { + fn from(err: ReposGetWebhookConfigForRepoError) -> Self { + let (description, status_code) = match err { + ReposGetWebhookConfigForRepoError::Generic { code } => (String::from("Generic"), code) + }; - #[error("Status code: {}", code)] - Generic { code: u16 }, + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } } /// Errors for the [Get a delivery for a repository webhook](Repos::get_webhook_delivery_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposGetWebhookDeliveryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -2629,91 +3323,115 @@ pub enum ReposGetWebhookDeliveryError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposGetWebhookDeliveryError) -> Self { + let (description, status_code) = match err { + ReposGetWebhookDeliveryError::Status400(_) => (String::from("Bad Request"), 400), + ReposGetWebhookDeliveryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposGetWebhookDeliveryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository activities](Repos::list_activities_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListActivitiesError { - #[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, or the endpoint has been spammed.")] Status422(ValidationErrorSimple), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListActivitiesError) -> Self { + let (description, status_code) = match err { + ReposListActivitiesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposListActivitiesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List attestations](Repos::list_attestations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListAttestationsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListAttestationsError) -> Self { + let (description, status_code) = match err { + ReposListAttestationsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get all autolinks of a repository](Repos::list_autolinks_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListAutolinksError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListAutolinksError) -> Self { + let (description, status_code) = match err { + ReposListAutolinksError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List branches](Repos::list_branches_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListBranchesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListBranchesError) -> Self { + let (description, status_code) = match err { + ReposListBranchesError::Status404(_) => (String::from("Resource not found"), 404), + ReposListBranchesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List branches for HEAD commit](Repos::list_branches_for_head_commit_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListBranchesForHeadCommitError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Conflict")] @@ -2722,91 +3440,115 @@ pub enum ReposListBranchesForHeadCommitError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListBranchesForHeadCommitError) -> Self { + let (description, status_code) = match err { + ReposListBranchesForHeadCommitError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposListBranchesForHeadCommitError::Status409(_) => (String::from("Conflict"), 409), + ReposListBranchesForHeadCommitError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository collaborators](Repos::list_collaborators_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListCollaboratorsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListCollaboratorsError) -> Self { + let (description, status_code) = match err { + ReposListCollaboratorsError::Status404(_) => (String::from("Resource not found"), 404), + ReposListCollaboratorsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List commit comments](Repos::list_comments_for_commit_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListCommentsForCommitError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListCommentsForCommitError) -> Self { + let (description, status_code) = match err { + ReposListCommentsForCommitError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List commit comments for a repository](Repos::list_commit_comments_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListCommitCommentsForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListCommitCommentsForRepoError) -> Self { + let (description, status_code) = match err { + ReposListCommitCommentsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List commit statuses for a reference](Repos::list_commit_statuses_for_ref_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListCommitStatusesForRefError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Moved permanently")] Status301(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListCommitStatusesForRefError) -> Self { + let (description, status_code) = match err { + ReposListCommitStatusesForRefError::Status301(_) => (String::from("Moved permanently"), 301), + ReposListCommitStatusesForRefError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List commits](Repos::list_commits_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListCommitsError { - #[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("Bad Request")] @@ -2819,19 +3561,27 @@ pub enum ReposListCommitsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListCommitsError) -> Self { + let (description, status_code) = match err { + ReposListCommitsError::Status500(_) => (String::from("Internal Error"), 500), + ReposListCommitsError::Status400(_) => (String::from("Bad Request"), 400), + ReposListCommitsError::Status404(_) => (String::from("Resource not found"), 404), + ReposListCommitsError::Status409(_) => (String::from("Conflict"), 409), + ReposListCommitsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository contributors](Repos::list_contributors_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListContributorsError { - #[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 repository is empty")] Status204, #[error("Forbidden")] @@ -2842,106 +3592,134 @@ pub enum ReposListContributorsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListContributorsError) -> Self { + let (description, status_code) = match err { + ReposListContributorsError::Status204 => (String::from("Response if repository is empty"), 204), + ReposListContributorsError::Status403(_) => (String::from("Forbidden"), 403), + ReposListContributorsError::Status404(_) => (String::from("Resource not found"), 404), + ReposListContributorsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List custom deployment rule integrations available for an environment](Repos::list_custom_deployment_rule_integrations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListCustomDeploymentRuleIntegrationsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListCustomDeploymentRuleIntegrationsError) -> Self { + let (description, status_code) = match err { + ReposListCustomDeploymentRuleIntegrationsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List deploy keys](Repos::list_deploy_keys_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListDeployKeysError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListDeployKeysError) -> Self { + let (description, status_code) = match err { + ReposListDeployKeysError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List deployment branch policies](Repos::list_deployment_branch_policies_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListDeploymentBranchPoliciesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListDeploymentBranchPoliciesError) -> Self { + let (description, status_code) = match err { + ReposListDeploymentBranchPoliciesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List deployment statuses](Repos::list_deployment_statuses_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListDeploymentStatusesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListDeploymentStatusesError) -> Self { + let (description, status_code) = match err { + ReposListDeploymentStatusesError::Status404(_) => (String::from("Resource not found"), 404), + ReposListDeploymentStatusesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List deployments](Repos::list_deployments_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListDeploymentsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListDeploymentsError) -> Self { + let (description, status_code) = match err { + ReposListDeploymentsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories for the authenticated user](Repos::list_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListForAuthenticatedUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -2954,89 +3732,114 @@ pub enum ReposListForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ReposListForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposListForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ReposListForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ReposListForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + ReposListForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List organization repositories](Repos::list_for_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListForOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListForOrgError) -> Self { + let (description, status_code) = match err { + ReposListForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repositories for a user](Repos::list_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListForUserError) -> Self { + let (description, status_code) = match err { + ReposListForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List forks](Repos::list_forks_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListForksError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListForksError) -> Self { + let (description, status_code) = match err { + ReposListForksError::Status400(_) => (String::from("Bad Request"), 400), + ReposListForksError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository invitations](Repos::list_invitations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListInvitationsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListInvitationsError) -> Self { + let (description, status_code) = match err { + ReposListInvitationsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository invitations for the authenticated user](Repos::list_invitations_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListInvitationsForAuthenticatedUserError { - #[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("Resource not found")] @@ -3049,53 +3852,69 @@ pub enum ReposListInvitationsForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListInvitationsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + ReposListInvitationsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + ReposListInvitationsForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + ReposListInvitationsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + ReposListInvitationsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + ReposListInvitationsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository languages](Repos::list_languages_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListLanguagesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListLanguagesError) -> Self { + let (description, status_code) = match err { + ReposListLanguagesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List GitHub Pages builds](Repos::list_pages_builds_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListPagesBuildsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListPagesBuildsError) -> Self { + let (description, status_code) = match err { + ReposListPagesBuildsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List public repositories](Repos::list_public_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListPublicError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -3104,74 +3923,94 @@ pub enum ReposListPublicError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListPublicError) -> Self { + let (description, status_code) = match err { + ReposListPublicError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposListPublicError::Status304 => (String::from("Not modified"), 304), + ReposListPublicError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List pull requests associated with a commit](Repos::list_pull_requests_associated_with_commit_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListPullRequestsAssociatedWithCommitError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Conflict")] Status409(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListPullRequestsAssociatedWithCommitError) -> Self { + let (description, status_code) = match err { + ReposListPullRequestsAssociatedWithCommitError::Status409(_) => (String::from("Conflict"), 409), + ReposListPullRequestsAssociatedWithCommitError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List release assets](Repos::list_release_assets_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListReleaseAssetsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListReleaseAssetsError) -> Self { + let (description, status_code) = match err { + ReposListReleaseAssetsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List releases](Repos::list_releases_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListReleasesError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListReleasesError) -> Self { + let (description, status_code) = match err { + ReposListReleasesError::Status404(_) => (String::from("Resource not found"), 404), + ReposListReleasesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Deprecated - List tag protection states for a repository](Repos::list_tag_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListTagProtectionError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -3180,55 +4019,70 @@ pub enum ReposListTagProtectionError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListTagProtectionError) -> Self { + let (description, status_code) = match err { + ReposListTagProtectionError::Status403(_) => (String::from("Forbidden"), 403), + ReposListTagProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposListTagProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository tags](Repos::list_tags_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListTagsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListTagsError) -> Self { + let (description, status_code) = match err { + ReposListTagsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository teams](Repos::list_teams_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListTeamsError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListTeamsError) -> Self { + let (description, status_code) = match err { + ReposListTeamsError::Status404(_) => (String::from("Resource not found"), 404), + ReposListTeamsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List deliveries for a repository webhook](Repos::list_webhook_deliveries_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListWebhookDeliveriesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -3237,38 +4091,49 @@ pub enum ReposListWebhookDeliveriesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposListWebhookDeliveriesError) -> Self { + let (description, status_code) = match err { + ReposListWebhookDeliveriesError::Status400(_) => (String::from("Bad Request"), 400), + ReposListWebhookDeliveriesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposListWebhookDeliveriesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository webhooks](Repos::list_webhooks_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposListWebhooksError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposListWebhooksError) -> Self { + let (description, status_code) = match err { + ReposListWebhooksError::Status404(_) => (String::from("Resource not found"), 404), + ReposListWebhooksError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Merge a branch](Repos::merge_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposMergeError { - #[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 already merged")] Status204, #[error("Not Found when the base or head does not exist")] @@ -3283,19 +4148,28 @@ pub enum ReposMergeError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposMergeError) -> Self { + let (description, status_code) = match err { + ReposMergeError::Status204 => (String::from("Response when already merged"), 204), + ReposMergeError::Status404 => (String::from("Not Found when the base or head does not exist"), 404), + ReposMergeError::Status409 => (String::from("Conflict when there is a merge conflict"), 409), + ReposMergeError::Status403(_) => (String::from("Forbidden"), 403), + ReposMergeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposMergeError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Sync a fork branch with the upstream repository](Repos::merge_upstream_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposMergeUpstreamError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("The branch could not be synced because of a merge conflict")] Status409, #[error("The branch could not be synced for some other reason")] @@ -3304,38 +4178,49 @@ pub enum ReposMergeUpstreamError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposMergeUpstreamError) -> Self { + let (description, status_code) = match err { + ReposMergeUpstreamError::Status409 => (String::from("The branch could not be synced because of a merge conflict"), 409), + ReposMergeUpstreamError::Status422 => (String::from("The branch could not be synced for some other reason"), 422), + ReposMergeUpstreamError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Ping a repository webhook](Repos::ping_webhook_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposPingWebhookError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposPingWebhookError) -> Self { + let (description, status_code) = match err { + ReposPingWebhookError::Status404(_) => (String::from("Resource not found"), 404), + ReposPingWebhookError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Redeliver a delivery for a repository webhook](Repos::redeliver_webhook_delivery_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposRedeliverWebhookDeliveryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -3344,38 +4229,49 @@ pub enum ReposRedeliverWebhookDeliveryError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposRedeliverWebhookDeliveryError) -> Self { + let (description, status_code) = match err { + ReposRedeliverWebhookDeliveryError::Status400(_) => (String::from("Bad Request"), 400), + ReposRedeliverWebhookDeliveryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposRedeliverWebhookDeliveryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove app access restrictions](Repos::remove_app_access_restrictions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposRemoveAppAccessRestrictionsError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposRemoveAppAccessRestrictionsError) -> Self { + let (description, status_code) = match err { + ReposRemoveAppAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposRemoveAppAccessRestrictionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove a repository collaborator](Repos::remove_collaborator_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposRemoveCollaboratorError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Forbidden")] @@ -3384,19 +4280,25 @@ pub enum ReposRemoveCollaboratorError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposRemoveCollaboratorError) -> Self { + let (description, status_code) = match err { + ReposRemoveCollaboratorError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposRemoveCollaboratorError::Status403(_) => (String::from("Forbidden"), 403), + ReposRemoveCollaboratorError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove status check contexts](Repos::remove_status_check_contexts_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposRemoveStatusCheckContextsError { - #[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, or the endpoint has been spammed.")] @@ -3405,74 +4307,94 @@ pub enum ReposRemoveStatusCheckContextsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposRemoveStatusCheckContextsError) -> Self { + let (description, status_code) = match err { + ReposRemoveStatusCheckContextsError::Status404(_) => (String::from("Resource not found"), 404), + ReposRemoveStatusCheckContextsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposRemoveStatusCheckContextsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove status check protection](Repos::remove_status_check_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposRemoveStatusCheckProtectionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposRemoveStatusCheckProtectionError) -> Self { + let (description, status_code) = match err { + ReposRemoveStatusCheckProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove team access restrictions](Repos::remove_team_access_restrictions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposRemoveTeamAccessRestrictionsError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposRemoveTeamAccessRestrictionsError) -> Self { + let (description, status_code) = match err { + ReposRemoveTeamAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposRemoveTeamAccessRestrictionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove user access restrictions](Repos::remove_user_access_restrictions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposRemoveUserAccessRestrictionsError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposRemoveUserAccessRestrictionsError) -> Self { + let (description, status_code) = match err { + ReposRemoveUserAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposRemoveUserAccessRestrictionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Rename a branch](Repos::rename_branch_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposRenameBranchError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -3483,19 +4405,26 @@ pub enum ReposRenameBranchError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposRenameBranchError) -> Self { + let (description, status_code) = match err { + ReposRenameBranchError::Status403(_) => (String::from("Forbidden"), 403), + ReposRenameBranchError::Status404(_) => (String::from("Resource not found"), 404), + ReposRenameBranchError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposRenameBranchError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Replace all repository topics](Repos::replace_all_topics_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposReplaceAllTopicsError { - #[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, or the endpoint has been spammed.")] @@ -3504,72 +4433,91 @@ pub enum ReposReplaceAllTopicsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposReplaceAllTopicsError) -> Self { + let (description, status_code) = match err { + ReposReplaceAllTopicsError::Status404(_) => (String::from("Resource not found"), 404), + ReposReplaceAllTopicsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposReplaceAllTopicsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Request a GitHub Pages build](Repos::request_pages_build_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposRequestPagesBuildError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposRequestPagesBuildError) -> Self { + let (description, status_code) = match err { + ReposRequestPagesBuildError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set admin branch protection](Repos::set_admin_branch_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposSetAdminBranchProtectionError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposSetAdminBranchProtectionError) -> Self { + let (description, status_code) = match err { + ReposSetAdminBranchProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set app access restrictions](Repos::set_app_access_restrictions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposSetAppAccessRestrictionsError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposSetAppAccessRestrictionsError) -> Self { + let (description, status_code) = match err { + ReposSetAppAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposSetAppAccessRestrictionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set status check contexts](Repos::set_status_check_contexts_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposSetStatusCheckContextsError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -3578,93 +4526,118 @@ pub enum ReposSetStatusCheckContextsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposSetStatusCheckContextsError) -> Self { + let (description, status_code) = match err { + ReposSetStatusCheckContextsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposSetStatusCheckContextsError::Status404(_) => (String::from("Resource not found"), 404), + ReposSetStatusCheckContextsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set team access restrictions](Repos::set_team_access_restrictions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposSetTeamAccessRestrictionsError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposSetTeamAccessRestrictionsError) -> Self { + let (description, status_code) = match err { + ReposSetTeamAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposSetTeamAccessRestrictionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set user access restrictions](Repos::set_user_access_restrictions_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposSetUserAccessRestrictionsError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposSetUserAccessRestrictionsError) -> Self { + let (description, status_code) = match err { + ReposSetUserAccessRestrictionsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposSetUserAccessRestrictionsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Test the push repository webhook](Repos::test_push_webhook_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposTestPushWebhookError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposTestPushWebhookError) -> Self { + let (description, status_code) = match err { + ReposTestPushWebhookError::Status404(_) => (String::from("Resource not found"), 404), + ReposTestPushWebhookError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Transfer a repository](Repos::transfer_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposTransferError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposTransferError) -> Self { + let (description, status_code) = match err { + ReposTransferError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a repository](Repos::update_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Temporary Redirect")] Status307(BasicError), #[error("Forbidden")] @@ -3677,19 +4650,27 @@ pub enum ReposUpdateError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposUpdateError) -> Self { + let (description, status_code) = match err { + ReposUpdateError::Status307(_) => (String::from("Temporary Redirect"), 307), + ReposUpdateError::Status403(_) => (String::from("Forbidden"), 403), + ReposUpdateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposUpdateError::Status404(_) => (String::from("Resource not found"), 404), + ReposUpdateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update branch protection](Repos::update_branch_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateBranchProtectionError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -3700,55 +4681,71 @@ pub enum ReposUpdateBranchProtectionError { Generic { code: u16 }, } -/// Errors for the [Update a commit comment](Repos::update_commit_comment_async()) endpoint. -#[derive(Debug, thiserror::Error)] -pub enum ReposUpdateCommitCommentError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - +impl From for AdapterError { + fn from(err: ReposUpdateBranchProtectionError) -> Self { + let (description, status_code) = match err { + ReposUpdateBranchProtectionError::Status403(_) => (String::from("Forbidden"), 403), + ReposUpdateBranchProtectionError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposUpdateBranchProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposUpdateBranchProtectionError::Generic { code } => (String::from("Generic"), code) + }; - // -- endpoint errors + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} +/// Errors for the [Update a commit comment](Repos::update_commit_comment_async()) endpoint. +#[derive(Debug, thiserror::Error)] +pub enum ReposUpdateCommitCommentError { #[error("Resource not found")] Status404(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposUpdateCommitCommentError) -> Self { + let (description, status_code) = match err { + ReposUpdateCommitCommentError::Status404(_) => (String::from("Resource not found"), 404), + ReposUpdateCommitCommentError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a deployment branch policy](Repos::update_deployment_branch_policy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateDeploymentBranchPolicyError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposUpdateDeploymentBranchPolicyError) -> Self { + let (description, status_code) = match err { + ReposUpdateDeploymentBranchPolicyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update information about a GitHub Pages site](Repos::update_information_about_pages_site_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateInformationAboutPagesSiteError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Bad Request")] @@ -3759,36 +4756,47 @@ pub enum ReposUpdateInformationAboutPagesSiteError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposUpdateInformationAboutPagesSiteError) -> Self { + let (description, status_code) = match err { + ReposUpdateInformationAboutPagesSiteError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposUpdateInformationAboutPagesSiteError::Status400(_) => (String::from("Bad Request"), 400), + ReposUpdateInformationAboutPagesSiteError::Status409(_) => (String::from("Conflict"), 409), + ReposUpdateInformationAboutPagesSiteError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a repository invitation](Repos::update_invitation_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateInvitationError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposUpdateInvitationError) -> Self { + let (description, status_code) = match err { + ReposUpdateInvitationError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update an organization repository ruleset](Repos::update_org_ruleset_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateOrgRulesetError { - #[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("Internal Error")] @@ -3797,74 +4805,94 @@ pub enum ReposUpdateOrgRulesetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposUpdateOrgRulesetError) -> Self { + let (description, status_code) = match err { + ReposUpdateOrgRulesetError::Status404(_) => (String::from("Resource not found"), 404), + ReposUpdateOrgRulesetError::Status500(_) => (String::from("Internal Error"), 500), + ReposUpdateOrgRulesetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update pull request review protection](Repos::update_pull_request_review_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdatePullRequestReviewProtectionError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposUpdatePullRequestReviewProtectionError) -> Self { + let (description, status_code) = match err { + ReposUpdatePullRequestReviewProtectionError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposUpdatePullRequestReviewProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a release](Repos::update_release_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateReleaseError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if the discussion category name is invalid")] Status404(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposUpdateReleaseError) -> Self { + let (description, status_code) = match err { + ReposUpdateReleaseError::Status404(_) => (String::from("Not Found if the discussion category name is invalid"), 404), + ReposUpdateReleaseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a release asset](Repos::update_release_asset_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateReleaseAssetError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposUpdateReleaseAssetError) -> Self { + let (description, status_code) = match err { + ReposUpdateReleaseAssetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a repository ruleset](Repos::update_repo_ruleset_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateRepoRulesetError { - #[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("Internal Error")] @@ -3873,19 +4901,25 @@ pub enum ReposUpdateRepoRulesetError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposUpdateRepoRulesetError) -> Self { + let (description, status_code) = match err { + ReposUpdateRepoRulesetError::Status404(_) => (String::from("Resource not found"), 404), + ReposUpdateRepoRulesetError::Status500(_) => (String::from("Internal Error"), 500), + ReposUpdateRepoRulesetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update status check protection](Repos::update_status_check_protection_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateStatusCheckProtectionError { - #[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, or the endpoint has been spammed.")] @@ -3894,19 +4928,25 @@ pub enum ReposUpdateStatusCheckProtectionError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposUpdateStatusCheckProtectionError) -> Self { + let (description, status_code) = match err { + ReposUpdateStatusCheckProtectionError::Status404(_) => (String::from("Resource not found"), 404), + ReposUpdateStatusCheckProtectionError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposUpdateStatusCheckProtectionError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a repository webhook](Repos::update_webhook_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateWebhookError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Resource not found")] @@ -3915,42 +4955,67 @@ pub enum ReposUpdateWebhookError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposUpdateWebhookError) -> Self { + let (description, status_code) = match err { + ReposUpdateWebhookError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + ReposUpdateWebhookError::Status404(_) => (String::from("Resource not found"), 404), + ReposUpdateWebhookError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a webhook configuration for a repository](Repos::update_webhook_config_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUpdateWebhookConfigForRepoError { - #[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 }, } +impl From for AdapterError { + fn from(err: ReposUpdateWebhookConfigForRepoError) -> Self { + let (description, status_code) = match err { + ReposUpdateWebhookConfigForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Upload a release asset](Repos::upload_release_asset_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum ReposUploadReleaseAssetError { - #[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 you upload an asset with the same filename as another uploaded asset")] Status422, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: ReposUploadReleaseAssetError) -> Self { + let (description, status_code) = match err { + ReposUploadReleaseAssetError::Status422 => (String::from("Response if you upload an asset with the same filename as another uploaded asset"), 422), + ReposUploadReleaseAssetError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List CODEOWNERS errors](Repos::codeowners_errors_async()) endpoint. #[derive(Default, Serialize)] @@ -6423,7 +7488,7 @@ impl<'req> ReposUploadReleaseAssetParams<'req> { } -impl<'api, C: Client> Repos<'api, C> { +impl<'api, C: Client> Repos<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Accept a repository invitation @@ -6431,19 +7496,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for accept_invitation_for_authenticated_user](https://docs.github.com/rest/collaborators/invitations#accept-a-repository-invitation) /// /// --- - pub async fn accept_invitation_for_authenticated_user_async(&self, invitation_id: i32) -> Result<(), ReposAcceptInvitationForAuthenticatedUserError> { + pub async fn accept_invitation_for_authenticated_user_async(&self, invitation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/repository_invitations/{}", super::GITHUB_BASE_API_URL, invitation_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6455,11 +7520,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 409 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status409(github_response.to_json_async().await?)), - 404 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 304 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status304), - code => Err(ReposAcceptInvitationForAuthenticatedUserError::Generic { code }), + 403 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 409 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status409(github_response.to_json_async().await?).into()), + 404 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status304.into()), + code => Err(ReposAcceptInvitationForAuthenticatedUserError::Generic { code }.into()), } } } @@ -6472,7 +7537,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn accept_invitation_for_authenticated_user(&self, invitation_id: i32) -> Result<(), ReposAcceptInvitationForAuthenticatedUserError> { + pub fn accept_invitation_for_authenticated_user(&self, invitation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/repository_invitations/{}", super::GITHUB_BASE_API_URL, invitation_id); @@ -6484,7 +7549,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6496,11 +7561,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status403(github_response.to_json()?)), - 409 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status409(github_response.to_json()?)), - 404 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status404(github_response.to_json()?)), - 304 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status304), - code => Err(ReposAcceptInvitationForAuthenticatedUserError::Generic { code }), + 403 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 409 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status409(github_response.to_json()?).into()), + 404 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 304 => Err(ReposAcceptInvitationForAuthenticatedUserError::Status304.into()), + code => Err(ReposAcceptInvitationForAuthenticatedUserError::Generic { code }.into()), } } } @@ -6516,19 +7581,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for add_app_access_restrictions](https://docs.github.com/rest/branches/branch-protection#add-app-access-restrictions) /// /// --- - pub async fn add_app_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddAppAccessRestrictions) -> Result, ReposAddAppAccessRestrictionsError> { + pub async fn add_app_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddAppAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposAddAppAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6540,8 +7605,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposAddAppAccessRestrictionsError::Status422(github_response.to_json_async().await?)), - code => Err(ReposAddAppAccessRestrictionsError::Generic { code }), + 422 => Err(ReposAddAppAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposAddAppAccessRestrictionsError::Generic { code }.into()), } } } @@ -6558,19 +7623,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_app_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddAppAccessRestrictions) -> Result, ReposAddAppAccessRestrictionsError> { + pub fn add_app_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddAppAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposAddAppAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6582,8 +7647,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposAddAppAccessRestrictionsError::Status422(github_response.to_json()?)), - code => Err(ReposAddAppAccessRestrictionsError::Generic { code }), + 422 => Err(ReposAddAppAccessRestrictionsError::Status422(github_response.to_json()?).into()), + code => Err(ReposAddAppAccessRestrictionsError::Generic { code }.into()), } } } @@ -6617,19 +7682,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for add_collaborator](https://docs.github.com/rest/collaborators/collaborators#add-a-repository-collaborator) /// /// --- - pub async fn add_collaborator_async(&self, owner: &str, repo: &str, username: &str, body: PutReposAddCollaborator) -> Result { + pub async fn add_collaborator_async(&self, owner: &str, repo: &str, username: &str, body: PutReposAddCollaborator) -> Result { let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposAddCollaborator::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6641,10 +7706,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(ReposAddCollaboratorError::Status204), - 422 => Err(ReposAddCollaboratorError::Status422(github_response.to_json_async().await?)), - 403 => Err(ReposAddCollaboratorError::Status403(github_response.to_json_async().await?)), - code => Err(ReposAddCollaboratorError::Generic { code }), + 204 => Err(ReposAddCollaboratorError::Status204.into()), + 422 => Err(ReposAddCollaboratorError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(ReposAddCollaboratorError::Status403(github_response.to_json_async().await?).into()), + code => Err(ReposAddCollaboratorError::Generic { code }.into()), } } } @@ -6679,19 +7744,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_collaborator(&self, owner: &str, repo: &str, username: &str, body: PutReposAddCollaborator) -> Result { + pub fn add_collaborator(&self, owner: &str, repo: &str, username: &str, body: PutReposAddCollaborator) -> Result { let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposAddCollaborator::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6703,10 +7768,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(ReposAddCollaboratorError::Status204), - 422 => Err(ReposAddCollaboratorError::Status422(github_response.to_json()?)), - 403 => Err(ReposAddCollaboratorError::Status403(github_response.to_json()?)), - code => Err(ReposAddCollaboratorError::Generic { code }), + 204 => Err(ReposAddCollaboratorError::Status204.into()), + 422 => Err(ReposAddCollaboratorError::Status422(github_response.to_json()?).into()), + 403 => Err(ReposAddCollaboratorError::Status403(github_response.to_json()?).into()), + code => Err(ReposAddCollaboratorError::Generic { code }.into()), } } } @@ -6720,19 +7785,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for add_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#add-status-check-contexts) /// /// --- - pub async fn add_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddStatusCheckContexts) -> Result, ReposAddStatusCheckContextsError> { + pub async fn add_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddStatusCheckContexts) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposAddStatusCheckContexts::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6744,10 +7809,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposAddStatusCheckContextsError::Status422(github_response.to_json_async().await?)), - 403 => Err(ReposAddStatusCheckContextsError::Status403(github_response.to_json_async().await?)), - 404 => Err(ReposAddStatusCheckContextsError::Status404(github_response.to_json_async().await?)), - code => Err(ReposAddStatusCheckContextsError::Generic { code }), + 422 => Err(ReposAddStatusCheckContextsError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(ReposAddStatusCheckContextsError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ReposAddStatusCheckContextsError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposAddStatusCheckContextsError::Generic { code }.into()), } } } @@ -6762,19 +7827,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_status_check_contexts(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddStatusCheckContexts) -> Result, ReposAddStatusCheckContextsError> { + pub fn add_status_check_contexts(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddStatusCheckContexts) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposAddStatusCheckContexts::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6786,10 +7851,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposAddStatusCheckContextsError::Status422(github_response.to_json()?)), - 403 => Err(ReposAddStatusCheckContextsError::Status403(github_response.to_json()?)), - 404 => Err(ReposAddStatusCheckContextsError::Status404(github_response.to_json()?)), - code => Err(ReposAddStatusCheckContextsError::Generic { code }), + 422 => Err(ReposAddStatusCheckContextsError::Status422(github_response.to_json()?).into()), + 403 => Err(ReposAddStatusCheckContextsError::Status403(github_response.to_json()?).into()), + 404 => Err(ReposAddStatusCheckContextsError::Status404(github_response.to_json()?).into()), + code => Err(ReposAddStatusCheckContextsError::Generic { code }.into()), } } } @@ -6805,19 +7870,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for add_team_access_restrictions](https://docs.github.com/rest/branches/branch-protection#add-team-access-restrictions) /// /// --- - pub async fn add_team_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddTeamAccessRestrictions) -> Result, ReposAddTeamAccessRestrictionsError> { + pub async fn add_team_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddTeamAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposAddTeamAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6829,8 +7894,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposAddTeamAccessRestrictionsError::Status422(github_response.to_json_async().await?)), - code => Err(ReposAddTeamAccessRestrictionsError::Generic { code }), + 422 => Err(ReposAddTeamAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposAddTeamAccessRestrictionsError::Generic { code }.into()), } } } @@ -6847,19 +7912,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_team_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddTeamAccessRestrictions) -> Result, ReposAddTeamAccessRestrictionsError> { + pub fn add_team_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddTeamAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposAddTeamAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6871,8 +7936,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposAddTeamAccessRestrictionsError::Status422(github_response.to_json()?)), - code => Err(ReposAddTeamAccessRestrictionsError::Generic { code }), + 422 => Err(ReposAddTeamAccessRestrictionsError::Status422(github_response.to_json()?).into()), + code => Err(ReposAddTeamAccessRestrictionsError::Generic { code }.into()), } } } @@ -6892,19 +7957,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for add_user_access_restrictions](https://docs.github.com/rest/branches/branch-protection#add-user-access-restrictions) /// /// --- - pub async fn add_user_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddUserAccessRestrictions) -> Result, ReposAddUserAccessRestrictionsError> { + pub async fn add_user_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddUserAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposAddUserAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6916,8 +7981,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposAddUserAccessRestrictionsError::Status422(github_response.to_json_async().await?)), - code => Err(ReposAddUserAccessRestrictionsError::Generic { code }), + 422 => Err(ReposAddUserAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposAddUserAccessRestrictionsError::Generic { code }.into()), } } } @@ -6938,19 +8003,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_user_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddUserAccessRestrictions) -> Result, ReposAddUserAccessRestrictionsError> { + pub fn add_user_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PostReposAddUserAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposAddUserAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6962,8 +8027,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposAddUserAccessRestrictionsError::Status422(github_response.to_json()?)), - code => Err(ReposAddUserAccessRestrictionsError::Generic { code }), + 422 => Err(ReposAddUserAccessRestrictionsError::Status422(github_response.to_json()?).into()), + code => Err(ReposAddUserAccessRestrictionsError::Generic { code }.into()), } } } @@ -6979,19 +8044,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for cancel_pages_deployment](https://docs.github.com/rest/pages/pages#cancel-a-github-pages-deployment) /// /// --- - pub async fn cancel_pages_deployment_async(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result<(), ReposCancelPagesDeploymentError> { + pub async fn cancel_pages_deployment_async(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pages/deployments/{}/cancel", super::GITHUB_BASE_API_URL, owner, repo, pages_deployment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7003,8 +8068,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCancelPagesDeploymentError::Status404(github_response.to_json_async().await?)), - code => Err(ReposCancelPagesDeploymentError::Generic { code }), + 404 => Err(ReposCancelPagesDeploymentError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposCancelPagesDeploymentError::Generic { code }.into()), } } } @@ -7021,7 +8086,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn cancel_pages_deployment(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result<(), ReposCancelPagesDeploymentError> { + pub fn cancel_pages_deployment(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pages/deployments/{}/cancel", super::GITHUB_BASE_API_URL, owner, repo, pages_deployment_id); @@ -7033,7 +8098,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7045,8 +8110,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCancelPagesDeploymentError::Status404(github_response.to_json()?)), - code => Err(ReposCancelPagesDeploymentError::Generic { code }), + 404 => Err(ReposCancelPagesDeploymentError::Status404(github_response.to_json()?).into()), + code => Err(ReposCancelPagesDeploymentError::Generic { code }.into()), } } } @@ -7060,19 +8125,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for check_automated_security_fixes](https://docs.github.com/rest/repos/repos#check-if-automated-security-fixes-are-enabled-for-a-repository) /// /// --- - pub async fn check_automated_security_fixes_async(&self, owner: &str, repo: &str) -> Result { + pub async fn check_automated_security_fixes_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7084,8 +8149,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCheckAutomatedSecurityFixesError::Status404), - code => Err(ReposCheckAutomatedSecurityFixesError::Generic { code }), + 404 => Err(ReposCheckAutomatedSecurityFixesError::Status404.into()), + code => Err(ReposCheckAutomatedSecurityFixesError::Generic { code }.into()), } } } @@ -7100,7 +8165,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_automated_security_fixes(&self, owner: &str, repo: &str) -> Result { + pub fn check_automated_security_fixes(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo); @@ -7112,7 +8177,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7124,8 +8189,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCheckAutomatedSecurityFixesError::Status404), - code => Err(ReposCheckAutomatedSecurityFixesError::Generic { code }), + 404 => Err(ReposCheckAutomatedSecurityFixesError::Status404.into()), + code => Err(ReposCheckAutomatedSecurityFixesError::Generic { code }.into()), } } } @@ -7145,19 +8210,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for check_collaborator](https://docs.github.com/rest/collaborators/collaborators#check-if-a-user-is-a-repository-collaborator) /// /// --- - pub async fn check_collaborator_async(&self, owner: &str, repo: &str, username: &str) -> Result<(), ReposCheckCollaboratorError> { + pub async fn check_collaborator_async(&self, owner: &str, repo: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7169,8 +8234,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCheckCollaboratorError::Status404), - code => Err(ReposCheckCollaboratorError::Generic { code }), + 404 => Err(ReposCheckCollaboratorError::Status404.into()), + code => Err(ReposCheckCollaboratorError::Generic { code }.into()), } } } @@ -7191,7 +8256,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_collaborator(&self, owner: &str, repo: &str, username: &str) -> Result<(), ReposCheckCollaboratorError> { + pub fn check_collaborator(&self, owner: &str, repo: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, username); @@ -7203,7 +8268,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7215,8 +8280,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCheckCollaboratorError::Status404), - code => Err(ReposCheckCollaboratorError::Generic { code }), + 404 => Err(ReposCheckCollaboratorError::Status404.into()), + code => Err(ReposCheckCollaboratorError::Generic { code }.into()), } } } @@ -7230,19 +8295,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for check_private_vulnerability_reporting](https://docs.github.com/rest/repos/repos#check-if-private-vulnerability-reporting-is-enabled-for-a-repository) /// /// --- - pub async fn check_private_vulnerability_reporting_async(&self, owner: &str, repo: &str) -> Result { + pub async fn check_private_vulnerability_reporting_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7254,8 +8319,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposCheckPrivateVulnerabilityReportingError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCheckPrivateVulnerabilityReportingError::Generic { code }), + 422 => Err(ReposCheckPrivateVulnerabilityReportingError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCheckPrivateVulnerabilityReportingError::Generic { code }.into()), } } } @@ -7270,7 +8335,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_private_vulnerability_reporting(&self, owner: &str, repo: &str) -> Result { + pub fn check_private_vulnerability_reporting(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo); @@ -7282,7 +8347,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7294,8 +8359,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposCheckPrivateVulnerabilityReportingError::Status422(github_response.to_json()?)), - code => Err(ReposCheckPrivateVulnerabilityReportingError::Generic { code }), + 422 => Err(ReposCheckPrivateVulnerabilityReportingError::Status422(github_response.to_json()?).into()), + code => Err(ReposCheckPrivateVulnerabilityReportingError::Generic { code }.into()), } } } @@ -7309,19 +8374,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for check_vulnerability_alerts](https://docs.github.com/rest/repos/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository) /// /// --- - pub async fn check_vulnerability_alerts_async(&self, owner: &str, repo: &str) -> Result<(), ReposCheckVulnerabilityAlertsError> { + pub async fn check_vulnerability_alerts_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7333,8 +8398,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCheckVulnerabilityAlertsError::Status404), - code => Err(ReposCheckVulnerabilityAlertsError::Generic { code }), + 404 => Err(ReposCheckVulnerabilityAlertsError::Status404.into()), + code => Err(ReposCheckVulnerabilityAlertsError::Generic { code }.into()), } } } @@ -7349,7 +8414,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_vulnerability_alerts(&self, owner: &str, repo: &str) -> Result<(), ReposCheckVulnerabilityAlertsError> { + pub fn check_vulnerability_alerts(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo); @@ -7361,7 +8426,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7373,8 +8438,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCheckVulnerabilityAlertsError::Status404), - code => Err(ReposCheckVulnerabilityAlertsError::Generic { code }), + 404 => Err(ReposCheckVulnerabilityAlertsError::Status404.into()), + code => Err(ReposCheckVulnerabilityAlertsError::Generic { code }.into()), } } } @@ -7392,7 +8457,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for codeowners_errors](https://docs.github.com/rest/repos/repos#list-codeowners-errors) /// /// --- - pub async fn codeowners_errors_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub async fn codeowners_errors_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codeowners/errors", super::GITHUB_BASE_API_URL, owner, repo); @@ -7403,12 +8468,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7420,8 +8485,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCodeownersErrorsError::Status404), - code => Err(ReposCodeownersErrorsError::Generic { code }), + 404 => Err(ReposCodeownersErrorsError::Status404.into()), + code => Err(ReposCodeownersErrorsError::Generic { code }.into()), } } } @@ -7440,7 +8505,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn codeowners_errors(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub fn codeowners_errors(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/codeowners/errors", super::GITHUB_BASE_API_URL, owner, repo); @@ -7457,7 +8522,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7469,8 +8534,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCodeownersErrorsError::Status404), - code => Err(ReposCodeownersErrorsError::Generic { code }), + 404 => Err(ReposCodeownersErrorsError::Status404.into()), + code => Err(ReposCodeownersErrorsError::Generic { code }.into()), } } } @@ -7533,7 +8598,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for compare_commits](https://docs.github.com/rest/commits/commits#compare-two-commits) /// /// --- - pub async fn compare_commits_async(&self, owner: &str, repo: &str, basehead: &str, query_params: Option>) -> Result { + pub async fn compare_commits_async(&self, owner: &str, repo: &str, basehead: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/compare/{}", super::GITHUB_BASE_API_URL, owner, repo, basehead); @@ -7544,12 +8609,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7561,10 +8626,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCompareCommitsError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposCompareCommitsError::Status500(github_response.to_json_async().await?)), - 503 => Err(ReposCompareCommitsError::Status503(github_response.to_json_async().await?)), - code => Err(ReposCompareCommitsError::Generic { code }), + 404 => Err(ReposCompareCommitsError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposCompareCommitsError::Status500(github_response.to_json_async().await?).into()), + 503 => Err(ReposCompareCommitsError::Status503(github_response.to_json_async().await?).into()), + code => Err(ReposCompareCommitsError::Generic { code }.into()), } } } @@ -7628,7 +8693,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn compare_commits(&self, owner: &str, repo: &str, basehead: &str, query_params: Option>) -> Result { + pub fn compare_commits(&self, owner: &str, repo: &str, basehead: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/compare/{}", super::GITHUB_BASE_API_URL, owner, repo, basehead); @@ -7645,7 +8710,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7657,10 +8722,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCompareCommitsError::Status404(github_response.to_json()?)), - 500 => Err(ReposCompareCommitsError::Status500(github_response.to_json()?)), - 503 => Err(ReposCompareCommitsError::Status503(github_response.to_json()?)), - code => Err(ReposCompareCommitsError::Generic { code }), + 404 => Err(ReposCompareCommitsError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposCompareCommitsError::Status500(github_response.to_json()?).into()), + 503 => Err(ReposCompareCommitsError::Status503(github_response.to_json()?).into()), + code => Err(ReposCompareCommitsError::Generic { code }.into()), } } } @@ -7678,19 +8743,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_attestation](https://docs.github.com/rest/repos/repos#create-an-attestation) /// /// --- - pub async fn create_attestation_async(&self, owner: &str, repo: &str, body: PostReposCreateAttestation) -> Result { + pub async fn create_attestation_async(&self, owner: &str, repo: &str, body: PostReposCreateAttestation) -> Result { let request_uri = format!("{}/repos/{}/{}/attestations", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateAttestation::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7702,9 +8767,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposCreateAttestationError::Status403(github_response.to_json_async().await?)), - 422 => Err(ReposCreateAttestationError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCreateAttestationError::Generic { code }), + 403 => Err(ReposCreateAttestationError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(ReposCreateAttestationError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCreateAttestationError::Generic { code }.into()), } } } @@ -7723,19 +8788,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_attestation(&self, owner: &str, repo: &str, body: PostReposCreateAttestation) -> Result { + pub fn create_attestation(&self, owner: &str, repo: &str, body: PostReposCreateAttestation) -> Result { let request_uri = format!("{}/repos/{}/{}/attestations", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateAttestation::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7747,9 +8812,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposCreateAttestationError::Status403(github_response.to_json()?)), - 422 => Err(ReposCreateAttestationError::Status422(github_response.to_json()?)), - code => Err(ReposCreateAttestationError::Generic { code }), + 403 => Err(ReposCreateAttestationError::Status403(github_response.to_json()?).into()), + 422 => Err(ReposCreateAttestationError::Status422(github_response.to_json()?).into()), + code => Err(ReposCreateAttestationError::Generic { code }.into()), } } } @@ -7763,19 +8828,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_autolink](https://docs.github.com/rest/repos/autolinks#create-an-autolink-reference-for-a-repository) /// /// --- - pub async fn create_autolink_async(&self, owner: &str, repo: &str, body: PostReposCreateAutolink) -> Result { + pub async fn create_autolink_async(&self, owner: &str, repo: &str, body: PostReposCreateAutolink) -> Result { let request_uri = format!("{}/repos/{}/{}/autolinks", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateAutolink::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7787,8 +8852,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposCreateAutolinkError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCreateAutolinkError::Generic { code }), + 422 => Err(ReposCreateAutolinkError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCreateAutolinkError::Generic { code }.into()), } } } @@ -7803,19 +8868,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_autolink(&self, owner: &str, repo: &str, body: PostReposCreateAutolink) -> Result { + pub fn create_autolink(&self, owner: &str, repo: &str, body: PostReposCreateAutolink) -> Result { let request_uri = format!("{}/repos/{}/{}/autolinks", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateAutolink::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7827,8 +8892,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposCreateAutolinkError::Status422(github_response.to_json()?)), - code => Err(ReposCreateAutolinkError::Generic { code }), + 422 => Err(ReposCreateAutolinkError::Status422(github_response.to_json()?).into()), + code => Err(ReposCreateAutolinkError::Generic { code }.into()), } } } @@ -7851,19 +8916,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_commit_comment](https://docs.github.com/rest/commits/comments#create-a-commit-comment) /// /// --- - pub async fn create_commit_comment_async(&self, owner: &str, repo: &str, commit_sha: &str, body: PostReposCreateCommitComment) -> Result { + pub async fn create_commit_comment_async(&self, owner: &str, repo: &str, commit_sha: &str, body: PostReposCreateCommitComment) -> Result { let request_uri = format!("{}/repos/{}/{}/commits/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, commit_sha); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateCommitComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7875,9 +8940,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposCreateCommitCommentError::Status403(github_response.to_json_async().await?)), - 422 => Err(ReposCreateCommitCommentError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCreateCommitCommentError::Generic { code }), + 403 => Err(ReposCreateCommitCommentError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(ReposCreateCommitCommentError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCreateCommitCommentError::Generic { code }.into()), } } } @@ -7901,19 +8966,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_commit_comment(&self, owner: &str, repo: &str, commit_sha: &str, body: PostReposCreateCommitComment) -> Result { + pub fn create_commit_comment(&self, owner: &str, repo: &str, commit_sha: &str, body: PostReposCreateCommitComment) -> Result { let request_uri = format!("{}/repos/{}/{}/commits/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, commit_sha); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateCommitComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7925,9 +8990,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposCreateCommitCommentError::Status403(github_response.to_json()?)), - 422 => Err(ReposCreateCommitCommentError::Status422(github_response.to_json()?)), - code => Err(ReposCreateCommitCommentError::Generic { code }), + 403 => Err(ReposCreateCommitCommentError::Status403(github_response.to_json()?).into()), + 422 => Err(ReposCreateCommitCommentError::Status422(github_response.to_json()?).into()), + code => Err(ReposCreateCommitCommentError::Generic { code }.into()), } } } @@ -7943,19 +9008,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_commit_signature_protection](https://docs.github.com/rest/branches/branch-protection#create-commit-signature-protection) /// /// --- - pub async fn create_commit_signature_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub async fn create_commit_signature_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7967,8 +9032,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCreateCommitSignatureProtectionError::Status404(github_response.to_json_async().await?)), - code => Err(ReposCreateCommitSignatureProtectionError::Generic { code }), + 404 => Err(ReposCreateCommitSignatureProtectionError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposCreateCommitSignatureProtectionError::Generic { code }.into()), } } } @@ -7985,7 +9050,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_commit_signature_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub fn create_commit_signature_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -7997,7 +9062,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8009,8 +9074,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCreateCommitSignatureProtectionError::Status404(github_response.to_json()?)), - code => Err(ReposCreateCommitSignatureProtectionError::Generic { code }), + 404 => Err(ReposCreateCommitSignatureProtectionError::Status404(github_response.to_json()?).into()), + code => Err(ReposCreateCommitSignatureProtectionError::Generic { code }.into()), } } } @@ -8026,19 +9091,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_commit_status](https://docs.github.com/rest/commits/statuses#create-a-commit-status) /// /// --- - pub async fn create_commit_status_async(&self, owner: &str, repo: &str, sha: &str, body: PostReposCreateCommitStatus) -> Result { + pub async fn create_commit_status_async(&self, owner: &str, repo: &str, sha: &str, body: PostReposCreateCommitStatus) -> Result { let request_uri = format!("{}/repos/{}/{}/statuses/{}", super::GITHUB_BASE_API_URL, owner, repo, sha); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateCommitStatus::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8050,7 +9115,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposCreateCommitStatusError::Generic { code }), + code => Err(ReposCreateCommitStatusError::Generic { code }.into()), } } } @@ -8067,19 +9132,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_commit_status(&self, owner: &str, repo: &str, sha: &str, body: PostReposCreateCommitStatus) -> Result { + pub fn create_commit_status(&self, owner: &str, repo: &str, sha: &str, body: PostReposCreateCommitStatus) -> Result { let request_uri = format!("{}/repos/{}/{}/statuses/{}", super::GITHUB_BASE_API_URL, owner, repo, sha); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateCommitStatus::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8091,7 +9156,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposCreateCommitStatusError::Generic { code }), + code => Err(ReposCreateCommitStatusError::Generic { code }.into()), } } } @@ -8105,19 +9170,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_deploy_key](https://docs.github.com/rest/deploy-keys/deploy-keys#create-a-deploy-key) /// /// --- - pub async fn create_deploy_key_async(&self, owner: &str, repo: &str, body: PostReposCreateDeployKey) -> Result { + pub async fn create_deploy_key_async(&self, owner: &str, repo: &str, body: PostReposCreateDeployKey) -> Result { let request_uri = format!("{}/repos/{}/{}/keys", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDeployKey::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8129,8 +9194,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposCreateDeployKeyError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCreateDeployKeyError::Generic { code }), + 422 => Err(ReposCreateDeployKeyError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCreateDeployKeyError::Generic { code }.into()), } } } @@ -8145,19 +9210,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_deploy_key(&self, owner: &str, repo: &str, body: PostReposCreateDeployKey) -> Result { + pub fn create_deploy_key(&self, owner: &str, repo: &str, body: PostReposCreateDeployKey) -> Result { let request_uri = format!("{}/repos/{}/{}/keys", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDeployKey::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8169,8 +9234,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposCreateDeployKeyError::Status422(github_response.to_json()?)), - code => Err(ReposCreateDeployKeyError::Generic { code }), + 422 => Err(ReposCreateDeployKeyError::Status422(github_response.to_json()?).into()), + code => Err(ReposCreateDeployKeyError::Generic { code }.into()), } } } @@ -8231,19 +9296,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_deployment](https://docs.github.com/rest/deployments/deployments#create-a-deployment) /// /// --- - pub async fn create_deployment_async(&self, owner: &str, repo: &str, body: PostReposCreateDeployment) -> Result { + pub async fn create_deployment_async(&self, owner: &str, repo: &str, body: PostReposCreateDeployment) -> Result { let request_uri = format!("{}/repos/{}/{}/deployments", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDeployment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8255,10 +9320,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 202 => Err(ReposCreateDeploymentError::Status202(github_response.to_json_async().await?)), - 409 => Err(ReposCreateDeploymentError::Status409), - 422 => Err(ReposCreateDeploymentError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCreateDeploymentError::Generic { code }), + 202 => Err(ReposCreateDeploymentError::Status202(github_response.to_json_async().await?).into()), + 409 => Err(ReposCreateDeploymentError::Status409.into()), + 422 => Err(ReposCreateDeploymentError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCreateDeploymentError::Generic { code }.into()), } } } @@ -8320,19 +9385,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_deployment(&self, owner: &str, repo: &str, body: PostReposCreateDeployment) -> Result { + pub fn create_deployment(&self, owner: &str, repo: &str, body: PostReposCreateDeployment) -> Result { let request_uri = format!("{}/repos/{}/{}/deployments", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDeployment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8344,10 +9409,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 202 => Err(ReposCreateDeploymentError::Status202(github_response.to_json()?)), - 409 => Err(ReposCreateDeploymentError::Status409), - 422 => Err(ReposCreateDeploymentError::Status422(github_response.to_json()?)), - code => Err(ReposCreateDeploymentError::Generic { code }), + 202 => Err(ReposCreateDeploymentError::Status202(github_response.to_json()?).into()), + 409 => Err(ReposCreateDeploymentError::Status409.into()), + 422 => Err(ReposCreateDeploymentError::Status422(github_response.to_json()?).into()), + code => Err(ReposCreateDeploymentError::Generic { code }.into()), } } } @@ -8363,19 +9428,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#create-a-deployment-branch-policy) /// /// --- - pub async fn create_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, body: PostReposCreateDeploymentBranchPolicy) -> Result { + pub async fn create_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, body: PostReposCreateDeploymentBranchPolicy) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies", super::GITHUB_BASE_API_URL, owner, repo, environment_name); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDeploymentBranchPolicy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8387,9 +9452,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCreateDeploymentBranchPolicyError::Status404), - 303 => Err(ReposCreateDeploymentBranchPolicyError::Status303), - code => Err(ReposCreateDeploymentBranchPolicyError::Generic { code }), + 404 => Err(ReposCreateDeploymentBranchPolicyError::Status404.into()), + 303 => Err(ReposCreateDeploymentBranchPolicyError::Status303.into()), + code => Err(ReposCreateDeploymentBranchPolicyError::Generic { code }.into()), } } } @@ -8406,19 +9471,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, body: PostReposCreateDeploymentBranchPolicy) -> Result { + pub fn create_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, body: PostReposCreateDeploymentBranchPolicy) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies", super::GITHUB_BASE_API_URL, owner, repo, environment_name); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDeploymentBranchPolicy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8430,9 +9495,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCreateDeploymentBranchPolicyError::Status404), - 303 => Err(ReposCreateDeploymentBranchPolicyError::Status303), - code => Err(ReposCreateDeploymentBranchPolicyError::Generic { code }), + 404 => Err(ReposCreateDeploymentBranchPolicyError::Status404.into()), + 303 => Err(ReposCreateDeploymentBranchPolicyError::Status303.into()), + code => Err(ReposCreateDeploymentBranchPolicyError::Generic { code }.into()), } } } @@ -8452,19 +9517,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_deployment_protection_rule](https://docs.github.com/rest/deployments/protection-rules#create-a-custom-deployment-protection-rule-on-an-environment) /// /// --- - pub async fn create_deployment_protection_rule_async(&self, environment_name: &str, repo: &str, owner: &str, body: PostReposCreateDeploymentProtectionRule) -> Result { + pub async fn create_deployment_protection_rule_async(&self, environment_name: &str, repo: &str, owner: &str, body: PostReposCreateDeploymentProtectionRule) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules", super::GITHUB_BASE_API_URL, environment_name, repo, owner); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDeploymentProtectionRule::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8476,7 +9541,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposCreateDeploymentProtectionRuleError::Generic { code }), + code => Err(ReposCreateDeploymentProtectionRuleError::Generic { code }.into()), } } } @@ -8497,19 +9562,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_deployment_protection_rule(&self, environment_name: &str, repo: &str, owner: &str, body: PostReposCreateDeploymentProtectionRule) -> Result { + pub fn create_deployment_protection_rule(&self, environment_name: &str, repo: &str, owner: &str, body: PostReposCreateDeploymentProtectionRule) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules", super::GITHUB_BASE_API_URL, environment_name, repo, owner); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDeploymentProtectionRule::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8521,7 +9586,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposCreateDeploymentProtectionRuleError::Generic { code }), + code => Err(ReposCreateDeploymentProtectionRuleError::Generic { code }.into()), } } } @@ -8537,19 +9602,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_deployment_status](https://docs.github.com/rest/deployments/statuses#create-a-deployment-status) /// /// --- - pub async fn create_deployment_status_async(&self, owner: &str, repo: &str, deployment_id: i32, body: PostReposCreateDeploymentStatus) -> Result { + pub async fn create_deployment_status_async(&self, owner: &str, repo: &str, deployment_id: i32, body: PostReposCreateDeploymentStatus) -> Result { let request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, deployment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDeploymentStatus::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8561,8 +9626,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposCreateDeploymentStatusError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCreateDeploymentStatusError::Generic { code }), + 422 => Err(ReposCreateDeploymentStatusError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCreateDeploymentStatusError::Generic { code }.into()), } } } @@ -8579,19 +9644,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_deployment_status(&self, owner: &str, repo: &str, deployment_id: i32, body: PostReposCreateDeploymentStatus) -> Result { + pub fn create_deployment_status(&self, owner: &str, repo: &str, deployment_id: i32, body: PostReposCreateDeploymentStatus) -> Result { let request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, deployment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDeploymentStatus::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8603,8 +9668,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposCreateDeploymentStatusError::Status422(github_response.to_json()?)), - code => Err(ReposCreateDeploymentStatusError::Generic { code }), + 422 => Err(ReposCreateDeploymentStatusError::Status422(github_response.to_json()?).into()), + code => Err(ReposCreateDeploymentStatusError::Generic { code }.into()), } } } @@ -8624,19 +9689,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_dispatch_event](https://docs.github.com/rest/repos/repos#create-a-repository-dispatch-event) /// /// --- - pub async fn create_dispatch_event_async(&self, owner: &str, repo: &str, body: PostReposCreateDispatchEvent) -> Result<(), ReposCreateDispatchEventError> { + pub async fn create_dispatch_event_async(&self, owner: &str, repo: &str, body: PostReposCreateDispatchEvent) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/dispatches", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDispatchEvent::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8648,9 +9713,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCreateDispatchEventError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposCreateDispatchEventError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCreateDispatchEventError::Generic { code }), + 404 => Err(ReposCreateDispatchEventError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposCreateDispatchEventError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCreateDispatchEventError::Generic { code }.into()), } } } @@ -8671,19 +9736,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_dispatch_event(&self, owner: &str, repo: &str, body: PostReposCreateDispatchEvent) -> Result<(), ReposCreateDispatchEventError> { + pub fn create_dispatch_event(&self, owner: &str, repo: &str, body: PostReposCreateDispatchEvent) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/dispatches", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateDispatchEvent::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8695,9 +9760,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCreateDispatchEventError::Status404(github_response.to_json()?)), - 422 => Err(ReposCreateDispatchEventError::Status422(github_response.to_json()?)), - code => Err(ReposCreateDispatchEventError::Generic { code }), + 404 => Err(ReposCreateDispatchEventError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposCreateDispatchEventError::Status422(github_response.to_json()?).into()), + code => Err(ReposCreateDispatchEventError::Generic { code }.into()), } } } @@ -8713,19 +9778,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_for_authenticated_user](https://docs.github.com/rest/repos/repos#create-a-repository-for-the-authenticated-user) /// /// --- - pub async fn create_for_authenticated_user_async(&self, body: PostReposCreateForAuthenticatedUser) -> Result { + pub async fn create_for_authenticated_user_async(&self, body: PostReposCreateForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/repos", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8737,13 +9802,13 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(ReposCreateForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 304 => Err(ReposCreateForAuthenticatedUserError::Status304), - 404 => Err(ReposCreateForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(ReposCreateForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 422 => Err(ReposCreateForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - 400 => Err(ReposCreateForAuthenticatedUserError::Status400(github_response.to_json_async().await?)), - code => Err(ReposCreateForAuthenticatedUserError::Generic { code }), + 401 => Err(ReposCreateForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 304 => Err(ReposCreateForAuthenticatedUserError::Status304.into()), + 404 => Err(ReposCreateForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(ReposCreateForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(ReposCreateForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + 400 => Err(ReposCreateForAuthenticatedUserError::Status400(github_response.to_json_async().await?).into()), + code => Err(ReposCreateForAuthenticatedUserError::Generic { code }.into()), } } } @@ -8760,19 +9825,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_for_authenticated_user(&self, body: PostReposCreateForAuthenticatedUser) -> Result { + pub fn create_for_authenticated_user(&self, body: PostReposCreateForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/repos", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8784,13 +9849,13 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(ReposCreateForAuthenticatedUserError::Status401(github_response.to_json()?)), - 304 => Err(ReposCreateForAuthenticatedUserError::Status304), - 404 => Err(ReposCreateForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(ReposCreateForAuthenticatedUserError::Status403(github_response.to_json()?)), - 422 => Err(ReposCreateForAuthenticatedUserError::Status422(github_response.to_json()?)), - 400 => Err(ReposCreateForAuthenticatedUserError::Status400(github_response.to_json()?)), - code => Err(ReposCreateForAuthenticatedUserError::Generic { code }), + 401 => Err(ReposCreateForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 304 => Err(ReposCreateForAuthenticatedUserError::Status304.into()), + 404 => Err(ReposCreateForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(ReposCreateForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 422 => Err(ReposCreateForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + 400 => Err(ReposCreateForAuthenticatedUserError::Status400(github_response.to_json()?).into()), + code => Err(ReposCreateForAuthenticatedUserError::Generic { code }.into()), } } } @@ -8810,19 +9875,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_fork](https://docs.github.com/rest/repos/forks#create-a-fork) /// /// --- - pub async fn create_fork_async(&self, owner: &str, repo: &str, body: PostReposCreateFork) -> Result { + pub async fn create_fork_async(&self, owner: &str, repo: &str, body: PostReposCreateFork) -> Result { let request_uri = format!("{}/repos/{}/{}/forks", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateFork::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8834,11 +9899,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(ReposCreateForkError::Status400(github_response.to_json_async().await?)), - 422 => Err(ReposCreateForkError::Status422(github_response.to_json_async().await?)), - 403 => Err(ReposCreateForkError::Status403(github_response.to_json_async().await?)), - 404 => Err(ReposCreateForkError::Status404(github_response.to_json_async().await?)), - code => Err(ReposCreateForkError::Generic { code }), + 400 => Err(ReposCreateForkError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(ReposCreateForkError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(ReposCreateForkError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ReposCreateForkError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposCreateForkError::Generic { code }.into()), } } } @@ -8859,19 +9924,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_fork(&self, owner: &str, repo: &str, body: PostReposCreateFork) -> Result { + pub fn create_fork(&self, owner: &str, repo: &str, body: PostReposCreateFork) -> Result { let request_uri = format!("{}/repos/{}/{}/forks", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateFork::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8883,11 +9948,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(ReposCreateForkError::Status400(github_response.to_json()?)), - 422 => Err(ReposCreateForkError::Status422(github_response.to_json()?)), - 403 => Err(ReposCreateForkError::Status403(github_response.to_json()?)), - 404 => Err(ReposCreateForkError::Status404(github_response.to_json()?)), - code => Err(ReposCreateForkError::Generic { code }), + 400 => Err(ReposCreateForkError::Status400(github_response.to_json()?).into()), + 422 => Err(ReposCreateForkError::Status422(github_response.to_json()?).into()), + 403 => Err(ReposCreateForkError::Status403(github_response.to_json()?).into()), + 404 => Err(ReposCreateForkError::Status404(github_response.to_json()?).into()), + code => Err(ReposCreateForkError::Generic { code }.into()), } } } @@ -8903,19 +9968,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_in_org](https://docs.github.com/rest/repos/repos#create-an-organization-repository) /// /// --- - pub async fn create_in_org_async(&self, org: &str, body: PostReposCreateInOrg) -> Result { + pub async fn create_in_org_async(&self, org: &str, body: PostReposCreateInOrg) -> Result { let request_uri = format!("{}/orgs/{}/repos", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8927,9 +9992,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposCreateInOrgError::Status403(github_response.to_json_async().await?)), - 422 => Err(ReposCreateInOrgError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCreateInOrgError::Generic { code }), + 403 => Err(ReposCreateInOrgError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(ReposCreateInOrgError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCreateInOrgError::Generic { code }.into()), } } } @@ -8946,19 +10011,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_in_org(&self, org: &str, body: PostReposCreateInOrg) -> Result { + pub fn create_in_org(&self, org: &str, body: PostReposCreateInOrg) -> Result { let request_uri = format!("{}/orgs/{}/repos", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -8970,9 +10035,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposCreateInOrgError::Status403(github_response.to_json()?)), - 422 => Err(ReposCreateInOrgError::Status422(github_response.to_json()?)), - code => Err(ReposCreateInOrgError::Generic { code }), + 403 => Err(ReposCreateInOrgError::Status403(github_response.to_json()?).into()), + 422 => Err(ReposCreateInOrgError::Status422(github_response.to_json()?).into()), + code => Err(ReposCreateInOrgError::Generic { code }.into()), } } } @@ -8989,19 +10054,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_or_update_custom_properties_values](https://docs.github.com/rest/repos/custom-properties#create-or-update-custom-property-values-for-a-repository) /// /// --- - pub async fn create_or_update_custom_properties_values_async(&self, owner: &str, repo: &str, body: PatchReposCreateOrUpdateCustomPropertiesValues) -> Result<(), ReposCreateOrUpdateCustomPropertiesValuesError> { + pub async fn create_or_update_custom_properties_values_async(&self, owner: &str, repo: &str, body: PatchReposCreateOrUpdateCustomPropertiesValues) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/properties/values", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposCreateOrUpdateCustomPropertiesValues::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9013,10 +10078,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status403(github_response.to_json_async().await?)), - 404 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Generic { code }), + 403 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Generic { code }.into()), } } } @@ -9034,19 +10099,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_custom_properties_values(&self, owner: &str, repo: &str, body: PatchReposCreateOrUpdateCustomPropertiesValues) -> Result<(), ReposCreateOrUpdateCustomPropertiesValuesError> { + pub fn create_or_update_custom_properties_values(&self, owner: &str, repo: &str, body: PatchReposCreateOrUpdateCustomPropertiesValues) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/properties/values", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposCreateOrUpdateCustomPropertiesValues::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9058,10 +10123,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status403(github_response.to_json()?)), - 404 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status404(github_response.to_json()?)), - 422 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status422(github_response.to_json()?)), - code => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Generic { code }), + 403 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status403(github_response.to_json()?).into()), + 404 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Status422(github_response.to_json()?).into()), + code => Err(ReposCreateOrUpdateCustomPropertiesValuesError::Generic { code }.into()), } } } @@ -9083,19 +10148,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_or_update_environment](https://docs.github.com/rest/deployments/environments#create-or-update-an-environment) /// /// --- - pub async fn create_or_update_environment_async(&self, owner: &str, repo: &str, environment_name: &str, body: PutReposCreateOrUpdateEnvironment) -> Result { + pub async fn create_or_update_environment_async(&self, owner: &str, repo: &str, environment_name: &str, body: PutReposCreateOrUpdateEnvironment) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposCreateOrUpdateEnvironment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9107,8 +10172,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposCreateOrUpdateEnvironmentError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCreateOrUpdateEnvironmentError::Generic { code }), + 422 => Err(ReposCreateOrUpdateEnvironmentError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCreateOrUpdateEnvironmentError::Generic { code }.into()), } } } @@ -9131,19 +10196,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_environment(&self, owner: &str, repo: &str, environment_name: &str, body: PutReposCreateOrUpdateEnvironment) -> Result { + pub fn create_or_update_environment(&self, owner: &str, repo: &str, environment_name: &str, body: PutReposCreateOrUpdateEnvironment) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposCreateOrUpdateEnvironment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9155,8 +10220,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposCreateOrUpdateEnvironmentError::Status422(github_response.to_json()?)), - code => Err(ReposCreateOrUpdateEnvironmentError::Generic { code }), + 422 => Err(ReposCreateOrUpdateEnvironmentError::Status422(github_response.to_json()?).into()), + code => Err(ReposCreateOrUpdateEnvironmentError::Generic { code }.into()), } } } @@ -9175,19 +10240,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_or_update_file_contents](https://docs.github.com/rest/repos/contents#create-or-update-file-contents) /// /// --- - pub async fn create_or_update_file_contents_async(&self, owner: &str, repo: &str, path: &str, body: PutReposCreateOrUpdateFileContents) -> Result { + pub async fn create_or_update_file_contents_async(&self, owner: &str, repo: &str, path: &str, body: PutReposCreateOrUpdateFileContents) -> Result { let request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposCreateOrUpdateFileContents::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9199,11 +10264,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(ReposCreateOrUpdateFileContentsError::Status201(github_response.to_json_async().await?)), - 404 => Err(ReposCreateOrUpdateFileContentsError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposCreateOrUpdateFileContentsError::Status422(github_response.to_json_async().await?)), - 409 => Err(ReposCreateOrUpdateFileContentsError::Status409(github_response.to_json_async().await?)), - code => Err(ReposCreateOrUpdateFileContentsError::Generic { code }), + 201 => Err(ReposCreateOrUpdateFileContentsError::Status201(github_response.to_json_async().await?).into()), + 404 => Err(ReposCreateOrUpdateFileContentsError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposCreateOrUpdateFileContentsError::Status422(github_response.to_json_async().await?).into()), + 409 => Err(ReposCreateOrUpdateFileContentsError::Status409(github_response.to_json_async().await?).into()), + code => Err(ReposCreateOrUpdateFileContentsError::Generic { code }.into()), } } } @@ -9223,19 +10288,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_or_update_file_contents(&self, owner: &str, repo: &str, path: &str, body: PutReposCreateOrUpdateFileContents) -> Result { + pub fn create_or_update_file_contents(&self, owner: &str, repo: &str, path: &str, body: PutReposCreateOrUpdateFileContents) -> Result { let request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposCreateOrUpdateFileContents::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9247,11 +10312,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(ReposCreateOrUpdateFileContentsError::Status201(github_response.to_json()?)), - 404 => Err(ReposCreateOrUpdateFileContentsError::Status404(github_response.to_json()?)), - 422 => Err(ReposCreateOrUpdateFileContentsError::Status422(github_response.to_json()?)), - 409 => Err(ReposCreateOrUpdateFileContentsError::Status409(github_response.to_json()?)), - code => Err(ReposCreateOrUpdateFileContentsError::Generic { code }), + 201 => Err(ReposCreateOrUpdateFileContentsError::Status201(github_response.to_json()?).into()), + 404 => Err(ReposCreateOrUpdateFileContentsError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposCreateOrUpdateFileContentsError::Status422(github_response.to_json()?).into()), + 409 => Err(ReposCreateOrUpdateFileContentsError::Status409(github_response.to_json()?).into()), + code => Err(ReposCreateOrUpdateFileContentsError::Generic { code }.into()), } } } @@ -9265,19 +10330,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_org_ruleset](https://docs.github.com/rest/orgs/rules#create-an-organization-repository-ruleset) /// /// --- - pub async fn create_org_ruleset_async(&self, org: &str, body: PostReposCreateOrgRuleset) -> Result { + pub async fn create_org_ruleset_async(&self, org: &str, body: PostReposCreateOrgRuleset) -> Result { let request_uri = format!("{}/orgs/{}/rulesets", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateOrgRuleset::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9289,9 +10354,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCreateOrgRulesetError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposCreateOrgRulesetError::Status500(github_response.to_json_async().await?)), - code => Err(ReposCreateOrgRulesetError::Generic { code }), + 404 => Err(ReposCreateOrgRulesetError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposCreateOrgRulesetError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposCreateOrgRulesetError::Generic { code }.into()), } } } @@ -9306,19 +10371,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_org_ruleset(&self, org: &str, body: PostReposCreateOrgRuleset) -> Result { + pub fn create_org_ruleset(&self, org: &str, body: PostReposCreateOrgRuleset) -> Result { let request_uri = format!("{}/orgs/{}/rulesets", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateOrgRuleset::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9330,9 +10395,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCreateOrgRulesetError::Status404(github_response.to_json()?)), - 500 => Err(ReposCreateOrgRulesetError::Status500(github_response.to_json()?)), - code => Err(ReposCreateOrgRulesetError::Generic { code }), + 404 => Err(ReposCreateOrgRulesetError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposCreateOrgRulesetError::Status500(github_response.to_json()?).into()), + code => Err(ReposCreateOrgRulesetError::Generic { code }.into()), } } } @@ -9348,19 +10413,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_pages_deployment](https://docs.github.com/rest/pages/pages#create-a-github-pages-deployment) /// /// --- - pub async fn create_pages_deployment_async(&self, owner: &str, repo: &str, body: PostReposCreatePagesDeployment) -> Result { + pub async fn create_pages_deployment_async(&self, owner: &str, repo: &str, body: PostReposCreatePagesDeployment) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/deployments", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreatePagesDeployment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9372,10 +10437,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(ReposCreatePagesDeploymentError::Status400(github_response.to_json_async().await?)), - 422 => Err(ReposCreatePagesDeploymentError::Status422(github_response.to_json_async().await?)), - 404 => Err(ReposCreatePagesDeploymentError::Status404(github_response.to_json_async().await?)), - code => Err(ReposCreatePagesDeploymentError::Generic { code }), + 400 => Err(ReposCreatePagesDeploymentError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(ReposCreatePagesDeploymentError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(ReposCreatePagesDeploymentError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposCreatePagesDeploymentError::Generic { code }.into()), } } } @@ -9392,19 +10457,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_pages_deployment(&self, owner: &str, repo: &str, body: PostReposCreatePagesDeployment) -> Result { + pub fn create_pages_deployment(&self, owner: &str, repo: &str, body: PostReposCreatePagesDeployment) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/deployments", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreatePagesDeployment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9416,10 +10481,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(ReposCreatePagesDeploymentError::Status400(github_response.to_json()?)), - 422 => Err(ReposCreatePagesDeploymentError::Status422(github_response.to_json()?)), - 404 => Err(ReposCreatePagesDeploymentError::Status404(github_response.to_json()?)), - code => Err(ReposCreatePagesDeploymentError::Generic { code }), + 400 => Err(ReposCreatePagesDeploymentError::Status400(github_response.to_json()?).into()), + 422 => Err(ReposCreatePagesDeploymentError::Status422(github_response.to_json()?).into()), + 404 => Err(ReposCreatePagesDeploymentError::Status404(github_response.to_json()?).into()), + code => Err(ReposCreatePagesDeploymentError::Generic { code }.into()), } } } @@ -9437,19 +10502,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_pages_site](https://docs.github.com/rest/pages/pages#create-a-apiname-pages-site) /// /// --- - pub async fn create_pages_site_async(&self, owner: &str, repo: &str, body: PostReposCreatePagesSite) -> Result { + pub async fn create_pages_site_async(&self, owner: &str, repo: &str, body: PostReposCreatePagesSite) -> Result { let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreatePagesSite::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9461,9 +10526,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposCreatePagesSiteError::Status422(github_response.to_json_async().await?)), - 409 => Err(ReposCreatePagesSiteError::Status409(github_response.to_json_async().await?)), - code => Err(ReposCreatePagesSiteError::Generic { code }), + 422 => Err(ReposCreatePagesSiteError::Status422(github_response.to_json_async().await?).into()), + 409 => Err(ReposCreatePagesSiteError::Status409(github_response.to_json_async().await?).into()), + code => Err(ReposCreatePagesSiteError::Generic { code }.into()), } } } @@ -9482,19 +10547,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_pages_site(&self, owner: &str, repo: &str, body: PostReposCreatePagesSite) -> Result { + pub fn create_pages_site(&self, owner: &str, repo: &str, body: PostReposCreatePagesSite) -> Result { let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreatePagesSite::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9506,9 +10571,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposCreatePagesSiteError::Status422(github_response.to_json()?)), - 409 => Err(ReposCreatePagesSiteError::Status409(github_response.to_json()?)), - code => Err(ReposCreatePagesSiteError::Generic { code }), + 422 => Err(ReposCreatePagesSiteError::Status422(github_response.to_json()?).into()), + 409 => Err(ReposCreatePagesSiteError::Status409(github_response.to_json()?).into()), + code => Err(ReposCreatePagesSiteError::Generic { code }.into()), } } } @@ -9524,19 +10589,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_release](https://docs.github.com/rest/releases/releases#create-a-release) /// /// --- - pub async fn create_release_async(&self, owner: &str, repo: &str, body: PostReposCreateRelease) -> Result { + pub async fn create_release_async(&self, owner: &str, repo: &str, body: PostReposCreateRelease) -> Result { let request_uri = format!("{}/repos/{}/{}/releases", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateRelease::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9548,9 +10613,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCreateReleaseError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposCreateReleaseError::Status422(github_response.to_json_async().await?)), - code => Err(ReposCreateReleaseError::Generic { code }), + 404 => Err(ReposCreateReleaseError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposCreateReleaseError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposCreateReleaseError::Generic { code }.into()), } } } @@ -9567,19 +10632,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_release(&self, owner: &str, repo: &str, body: PostReposCreateRelease) -> Result { + pub fn create_release(&self, owner: &str, repo: &str, body: PostReposCreateRelease) -> Result { let request_uri = format!("{}/repos/{}/{}/releases", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateRelease::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9591,9 +10656,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCreateReleaseError::Status404(github_response.to_json()?)), - 422 => Err(ReposCreateReleaseError::Status422(github_response.to_json()?)), - code => Err(ReposCreateReleaseError::Generic { code }), + 404 => Err(ReposCreateReleaseError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposCreateReleaseError::Status422(github_response.to_json()?).into()), + code => Err(ReposCreateReleaseError::Generic { code }.into()), } } } @@ -9607,19 +10672,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_repo_ruleset](https://docs.github.com/rest/repos/rules#create-a-repository-ruleset) /// /// --- - pub async fn create_repo_ruleset_async(&self, owner: &str, repo: &str, body: PostReposCreateRepoRuleset) -> Result { + pub async fn create_repo_ruleset_async(&self, owner: &str, repo: &str, body: PostReposCreateRepoRuleset) -> Result { let request_uri = format!("{}/repos/{}/{}/rulesets", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateRepoRuleset::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9631,9 +10696,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCreateRepoRulesetError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposCreateRepoRulesetError::Status500(github_response.to_json_async().await?)), - code => Err(ReposCreateRepoRulesetError::Generic { code }), + 404 => Err(ReposCreateRepoRulesetError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposCreateRepoRulesetError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposCreateRepoRulesetError::Generic { code }.into()), } } } @@ -9648,19 +10713,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_repo_ruleset(&self, owner: &str, repo: &str, body: PostReposCreateRepoRuleset) -> Result { + pub fn create_repo_ruleset(&self, owner: &str, repo: &str, body: PostReposCreateRepoRuleset) -> Result { let request_uri = format!("{}/repos/{}/{}/rulesets", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateRepoRuleset::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9672,9 +10737,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCreateRepoRulesetError::Status404(github_response.to_json()?)), - 500 => Err(ReposCreateRepoRulesetError::Status500(github_response.to_json()?)), - code => Err(ReposCreateRepoRulesetError::Generic { code }), + 404 => Err(ReposCreateRepoRulesetError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposCreateRepoRulesetError::Status500(github_response.to_json()?).into()), + code => Err(ReposCreateRepoRulesetError::Generic { code }.into()), } } } @@ -9692,19 +10757,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_tag_protection](https://docs.github.com/rest/repos/tags#deprecated---create-a-tag-protection-state-for-a-repository) /// /// --- - pub async fn create_tag_protection_async(&self, owner: &str, repo: &str, body: PostReposCreateTagProtection) -> Result { + pub async fn create_tag_protection_async(&self, owner: &str, repo: &str, body: PostReposCreateTagProtection) -> Result { let request_uri = format!("{}/repos/{}/{}/tags/protection", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateTagProtection::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9716,9 +10781,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposCreateTagProtectionError::Status403(github_response.to_json_async().await?)), - 404 => Err(ReposCreateTagProtectionError::Status404(github_response.to_json_async().await?)), - code => Err(ReposCreateTagProtectionError::Generic { code }), + 403 => Err(ReposCreateTagProtectionError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ReposCreateTagProtectionError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposCreateTagProtectionError::Generic { code }.into()), } } } @@ -9737,19 +10802,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_tag_protection(&self, owner: &str, repo: &str, body: PostReposCreateTagProtection) -> Result { + pub fn create_tag_protection(&self, owner: &str, repo: &str, body: PostReposCreateTagProtection) -> Result { let request_uri = format!("{}/repos/{}/{}/tags/protection", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateTagProtection::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9761,9 +10826,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposCreateTagProtectionError::Status403(github_response.to_json()?)), - 404 => Err(ReposCreateTagProtectionError::Status404(github_response.to_json()?)), - code => Err(ReposCreateTagProtectionError::Generic { code }), + 403 => Err(ReposCreateTagProtectionError::Status403(github_response.to_json()?).into()), + 404 => Err(ReposCreateTagProtectionError::Status404(github_response.to_json()?).into()), + code => Err(ReposCreateTagProtectionError::Generic { code }.into()), } } } @@ -9779,19 +10844,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_using_template](https://docs.github.com/rest/repos/repos#create-a-repository-using-a-template) /// /// --- - pub async fn create_using_template_async(&self, template_owner: &str, template_repo: &str, body: PostReposCreateUsingTemplate) -> Result { + pub async fn create_using_template_async(&self, template_owner: &str, template_repo: &str, body: PostReposCreateUsingTemplate) -> Result { let request_uri = format!("{}/repos/{}/{}/generate", super::GITHUB_BASE_API_URL, template_owner, template_repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateUsingTemplate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9803,7 +10868,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposCreateUsingTemplateError::Generic { code }), + code => Err(ReposCreateUsingTemplateError::Generic { code }.into()), } } } @@ -9820,19 +10885,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_using_template(&self, template_owner: &str, template_repo: &str, body: PostReposCreateUsingTemplate) -> Result { + pub fn create_using_template(&self, template_owner: &str, template_repo: &str, body: PostReposCreateUsingTemplate) -> Result { let request_uri = format!("{}/repos/{}/{}/generate", super::GITHUB_BASE_API_URL, template_owner, template_repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateUsingTemplate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9844,7 +10909,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposCreateUsingTemplateError::Generic { code }), + code => Err(ReposCreateUsingTemplateError::Generic { code }.into()), } } } @@ -9859,19 +10924,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for create_webhook](https://docs.github.com/rest/repos/webhooks#create-a-repository-webhook) /// /// --- - pub async fn create_webhook_async(&self, owner: &str, repo: &str, body: PostReposCreateWebhook) -> Result { + pub async fn create_webhook_async(&self, owner: &str, repo: &str, body: PostReposCreateWebhook) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateWebhook::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9883,10 +10948,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposCreateWebhookError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposCreateWebhookError::Status422(github_response.to_json_async().await?)), - 403 => Err(ReposCreateWebhookError::Status403(github_response.to_json_async().await?)), - code => Err(ReposCreateWebhookError::Generic { code }), + 404 => Err(ReposCreateWebhookError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposCreateWebhookError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(ReposCreateWebhookError::Status403(github_response.to_json_async().await?).into()), + code => Err(ReposCreateWebhookError::Generic { code }.into()), } } } @@ -9902,19 +10967,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_webhook(&self, owner: &str, repo: &str, body: PostReposCreateWebhook) -> Result { + pub fn create_webhook(&self, owner: &str, repo: &str, body: PostReposCreateWebhook) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposCreateWebhook::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9926,10 +10991,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposCreateWebhookError::Status404(github_response.to_json()?)), - 422 => Err(ReposCreateWebhookError::Status422(github_response.to_json()?)), - 403 => Err(ReposCreateWebhookError::Status403(github_response.to_json()?)), - code => Err(ReposCreateWebhookError::Generic { code }), + 404 => Err(ReposCreateWebhookError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposCreateWebhookError::Status422(github_response.to_json()?).into()), + 403 => Err(ReposCreateWebhookError::Status403(github_response.to_json()?).into()), + code => Err(ReposCreateWebhookError::Generic { code }.into()), } } } @@ -9941,19 +11006,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for decline_invitation_for_authenticated_user](https://docs.github.com/rest/collaborators/invitations#decline-a-repository-invitation) /// /// --- - pub async fn decline_invitation_for_authenticated_user_async(&self, invitation_id: i32) -> Result<(), ReposDeclineInvitationForAuthenticatedUserError> { + pub async fn decline_invitation_for_authenticated_user_async(&self, invitation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/repository_invitations/{}", super::GITHUB_BASE_API_URL, invitation_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -9965,11 +11030,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status409(github_response.to_json_async().await?)), - 304 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status304), - 404 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - code => Err(ReposDeclineInvitationForAuthenticatedUserError::Generic { code }), + 409 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status409(github_response.to_json_async().await?).into()), + 304 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status304.into()), + 404 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + code => Err(ReposDeclineInvitationForAuthenticatedUserError::Generic { code }.into()), } } } @@ -9982,7 +11047,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn decline_invitation_for_authenticated_user(&self, invitation_id: i32) -> Result<(), ReposDeclineInvitationForAuthenticatedUserError> { + pub fn decline_invitation_for_authenticated_user(&self, invitation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/repository_invitations/{}", super::GITHUB_BASE_API_URL, invitation_id); @@ -9994,7 +11059,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10006,11 +11071,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status409(github_response.to_json()?)), - 304 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status304), - 404 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status403(github_response.to_json()?)), - code => Err(ReposDeclineInvitationForAuthenticatedUserError::Generic { code }), + 409 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status409(github_response.to_json()?).into()), + 304 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status304.into()), + 404 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(ReposDeclineInvitationForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + code => Err(ReposDeclineInvitationForAuthenticatedUserError::Generic { code }.into()), } } } @@ -10029,19 +11094,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete](https://docs.github.com/rest/repos/repos#delete-a-repository) /// /// --- - pub async fn delete_async(&self, owner: &str, repo: &str) -> Result<(), ReposDeleteError> { + pub async fn delete_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10053,10 +11118,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposDeleteError::Status403(github_response.to_json_async().await?)), - 307 => Err(ReposDeleteError::Status307(github_response.to_json_async().await?)), - 404 => Err(ReposDeleteError::Status404(github_response.to_json_async().await?)), - code => Err(ReposDeleteError::Generic { code }), + 403 => Err(ReposDeleteError::Status403(github_response.to_json_async().await?).into()), + 307 => Err(ReposDeleteError::Status307(github_response.to_json_async().await?).into()), + 404 => Err(ReposDeleteError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteError::Generic { code }.into()), } } } @@ -10076,7 +11141,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete(&self, owner: &str, repo: &str) -> Result<(), ReposDeleteError> { + pub fn delete(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); @@ -10088,7 +11153,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10100,10 +11165,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposDeleteError::Status403(github_response.to_json()?)), - 307 => Err(ReposDeleteError::Status307(github_response.to_json()?)), - 404 => Err(ReposDeleteError::Status404(github_response.to_json()?)), - code => Err(ReposDeleteError::Generic { code }), + 403 => Err(ReposDeleteError::Status403(github_response.to_json()?).into()), + 307 => Err(ReposDeleteError::Status307(github_response.to_json()?).into()), + 404 => Err(ReposDeleteError::Status404(github_response.to_json()?).into()), + code => Err(ReposDeleteError::Generic { code }.into()), } } } @@ -10119,19 +11184,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_access_restrictions](https://docs.github.com/rest/branches/branch-protection#delete-access-restrictions) /// /// --- - pub async fn delete_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposDeleteAccessRestrictionsError> { + pub async fn delete_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10143,7 +11208,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposDeleteAccessRestrictionsError::Generic { code }), + code => Err(ReposDeleteAccessRestrictionsError::Generic { code }.into()), } } } @@ -10160,7 +11225,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_access_restrictions(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposDeleteAccessRestrictionsError> { + pub fn delete_access_restrictions(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -10172,7 +11237,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10184,7 +11249,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposDeleteAccessRestrictionsError::Generic { code }), + code => Err(ReposDeleteAccessRestrictionsError::Generic { code }.into()), } } } @@ -10200,19 +11265,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_admin_branch_protection](https://docs.github.com/rest/branches/branch-protection#delete-admin-branch-protection) /// /// --- - pub async fn delete_admin_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposDeleteAdminBranchProtectionError> { + pub async fn delete_admin_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10224,8 +11289,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteAdminBranchProtectionError::Status404(github_response.to_json_async().await?)), - code => Err(ReposDeleteAdminBranchProtectionError::Generic { code }), + 404 => Err(ReposDeleteAdminBranchProtectionError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteAdminBranchProtectionError::Generic { code }.into()), } } } @@ -10242,7 +11307,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_admin_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposDeleteAdminBranchProtectionError> { + pub fn delete_admin_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -10254,7 +11319,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10266,8 +11331,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteAdminBranchProtectionError::Status404(github_response.to_json()?)), - code => Err(ReposDeleteAdminBranchProtectionError::Generic { code }), + 404 => Err(ReposDeleteAdminBranchProtectionError::Status404(github_response.to_json()?).into()), + code => Err(ReposDeleteAdminBranchProtectionError::Generic { code }.into()), } } } @@ -10281,19 +11346,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_an_environment](https://docs.github.com/rest/deployments/environments#delete-an-environment) /// /// --- - pub async fn delete_an_environment_async(&self, owner: &str, repo: &str, environment_name: &str) -> Result<(), ReposDeleteAnEnvironmentError> { + pub async fn delete_an_environment_async(&self, owner: &str, repo: &str, environment_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10305,7 +11370,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposDeleteAnEnvironmentError::Generic { code }), + code => Err(ReposDeleteAnEnvironmentError::Generic { code }.into()), } } } @@ -10320,7 +11385,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_an_environment(&self, owner: &str, repo: &str, environment_name: &str) -> Result<(), ReposDeleteAnEnvironmentError> { + pub fn delete_an_environment(&self, owner: &str, repo: &str, environment_name: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name); @@ -10332,7 +11397,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10344,7 +11409,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposDeleteAnEnvironmentError::Generic { code }), + code => Err(ReposDeleteAnEnvironmentError::Generic { code }.into()), } } } @@ -10360,19 +11425,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_autolink](https://docs.github.com/rest/repos/autolinks#delete-an-autolink-reference-from-a-repository) /// /// --- - pub async fn delete_autolink_async(&self, owner: &str, repo: &str, autolink_id: i32) -> Result<(), ReposDeleteAutolinkError> { + pub async fn delete_autolink_async(&self, owner: &str, repo: &str, autolink_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/autolinks/{}", super::GITHUB_BASE_API_URL, owner, repo, autolink_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10384,8 +11449,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteAutolinkError::Status404(github_response.to_json_async().await?)), - code => Err(ReposDeleteAutolinkError::Generic { code }), + 404 => Err(ReposDeleteAutolinkError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteAutolinkError::Generic { code }.into()), } } } @@ -10402,7 +11467,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_autolink(&self, owner: &str, repo: &str, autolink_id: i32) -> Result<(), ReposDeleteAutolinkError> { + pub fn delete_autolink(&self, owner: &str, repo: &str, autolink_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/autolinks/{}", super::GITHUB_BASE_API_URL, owner, repo, autolink_id); @@ -10414,7 +11479,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10426,8 +11491,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteAutolinkError::Status404(github_response.to_json()?)), - code => Err(ReposDeleteAutolinkError::Generic { code }), + 404 => Err(ReposDeleteAutolinkError::Status404(github_response.to_json()?).into()), + code => Err(ReposDeleteAutolinkError::Generic { code }.into()), } } } @@ -10441,19 +11506,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_branch_protection](https://docs.github.com/rest/branches/branch-protection#delete-branch-protection) /// /// --- - pub async fn delete_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposDeleteBranchProtectionError> { + pub async fn delete_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10465,8 +11530,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposDeleteBranchProtectionError::Status403(github_response.to_json_async().await?)), - code => Err(ReposDeleteBranchProtectionError::Generic { code }), + 403 => Err(ReposDeleteBranchProtectionError::Status403(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteBranchProtectionError::Generic { code }.into()), } } } @@ -10481,7 +11546,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposDeleteBranchProtectionError> { + pub fn delete_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -10493,7 +11558,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10505,8 +11570,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposDeleteBranchProtectionError::Status403(github_response.to_json()?)), - code => Err(ReposDeleteBranchProtectionError::Generic { code }), + 403 => Err(ReposDeleteBranchProtectionError::Status403(github_response.to_json()?).into()), + code => Err(ReposDeleteBranchProtectionError::Generic { code }.into()), } } } @@ -10518,19 +11583,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_commit_comment](https://docs.github.com/rest/commits/comments#delete-a-commit-comment) /// /// --- - pub async fn delete_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), ReposDeleteCommitCommentError> { + pub async fn delete_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10542,8 +11607,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteCommitCommentError::Status404(github_response.to_json_async().await?)), - code => Err(ReposDeleteCommitCommentError::Generic { code }), + 404 => Err(ReposDeleteCommitCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteCommitCommentError::Generic { code }.into()), } } } @@ -10556,7 +11621,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_commit_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), ReposDeleteCommitCommentError> { + pub fn delete_commit_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -10568,7 +11633,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10580,8 +11645,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteCommitCommentError::Status404(github_response.to_json()?)), - code => Err(ReposDeleteCommitCommentError::Generic { code }), + 404 => Err(ReposDeleteCommitCommentError::Status404(github_response.to_json()?).into()), + code => Err(ReposDeleteCommitCommentError::Generic { code }.into()), } } } @@ -10597,19 +11662,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_commit_signature_protection](https://docs.github.com/rest/branches/branch-protection#delete-commit-signature-protection) /// /// --- - pub async fn delete_commit_signature_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposDeleteCommitSignatureProtectionError> { + pub async fn delete_commit_signature_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10621,8 +11686,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteCommitSignatureProtectionError::Status404(github_response.to_json_async().await?)), - code => Err(ReposDeleteCommitSignatureProtectionError::Generic { code }), + 404 => Err(ReposDeleteCommitSignatureProtectionError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteCommitSignatureProtectionError::Generic { code }.into()), } } } @@ -10639,7 +11704,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_commit_signature_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposDeleteCommitSignatureProtectionError> { + pub fn delete_commit_signature_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -10651,7 +11716,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10663,8 +11728,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteCommitSignatureProtectionError::Status404(github_response.to_json()?)), - code => Err(ReposDeleteCommitSignatureProtectionError::Generic { code }), + 404 => Err(ReposDeleteCommitSignatureProtectionError::Status404(github_response.to_json()?).into()), + code => Err(ReposDeleteCommitSignatureProtectionError::Generic { code }.into()), } } } @@ -10678,19 +11743,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_deploy_key](https://docs.github.com/rest/deploy-keys/deploy-keys#delete-a-deploy-key) /// /// --- - pub async fn delete_deploy_key_async(&self, owner: &str, repo: &str, key_id: i32) -> Result<(), ReposDeleteDeployKeyError> { + pub async fn delete_deploy_key_async(&self, owner: &str, repo: &str, key_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/keys/{}", super::GITHUB_BASE_API_URL, owner, repo, key_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10702,7 +11767,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposDeleteDeployKeyError::Generic { code }), + code => Err(ReposDeleteDeployKeyError::Generic { code }.into()), } } } @@ -10717,7 +11782,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_deploy_key(&self, owner: &str, repo: &str, key_id: i32) -> Result<(), ReposDeleteDeployKeyError> { + pub fn delete_deploy_key(&self, owner: &str, repo: &str, key_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/keys/{}", super::GITHUB_BASE_API_URL, owner, repo, key_id); @@ -10729,7 +11794,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10741,7 +11806,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposDeleteDeployKeyError::Generic { code }), + code => Err(ReposDeleteDeployKeyError::Generic { code }.into()), } } } @@ -10764,19 +11829,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_deployment](https://docs.github.com/rest/deployments/deployments#delete-a-deployment) /// /// --- - pub async fn delete_deployment_async(&self, owner: &str, repo: &str, deployment_id: i32) -> Result<(), ReposDeleteDeploymentError> { + pub async fn delete_deployment_async(&self, owner: &str, repo: &str, deployment_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10788,9 +11853,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteDeploymentError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposDeleteDeploymentError::Status422(github_response.to_json_async().await?)), - code => Err(ReposDeleteDeploymentError::Generic { code }), + 404 => Err(ReposDeleteDeploymentError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposDeleteDeploymentError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteDeploymentError::Generic { code }.into()), } } } @@ -10814,7 +11879,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_deployment(&self, owner: &str, repo: &str, deployment_id: i32) -> Result<(), ReposDeleteDeploymentError> { + pub fn delete_deployment(&self, owner: &str, repo: &str, deployment_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_id); @@ -10826,7 +11891,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10838,9 +11903,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteDeploymentError::Status404(github_response.to_json()?)), - 422 => Err(ReposDeleteDeploymentError::Status422(github_response.to_json()?)), - code => Err(ReposDeleteDeploymentError::Generic { code }), + 404 => Err(ReposDeleteDeploymentError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposDeleteDeploymentError::Status422(github_response.to_json()?).into()), + code => Err(ReposDeleteDeploymentError::Generic { code }.into()), } } } @@ -10856,19 +11921,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#delete-a-deployment-branch-policy) /// /// --- - pub async fn delete_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result<(), ReposDeleteDeploymentBranchPolicyError> { + pub async fn delete_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10880,7 +11945,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposDeleteDeploymentBranchPolicyError::Generic { code }), + code => Err(ReposDeleteDeploymentBranchPolicyError::Generic { code }.into()), } } } @@ -10897,7 +11962,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result<(), ReposDeleteDeploymentBranchPolicyError> { + pub fn delete_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_id); @@ -10909,7 +11974,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10921,7 +11986,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposDeleteDeploymentBranchPolicyError::Generic { code }), + code => Err(ReposDeleteDeploymentBranchPolicyError::Generic { code }.into()), } } } @@ -10944,19 +12009,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_file](https://docs.github.com/rest/repos/contents#delete-a-file) /// /// --- - pub async fn delete_file_async(&self, owner: &str, repo: &str, path: &str, body: DeleteReposDeleteFile) -> Result { + pub async fn delete_file_async(&self, owner: &str, repo: &str, path: &str, body: DeleteReposDeleteFile) -> Result { let request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteReposDeleteFile::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -10968,11 +12033,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposDeleteFileError::Status422(github_response.to_json_async().await?)), - 404 => Err(ReposDeleteFileError::Status404(github_response.to_json_async().await?)), - 409 => Err(ReposDeleteFileError::Status409(github_response.to_json_async().await?)), - 503 => Err(ReposDeleteFileError::Status503(github_response.to_json_async().await?)), - code => Err(ReposDeleteFileError::Generic { code }), + 422 => Err(ReposDeleteFileError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(ReposDeleteFileError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(ReposDeleteFileError::Status409(github_response.to_json_async().await?).into()), + 503 => Err(ReposDeleteFileError::Status503(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteFileError::Generic { code }.into()), } } } @@ -10996,19 +12061,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_file(&self, owner: &str, repo: &str, path: &str, body: DeleteReposDeleteFile) -> Result { + pub fn delete_file(&self, owner: &str, repo: &str, path: &str, body: DeleteReposDeleteFile) -> Result { let request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteReposDeleteFile::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11020,11 +12085,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposDeleteFileError::Status422(github_response.to_json()?)), - 404 => Err(ReposDeleteFileError::Status404(github_response.to_json()?)), - 409 => Err(ReposDeleteFileError::Status409(github_response.to_json()?)), - 503 => Err(ReposDeleteFileError::Status503(github_response.to_json()?)), - code => Err(ReposDeleteFileError::Generic { code }), + 422 => Err(ReposDeleteFileError::Status422(github_response.to_json()?).into()), + 404 => Err(ReposDeleteFileError::Status404(github_response.to_json()?).into()), + 409 => Err(ReposDeleteFileError::Status409(github_response.to_json()?).into()), + 503 => Err(ReposDeleteFileError::Status503(github_response.to_json()?).into()), + code => Err(ReposDeleteFileError::Generic { code }.into()), } } } @@ -11036,19 +12101,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_invitation](https://docs.github.com/rest/collaborators/invitations#delete-a-repository-invitation) /// /// --- - pub async fn delete_invitation_async(&self, owner: &str, repo: &str, invitation_id: i32) -> Result<(), ReposDeleteInvitationError> { + pub async fn delete_invitation_async(&self, owner: &str, repo: &str, invitation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/invitations/{}", super::GITHUB_BASE_API_URL, owner, repo, invitation_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11060,7 +12125,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposDeleteInvitationError::Generic { code }), + code => Err(ReposDeleteInvitationError::Generic { code }.into()), } } } @@ -11073,7 +12138,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_invitation(&self, owner: &str, repo: &str, invitation_id: i32) -> Result<(), ReposDeleteInvitationError> { + pub fn delete_invitation(&self, owner: &str, repo: &str, invitation_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/invitations/{}", super::GITHUB_BASE_API_URL, owner, repo, invitation_id); @@ -11085,7 +12150,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11097,7 +12162,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposDeleteInvitationError::Generic { code }), + code => Err(ReposDeleteInvitationError::Generic { code }.into()), } } } @@ -11111,19 +12176,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_org_ruleset](https://docs.github.com/rest/orgs/rules#delete-an-organization-repository-ruleset) /// /// --- - pub async fn delete_org_ruleset_async(&self, org: &str, ruleset_id: i32) -> Result<(), ReposDeleteOrgRulesetError> { + pub async fn delete_org_ruleset_async(&self, org: &str, ruleset_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11135,9 +12200,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteOrgRulesetError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposDeleteOrgRulesetError::Status500(github_response.to_json_async().await?)), - code => Err(ReposDeleteOrgRulesetError::Generic { code }), + 404 => Err(ReposDeleteOrgRulesetError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposDeleteOrgRulesetError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteOrgRulesetError::Generic { code }.into()), } } } @@ -11152,7 +12217,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_org_ruleset(&self, org: &str, ruleset_id: i32) -> Result<(), ReposDeleteOrgRulesetError> { + pub fn delete_org_ruleset(&self, org: &str, ruleset_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_id); @@ -11164,7 +12229,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11176,9 +12241,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteOrgRulesetError::Status404(github_response.to_json()?)), - 500 => Err(ReposDeleteOrgRulesetError::Status500(github_response.to_json()?)), - code => Err(ReposDeleteOrgRulesetError::Generic { code }), + 404 => Err(ReposDeleteOrgRulesetError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposDeleteOrgRulesetError::Status500(github_response.to_json()?).into()), + code => Err(ReposDeleteOrgRulesetError::Generic { code }.into()), } } } @@ -11196,19 +12261,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_pages_site](https://docs.github.com/rest/pages/pages#delete-a-apiname-pages-site) /// /// --- - pub async fn delete_pages_site_async(&self, owner: &str, repo: &str) -> Result<(), ReposDeletePagesSiteError> { + pub async fn delete_pages_site_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11220,10 +12285,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposDeletePagesSiteError::Status422(github_response.to_json_async().await?)), - 404 => Err(ReposDeletePagesSiteError::Status404(github_response.to_json_async().await?)), - 409 => Err(ReposDeletePagesSiteError::Status409(github_response.to_json_async().await?)), - code => Err(ReposDeletePagesSiteError::Generic { code }), + 422 => Err(ReposDeletePagesSiteError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(ReposDeletePagesSiteError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(ReposDeletePagesSiteError::Status409(github_response.to_json_async().await?).into()), + code => Err(ReposDeletePagesSiteError::Generic { code }.into()), } } } @@ -11242,7 +12307,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_pages_site(&self, owner: &str, repo: &str) -> Result<(), ReposDeletePagesSiteError> { + pub fn delete_pages_site(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo); @@ -11254,7 +12319,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11266,10 +12331,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposDeletePagesSiteError::Status422(github_response.to_json()?)), - 404 => Err(ReposDeletePagesSiteError::Status404(github_response.to_json()?)), - 409 => Err(ReposDeletePagesSiteError::Status409(github_response.to_json()?)), - code => Err(ReposDeletePagesSiteError::Generic { code }), + 422 => Err(ReposDeletePagesSiteError::Status422(github_response.to_json()?).into()), + 404 => Err(ReposDeletePagesSiteError::Status404(github_response.to_json()?).into()), + 409 => Err(ReposDeletePagesSiteError::Status409(github_response.to_json()?).into()), + code => Err(ReposDeletePagesSiteError::Generic { code }.into()), } } } @@ -11283,19 +12348,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_pull_request_review_protection](https://docs.github.com/rest/branches/branch-protection#delete-pull-request-review-protection) /// /// --- - pub async fn delete_pull_request_review_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposDeletePullRequestReviewProtectionError> { + pub async fn delete_pull_request_review_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11307,8 +12372,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposDeletePullRequestReviewProtectionError::Status404(github_response.to_json_async().await?)), - code => Err(ReposDeletePullRequestReviewProtectionError::Generic { code }), + 404 => Err(ReposDeletePullRequestReviewProtectionError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposDeletePullRequestReviewProtectionError::Generic { code }.into()), } } } @@ -11323,7 +12388,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_pull_request_review_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposDeletePullRequestReviewProtectionError> { + pub fn delete_pull_request_review_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -11335,7 +12400,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11347,8 +12412,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposDeletePullRequestReviewProtectionError::Status404(github_response.to_json()?)), - code => Err(ReposDeletePullRequestReviewProtectionError::Generic { code }), + 404 => Err(ReposDeletePullRequestReviewProtectionError::Status404(github_response.to_json()?).into()), + code => Err(ReposDeletePullRequestReviewProtectionError::Generic { code }.into()), } } } @@ -11362,19 +12427,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_release](https://docs.github.com/rest/releases/releases#delete-a-release) /// /// --- - pub async fn delete_release_async(&self, owner: &str, repo: &str, release_id: i32) -> Result<(), ReposDeleteReleaseError> { + pub async fn delete_release_async(&self, owner: &str, repo: &str, release_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11386,7 +12451,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposDeleteReleaseError::Generic { code }), + code => Err(ReposDeleteReleaseError::Generic { code }.into()), } } } @@ -11401,7 +12466,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_release(&self, owner: &str, repo: &str, release_id: i32) -> Result<(), ReposDeleteReleaseError> { + pub fn delete_release(&self, owner: &str, repo: &str, release_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_id); @@ -11413,7 +12478,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11425,7 +12490,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposDeleteReleaseError::Generic { code }), + code => Err(ReposDeleteReleaseError::Generic { code }.into()), } } } @@ -11437,19 +12502,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_release_asset](https://docs.github.com/rest/releases/assets#delete-a-release-asset) /// /// --- - pub async fn delete_release_asset_async(&self, owner: &str, repo: &str, asset_id: i32) -> Result<(), ReposDeleteReleaseAssetError> { + pub async fn delete_release_asset_async(&self, owner: &str, repo: &str, asset_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11461,7 +12526,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposDeleteReleaseAssetError::Generic { code }), + code => Err(ReposDeleteReleaseAssetError::Generic { code }.into()), } } } @@ -11474,7 +12539,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_release_asset(&self, owner: &str, repo: &str, asset_id: i32) -> Result<(), ReposDeleteReleaseAssetError> { + pub fn delete_release_asset(&self, owner: &str, repo: &str, asset_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_id); @@ -11486,7 +12551,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11498,7 +12563,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposDeleteReleaseAssetError::Generic { code }), + code => Err(ReposDeleteReleaseAssetError::Generic { code }.into()), } } } @@ -11512,19 +12577,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_repo_ruleset](https://docs.github.com/rest/repos/rules#delete-a-repository-ruleset) /// /// --- - pub async fn delete_repo_ruleset_async(&self, owner: &str, repo: &str, ruleset_id: i32) -> Result<(), ReposDeleteRepoRulesetError> { + pub async fn delete_repo_ruleset_async(&self, owner: &str, repo: &str, ruleset_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, ruleset_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11536,9 +12601,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteRepoRulesetError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposDeleteRepoRulesetError::Status500(github_response.to_json_async().await?)), - code => Err(ReposDeleteRepoRulesetError::Generic { code }), + 404 => Err(ReposDeleteRepoRulesetError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposDeleteRepoRulesetError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteRepoRulesetError::Generic { code }.into()), } } } @@ -11553,7 +12618,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_repo_ruleset(&self, owner: &str, repo: &str, ruleset_id: i32) -> Result<(), ReposDeleteRepoRulesetError> { + pub fn delete_repo_ruleset(&self, owner: &str, repo: &str, ruleset_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, ruleset_id); @@ -11565,7 +12630,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11577,9 +12642,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteRepoRulesetError::Status404(github_response.to_json()?)), - 500 => Err(ReposDeleteRepoRulesetError::Status500(github_response.to_json()?)), - code => Err(ReposDeleteRepoRulesetError::Generic { code }), + 404 => Err(ReposDeleteRepoRulesetError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposDeleteRepoRulesetError::Status500(github_response.to_json()?).into()), + code => Err(ReposDeleteRepoRulesetError::Generic { code }.into()), } } } @@ -11597,19 +12662,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_tag_protection](https://docs.github.com/rest/repos/tags#deprecated---delete-a-tag-protection-state-for-a-repository) /// /// --- - pub async fn delete_tag_protection_async(&self, owner: &str, repo: &str, tag_protection_id: i32) -> Result<(), ReposDeleteTagProtectionError> { + pub async fn delete_tag_protection_async(&self, owner: &str, repo: &str, tag_protection_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/tags/protection/{}", super::GITHUB_BASE_API_URL, owner, repo, tag_protection_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11621,9 +12686,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposDeleteTagProtectionError::Status403(github_response.to_json_async().await?)), - 404 => Err(ReposDeleteTagProtectionError::Status404(github_response.to_json_async().await?)), - code => Err(ReposDeleteTagProtectionError::Generic { code }), + 403 => Err(ReposDeleteTagProtectionError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ReposDeleteTagProtectionError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteTagProtectionError::Generic { code }.into()), } } } @@ -11642,7 +12707,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_tag_protection(&self, owner: &str, repo: &str, tag_protection_id: i32) -> Result<(), ReposDeleteTagProtectionError> { + pub fn delete_tag_protection(&self, owner: &str, repo: &str, tag_protection_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/tags/protection/{}", super::GITHUB_BASE_API_URL, owner, repo, tag_protection_id); @@ -11654,7 +12719,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11666,9 +12731,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposDeleteTagProtectionError::Status403(github_response.to_json()?)), - 404 => Err(ReposDeleteTagProtectionError::Status404(github_response.to_json()?)), - code => Err(ReposDeleteTagProtectionError::Generic { code }), + 403 => Err(ReposDeleteTagProtectionError::Status403(github_response.to_json()?).into()), + 404 => Err(ReposDeleteTagProtectionError::Status404(github_response.to_json()?).into()), + code => Err(ReposDeleteTagProtectionError::Generic { code }.into()), } } } @@ -11680,19 +12745,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for delete_webhook](https://docs.github.com/rest/repos/webhooks#delete-a-repository-webhook) /// /// --- - pub async fn delete_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), ReposDeleteWebhookError> { + pub async fn delete_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, hook_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11704,8 +12769,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteWebhookError::Status404(github_response.to_json_async().await?)), - code => Err(ReposDeleteWebhookError::Generic { code }), + 404 => Err(ReposDeleteWebhookError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposDeleteWebhookError::Generic { code }.into()), } } } @@ -11718,7 +12783,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), ReposDeleteWebhookError> { + pub fn delete_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, hook_id); @@ -11730,7 +12795,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11742,8 +12807,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposDeleteWebhookError::Status404(github_response.to_json()?)), - code => Err(ReposDeleteWebhookError::Generic { code }), + 404 => Err(ReposDeleteWebhookError::Status404(github_response.to_json()?).into()), + code => Err(ReposDeleteWebhookError::Generic { code }.into()), } } } @@ -11757,19 +12822,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for disable_automated_security_fixes](https://docs.github.com/rest/repos/repos#disable-automated-security-fixes) /// /// --- - pub async fn disable_automated_security_fixes_async(&self, owner: &str, repo: &str) -> Result<(), ReposDisableAutomatedSecurityFixesError> { + pub async fn disable_automated_security_fixes_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11781,7 +12846,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposDisableAutomatedSecurityFixesError::Generic { code }), + code => Err(ReposDisableAutomatedSecurityFixesError::Generic { code }.into()), } } } @@ -11796,7 +12861,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn disable_automated_security_fixes(&self, owner: &str, repo: &str) -> Result<(), ReposDisableAutomatedSecurityFixesError> { + pub fn disable_automated_security_fixes(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo); @@ -11808,7 +12873,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11820,7 +12885,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposDisableAutomatedSecurityFixesError::Generic { code }), + code => Err(ReposDisableAutomatedSecurityFixesError::Generic { code }.into()), } } } @@ -11838,19 +12903,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for disable_deployment_protection_rule](https://docs.github.com/rest/deployments/protection-rules#disable-a-custom-protection-rule-for-an-environment) /// /// --- - pub async fn disable_deployment_protection_rule_async(&self, environment_name: &str, repo: &str, owner: &str, protection_rule_id: i32) -> Result<(), ReposDisableDeploymentProtectionRuleError> { + pub async fn disable_deployment_protection_rule_async(&self, environment_name: &str, repo: &str, owner: &str, protection_rule_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/{}", super::GITHUB_BASE_API_URL, environment_name, repo, owner, protection_rule_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11862,7 +12927,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposDisableDeploymentProtectionRuleError::Generic { code }), + code => Err(ReposDisableDeploymentProtectionRuleError::Generic { code }.into()), } } } @@ -11881,7 +12946,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn disable_deployment_protection_rule(&self, environment_name: &str, repo: &str, owner: &str, protection_rule_id: i32) -> Result<(), ReposDisableDeploymentProtectionRuleError> { + pub fn disable_deployment_protection_rule(&self, environment_name: &str, repo: &str, owner: &str, protection_rule_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/{}", super::GITHUB_BASE_API_URL, environment_name, repo, owner, protection_rule_id); @@ -11893,7 +12958,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11905,7 +12970,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposDisableDeploymentProtectionRuleError::Generic { code }), + code => Err(ReposDisableDeploymentProtectionRuleError::Generic { code }.into()), } } } @@ -11919,19 +12984,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for disable_private_vulnerability_reporting](https://docs.github.com/rest/repos/repos#disable-private-vulnerability-reporting-for-a-repository) /// /// --- - pub async fn disable_private_vulnerability_reporting_async(&self, owner: &str, repo: &str) -> Result<(), ReposDisablePrivateVulnerabilityReportingError> { + pub async fn disable_private_vulnerability_reporting_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11943,8 +13008,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposDisablePrivateVulnerabilityReportingError::Status422(github_response.to_json_async().await?)), - code => Err(ReposDisablePrivateVulnerabilityReportingError::Generic { code }), + 422 => Err(ReposDisablePrivateVulnerabilityReportingError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposDisablePrivateVulnerabilityReportingError::Generic { code }.into()), } } } @@ -11959,7 +13024,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn disable_private_vulnerability_reporting(&self, owner: &str, repo: &str) -> Result<(), ReposDisablePrivateVulnerabilityReportingError> { + pub fn disable_private_vulnerability_reporting(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo); @@ -11971,7 +13036,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -11983,8 +13048,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposDisablePrivateVulnerabilityReportingError::Status422(github_response.to_json()?)), - code => Err(ReposDisablePrivateVulnerabilityReportingError::Generic { code }), + 422 => Err(ReposDisablePrivateVulnerabilityReportingError::Status422(github_response.to_json()?).into()), + code => Err(ReposDisablePrivateVulnerabilityReportingError::Generic { code }.into()), } } } @@ -12000,19 +13065,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for disable_vulnerability_alerts](https://docs.github.com/rest/repos/repos#disable-vulnerability-alerts) /// /// --- - pub async fn disable_vulnerability_alerts_async(&self, owner: &str, repo: &str) -> Result<(), ReposDisableVulnerabilityAlertsError> { + pub async fn disable_vulnerability_alerts_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12024,7 +13089,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposDisableVulnerabilityAlertsError::Generic { code }), + code => Err(ReposDisableVulnerabilityAlertsError::Generic { code }.into()), } } } @@ -12041,7 +13106,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn disable_vulnerability_alerts(&self, owner: &str, repo: &str) -> Result<(), ReposDisableVulnerabilityAlertsError> { + pub fn disable_vulnerability_alerts(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo); @@ -12053,7 +13118,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12065,7 +13130,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposDisableVulnerabilityAlertsError::Generic { code }), + code => Err(ReposDisableVulnerabilityAlertsError::Generic { code }.into()), } } } @@ -12084,19 +13149,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for download_tarball_archive](https://docs.github.com/rest/repos/contents#download-a-repository-archive-tar) /// /// --- - pub async fn download_tarball_archive_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), ReposDownloadTarballArchiveError> { + pub async fn download_tarball_archive_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/tarball/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12108,8 +13173,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 302 => Err(ReposDownloadTarballArchiveError::Status302), - code => Err(ReposDownloadTarballArchiveError::Generic { code }), + 302 => Err(ReposDownloadTarballArchiveError::Status302.into()), + code => Err(ReposDownloadTarballArchiveError::Generic { code }.into()), } } } @@ -12129,7 +13194,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn download_tarball_archive(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), ReposDownloadTarballArchiveError> { + pub fn download_tarball_archive(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/tarball/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -12141,7 +13206,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12153,8 +13218,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 302 => Err(ReposDownloadTarballArchiveError::Status302), - code => Err(ReposDownloadTarballArchiveError::Generic { code }), + 302 => Err(ReposDownloadTarballArchiveError::Status302.into()), + code => Err(ReposDownloadTarballArchiveError::Generic { code }.into()), } } } @@ -12173,19 +13238,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for download_zipball_archive](https://docs.github.com/rest/repos/contents#download-a-repository-archive-zip) /// /// --- - pub async fn download_zipball_archive_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), ReposDownloadZipballArchiveError> { + pub async fn download_zipball_archive_async(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/zipball/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12197,8 +13262,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 302 => Err(ReposDownloadZipballArchiveError::Status302), - code => Err(ReposDownloadZipballArchiveError::Generic { code }), + 302 => Err(ReposDownloadZipballArchiveError::Status302.into()), + code => Err(ReposDownloadZipballArchiveError::Generic { code }.into()), } } } @@ -12218,7 +13283,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn download_zipball_archive(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), ReposDownloadZipballArchiveError> { + pub fn download_zipball_archive(&self, owner: &str, repo: &str, git_ref: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/zipball/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -12230,7 +13295,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12242,8 +13307,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 302 => Err(ReposDownloadZipballArchiveError::Status302), - code => Err(ReposDownloadZipballArchiveError::Generic { code }), + 302 => Err(ReposDownloadZipballArchiveError::Status302.into()), + code => Err(ReposDownloadZipballArchiveError::Generic { code }.into()), } } } @@ -12257,19 +13322,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for enable_automated_security_fixes](https://docs.github.com/rest/repos/repos#enable-automated-security-fixes) /// /// --- - pub async fn enable_automated_security_fixes_async(&self, owner: &str, repo: &str) -> Result<(), ReposEnableAutomatedSecurityFixesError> { + pub async fn enable_automated_security_fixes_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12281,7 +13346,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposEnableAutomatedSecurityFixesError::Generic { code }), + code => Err(ReposEnableAutomatedSecurityFixesError::Generic { code }.into()), } } } @@ -12296,7 +13361,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn enable_automated_security_fixes(&self, owner: &str, repo: &str) -> Result<(), ReposEnableAutomatedSecurityFixesError> { + pub fn enable_automated_security_fixes(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/automated-security-fixes", super::GITHUB_BASE_API_URL, owner, repo); @@ -12308,7 +13373,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12320,7 +13385,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposEnableAutomatedSecurityFixesError::Generic { code }), + code => Err(ReposEnableAutomatedSecurityFixesError::Generic { code }.into()), } } } @@ -12334,19 +13399,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for enable_private_vulnerability_reporting](https://docs.github.com/rest/repos/repos#enable-private-vulnerability-reporting-for-a-repository) /// /// --- - pub async fn enable_private_vulnerability_reporting_async(&self, owner: &str, repo: &str) -> Result<(), ReposEnablePrivateVulnerabilityReportingError> { + pub async fn enable_private_vulnerability_reporting_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12358,8 +13423,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposEnablePrivateVulnerabilityReportingError::Status422(github_response.to_json_async().await?)), - code => Err(ReposEnablePrivateVulnerabilityReportingError::Generic { code }), + 422 => Err(ReposEnablePrivateVulnerabilityReportingError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposEnablePrivateVulnerabilityReportingError::Generic { code }.into()), } } } @@ -12374,7 +13439,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn enable_private_vulnerability_reporting(&self, owner: &str, repo: &str) -> Result<(), ReposEnablePrivateVulnerabilityReportingError> { + pub fn enable_private_vulnerability_reporting(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/private-vulnerability-reporting", super::GITHUB_BASE_API_URL, owner, repo); @@ -12386,7 +13451,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12398,8 +13463,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposEnablePrivateVulnerabilityReportingError::Status422(github_response.to_json()?)), - code => Err(ReposEnablePrivateVulnerabilityReportingError::Generic { code }), + 422 => Err(ReposEnablePrivateVulnerabilityReportingError::Status422(github_response.to_json()?).into()), + code => Err(ReposEnablePrivateVulnerabilityReportingError::Generic { code }.into()), } } } @@ -12413,19 +13478,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for enable_vulnerability_alerts](https://docs.github.com/rest/repos/repos#enable-vulnerability-alerts) /// /// --- - pub async fn enable_vulnerability_alerts_async(&self, owner: &str, repo: &str) -> Result<(), ReposEnableVulnerabilityAlertsError> { + pub async fn enable_vulnerability_alerts_async(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12437,7 +13502,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposEnableVulnerabilityAlertsError::Generic { code }), + code => Err(ReposEnableVulnerabilityAlertsError::Generic { code }.into()), } } } @@ -12452,7 +13517,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn enable_vulnerability_alerts(&self, owner: &str, repo: &str) -> Result<(), ReposEnableVulnerabilityAlertsError> { + pub fn enable_vulnerability_alerts(&self, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/vulnerability-alerts", super::GITHUB_BASE_API_URL, owner, repo); @@ -12464,7 +13529,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12476,7 +13541,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposEnableVulnerabilityAlertsError::Generic { code }), + code => Err(ReposEnableVulnerabilityAlertsError::Generic { code }.into()), } } } @@ -12490,19 +13555,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for generate_release_notes](https://docs.github.com/rest/releases/releases#generate-release-notes-content-for-a-release) /// /// --- - pub async fn generate_release_notes_async(&self, owner: &str, repo: &str, body: PostReposGenerateReleaseNotes) -> Result { + pub async fn generate_release_notes_async(&self, owner: &str, repo: &str, body: PostReposGenerateReleaseNotes) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/generate-notes", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposGenerateReleaseNotes::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12514,8 +13579,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGenerateReleaseNotesError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGenerateReleaseNotesError::Generic { code }), + 404 => Err(ReposGenerateReleaseNotesError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGenerateReleaseNotesError::Generic { code }.into()), } } } @@ -12530,19 +13595,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn generate_release_notes(&self, owner: &str, repo: &str, body: PostReposGenerateReleaseNotes) -> Result { + pub fn generate_release_notes(&self, owner: &str, repo: &str, body: PostReposGenerateReleaseNotes) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/generate-notes", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposGenerateReleaseNotes::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12554,8 +13619,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGenerateReleaseNotesError::Status404(github_response.to_json()?)), - code => Err(ReposGenerateReleaseNotesError::Generic { code }), + 404 => Err(ReposGenerateReleaseNotesError::Status404(github_response.to_json()?).into()), + code => Err(ReposGenerateReleaseNotesError::Generic { code }.into()), } } } @@ -12572,19 +13637,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get](https://docs.github.com/rest/repos/repos#get-a-repository) /// /// --- - pub async fn get_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12596,10 +13661,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposGetError::Status403(github_response.to_json_async().await?)), - 404 => Err(ReposGetError::Status404(github_response.to_json_async().await?)), - 301 => Err(ReposGetError::Status301(github_response.to_json_async().await?)), - code => Err(ReposGetError::Generic { code }), + 403 => Err(ReposGetError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ReposGetError::Status404(github_response.to_json_async().await?).into()), + 301 => Err(ReposGetError::Status301(github_response.to_json_async().await?).into()), + code => Err(ReposGetError::Generic { code }.into()), } } } @@ -12617,7 +13682,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get(&self, owner: &str, repo: &str) -> Result { + pub fn get(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); @@ -12629,7 +13694,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12641,10 +13706,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposGetError::Status403(github_response.to_json()?)), - 404 => Err(ReposGetError::Status404(github_response.to_json()?)), - 301 => Err(ReposGetError::Status301(github_response.to_json()?)), - code => Err(ReposGetError::Generic { code }), + 403 => Err(ReposGetError::Status403(github_response.to_json()?).into()), + 404 => Err(ReposGetError::Status404(github_response.to_json()?).into()), + 301 => Err(ReposGetError::Status301(github_response.to_json()?).into()), + code => Err(ReposGetError::Generic { code }.into()), } } } @@ -12663,19 +13728,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_access_restrictions](https://docs.github.com/rest/branches/branch-protection#get-access-restrictions) /// /// --- - pub async fn get_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub async fn get_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12687,8 +13752,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetAccessRestrictionsError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetAccessRestrictionsError::Generic { code }), + 404 => Err(ReposGetAccessRestrictionsError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetAccessRestrictionsError::Generic { code }.into()), } } } @@ -12708,7 +13773,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_access_restrictions(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub fn get_access_restrictions(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -12720,7 +13785,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12732,8 +13797,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetAccessRestrictionsError::Status404(github_response.to_json()?)), - code => Err(ReposGetAccessRestrictionsError::Generic { code }), + 404 => Err(ReposGetAccessRestrictionsError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetAccessRestrictionsError::Generic { code }.into()), } } } @@ -12747,19 +13812,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_admin_branch_protection](https://docs.github.com/rest/branches/branch-protection#get-admin-branch-protection) /// /// --- - pub async fn get_admin_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub async fn get_admin_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12771,7 +13836,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetAdminBranchProtectionError::Generic { code }), + code => Err(ReposGetAdminBranchProtectionError::Generic { code }.into()), } } } @@ -12786,7 +13851,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_admin_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub fn get_admin_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -12798,7 +13863,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12810,7 +13875,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetAdminBranchProtectionError::Generic { code }), + code => Err(ReposGetAdminBranchProtectionError::Generic { code }.into()), } } } @@ -12828,19 +13893,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_all_deployment_protection_rules](https://docs.github.com/rest/deployments/protection-rules#get-all-deployment-protection-rules-for-an-environment) /// /// --- - pub async fn get_all_deployment_protection_rules_async(&self, environment_name: &str, repo: &str, owner: &str) -> Result { + pub async fn get_all_deployment_protection_rules_async(&self, environment_name: &str, repo: &str, owner: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules", super::GITHUB_BASE_API_URL, environment_name, repo, owner); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12852,7 +13917,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetAllDeploymentProtectionRulesError::Generic { code }), + code => Err(ReposGetAllDeploymentProtectionRulesError::Generic { code }.into()), } } } @@ -12871,7 +13936,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_deployment_protection_rules(&self, environment_name: &str, repo: &str, owner: &str) -> Result { + pub fn get_all_deployment_protection_rules(&self, environment_name: &str, repo: &str, owner: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules", super::GITHUB_BASE_API_URL, environment_name, repo, owner); @@ -12883,7 +13948,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12895,7 +13960,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetAllDeploymentProtectionRulesError::Generic { code }), + code => Err(ReposGetAllDeploymentProtectionRulesError::Generic { code }.into()), } } } @@ -12913,7 +13978,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_all_environments](https://docs.github.com/rest/deployments/environments#list-environments) /// /// --- - pub async fn get_all_environments_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub async fn get_all_environments_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/environments", super::GITHUB_BASE_API_URL, owner, repo); @@ -12924,12 +13989,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12941,7 +14006,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetAllEnvironmentsError::Generic { code }), + code => Err(ReposGetAllEnvironmentsError::Generic { code }.into()), } } } @@ -12960,7 +14025,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_environments(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + pub fn get_all_environments(&self, owner: &str, repo: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/environments", super::GITHUB_BASE_API_URL, owner, repo); @@ -12977,7 +14042,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -12989,7 +14054,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetAllEnvironmentsError::Generic { code }), + code => Err(ReposGetAllEnvironmentsError::Generic { code }.into()), } } } @@ -13003,19 +14068,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_all_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#get-all-status-check-contexts) /// /// --- - pub async fn get_all_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str) -> Result, ReposGetAllStatusCheckContextsError> { + pub async fn get_all_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13027,8 +14092,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetAllStatusCheckContextsError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetAllStatusCheckContextsError::Generic { code }), + 404 => Err(ReposGetAllStatusCheckContextsError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetAllStatusCheckContextsError::Generic { code }.into()), } } } @@ -13043,7 +14108,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_status_check_contexts(&self, owner: &str, repo: &str, branch: &str) -> Result, ReposGetAllStatusCheckContextsError> { + pub fn get_all_status_check_contexts(&self, owner: &str, repo: &str, branch: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -13055,7 +14120,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13067,8 +14132,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetAllStatusCheckContextsError::Status404(github_response.to_json()?)), - code => Err(ReposGetAllStatusCheckContextsError::Generic { code }), + 404 => Err(ReposGetAllStatusCheckContextsError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetAllStatusCheckContextsError::Generic { code }.into()), } } } @@ -13080,7 +14145,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_all_topics](https://docs.github.com/rest/repos/repos#get-all-repository-topics) /// /// --- - pub async fn get_all_topics_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + 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); @@ -13091,12 +14156,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13108,8 +14173,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetAllTopicsError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetAllTopicsError::Generic { code }), + 404 => Err(ReposGetAllTopicsError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetAllTopicsError::Generic { code }.into()), } } } @@ -13122,7 +14187,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_all_topics(&self, owner: &str, repo: &str, query_params: Option>) -> Result { + 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); @@ -13139,7 +14204,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13151,8 +14216,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetAllTopicsError::Status404(github_response.to_json()?)), - code => Err(ReposGetAllTopicsError::Generic { code }), + 404 => Err(ReposGetAllTopicsError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetAllTopicsError::Generic { code }.into()), } } } @@ -13168,19 +14233,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_apps_with_access_to_protected_branch](https://docs.github.com/rest/branches/branch-protection#get-apps-with-access-to-the-protected-branch) /// /// --- - pub async fn get_apps_with_access_to_protected_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result, ReposGetAppsWithAccessToProtectedBranchError> { + pub async fn get_apps_with_access_to_protected_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13192,8 +14257,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetAppsWithAccessToProtectedBranchError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetAppsWithAccessToProtectedBranchError::Generic { code }), + 404 => Err(ReposGetAppsWithAccessToProtectedBranchError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetAppsWithAccessToProtectedBranchError::Generic { code }.into()), } } } @@ -13210,7 +14275,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_apps_with_access_to_protected_branch(&self, owner: &str, repo: &str, branch: &str) -> Result, ReposGetAppsWithAccessToProtectedBranchError> { + pub fn get_apps_with_access_to_protected_branch(&self, owner: &str, repo: &str, branch: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -13222,7 +14287,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13234,8 +14299,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetAppsWithAccessToProtectedBranchError::Status404(github_response.to_json()?)), - code => Err(ReposGetAppsWithAccessToProtectedBranchError::Generic { code }), + 404 => Err(ReposGetAppsWithAccessToProtectedBranchError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetAppsWithAccessToProtectedBranchError::Generic { code }.into()), } } } @@ -13251,19 +14316,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_autolink](https://docs.github.com/rest/repos/autolinks#get-an-autolink-reference-of-a-repository) /// /// --- - pub async fn get_autolink_async(&self, owner: &str, repo: &str, autolink_id: i32) -> Result { + pub async fn get_autolink_async(&self, owner: &str, repo: &str, autolink_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/autolinks/{}", super::GITHUB_BASE_API_URL, owner, repo, autolink_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13275,8 +14340,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetAutolinkError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetAutolinkError::Generic { code }), + 404 => Err(ReposGetAutolinkError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetAutolinkError::Generic { code }.into()), } } } @@ -13293,7 +14358,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_autolink(&self, owner: &str, repo: &str, autolink_id: i32) -> Result { + pub fn get_autolink(&self, owner: &str, repo: &str, autolink_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/autolinks/{}", super::GITHUB_BASE_API_URL, owner, repo, autolink_id); @@ -13305,7 +14370,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13317,8 +14382,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetAutolinkError::Status404(github_response.to_json()?)), - code => Err(ReposGetAutolinkError::Generic { code }), + 404 => Err(ReposGetAutolinkError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetAutolinkError::Generic { code }.into()), } } } @@ -13330,19 +14395,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_branch](https://docs.github.com/rest/branches/branches#get-a-branch) /// /// --- - pub async fn get_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub async fn get_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13354,9 +14419,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 301 => Err(ReposGetBranchError::Status301(github_response.to_json_async().await?)), - 404 => Err(ReposGetBranchError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetBranchError::Generic { code }), + 301 => Err(ReposGetBranchError::Status301(github_response.to_json_async().await?).into()), + 404 => Err(ReposGetBranchError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetBranchError::Generic { code }.into()), } } } @@ -13369,7 +14434,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_branch(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub fn get_branch(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -13381,7 +14446,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13393,9 +14458,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 301 => Err(ReposGetBranchError::Status301(github_response.to_json()?)), - 404 => Err(ReposGetBranchError::Status404(github_response.to_json()?)), - code => Err(ReposGetBranchError::Generic { code }), + 301 => Err(ReposGetBranchError::Status301(github_response.to_json()?).into()), + 404 => Err(ReposGetBranchError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetBranchError::Generic { code }.into()), } } } @@ -13409,19 +14474,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_branch_protection](https://docs.github.com/rest/branches/branch-protection#get-branch-protection) /// /// --- - pub async fn get_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub async fn get_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13433,8 +14498,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetBranchProtectionError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetBranchProtectionError::Generic { code }), + 404 => Err(ReposGetBranchProtectionError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetBranchProtectionError::Generic { code }.into()), } } } @@ -13449,7 +14514,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub fn get_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -13461,7 +14526,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13473,8 +14538,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetBranchProtectionError::Status404(github_response.to_json()?)), - code => Err(ReposGetBranchProtectionError::Generic { code }), + 404 => Err(ReposGetBranchProtectionError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetBranchProtectionError::Generic { code }.into()), } } } @@ -13491,7 +14556,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_branch_rules](https://docs.github.com/rest/repos/rules#get-rules-for-a-branch) /// /// --- - pub async fn get_branch_rules_async(&self, owner: &str, repo: &str, branch: &str, query_params: Option>) -> Result, ReposGetBranchRulesError> { + pub async fn get_branch_rules_async(&self, owner: &str, repo: &str, branch: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/rules/branches/{}", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -13502,12 +14567,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13519,7 +14584,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetBranchRulesError::Generic { code }), + code => Err(ReposGetBranchRulesError::Generic { code }.into()), } } } @@ -13537,7 +14602,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_branch_rules(&self, owner: &str, repo: &str, branch: &str, query_params: Option>) -> Result, ReposGetBranchRulesError> { + pub fn get_branch_rules(&self, owner: &str, repo: &str, branch: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/rules/branches/{}", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -13554,7 +14619,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13566,7 +14631,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetBranchRulesError::Generic { code }), + code => Err(ReposGetBranchRulesError::Generic { code }.into()), } } } @@ -13580,7 +14645,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_clones](https://docs.github.com/rest/metrics/traffic#get-repository-clones) /// /// --- - pub async fn get_clones_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub async fn get_clones_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/traffic/clones", super::GITHUB_BASE_API_URL, owner, repo); @@ -13591,12 +14656,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13608,8 +14673,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposGetClonesError::Status403(github_response.to_json_async().await?)), - code => Err(ReposGetClonesError::Generic { code }), + 403 => Err(ReposGetClonesError::Status403(github_response.to_json_async().await?).into()), + code => Err(ReposGetClonesError::Generic { code }.into()), } } } @@ -13624,7 +14689,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_clones(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub fn get_clones(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/traffic/clones", super::GITHUB_BASE_API_URL, owner, repo); @@ -13641,7 +14706,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13653,8 +14718,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposGetClonesError::Status403(github_response.to_json()?)), - code => Err(ReposGetClonesError::Generic { code }), + 403 => Err(ReposGetClonesError::Status403(github_response.to_json()?).into()), + code => Err(ReposGetClonesError::Generic { code }.into()), } } } @@ -13671,19 +14736,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_code_frequency_stats](https://docs.github.com/rest/metrics/statistics#get-the-weekly-commit-activity) /// /// --- - pub async fn get_code_frequency_stats_async(&self, owner: &str, repo: &str) -> Result, ReposGetCodeFrequencyStatsError> { + pub async fn get_code_frequency_stats_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/stats/code_frequency", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13695,10 +14760,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 202 => Err(ReposGetCodeFrequencyStatsError::Status202(github_response.to_json_async().await?)), - 204 => Err(ReposGetCodeFrequencyStatsError::Status204), - 422 => Err(ReposGetCodeFrequencyStatsError::Status422), - code => Err(ReposGetCodeFrequencyStatsError::Generic { code }), + 202 => Err(ReposGetCodeFrequencyStatsError::Status202(github_response.to_json_async().await?).into()), + 204 => Err(ReposGetCodeFrequencyStatsError::Status204.into()), + 422 => Err(ReposGetCodeFrequencyStatsError::Status422.into()), + code => Err(ReposGetCodeFrequencyStatsError::Generic { code }.into()), } } } @@ -13716,7 +14781,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_code_frequency_stats(&self, owner: &str, repo: &str) -> Result, ReposGetCodeFrequencyStatsError> { + pub fn get_code_frequency_stats(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/stats/code_frequency", super::GITHUB_BASE_API_URL, owner, repo); @@ -13728,7 +14793,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13740,10 +14805,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 202 => Err(ReposGetCodeFrequencyStatsError::Status202(github_response.to_json()?)), - 204 => Err(ReposGetCodeFrequencyStatsError::Status204), - 422 => Err(ReposGetCodeFrequencyStatsError::Status422), - code => Err(ReposGetCodeFrequencyStatsError::Generic { code }), + 202 => Err(ReposGetCodeFrequencyStatsError::Status202(github_response.to_json()?).into()), + 204 => Err(ReposGetCodeFrequencyStatsError::Status204.into()), + 422 => Err(ReposGetCodeFrequencyStatsError::Status422.into()), + code => Err(ReposGetCodeFrequencyStatsError::Generic { code }.into()), } } } @@ -13763,19 +14828,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_collaborator_permission_level](https://docs.github.com/rest/collaborators/collaborators#get-repository-permissions-for-a-user) /// /// --- - pub async fn get_collaborator_permission_level_async(&self, owner: &str, repo: &str, username: &str) -> Result { + pub async fn get_collaborator_permission_level_async(&self, owner: &str, repo: &str, username: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/collaborators/{}/permission", super::GITHUB_BASE_API_URL, owner, repo, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13787,8 +14852,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetCollaboratorPermissionLevelError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetCollaboratorPermissionLevelError::Generic { code }), + 404 => Err(ReposGetCollaboratorPermissionLevelError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetCollaboratorPermissionLevelError::Generic { code }.into()), } } } @@ -13809,7 +14874,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_collaborator_permission_level(&self, owner: &str, repo: &str, username: &str) -> Result { + pub fn get_collaborator_permission_level(&self, owner: &str, repo: &str, username: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/collaborators/{}/permission", super::GITHUB_BASE_API_URL, owner, repo, username); @@ -13821,7 +14886,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13833,8 +14898,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetCollaboratorPermissionLevelError::Status404(github_response.to_json()?)), - code => Err(ReposGetCollaboratorPermissionLevelError::Generic { code }), + 404 => Err(ReposGetCollaboratorPermissionLevelError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetCollaboratorPermissionLevelError::Generic { code }.into()), } } } @@ -13855,7 +14920,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_combined_status_for_ref](https://docs.github.com/rest/commits/statuses#get-the-combined-status-for-a-specific-reference) /// /// --- - pub async fn get_combined_status_for_ref_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result { + pub async fn get_combined_status_for_ref_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/status", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -13866,12 +14931,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13883,8 +14948,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetCombinedStatusForRefError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetCombinedStatusForRefError::Generic { code }), + 404 => Err(ReposGetCombinedStatusForRefError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetCombinedStatusForRefError::Generic { code }.into()), } } } @@ -13906,7 +14971,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_combined_status_for_ref(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result { + pub fn get_combined_status_for_ref(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/status", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -13923,7 +14988,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -13935,8 +15000,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetCombinedStatusForRefError::Status404(github_response.to_json()?)), - code => Err(ReposGetCombinedStatusForRefError::Generic { code }), + 404 => Err(ReposGetCombinedStatusForRefError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetCombinedStatusForRefError::Generic { code }.into()), } } } @@ -13988,7 +15053,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_commit](https://docs.github.com/rest/commits/commits#get-a-commit) /// /// --- - pub async fn get_commit_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result { + pub async fn get_commit_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/commits/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -13999,12 +15064,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14016,12 +15081,12 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposGetCommitError::Status422(github_response.to_json_async().await?)), - 404 => Err(ReposGetCommitError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposGetCommitError::Status500(github_response.to_json_async().await?)), - 503 => Err(ReposGetCommitError::Status503(github_response.to_json_async().await?)), - 409 => Err(ReposGetCommitError::Status409(github_response.to_json_async().await?)), - code => Err(ReposGetCommitError::Generic { code }), + 422 => Err(ReposGetCommitError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(ReposGetCommitError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposGetCommitError::Status500(github_response.to_json_async().await?).into()), + 503 => Err(ReposGetCommitError::Status503(github_response.to_json_async().await?).into()), + 409 => Err(ReposGetCommitError::Status409(github_response.to_json_async().await?).into()), + code => Err(ReposGetCommitError::Generic { code }.into()), } } } @@ -14074,7 +15139,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_commit(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result { + pub fn get_commit(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/commits/{}", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -14091,7 +15156,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14103,12 +15168,12 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposGetCommitError::Status422(github_response.to_json()?)), - 404 => Err(ReposGetCommitError::Status404(github_response.to_json()?)), - 500 => Err(ReposGetCommitError::Status500(github_response.to_json()?)), - 503 => Err(ReposGetCommitError::Status503(github_response.to_json()?)), - 409 => Err(ReposGetCommitError::Status409(github_response.to_json()?)), - code => Err(ReposGetCommitError::Generic { code }), + 422 => Err(ReposGetCommitError::Status422(github_response.to_json()?).into()), + 404 => Err(ReposGetCommitError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposGetCommitError::Status500(github_response.to_json()?).into()), + 503 => Err(ReposGetCommitError::Status503(github_response.to_json()?).into()), + 409 => Err(ReposGetCommitError::Status409(github_response.to_json()?).into()), + code => Err(ReposGetCommitError::Generic { code }.into()), } } } @@ -14122,19 +15187,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_commit_activity_stats](https://docs.github.com/rest/metrics/statistics#get-the-last-year-of-commit-activity) /// /// --- - pub async fn get_commit_activity_stats_async(&self, owner: &str, repo: &str) -> Result, ReposGetCommitActivityStatsError> { + pub async fn get_commit_activity_stats_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/stats/commit_activity", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14146,9 +15211,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 202 => Err(ReposGetCommitActivityStatsError::Status202(github_response.to_json_async().await?)), - 204 => Err(ReposGetCommitActivityStatsError::Status204), - code => Err(ReposGetCommitActivityStatsError::Generic { code }), + 202 => Err(ReposGetCommitActivityStatsError::Status202(github_response.to_json_async().await?).into()), + 204 => Err(ReposGetCommitActivityStatsError::Status204.into()), + code => Err(ReposGetCommitActivityStatsError::Generic { code }.into()), } } } @@ -14163,7 +15228,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_commit_activity_stats(&self, owner: &str, repo: &str) -> Result, ReposGetCommitActivityStatsError> { + pub fn get_commit_activity_stats(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/stats/commit_activity", super::GITHUB_BASE_API_URL, owner, repo); @@ -14175,7 +15240,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14187,9 +15252,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 202 => Err(ReposGetCommitActivityStatsError::Status202(github_response.to_json()?)), - 204 => Err(ReposGetCommitActivityStatsError::Status204), - code => Err(ReposGetCommitActivityStatsError::Generic { code }), + 202 => Err(ReposGetCommitActivityStatsError::Status202(github_response.to_json()?).into()), + 204 => Err(ReposGetCommitActivityStatsError::Status204.into()), + code => Err(ReposGetCommitActivityStatsError::Generic { code }.into()), } } } @@ -14210,19 +15275,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_commit_comment](https://docs.github.com/rest/commits/comments#get-a-commit-comment) /// /// --- - pub async fn get_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result { + pub async fn get_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64) -> Result { let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14234,8 +15299,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetCommitCommentError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetCommitCommentError::Generic { code }), + 404 => Err(ReposGetCommitCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetCommitCommentError::Generic { code }.into()), } } } @@ -14257,7 +15322,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_commit_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result { + pub fn get_commit_comment(&self, owner: &str, repo: &str, comment_id: i64) -> Result { let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); @@ -14269,7 +15334,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14281,8 +15346,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetCommitCommentError::Status404(github_response.to_json()?)), - code => Err(ReposGetCommitCommentError::Generic { code }), + 404 => Err(ReposGetCommitCommentError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetCommitCommentError::Generic { code }.into()), } } } @@ -14301,19 +15366,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_commit_signature_protection](https://docs.github.com/rest/branches/branch-protection#get-commit-signature-protection) /// /// --- - pub async fn get_commit_signature_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub async fn get_commit_signature_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14325,8 +15390,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetCommitSignatureProtectionError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetCommitSignatureProtectionError::Generic { code }), + 404 => Err(ReposGetCommitSignatureProtectionError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetCommitSignatureProtectionError::Generic { code }.into()), } } } @@ -14346,7 +15411,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_commit_signature_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub fn get_commit_signature_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_signatures", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -14358,7 +15423,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14370,8 +15435,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetCommitSignatureProtectionError::Status404(github_response.to_json()?)), - code => Err(ReposGetCommitSignatureProtectionError::Generic { code }), + 404 => Err(ReposGetCommitSignatureProtectionError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetCommitSignatureProtectionError::Generic { code }.into()), } } } @@ -14395,19 +15460,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_community_profile_metrics](https://docs.github.com/rest/metrics/community#get-community-profile-metrics) /// /// --- - pub async fn get_community_profile_metrics_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_community_profile_metrics_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/community/profile", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14419,7 +15484,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetCommunityProfileMetricsError::Generic { code }), + code => Err(ReposGetCommunityProfileMetricsError::Generic { code }.into()), } } } @@ -14444,7 +15509,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_community_profile_metrics(&self, owner: &str, repo: &str) -> Result { + pub fn get_community_profile_metrics(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/community/profile", super::GITHUB_BASE_API_URL, owner, repo); @@ -14456,7 +15521,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14468,7 +15533,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetCommunityProfileMetricsError::Generic { code }), + code => Err(ReposGetCommunityProfileMetricsError::Generic { code }.into()), } } } @@ -14506,7 +15571,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_content](https://docs.github.com/rest/repos/contents#get-repository-content) /// /// --- - pub async fn get_content_async(&self, owner: &str, repo: &str, path: &str, query_params: Option>>) -> Result { + pub async fn get_content_async(&self, owner: &str, repo: &str, path: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path); @@ -14517,12 +15582,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14534,11 +15599,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetContentError::Status404(github_response.to_json_async().await?)), - 403 => Err(ReposGetContentError::Status403(github_response.to_json_async().await?)), - 302 => Err(ReposGetContentError::Status302), - 304 => Err(ReposGetContentError::Status304), - code => Err(ReposGetContentError::Generic { code }), + 404 => Err(ReposGetContentError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(ReposGetContentError::Status403(github_response.to_json_async().await?).into()), + 302 => Err(ReposGetContentError::Status302.into()), + 304 => Err(ReposGetContentError::Status304.into()), + code => Err(ReposGetContentError::Generic { code }.into()), } } } @@ -14577,7 +15642,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_content(&self, owner: &str, repo: &str, path: &str, query_params: Option>>) -> Result { + pub fn get_content(&self, owner: &str, repo: &str, path: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/contents/{}", super::GITHUB_BASE_API_URL, owner, repo, path); @@ -14594,7 +15659,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14606,11 +15671,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetContentError::Status404(github_response.to_json()?)), - 403 => Err(ReposGetContentError::Status403(github_response.to_json()?)), - 302 => Err(ReposGetContentError::Status302), - 304 => Err(ReposGetContentError::Status304), - code => Err(ReposGetContentError::Generic { code }), + 404 => Err(ReposGetContentError::Status404(github_response.to_json()?).into()), + 403 => Err(ReposGetContentError::Status403(github_response.to_json()?).into()), + 302 => Err(ReposGetContentError::Status302.into()), + 304 => Err(ReposGetContentError::Status304.into()), + code => Err(ReposGetContentError::Generic { code }.into()), } } } @@ -14633,19 +15698,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_contributors_stats](https://docs.github.com/rest/metrics/statistics#get-all-contributor-commit-activity) /// /// --- - pub async fn get_contributors_stats_async(&self, owner: &str, repo: &str) -> Result, ReposGetContributorsStatsError> { + pub async fn get_contributors_stats_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/stats/contributors", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14657,9 +15722,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 202 => Err(ReposGetContributorsStatsError::Status202(github_response.to_json_async().await?)), - 204 => Err(ReposGetContributorsStatsError::Status204), - code => Err(ReposGetContributorsStatsError::Generic { code }), + 202 => Err(ReposGetContributorsStatsError::Status202(github_response.to_json_async().await?).into()), + 204 => Err(ReposGetContributorsStatsError::Status204.into()), + code => Err(ReposGetContributorsStatsError::Generic { code }.into()), } } } @@ -14683,7 +15748,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_contributors_stats(&self, owner: &str, repo: &str) -> Result, ReposGetContributorsStatsError> { + pub fn get_contributors_stats(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/stats/contributors", super::GITHUB_BASE_API_URL, owner, repo); @@ -14695,7 +15760,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14707,9 +15772,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 202 => Err(ReposGetContributorsStatsError::Status202(github_response.to_json()?)), - 204 => Err(ReposGetContributorsStatsError::Status204), - code => Err(ReposGetContributorsStatsError::Generic { code }), + 202 => Err(ReposGetContributorsStatsError::Status202(github_response.to_json()?).into()), + 204 => Err(ReposGetContributorsStatsError::Status204.into()), + code => Err(ReposGetContributorsStatsError::Generic { code }.into()), } } } @@ -14727,19 +15792,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_custom_deployment_protection_rule](https://docs.github.com/rest/deployments/protection-rules#get-a-custom-deployment-protection-rule) /// /// --- - pub async fn get_custom_deployment_protection_rule_async(&self, owner: &str, repo: &str, environment_name: &str, protection_rule_id: i32) -> Result { + pub async fn get_custom_deployment_protection_rule_async(&self, owner: &str, repo: &str, environment_name: &str, protection_rule_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, protection_rule_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14751,7 +15816,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetCustomDeploymentProtectionRuleError::Generic { code }), + code => Err(ReposGetCustomDeploymentProtectionRuleError::Generic { code }.into()), } } } @@ -14770,7 +15835,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_custom_deployment_protection_rule(&self, owner: &str, repo: &str, environment_name: &str, protection_rule_id: i32) -> Result { + pub fn get_custom_deployment_protection_rule(&self, owner: &str, repo: &str, environment_name: &str, protection_rule_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, protection_rule_id); @@ -14782,7 +15847,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14794,7 +15859,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetCustomDeploymentProtectionRuleError::Generic { code }), + code => Err(ReposGetCustomDeploymentProtectionRuleError::Generic { code }.into()), } } } @@ -14809,19 +15874,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_custom_properties_values](https://docs.github.com/rest/repos/custom-properties#get-all-custom-property-values-for-a-repository) /// /// --- - pub async fn get_custom_properties_values_async(&self, owner: &str, repo: &str) -> Result, ReposGetCustomPropertiesValuesError> { + pub async fn get_custom_properties_values_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/properties/values", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14833,9 +15898,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposGetCustomPropertiesValuesError::Status403(github_response.to_json_async().await?)), - 404 => Err(ReposGetCustomPropertiesValuesError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetCustomPropertiesValuesError::Generic { code }), + 403 => Err(ReposGetCustomPropertiesValuesError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ReposGetCustomPropertiesValuesError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetCustomPropertiesValuesError::Generic { code }.into()), } } } @@ -14851,7 +15916,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_custom_properties_values(&self, owner: &str, repo: &str) -> Result, ReposGetCustomPropertiesValuesError> { + pub fn get_custom_properties_values(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/properties/values", super::GITHUB_BASE_API_URL, owner, repo); @@ -14863,7 +15928,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14875,9 +15940,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposGetCustomPropertiesValuesError::Status403(github_response.to_json()?)), - 404 => Err(ReposGetCustomPropertiesValuesError::Status404(github_response.to_json()?)), - code => Err(ReposGetCustomPropertiesValuesError::Generic { code }), + 403 => Err(ReposGetCustomPropertiesValuesError::Status403(github_response.to_json()?).into()), + 404 => Err(ReposGetCustomPropertiesValuesError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetCustomPropertiesValuesError::Generic { code }.into()), } } } @@ -14889,19 +15954,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_deploy_key](https://docs.github.com/rest/deploy-keys/deploy-keys#get-a-deploy-key) /// /// --- - pub async fn get_deploy_key_async(&self, owner: &str, repo: &str, key_id: i32) -> Result { + pub async fn get_deploy_key_async(&self, owner: &str, repo: &str, key_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/keys/{}", super::GITHUB_BASE_API_URL, owner, repo, key_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14913,8 +15978,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetDeployKeyError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetDeployKeyError::Generic { code }), + 404 => Err(ReposGetDeployKeyError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetDeployKeyError::Generic { code }.into()), } } } @@ -14927,7 +15992,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_deploy_key(&self, owner: &str, repo: &str, key_id: i32) -> Result { + pub fn get_deploy_key(&self, owner: &str, repo: &str, key_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/keys/{}", super::GITHUB_BASE_API_URL, owner, repo, key_id); @@ -14939,7 +16004,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14951,8 +16016,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetDeployKeyError::Status404(github_response.to_json()?)), - code => Err(ReposGetDeployKeyError::Generic { code }), + 404 => Err(ReposGetDeployKeyError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetDeployKeyError::Generic { code }.into()), } } } @@ -14964,19 +16029,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_deployment](https://docs.github.com/rest/deployments/deployments#get-a-deployment) /// /// --- - pub async fn get_deployment_async(&self, owner: &str, repo: &str, deployment_id: i32) -> Result { + pub async fn get_deployment_async(&self, owner: &str, repo: &str, deployment_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -14988,8 +16053,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetDeploymentError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetDeploymentError::Generic { code }), + 404 => Err(ReposGetDeploymentError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetDeploymentError::Generic { code }.into()), } } } @@ -15002,7 +16067,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_deployment(&self, owner: &str, repo: &str, deployment_id: i32) -> Result { + pub fn get_deployment(&self, owner: &str, repo: &str, deployment_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_id); @@ -15014,7 +16079,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15026,8 +16091,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetDeploymentError::Status404(github_response.to_json()?)), - code => Err(ReposGetDeploymentError::Generic { code }), + 404 => Err(ReposGetDeploymentError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetDeploymentError::Generic { code }.into()), } } } @@ -15045,19 +16110,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#get-a-deployment-branch-policy) /// /// --- - pub async fn get_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result { + pub async fn get_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15069,7 +16134,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetDeploymentBranchPolicyError::Generic { code }), + code => Err(ReposGetDeploymentBranchPolicyError::Generic { code }.into()), } } } @@ -15088,7 +16153,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result { + pub fn get_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_id); @@ -15100,7 +16165,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15112,7 +16177,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetDeploymentBranchPolicyError::Generic { code }), + code => Err(ReposGetDeploymentBranchPolicyError::Generic { code }.into()), } } } @@ -15126,19 +16191,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_deployment_status](https://docs.github.com/rest/deployments/statuses#get-a-deployment-status) /// /// --- - pub async fn get_deployment_status_async(&self, owner: &str, repo: &str, deployment_id: i32, status_id: i32) -> Result { + pub async fn get_deployment_status_async(&self, owner: &str, repo: &str, deployment_id: i32, status_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_id, status_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15150,8 +16215,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetDeploymentStatusError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetDeploymentStatusError::Generic { code }), + 404 => Err(ReposGetDeploymentStatusError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetDeploymentStatusError::Generic { code }.into()), } } } @@ -15166,7 +16231,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_deployment_status(&self, owner: &str, repo: &str, deployment_id: i32, status_id: i32) -> Result { + pub fn get_deployment_status(&self, owner: &str, repo: &str, deployment_id: i32, status_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses/{}", super::GITHUB_BASE_API_URL, owner, repo, deployment_id, status_id); @@ -15178,7 +16243,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15190,8 +16255,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetDeploymentStatusError::Status404(github_response.to_json()?)), - code => Err(ReposGetDeploymentStatusError::Generic { code }), + 404 => Err(ReposGetDeploymentStatusError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetDeploymentStatusError::Generic { code }.into()), } } } @@ -15210,19 +16275,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_environment](https://docs.github.com/rest/deployments/environments#get-an-environment) /// /// --- - pub async fn get_environment_async(&self, owner: &str, repo: &str, environment_name: &str) -> Result { + pub async fn get_environment_async(&self, owner: &str, repo: &str, environment_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15234,7 +16299,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetEnvironmentError::Generic { code }), + code => Err(ReposGetEnvironmentError::Generic { code }.into()), } } } @@ -15254,7 +16319,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_environment(&self, owner: &str, repo: &str, environment_name: &str) -> Result { + pub fn get_environment(&self, owner: &str, repo: &str, environment_name: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name); @@ -15266,7 +16331,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15278,7 +16343,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetEnvironmentError::Generic { code }), + code => Err(ReposGetEnvironmentError::Generic { code }.into()), } } } @@ -15294,19 +16359,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_latest_pages_build](https://docs.github.com/rest/pages/pages#get-latest-pages-build) /// /// --- - pub async fn get_latest_pages_build_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_latest_pages_build_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/builds/latest", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15318,7 +16383,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetLatestPagesBuildError::Generic { code }), + code => Err(ReposGetLatestPagesBuildError::Generic { code }.into()), } } } @@ -15335,7 +16400,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_latest_pages_build(&self, owner: &str, repo: &str) -> Result { + pub fn get_latest_pages_build(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/builds/latest", super::GITHUB_BASE_API_URL, owner, repo); @@ -15347,7 +16412,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15359,7 +16424,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetLatestPagesBuildError::Generic { code }), + code => Err(ReposGetLatestPagesBuildError::Generic { code }.into()), } } } @@ -15375,19 +16440,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_latest_release](https://docs.github.com/rest/releases/releases#get-the-latest-release) /// /// --- - pub async fn get_latest_release_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_latest_release_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/latest", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15399,7 +16464,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetLatestReleaseError::Generic { code }), + code => Err(ReposGetLatestReleaseError::Generic { code }.into()), } } } @@ -15416,7 +16481,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_latest_release(&self, owner: &str, repo: &str) -> Result { + pub fn get_latest_release(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/latest", super::GITHUB_BASE_API_URL, owner, repo); @@ -15428,7 +16493,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15440,7 +16505,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetLatestReleaseError::Generic { code }), + code => Err(ReposGetLatestReleaseError::Generic { code }.into()), } } } @@ -15455,19 +16520,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_org_rule_suite](https://docs.github.com/rest/orgs/rule-suites#get-an-organization-rule-suite) /// /// --- - pub async fn get_org_rule_suite_async(&self, org: &str, rule_suite_id: i32) -> Result { + pub async fn get_org_rule_suite_async(&self, org: &str, rule_suite_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/rulesets/rule-suites/{}", super::GITHUB_BASE_API_URL, org, rule_suite_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15479,9 +16544,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetOrgRuleSuiteError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposGetOrgRuleSuiteError::Status500(github_response.to_json_async().await?)), - code => Err(ReposGetOrgRuleSuiteError::Generic { code }), + 404 => Err(ReposGetOrgRuleSuiteError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposGetOrgRuleSuiteError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposGetOrgRuleSuiteError::Generic { code }.into()), } } } @@ -15497,7 +16562,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_rule_suite(&self, org: &str, rule_suite_id: i32) -> Result { + pub fn get_org_rule_suite(&self, org: &str, rule_suite_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/rulesets/rule-suites/{}", super::GITHUB_BASE_API_URL, org, rule_suite_id); @@ -15509,7 +16574,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15521,9 +16586,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetOrgRuleSuiteError::Status404(github_response.to_json()?)), - 500 => Err(ReposGetOrgRuleSuiteError::Status500(github_response.to_json()?)), - code => Err(ReposGetOrgRuleSuiteError::Generic { code }), + 404 => Err(ReposGetOrgRuleSuiteError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposGetOrgRuleSuiteError::Status500(github_response.to_json()?).into()), + code => Err(ReposGetOrgRuleSuiteError::Generic { code }.into()), } } } @@ -15538,7 +16603,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_org_rule_suites](https://docs.github.com/rest/orgs/rule-suites#list-organization-rule-suites) /// /// --- - pub async fn get_org_rule_suites_async(&self, org: &str, query_params: Option>>) -> Result { + pub async fn get_org_rule_suites_async(&self, org: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/orgs/{}/rulesets/rule-suites", super::GITHUB_BASE_API_URL, org); @@ -15549,12 +16614,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15566,9 +16631,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetOrgRuleSuitesError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposGetOrgRuleSuitesError::Status500(github_response.to_json_async().await?)), - code => Err(ReposGetOrgRuleSuitesError::Generic { code }), + 404 => Err(ReposGetOrgRuleSuitesError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposGetOrgRuleSuitesError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposGetOrgRuleSuitesError::Generic { code }.into()), } } } @@ -15584,7 +16649,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_rule_suites(&self, org: &str, query_params: Option>>) -> Result { + pub fn get_org_rule_suites(&self, org: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/orgs/{}/rulesets/rule-suites", super::GITHUB_BASE_API_URL, org); @@ -15601,7 +16666,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15613,9 +16678,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetOrgRuleSuitesError::Status404(github_response.to_json()?)), - 500 => Err(ReposGetOrgRuleSuitesError::Status500(github_response.to_json()?)), - code => Err(ReposGetOrgRuleSuitesError::Generic { code }), + 404 => Err(ReposGetOrgRuleSuitesError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposGetOrgRuleSuitesError::Status500(github_response.to_json()?).into()), + code => Err(ReposGetOrgRuleSuitesError::Generic { code }.into()), } } } @@ -15632,19 +16697,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_org_ruleset](https://docs.github.com/rest/orgs/rules#get-an-organization-repository-ruleset) /// /// --- - pub async fn get_org_ruleset_async(&self, org: &str, ruleset_id: i32) -> Result { + pub async fn get_org_ruleset_async(&self, org: &str, ruleset_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15656,9 +16721,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetOrgRulesetError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposGetOrgRulesetError::Status500(github_response.to_json_async().await?)), - code => Err(ReposGetOrgRulesetError::Generic { code }), + 404 => Err(ReposGetOrgRulesetError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposGetOrgRulesetError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposGetOrgRulesetError::Generic { code }.into()), } } } @@ -15676,7 +16741,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_ruleset(&self, org: &str, ruleset_id: i32) -> Result { + pub fn get_org_ruleset(&self, org: &str, ruleset_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_id); @@ -15688,7 +16753,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15700,9 +16765,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetOrgRulesetError::Status404(github_response.to_json()?)), - 500 => Err(ReposGetOrgRulesetError::Status500(github_response.to_json()?)), - code => Err(ReposGetOrgRulesetError::Generic { code }), + 404 => Err(ReposGetOrgRulesetError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposGetOrgRulesetError::Status500(github_response.to_json()?).into()), + code => Err(ReposGetOrgRulesetError::Generic { code }.into()), } } } @@ -15716,7 +16781,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_org_rulesets](https://docs.github.com/rest/orgs/rules#get-all-organization-repository-rulesets) /// /// --- - pub async fn get_org_rulesets_async(&self, org: &str, query_params: Option>>) -> Result, ReposGetOrgRulesetsError> { + pub async fn get_org_rulesets_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/rulesets", super::GITHUB_BASE_API_URL, org); @@ -15727,12 +16792,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15744,9 +16809,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetOrgRulesetsError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposGetOrgRulesetsError::Status500(github_response.to_json_async().await?)), - code => Err(ReposGetOrgRulesetsError::Generic { code }), + 404 => Err(ReposGetOrgRulesetsError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposGetOrgRulesetsError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposGetOrgRulesetsError::Generic { code }.into()), } } } @@ -15761,7 +16826,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_org_rulesets(&self, org: &str, query_params: Option>>) -> Result, ReposGetOrgRulesetsError> { + pub fn get_org_rulesets(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/rulesets", super::GITHUB_BASE_API_URL, org); @@ -15778,7 +16843,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15790,9 +16855,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetOrgRulesetsError::Status404(github_response.to_json()?)), - 500 => Err(ReposGetOrgRulesetsError::Status500(github_response.to_json()?)), - code => Err(ReposGetOrgRulesetsError::Generic { code }), + 404 => Err(ReposGetOrgRulesetsError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposGetOrgRulesetsError::Status500(github_response.to_json()?).into()), + code => Err(ReposGetOrgRulesetsError::Generic { code }.into()), } } } @@ -15808,19 +16873,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_pages](https://docs.github.com/rest/pages/pages#get-a-apiname-pages-site) /// /// --- - pub async fn get_pages_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_pages_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15832,8 +16897,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetPagesError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetPagesError::Generic { code }), + 404 => Err(ReposGetPagesError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetPagesError::Generic { code }.into()), } } } @@ -15850,7 +16915,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_pages(&self, owner: &str, repo: &str) -> Result { + pub fn get_pages(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo); @@ -15862,7 +16927,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15874,8 +16939,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetPagesError::Status404(github_response.to_json()?)), - code => Err(ReposGetPagesError::Generic { code }), + 404 => Err(ReposGetPagesError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetPagesError::Generic { code }.into()), } } } @@ -15891,19 +16956,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_pages_build](https://docs.github.com/rest/pages/pages#get-apiname-pages-build) /// /// --- - pub async fn get_pages_build_async(&self, owner: &str, repo: &str, build_id: i32) -> Result { + pub async fn get_pages_build_async(&self, owner: &str, repo: &str, build_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/builds/{}", super::GITHUB_BASE_API_URL, owner, repo, build_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15915,7 +16980,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetPagesBuildError::Generic { code }), + code => Err(ReposGetPagesBuildError::Generic { code }.into()), } } } @@ -15932,7 +16997,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_pages_build(&self, owner: &str, repo: &str, build_id: i32) -> Result { + pub fn get_pages_build(&self, owner: &str, repo: &str, build_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/builds/{}", super::GITHUB_BASE_API_URL, owner, repo, build_id); @@ -15944,7 +17009,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15956,7 +17021,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetPagesBuildError::Generic { code }), + code => Err(ReposGetPagesBuildError::Generic { code }.into()), } } } @@ -15972,19 +17037,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_pages_deployment](https://docs.github.com/rest/pages/pages#get-the-status-of-a-github-pages-deployment) /// /// --- - pub async fn get_pages_deployment_async(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result { + pub async fn get_pages_deployment_async(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, pages_deployment_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -15996,8 +17061,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetPagesDeploymentError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetPagesDeploymentError::Generic { code }), + 404 => Err(ReposGetPagesDeploymentError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetPagesDeploymentError::Generic { code }.into()), } } } @@ -16014,7 +17079,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_pages_deployment(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result { + pub fn get_pages_deployment(&self, owner: &str, repo: &str, pages_deployment_id: PagesDeploymentId) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/deployments/{}", super::GITHUB_BASE_API_URL, owner, repo, pages_deployment_id); @@ -16026,7 +17091,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16038,8 +17103,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetPagesDeploymentError::Status404(github_response.to_json()?)), - code => Err(ReposGetPagesDeploymentError::Generic { code }), + 404 => Err(ReposGetPagesDeploymentError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetPagesDeploymentError::Generic { code }.into()), } } } @@ -16059,19 +17124,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_pages_health_check](https://docs.github.com/rest/pages/pages#get-a-dns-health-check-for-github-pages) /// /// --- - pub async fn get_pages_health_check_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_pages_health_check_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/health", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16083,11 +17148,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 202 => Err(ReposGetPagesHealthCheckError::Status202(github_response.to_json_async().await?)), - 400 => Err(ReposGetPagesHealthCheckError::Status400), - 422 => Err(ReposGetPagesHealthCheckError::Status422), - 404 => Err(ReposGetPagesHealthCheckError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetPagesHealthCheckError::Generic { code }), + 202 => Err(ReposGetPagesHealthCheckError::Status202(github_response.to_json_async().await?).into()), + 400 => Err(ReposGetPagesHealthCheckError::Status400.into()), + 422 => Err(ReposGetPagesHealthCheckError::Status422.into()), + 404 => Err(ReposGetPagesHealthCheckError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetPagesHealthCheckError::Generic { code }.into()), } } } @@ -16108,7 +17173,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_pages_health_check(&self, owner: &str, repo: &str) -> Result { + pub fn get_pages_health_check(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/health", super::GITHUB_BASE_API_URL, owner, repo); @@ -16120,7 +17185,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16132,11 +17197,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 202 => Err(ReposGetPagesHealthCheckError::Status202(github_response.to_json()?)), - 400 => Err(ReposGetPagesHealthCheckError::Status400), - 422 => Err(ReposGetPagesHealthCheckError::Status422), - 404 => Err(ReposGetPagesHealthCheckError::Status404(github_response.to_json()?)), - code => Err(ReposGetPagesHealthCheckError::Generic { code }), + 202 => Err(ReposGetPagesHealthCheckError::Status202(github_response.to_json()?).into()), + 400 => Err(ReposGetPagesHealthCheckError::Status400.into()), + 422 => Err(ReposGetPagesHealthCheckError::Status422.into()), + 404 => Err(ReposGetPagesHealthCheckError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetPagesHealthCheckError::Generic { code }.into()), } } } @@ -16154,19 +17219,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_participation_stats](https://docs.github.com/rest/metrics/statistics#get-the-weekly-commit-count) /// /// --- - pub async fn get_participation_stats_async(&self, owner: &str, repo: &str) -> Result { + pub async fn get_participation_stats_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/stats/participation", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16178,8 +17243,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetParticipationStatsError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetParticipationStatsError::Generic { code }), + 404 => Err(ReposGetParticipationStatsError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetParticipationStatsError::Generic { code }.into()), } } } @@ -16198,7 +17263,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_participation_stats(&self, owner: &str, repo: &str) -> Result { + pub fn get_participation_stats(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/stats/participation", super::GITHUB_BASE_API_URL, owner, repo); @@ -16210,7 +17275,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16222,8 +17287,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetParticipationStatsError::Status404(github_response.to_json()?)), - code => Err(ReposGetParticipationStatsError::Generic { code }), + 404 => Err(ReposGetParticipationStatsError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetParticipationStatsError::Generic { code }.into()), } } } @@ -16237,19 +17302,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_pull_request_review_protection](https://docs.github.com/rest/branches/branch-protection#get-pull-request-review-protection) /// /// --- - pub async fn get_pull_request_review_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub async fn get_pull_request_review_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16261,7 +17326,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetPullRequestReviewProtectionError::Generic { code }), + code => Err(ReposGetPullRequestReviewProtectionError::Generic { code }.into()), } } } @@ -16276,7 +17341,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_pull_request_review_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub fn get_pull_request_review_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -16288,7 +17353,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16300,7 +17365,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetPullRequestReviewProtectionError::Generic { code }), + code => Err(ReposGetPullRequestReviewProtectionError::Generic { code }.into()), } } } @@ -16320,19 +17385,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_punch_card_stats](https://docs.github.com/rest/metrics/statistics#get-the-hourly-commit-count-for-each-day) /// /// --- - pub async fn get_punch_card_stats_async(&self, owner: &str, repo: &str) -> Result, ReposGetPunchCardStatsError> { + pub async fn get_punch_card_stats_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/stats/punch_card", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16344,8 +17409,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(ReposGetPunchCardStatsError::Status204), - code => Err(ReposGetPunchCardStatsError::Generic { code }), + 204 => Err(ReposGetPunchCardStatsError::Status204.into()), + code => Err(ReposGetPunchCardStatsError::Generic { code }.into()), } } } @@ -16366,7 +17431,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_punch_card_stats(&self, owner: &str, repo: &str) -> Result, ReposGetPunchCardStatsError> { + pub fn get_punch_card_stats(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/stats/punch_card", super::GITHUB_BASE_API_URL, owner, repo); @@ -16378,7 +17443,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16390,8 +17455,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(ReposGetPunchCardStatsError::Status204), - code => Err(ReposGetPunchCardStatsError::Generic { code }), + 204 => Err(ReposGetPunchCardStatsError::Status204.into()), + code => Err(ReposGetPunchCardStatsError::Generic { code }.into()), } } } @@ -16410,7 +17475,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_readme](https://docs.github.com/rest/repos/contents#get-a-repository-readme) /// /// --- - pub async fn get_readme_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub async fn get_readme_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/readme", super::GITHUB_BASE_API_URL, owner, repo); @@ -16421,12 +17486,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16438,10 +17503,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ReposGetReadmeError::Status304), - 404 => Err(ReposGetReadmeError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposGetReadmeError::Status422(github_response.to_json_async().await?)), - code => Err(ReposGetReadmeError::Generic { code }), + 304 => Err(ReposGetReadmeError::Status304.into()), + 404 => Err(ReposGetReadmeError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposGetReadmeError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposGetReadmeError::Generic { code }.into()), } } } @@ -16461,7 +17526,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_readme(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub fn get_readme(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/readme", super::GITHUB_BASE_API_URL, owner, repo); @@ -16478,7 +17543,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16490,10 +17555,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ReposGetReadmeError::Status304), - 404 => Err(ReposGetReadmeError::Status404(github_response.to_json()?)), - 422 => Err(ReposGetReadmeError::Status422(github_response.to_json()?)), - code => Err(ReposGetReadmeError::Generic { code }), + 304 => Err(ReposGetReadmeError::Status304.into()), + 404 => Err(ReposGetReadmeError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposGetReadmeError::Status422(github_response.to_json()?).into()), + code => Err(ReposGetReadmeError::Generic { code }.into()), } } } @@ -16512,7 +17577,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_readme_in_directory](https://docs.github.com/rest/repos/contents#get-a-repository-readme-for-a-directory) /// /// --- - pub async fn get_readme_in_directory_async(&self, owner: &str, repo: &str, dir: &str, query_params: Option>>) -> Result { + pub async fn get_readme_in_directory_async(&self, owner: &str, repo: &str, dir: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/readme/{}", super::GITHUB_BASE_API_URL, owner, repo, dir); @@ -16523,12 +17588,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16540,9 +17605,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetReadmeInDirectoryError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposGetReadmeInDirectoryError::Status422(github_response.to_json_async().await?)), - code => Err(ReposGetReadmeInDirectoryError::Generic { code }), + 404 => Err(ReposGetReadmeInDirectoryError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposGetReadmeInDirectoryError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposGetReadmeInDirectoryError::Generic { code }.into()), } } } @@ -16562,7 +17627,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_readme_in_directory(&self, owner: &str, repo: &str, dir: &str, query_params: Option>>) -> Result { + pub fn get_readme_in_directory(&self, owner: &str, repo: &str, dir: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/readme/{}", super::GITHUB_BASE_API_URL, owner, repo, dir); @@ -16579,7 +17644,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16591,9 +17656,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetReadmeInDirectoryError::Status404(github_response.to_json()?)), - 422 => Err(ReposGetReadmeInDirectoryError::Status422(github_response.to_json()?)), - code => Err(ReposGetReadmeInDirectoryError::Generic { code }), + 404 => Err(ReposGetReadmeInDirectoryError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposGetReadmeInDirectoryError::Status422(github_response.to_json()?).into()), + code => Err(ReposGetReadmeInDirectoryError::Generic { code }.into()), } } } @@ -16610,19 +17675,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_release](https://docs.github.com/rest/releases/releases#get-a-release) /// /// --- - pub async fn get_release_async(&self, owner: &str, repo: &str, release_id: i32) -> Result { + pub async fn get_release_async(&self, owner: &str, repo: &str, release_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16634,8 +17699,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 401 => Err(ReposGetReleaseError::Status401), - code => Err(ReposGetReleaseError::Generic { code }), + 401 => Err(ReposGetReleaseError::Status401.into()), + code => Err(ReposGetReleaseError::Generic { code }.into()), } } } @@ -16653,7 +17718,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_release(&self, owner: &str, repo: &str, release_id: i32) -> Result { + pub fn get_release(&self, owner: &str, repo: &str, release_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_id); @@ -16665,7 +17730,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16677,8 +17742,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 401 => Err(ReposGetReleaseError::Status401), - code => Err(ReposGetReleaseError::Generic { code }), + 401 => Err(ReposGetReleaseError::Status401.into()), + code => Err(ReposGetReleaseError::Generic { code }.into()), } } } @@ -16692,19 +17757,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_release_asset](https://docs.github.com/rest/releases/assets#get-a-release-asset) /// /// --- - pub async fn get_release_asset_async(&self, owner: &str, repo: &str, asset_id: i32) -> Result { + pub async fn get_release_asset_async(&self, owner: &str, repo: &str, asset_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16716,9 +17781,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetReleaseAssetError::Status404(github_response.to_json_async().await?)), - 302 => Err(ReposGetReleaseAssetError::Status302), - code => Err(ReposGetReleaseAssetError::Generic { code }), + 404 => Err(ReposGetReleaseAssetError::Status404(github_response.to_json_async().await?).into()), + 302 => Err(ReposGetReleaseAssetError::Status302.into()), + code => Err(ReposGetReleaseAssetError::Generic { code }.into()), } } } @@ -16733,7 +17798,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_release_asset(&self, owner: &str, repo: &str, asset_id: i32) -> Result { + pub fn get_release_asset(&self, owner: &str, repo: &str, asset_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_id); @@ -16745,7 +17810,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16757,9 +17822,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetReleaseAssetError::Status404(github_response.to_json()?)), - 302 => Err(ReposGetReleaseAssetError::Status302), - code => Err(ReposGetReleaseAssetError::Generic { code }), + 404 => Err(ReposGetReleaseAssetError::Status404(github_response.to_json()?).into()), + 302 => Err(ReposGetReleaseAssetError::Status302.into()), + code => Err(ReposGetReleaseAssetError::Generic { code }.into()), } } } @@ -16773,19 +17838,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_release_by_tag](https://docs.github.com/rest/releases/releases#get-a-release-by-tag-name) /// /// --- - pub async fn get_release_by_tag_async(&self, owner: &str, repo: &str, tag: &str) -> Result { + pub async fn get_release_by_tag_async(&self, owner: &str, repo: &str, tag: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/tags/{}", super::GITHUB_BASE_API_URL, owner, repo, tag); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16797,8 +17862,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetReleaseByTagError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetReleaseByTagError::Generic { code }), + 404 => Err(ReposGetReleaseByTagError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetReleaseByTagError::Generic { code }.into()), } } } @@ -16813,7 +17878,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_release_by_tag(&self, owner: &str, repo: &str, tag: &str) -> Result { + pub fn get_release_by_tag(&self, owner: &str, repo: &str, tag: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/tags/{}", super::GITHUB_BASE_API_URL, owner, repo, tag); @@ -16825,7 +17890,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16837,8 +17902,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetReleaseByTagError::Status404(github_response.to_json()?)), - code => Err(ReposGetReleaseByTagError::Generic { code }), + 404 => Err(ReposGetReleaseByTagError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetReleaseByTagError::Generic { code }.into()), } } } @@ -16853,19 +17918,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_repo_rule_suite](https://docs.github.com/rest/repos/rule-suites#get-a-repository-rule-suite) /// /// --- - pub async fn get_repo_rule_suite_async(&self, owner: &str, repo: &str, rule_suite_id: i32) -> Result { + pub async fn get_repo_rule_suite_async(&self, owner: &str, repo: &str, rule_suite_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/rulesets/rule-suites/{}", super::GITHUB_BASE_API_URL, owner, repo, rule_suite_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16877,9 +17942,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetRepoRuleSuiteError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposGetRepoRuleSuiteError::Status500(github_response.to_json_async().await?)), - code => Err(ReposGetRepoRuleSuiteError::Generic { code }), + 404 => Err(ReposGetRepoRuleSuiteError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposGetRepoRuleSuiteError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposGetRepoRuleSuiteError::Generic { code }.into()), } } } @@ -16895,7 +17960,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_rule_suite(&self, owner: &str, repo: &str, rule_suite_id: i32) -> Result { + pub fn get_repo_rule_suite(&self, owner: &str, repo: &str, rule_suite_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/rulesets/rule-suites/{}", super::GITHUB_BASE_API_URL, owner, repo, rule_suite_id); @@ -16907,7 +17972,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16919,9 +17984,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetRepoRuleSuiteError::Status404(github_response.to_json()?)), - 500 => Err(ReposGetRepoRuleSuiteError::Status500(github_response.to_json()?)), - code => Err(ReposGetRepoRuleSuiteError::Generic { code }), + 404 => Err(ReposGetRepoRuleSuiteError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposGetRepoRuleSuiteError::Status500(github_response.to_json()?).into()), + code => Err(ReposGetRepoRuleSuiteError::Generic { code }.into()), } } } @@ -16936,7 +18001,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_repo_rule_suites](https://docs.github.com/rest/repos/rule-suites#list-repository-rule-suites) /// /// --- - pub async fn get_repo_rule_suites_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub async fn get_repo_rule_suites_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/rulesets/rule-suites", super::GITHUB_BASE_API_URL, owner, repo); @@ -16947,12 +18012,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -16964,9 +18029,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetRepoRuleSuitesError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposGetRepoRuleSuitesError::Status500(github_response.to_json_async().await?)), - code => Err(ReposGetRepoRuleSuitesError::Generic { code }), + 404 => Err(ReposGetRepoRuleSuitesError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposGetRepoRuleSuitesError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposGetRepoRuleSuitesError::Generic { code }.into()), } } } @@ -16982,7 +18047,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_rule_suites(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub fn get_repo_rule_suites(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/rulesets/rule-suites", super::GITHUB_BASE_API_URL, owner, repo); @@ -16999,7 +18064,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17011,9 +18076,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetRepoRuleSuitesError::Status404(github_response.to_json()?)), - 500 => Err(ReposGetRepoRuleSuitesError::Status500(github_response.to_json()?)), - code => Err(ReposGetRepoRuleSuitesError::Generic { code }), + 404 => Err(ReposGetRepoRuleSuitesError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposGetRepoRuleSuitesError::Status500(github_response.to_json()?).into()), + code => Err(ReposGetRepoRuleSuitesError::Generic { code }.into()), } } } @@ -17030,7 +18095,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_repo_ruleset](https://docs.github.com/rest/repos/rules#get-a-repository-ruleset) /// /// --- - pub async fn get_repo_ruleset_async(&self, owner: &str, repo: &str, ruleset_id: i32, query_params: Option>) -> Result { + pub async fn get_repo_ruleset_async(&self, owner: &str, repo: &str, ruleset_id: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, ruleset_id); @@ -17041,12 +18106,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17058,9 +18123,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetRepoRulesetError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposGetRepoRulesetError::Status500(github_response.to_json_async().await?)), - code => Err(ReposGetRepoRulesetError::Generic { code }), + 404 => Err(ReposGetRepoRulesetError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposGetRepoRulesetError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposGetRepoRulesetError::Generic { code }.into()), } } } @@ -17078,7 +18143,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_ruleset(&self, owner: &str, repo: &str, ruleset_id: i32, query_params: Option>) -> Result { + pub fn get_repo_ruleset(&self, owner: &str, repo: &str, ruleset_id: i32, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, ruleset_id); @@ -17095,7 +18160,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17107,9 +18172,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetRepoRulesetError::Status404(github_response.to_json()?)), - 500 => Err(ReposGetRepoRulesetError::Status500(github_response.to_json()?)), - code => Err(ReposGetRepoRulesetError::Generic { code }), + 404 => Err(ReposGetRepoRulesetError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposGetRepoRulesetError::Status500(github_response.to_json()?).into()), + code => Err(ReposGetRepoRulesetError::Generic { code }.into()), } } } @@ -17123,7 +18188,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_repo_rulesets](https://docs.github.com/rest/repos/rules#get-all-repository-rulesets) /// /// --- - pub async fn get_repo_rulesets_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposGetRepoRulesetsError> { + pub async fn get_repo_rulesets_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/rulesets", super::GITHUB_BASE_API_URL, owner, repo); @@ -17134,12 +18199,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17151,9 +18216,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetRepoRulesetsError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposGetRepoRulesetsError::Status500(github_response.to_json_async().await?)), - code => Err(ReposGetRepoRulesetsError::Generic { code }), + 404 => Err(ReposGetRepoRulesetsError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposGetRepoRulesetsError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposGetRepoRulesetsError::Generic { code }.into()), } } } @@ -17168,7 +18233,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repo_rulesets(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposGetRepoRulesetsError> { + pub fn get_repo_rulesets(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/rulesets", super::GITHUB_BASE_API_URL, owner, repo); @@ -17185,7 +18250,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17197,9 +18262,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetRepoRulesetsError::Status404(github_response.to_json()?)), - 500 => Err(ReposGetRepoRulesetsError::Status500(github_response.to_json()?)), - code => Err(ReposGetRepoRulesetsError::Generic { code }), + 404 => Err(ReposGetRepoRulesetsError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposGetRepoRulesetsError::Status500(github_response.to_json()?).into()), + code => Err(ReposGetRepoRulesetsError::Generic { code }.into()), } } } @@ -17213,19 +18278,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_status_checks_protection](https://docs.github.com/rest/branches/branch-protection#get-status-checks-protection) /// /// --- - pub async fn get_status_checks_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub async fn get_status_checks_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17237,8 +18302,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetStatusChecksProtectionError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetStatusChecksProtectionError::Generic { code }), + 404 => Err(ReposGetStatusChecksProtectionError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetStatusChecksProtectionError::Generic { code }.into()), } } } @@ -17253,7 +18318,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_status_checks_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub fn get_status_checks_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -17265,7 +18330,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17277,8 +18342,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetStatusChecksProtectionError::Status404(github_response.to_json()?)), - code => Err(ReposGetStatusChecksProtectionError::Generic { code }), + 404 => Err(ReposGetStatusChecksProtectionError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetStatusChecksProtectionError::Generic { code }.into()), } } } @@ -17294,19 +18359,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_teams_with_access_to_protected_branch](https://docs.github.com/rest/branches/branch-protection#get-teams-with-access-to-the-protected-branch) /// /// --- - pub async fn get_teams_with_access_to_protected_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result, ReposGetTeamsWithAccessToProtectedBranchError> { + pub async fn get_teams_with_access_to_protected_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17318,8 +18383,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetTeamsWithAccessToProtectedBranchError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetTeamsWithAccessToProtectedBranchError::Generic { code }), + 404 => Err(ReposGetTeamsWithAccessToProtectedBranchError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetTeamsWithAccessToProtectedBranchError::Generic { code }.into()), } } } @@ -17336,7 +18401,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_teams_with_access_to_protected_branch(&self, owner: &str, repo: &str, branch: &str) -> Result, ReposGetTeamsWithAccessToProtectedBranchError> { + pub fn get_teams_with_access_to_protected_branch(&self, owner: &str, repo: &str, branch: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -17348,7 +18413,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17360,8 +18425,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetTeamsWithAccessToProtectedBranchError::Status404(github_response.to_json()?)), - code => Err(ReposGetTeamsWithAccessToProtectedBranchError::Generic { code }), + 404 => Err(ReposGetTeamsWithAccessToProtectedBranchError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetTeamsWithAccessToProtectedBranchError::Generic { code }.into()), } } } @@ -17375,19 +18440,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_top_paths](https://docs.github.com/rest/metrics/traffic#get-top-referral-paths) /// /// --- - pub async fn get_top_paths_async(&self, owner: &str, repo: &str) -> Result, ReposGetTopPathsError> { + pub async fn get_top_paths_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/traffic/popular/paths", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17399,8 +18464,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposGetTopPathsError::Status403(github_response.to_json_async().await?)), - code => Err(ReposGetTopPathsError::Generic { code }), + 403 => Err(ReposGetTopPathsError::Status403(github_response.to_json_async().await?).into()), + code => Err(ReposGetTopPathsError::Generic { code }.into()), } } } @@ -17415,7 +18480,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_top_paths(&self, owner: &str, repo: &str) -> Result, ReposGetTopPathsError> { + pub fn get_top_paths(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/traffic/popular/paths", super::GITHUB_BASE_API_URL, owner, repo); @@ -17427,7 +18492,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17439,8 +18504,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposGetTopPathsError::Status403(github_response.to_json()?)), - code => Err(ReposGetTopPathsError::Generic { code }), + 403 => Err(ReposGetTopPathsError::Status403(github_response.to_json()?).into()), + code => Err(ReposGetTopPathsError::Generic { code }.into()), } } } @@ -17454,19 +18519,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_top_referrers](https://docs.github.com/rest/metrics/traffic#get-top-referral-sources) /// /// --- - pub async fn get_top_referrers_async(&self, owner: &str, repo: &str) -> Result, ReposGetTopReferrersError> { + pub async fn get_top_referrers_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/traffic/popular/referrers", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17478,8 +18543,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposGetTopReferrersError::Status403(github_response.to_json_async().await?)), - code => Err(ReposGetTopReferrersError::Generic { code }), + 403 => Err(ReposGetTopReferrersError::Status403(github_response.to_json_async().await?).into()), + code => Err(ReposGetTopReferrersError::Generic { code }.into()), } } } @@ -17494,7 +18559,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_top_referrers(&self, owner: &str, repo: &str) -> Result, ReposGetTopReferrersError> { + pub fn get_top_referrers(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/traffic/popular/referrers", super::GITHUB_BASE_API_URL, owner, repo); @@ -17506,7 +18571,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17518,8 +18583,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposGetTopReferrersError::Status403(github_response.to_json()?)), - code => Err(ReposGetTopReferrersError::Generic { code }), + 403 => Err(ReposGetTopReferrersError::Status403(github_response.to_json()?).into()), + code => Err(ReposGetTopReferrersError::Generic { code }.into()), } } } @@ -17535,19 +18600,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_users_with_access_to_protected_branch](https://docs.github.com/rest/branches/branch-protection#get-users-with-access-to-the-protected-branch) /// /// --- - pub async fn get_users_with_access_to_protected_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result, ReposGetUsersWithAccessToProtectedBranchError> { + pub async fn get_users_with_access_to_protected_branch_async(&self, owner: &str, repo: &str, branch: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17559,8 +18624,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetUsersWithAccessToProtectedBranchError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetUsersWithAccessToProtectedBranchError::Generic { code }), + 404 => Err(ReposGetUsersWithAccessToProtectedBranchError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetUsersWithAccessToProtectedBranchError::Generic { code }.into()), } } } @@ -17577,7 +18642,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_users_with_access_to_protected_branch(&self, owner: &str, repo: &str, branch: &str) -> Result, ReposGetUsersWithAccessToProtectedBranchError> { + pub fn get_users_with_access_to_protected_branch(&self, owner: &str, repo: &str, branch: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -17589,7 +18654,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17601,8 +18666,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetUsersWithAccessToProtectedBranchError::Status404(github_response.to_json()?)), - code => Err(ReposGetUsersWithAccessToProtectedBranchError::Generic { code }), + 404 => Err(ReposGetUsersWithAccessToProtectedBranchError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetUsersWithAccessToProtectedBranchError::Generic { code }.into()), } } } @@ -17616,7 +18681,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_views](https://docs.github.com/rest/metrics/traffic#get-page-views) /// /// --- - pub async fn get_views_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub async fn get_views_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/traffic/views", super::GITHUB_BASE_API_URL, owner, repo); @@ -17627,12 +18692,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17644,8 +18709,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposGetViewsError::Status403(github_response.to_json_async().await?)), - code => Err(ReposGetViewsError::Generic { code }), + 403 => Err(ReposGetViewsError::Status403(github_response.to_json_async().await?).into()), + code => Err(ReposGetViewsError::Generic { code }.into()), } } } @@ -17660,7 +18725,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_views(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { + pub fn get_views(&self, owner: &str, repo: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/traffic/views", super::GITHUB_BASE_API_URL, owner, repo); @@ -17677,7 +18742,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17689,8 +18754,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposGetViewsError::Status403(github_response.to_json()?)), - code => Err(ReposGetViewsError::Generic { code }), + 403 => Err(ReposGetViewsError::Status403(github_response.to_json()?).into()), + code => Err(ReposGetViewsError::Generic { code }.into()), } } } @@ -17704,19 +18769,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_webhook](https://docs.github.com/rest/repos/webhooks#get-a-repository-webhook) /// /// --- - pub async fn get_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result { + pub async fn get_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, hook_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17728,8 +18793,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposGetWebhookError::Status404(github_response.to_json_async().await?)), - code => Err(ReposGetWebhookError::Generic { code }), + 404 => Err(ReposGetWebhookError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposGetWebhookError::Generic { code }.into()), } } } @@ -17744,7 +18809,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result { + pub fn get_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, hook_id); @@ -17756,7 +18821,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17768,8 +18833,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposGetWebhookError::Status404(github_response.to_json()?)), - code => Err(ReposGetWebhookError::Generic { code }), + 404 => Err(ReposGetWebhookError::Status404(github_response.to_json()?).into()), + code => Err(ReposGetWebhookError::Generic { code }.into()), } } } @@ -17785,19 +18850,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_webhook_config_for_repo](https://docs.github.com/rest/repos/webhooks#get-a-webhook-configuration-for-a-repository) /// /// --- - pub async fn get_webhook_config_for_repo_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result { + pub async fn get_webhook_config_for_repo_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, owner, repo, hook_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17809,7 +18874,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposGetWebhookConfigForRepoError::Generic { code }), + code => Err(ReposGetWebhookConfigForRepoError::Generic { code }.into()), } } } @@ -17826,7 +18891,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_webhook_config_for_repo(&self, owner: &str, repo: &str, hook_id: i32) -> Result { + pub fn get_webhook_config_for_repo(&self, owner: &str, repo: &str, hook_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, owner, repo, hook_id); @@ -17838,7 +18903,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17850,7 +18915,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposGetWebhookConfigForRepoError::Generic { code }), + code => Err(ReposGetWebhookConfigForRepoError::Generic { code }.into()), } } } @@ -17864,19 +18929,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for get_webhook_delivery](https://docs.github.com/rest/repos/webhooks#get-a-delivery-for-a-repository-webhook) /// /// --- - pub async fn get_webhook_delivery_async(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result { + pub async fn get_webhook_delivery_async(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries/{}", super::GITHUB_BASE_API_URL, owner, repo, hook_id, delivery_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17888,9 +18953,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(ReposGetWebhookDeliveryError::Status400(github_response.to_json_async().await?)), - 422 => Err(ReposGetWebhookDeliveryError::Status422(github_response.to_json_async().await?)), - code => Err(ReposGetWebhookDeliveryError::Generic { code }), + 400 => Err(ReposGetWebhookDeliveryError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(ReposGetWebhookDeliveryError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposGetWebhookDeliveryError::Generic { code }.into()), } } } @@ -17905,7 +18970,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_webhook_delivery(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result { + pub fn get_webhook_delivery(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries/{}", super::GITHUB_BASE_API_URL, owner, repo, hook_id, delivery_id); @@ -17917,7 +18982,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17929,9 +18994,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(ReposGetWebhookDeliveryError::Status400(github_response.to_json()?)), - 422 => Err(ReposGetWebhookDeliveryError::Status422(github_response.to_json()?)), - code => Err(ReposGetWebhookDeliveryError::Generic { code }), + 400 => Err(ReposGetWebhookDeliveryError::Status400(github_response.to_json()?).into()), + 422 => Err(ReposGetWebhookDeliveryError::Status422(github_response.to_json()?).into()), + code => Err(ReposGetWebhookDeliveryError::Generic { code }.into()), } } } @@ -17948,7 +19013,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_activities](https://docs.github.com/rest/repos/repos#list-repository-activities) /// /// --- - pub async fn list_activities_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListActivitiesError> { + pub async fn list_activities_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/activity", super::GITHUB_BASE_API_URL, owner, repo); @@ -17959,12 +19024,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -17976,8 +19041,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposListActivitiesError::Status422(github_response.to_json_async().await?)), - code => Err(ReposListActivitiesError::Generic { code }), + 422 => Err(ReposListActivitiesError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposListActivitiesError::Generic { code }.into()), } } } @@ -17995,7 +19060,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_activities(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListActivitiesError> { + pub fn list_activities(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/activity", super::GITHUB_BASE_API_URL, owner, repo); @@ -18012,7 +19077,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18024,8 +19089,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposListActivitiesError::Status422(github_response.to_json()?)), - code => Err(ReposListActivitiesError::Generic { code }), + 422 => Err(ReposListActivitiesError::Status422(github_response.to_json()?).into()), + code => Err(ReposListActivitiesError::Generic { code }.into()), } } } @@ -18043,7 +19108,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_attestations](https://docs.github.com/rest/repos/repos#list-attestations) /// /// --- - pub async fn list_attestations_async(&self, owner: &str, repo: &str, subject_digest: &str, query_params: Option>>) -> Result { + pub async fn list_attestations_async(&self, owner: &str, repo: &str, subject_digest: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/attestations/{}", super::GITHUB_BASE_API_URL, owner, repo, subject_digest); @@ -18054,12 +19119,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18071,7 +19136,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListAttestationsError::Generic { code }), + code => Err(ReposListAttestationsError::Generic { code }.into()), } } } @@ -18090,7 +19155,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_attestations(&self, owner: &str, repo: &str, subject_digest: &str, query_params: Option>>) -> Result { + pub fn list_attestations(&self, owner: &str, repo: &str, subject_digest: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/attestations/{}", super::GITHUB_BASE_API_URL, owner, repo, subject_digest); @@ -18107,7 +19172,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18119,7 +19184,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListAttestationsError::Generic { code }), + code => Err(ReposListAttestationsError::Generic { code }.into()), } } } @@ -18135,19 +19200,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_autolinks](https://docs.github.com/rest/repos/autolinks#get-all-autolinks-of-a-repository) /// /// --- - pub async fn list_autolinks_async(&self, owner: &str, repo: &str) -> Result, ReposListAutolinksError> { + pub async fn list_autolinks_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/autolinks", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18159,7 +19224,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListAutolinksError::Generic { code }), + code => Err(ReposListAutolinksError::Generic { code }.into()), } } } @@ -18176,7 +19241,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_autolinks(&self, owner: &str, repo: &str) -> Result, ReposListAutolinksError> { + pub fn list_autolinks(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/autolinks", super::GITHUB_BASE_API_URL, owner, repo); @@ -18188,7 +19253,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18200,7 +19265,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListAutolinksError::Generic { code }), + code => Err(ReposListAutolinksError::Generic { code }.into()), } } } @@ -18212,7 +19277,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_branches](https://docs.github.com/rest/branches/branches#list-branches) /// /// --- - pub async fn list_branches_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListBranchesError> { + pub async fn list_branches_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/branches", super::GITHUB_BASE_API_URL, owner, repo); @@ -18223,12 +19288,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18240,8 +19305,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposListBranchesError::Status404(github_response.to_json_async().await?)), - code => Err(ReposListBranchesError::Generic { code }), + 404 => Err(ReposListBranchesError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposListBranchesError::Generic { code }.into()), } } } @@ -18254,7 +19319,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_branches(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListBranchesError> { + pub fn list_branches(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/branches", super::GITHUB_BASE_API_URL, owner, repo); @@ -18271,7 +19336,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18283,8 +19348,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposListBranchesError::Status404(github_response.to_json()?)), - code => Err(ReposListBranchesError::Generic { code }), + 404 => Err(ReposListBranchesError::Status404(github_response.to_json()?).into()), + code => Err(ReposListBranchesError::Generic { code }.into()), } } } @@ -18300,19 +19365,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_branches_for_head_commit](https://docs.github.com/rest/commits/commits#list-branches-for-head-commit) /// /// --- - pub async fn list_branches_for_head_commit_async(&self, owner: &str, repo: &str, commit_sha: &str) -> Result, ReposListBranchesForHeadCommitError> { + pub async fn list_branches_for_head_commit_async(&self, owner: &str, repo: &str, commit_sha: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/commits/{}/branches-where-head", super::GITHUB_BASE_API_URL, owner, repo, commit_sha); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18324,9 +19389,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposListBranchesForHeadCommitError::Status422(github_response.to_json_async().await?)), - 409 => Err(ReposListBranchesForHeadCommitError::Status409(github_response.to_json_async().await?)), - code => Err(ReposListBranchesForHeadCommitError::Generic { code }), + 422 => Err(ReposListBranchesForHeadCommitError::Status422(github_response.to_json_async().await?).into()), + 409 => Err(ReposListBranchesForHeadCommitError::Status409(github_response.to_json_async().await?).into()), + code => Err(ReposListBranchesForHeadCommitError::Generic { code }.into()), } } } @@ -18343,7 +19408,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_branches_for_head_commit(&self, owner: &str, repo: &str, commit_sha: &str) -> Result, ReposListBranchesForHeadCommitError> { + pub fn list_branches_for_head_commit(&self, owner: &str, repo: &str, commit_sha: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/commits/{}/branches-where-head", super::GITHUB_BASE_API_URL, owner, repo, commit_sha); @@ -18355,7 +19420,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18367,9 +19432,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposListBranchesForHeadCommitError::Status422(github_response.to_json()?)), - 409 => Err(ReposListBranchesForHeadCommitError::Status409(github_response.to_json()?)), - code => Err(ReposListBranchesForHeadCommitError::Generic { code }), + 422 => Err(ReposListBranchesForHeadCommitError::Status422(github_response.to_json()?).into()), + 409 => Err(ReposListBranchesForHeadCommitError::Status409(github_response.to_json()?).into()), + code => Err(ReposListBranchesForHeadCommitError::Generic { code }.into()), } } } @@ -18390,7 +19455,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_collaborators](https://docs.github.com/rest/collaborators/collaborators#list-repository-collaborators) /// /// --- - pub async fn list_collaborators_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListCollaboratorsError> { + pub async fn list_collaborators_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/collaborators", super::GITHUB_BASE_API_URL, owner, repo); @@ -18401,12 +19466,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18418,8 +19483,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposListCollaboratorsError::Status404(github_response.to_json_async().await?)), - code => Err(ReposListCollaboratorsError::Generic { code }), + 404 => Err(ReposListCollaboratorsError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposListCollaboratorsError::Generic { code }.into()), } } } @@ -18441,7 +19506,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_collaborators(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListCollaboratorsError> { + pub fn list_collaborators(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/collaborators", super::GITHUB_BASE_API_URL, owner, repo); @@ -18458,7 +19523,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18470,8 +19535,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposListCollaboratorsError::Status404(github_response.to_json()?)), - code => Err(ReposListCollaboratorsError::Generic { code }), + 404 => Err(ReposListCollaboratorsError::Status404(github_response.to_json()?).into()), + code => Err(ReposListCollaboratorsError::Generic { code }.into()), } } } @@ -18492,7 +19557,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_comments_for_commit](https://docs.github.com/rest/commits/comments#list-commit-comments) /// /// --- - pub async fn list_comments_for_commit_async(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option>) -> Result, ReposListCommentsForCommitError> { + pub async fn list_comments_for_commit_async(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, commit_sha); @@ -18503,12 +19568,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18520,7 +19585,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListCommentsForCommitError::Generic { code }), + code => Err(ReposListCommentsForCommitError::Generic { code }.into()), } } } @@ -18542,7 +19607,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_comments_for_commit(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option>) -> Result, ReposListCommentsForCommitError> { + pub fn list_comments_for_commit(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/comments", super::GITHUB_BASE_API_URL, owner, repo, commit_sha); @@ -18559,7 +19624,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18571,7 +19636,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListCommentsForCommitError::Generic { code }), + code => Err(ReposListCommentsForCommitError::Generic { code }.into()), } } } @@ -18592,7 +19657,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_commit_comments_for_repo](https://docs.github.com/rest/commits/comments#list-commit-comments-for-a-repository) /// /// --- - pub async fn list_commit_comments_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListCommitCommentsForRepoError> { + pub async fn list_commit_comments_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/comments", super::GITHUB_BASE_API_URL, owner, repo); @@ -18603,12 +19668,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18620,7 +19685,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListCommitCommentsForRepoError::Generic { code }), + code => Err(ReposListCommitCommentsForRepoError::Generic { code }.into()), } } } @@ -18642,7 +19707,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_commit_comments_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListCommitCommentsForRepoError> { + pub fn list_commit_comments_for_repo(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/comments", super::GITHUB_BASE_API_URL, owner, repo); @@ -18659,7 +19724,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18671,7 +19736,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListCommitCommentsForRepoError::Generic { code }), + code => Err(ReposListCommitCommentsForRepoError::Generic { code }.into()), } } } @@ -18687,7 +19752,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_commit_statuses_for_ref](https://docs.github.com/rest/commits/statuses#list-commit-statuses-for-a-reference) /// /// --- - pub async fn list_commit_statuses_for_ref_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result, ReposListCommitStatusesForRefError> { + pub async fn list_commit_statuses_for_ref_async(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -18698,12 +19763,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18715,8 +19780,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 301 => Err(ReposListCommitStatusesForRefError::Status301(github_response.to_json_async().await?)), - code => Err(ReposListCommitStatusesForRefError::Generic { code }), + 301 => Err(ReposListCommitStatusesForRefError::Status301(github_response.to_json_async().await?).into()), + code => Err(ReposListCommitStatusesForRefError::Generic { code }.into()), } } } @@ -18733,7 +19798,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_commit_statuses_for_ref(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result, ReposListCommitStatusesForRefError> { + pub fn list_commit_statuses_for_ref(&self, owner: &str, repo: &str, git_ref: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, git_ref); @@ -18750,7 +19815,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18762,8 +19827,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 301 => Err(ReposListCommitStatusesForRefError::Status301(github_response.to_json()?)), - code => Err(ReposListCommitStatusesForRefError::Generic { code }), + 301 => Err(ReposListCommitStatusesForRefError::Status301(github_response.to_json()?).into()), + code => Err(ReposListCommitStatusesForRefError::Generic { code }.into()), } } } @@ -18804,7 +19869,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_commits](https://docs.github.com/rest/commits/commits#list-commits) /// /// --- - pub async fn list_commits_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListCommitsError> { + pub async fn list_commits_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/commits", super::GITHUB_BASE_API_URL, owner, repo); @@ -18815,12 +19880,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18832,11 +19897,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 500 => Err(ReposListCommitsError::Status500(github_response.to_json_async().await?)), - 400 => Err(ReposListCommitsError::Status400(github_response.to_json_async().await?)), - 404 => Err(ReposListCommitsError::Status404(github_response.to_json_async().await?)), - 409 => Err(ReposListCommitsError::Status409(github_response.to_json_async().await?)), - code => Err(ReposListCommitsError::Generic { code }), + 500 => Err(ReposListCommitsError::Status500(github_response.to_json_async().await?).into()), + 400 => Err(ReposListCommitsError::Status400(github_response.to_json_async().await?).into()), + 404 => Err(ReposListCommitsError::Status404(github_response.to_json_async().await?).into()), + 409 => Err(ReposListCommitsError::Status409(github_response.to_json_async().await?).into()), + code => Err(ReposListCommitsError::Generic { code }.into()), } } } @@ -18878,7 +19943,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_commits(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListCommitsError> { + pub fn list_commits(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/commits", super::GITHUB_BASE_API_URL, owner, repo); @@ -18895,7 +19960,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18907,11 +19972,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 500 => Err(ReposListCommitsError::Status500(github_response.to_json()?)), - 400 => Err(ReposListCommitsError::Status400(github_response.to_json()?)), - 404 => Err(ReposListCommitsError::Status404(github_response.to_json()?)), - 409 => Err(ReposListCommitsError::Status409(github_response.to_json()?)), - code => Err(ReposListCommitsError::Generic { code }), + 500 => Err(ReposListCommitsError::Status500(github_response.to_json()?).into()), + 400 => Err(ReposListCommitsError::Status400(github_response.to_json()?).into()), + 404 => Err(ReposListCommitsError::Status404(github_response.to_json()?).into()), + 409 => Err(ReposListCommitsError::Status409(github_response.to_json()?).into()), + code => Err(ReposListCommitsError::Generic { code }.into()), } } } @@ -18927,7 +19992,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_contributors](https://docs.github.com/rest/repos/repos#list-repository-contributors) /// /// --- - pub async fn list_contributors_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListContributorsError> { + pub async fn list_contributors_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/contributors", super::GITHUB_BASE_API_URL, owner, repo); @@ -18938,12 +20003,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -18955,10 +20020,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(ReposListContributorsError::Status204), - 403 => Err(ReposListContributorsError::Status403(github_response.to_json_async().await?)), - 404 => Err(ReposListContributorsError::Status404(github_response.to_json_async().await?)), - code => Err(ReposListContributorsError::Generic { code }), + 204 => Err(ReposListContributorsError::Status204.into()), + 403 => Err(ReposListContributorsError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ReposListContributorsError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposListContributorsError::Generic { code }.into()), } } } @@ -18975,7 +20040,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_contributors(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListContributorsError> { + pub fn list_contributors(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/contributors", super::GITHUB_BASE_API_URL, owner, repo); @@ -18992,7 +20057,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19004,10 +20069,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(ReposListContributorsError::Status204), - 403 => Err(ReposListContributorsError::Status403(github_response.to_json()?)), - 404 => Err(ReposListContributorsError::Status404(github_response.to_json()?)), - code => Err(ReposListContributorsError::Generic { code }), + 204 => Err(ReposListContributorsError::Status204.into()), + 403 => Err(ReposListContributorsError::Status403(github_response.to_json()?).into()), + 404 => Err(ReposListContributorsError::Status404(github_response.to_json()?).into()), + code => Err(ReposListContributorsError::Generic { code }.into()), } } } @@ -19029,7 +20094,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_custom_deployment_rule_integrations](https://docs.github.com/rest/deployments/protection-rules#list-custom-deployment-rule-integrations-available-for-an-environment) /// /// --- - pub async fn list_custom_deployment_rule_integrations_async(&self, environment_name: &str, repo: &str, owner: &str, query_params: Option>) -> Result { + pub async fn list_custom_deployment_rule_integrations_async(&self, environment_name: &str, repo: &str, owner: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/apps", super::GITHUB_BASE_API_URL, environment_name, repo, owner); @@ -19040,12 +20105,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19057,7 +20122,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListCustomDeploymentRuleIntegrationsError::Generic { code }), + code => Err(ReposListCustomDeploymentRuleIntegrationsError::Generic { code }.into()), } } } @@ -19080,7 +20145,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_custom_deployment_rule_integrations(&self, environment_name: &str, repo: &str, owner: &str, query_params: Option>) -> Result { + pub fn list_custom_deployment_rule_integrations(&self, environment_name: &str, repo: &str, owner: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/environments/{}/deployment_protection_rules/apps", super::GITHUB_BASE_API_URL, environment_name, repo, owner); @@ -19097,7 +20162,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19109,7 +20174,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListCustomDeploymentRuleIntegrationsError::Generic { code }), + code => Err(ReposListCustomDeploymentRuleIntegrationsError::Generic { code }.into()), } } } @@ -19121,7 +20186,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_deploy_keys](https://docs.github.com/rest/deploy-keys/deploy-keys#list-deploy-keys) /// /// --- - pub async fn list_deploy_keys_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListDeployKeysError> { + pub async fn list_deploy_keys_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/keys", super::GITHUB_BASE_API_URL, owner, repo); @@ -19132,12 +20197,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19149,7 +20214,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListDeployKeysError::Generic { code }), + code => Err(ReposListDeployKeysError::Generic { code }.into()), } } } @@ -19162,7 +20227,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_deploy_keys(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListDeployKeysError> { + pub fn list_deploy_keys(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/keys", super::GITHUB_BASE_API_URL, owner, repo); @@ -19179,7 +20244,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19191,7 +20256,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListDeployKeysError::Generic { code }), + code => Err(ReposListDeployKeysError::Generic { code }.into()), } } } @@ -19209,7 +20274,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_deployment_branch_policies](https://docs.github.com/rest/deployments/branch-policies#list-deployment-branch-policies) /// /// --- - pub async fn list_deployment_branch_policies_async(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { + pub async fn list_deployment_branch_policies_async(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies", super::GITHUB_BASE_API_URL, owner, repo, environment_name); @@ -19220,12 +20285,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19237,7 +20302,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListDeploymentBranchPoliciesError::Generic { code }), + code => Err(ReposListDeploymentBranchPoliciesError::Generic { code }.into()), } } } @@ -19256,7 +20321,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_deployment_branch_policies(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { + pub fn list_deployment_branch_policies(&self, owner: &str, repo: &str, environment_name: &str, query_params: Option>) -> Result { let mut request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies", super::GITHUB_BASE_API_URL, owner, repo, environment_name); @@ -19273,7 +20338,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19285,7 +20350,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListDeploymentBranchPoliciesError::Generic { code }), + code => Err(ReposListDeploymentBranchPoliciesError::Generic { code }.into()), } } } @@ -19299,7 +20364,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_deployment_statuses](https://docs.github.com/rest/deployments/statuses#list-deployment-statuses) /// /// --- - pub async fn list_deployment_statuses_async(&self, owner: &str, repo: &str, deployment_id: i32, query_params: Option>) -> Result, ReposListDeploymentStatusesError> { + pub async fn list_deployment_statuses_async(&self, owner: &str, repo: &str, deployment_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, deployment_id); @@ -19310,12 +20375,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19327,8 +20392,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposListDeploymentStatusesError::Status404(github_response.to_json_async().await?)), - code => Err(ReposListDeploymentStatusesError::Generic { code }), + 404 => Err(ReposListDeploymentStatusesError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposListDeploymentStatusesError::Generic { code }.into()), } } } @@ -19343,7 +20408,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_deployment_statuses(&self, owner: &str, repo: &str, deployment_id: i32, query_params: Option>) -> Result, ReposListDeploymentStatusesError> { + pub fn list_deployment_statuses(&self, owner: &str, repo: &str, deployment_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/deployments/{}/statuses", super::GITHUB_BASE_API_URL, owner, repo, deployment_id); @@ -19360,7 +20425,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19372,8 +20437,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposListDeploymentStatusesError::Status404(github_response.to_json()?)), - code => Err(ReposListDeploymentStatusesError::Generic { code }), + 404 => Err(ReposListDeploymentStatusesError::Status404(github_response.to_json()?).into()), + code => Err(ReposListDeploymentStatusesError::Generic { code }.into()), } } } @@ -19387,7 +20452,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_deployments](https://docs.github.com/rest/deployments/deployments#list-deployments) /// /// --- - pub async fn list_deployments_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListDeploymentsError> { + pub async fn list_deployments_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/deployments", super::GITHUB_BASE_API_URL, owner, repo); @@ -19398,12 +20463,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19415,7 +20480,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListDeploymentsError::Generic { code }), + code => Err(ReposListDeploymentsError::Generic { code }.into()), } } } @@ -19430,7 +20495,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_deployments(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListDeploymentsError> { + pub fn list_deployments(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/deployments", super::GITHUB_BASE_API_URL, owner, repo); @@ -19447,7 +20512,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19459,7 +20524,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListDeploymentsError::Generic { code }), + code => Err(ReposListDeploymentsError::Generic { code }.into()), } } } @@ -19475,7 +20540,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/repos/repos#list-repositories-for-the-authenticated-user) /// /// --- - pub async fn list_for_authenticated_user_async(&self, query_params: Option>>) -> Result, ReposListForAuthenticatedUserError> { + pub async fn list_for_authenticated_user_async(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/repos", super::GITHUB_BASE_API_URL); @@ -19486,12 +20551,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19503,11 +20568,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposListForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - 304 => Err(ReposListForAuthenticatedUserError::Status304), - 403 => Err(ReposListForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(ReposListForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(ReposListForAuthenticatedUserError::Generic { code }), + 422 => Err(ReposListForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(ReposListForAuthenticatedUserError::Status304.into()), + 403 => Err(ReposListForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ReposListForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(ReposListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -19524,7 +20589,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_authenticated_user(&self, query_params: Option>>) -> Result, ReposListForAuthenticatedUserError> { + pub fn list_for_authenticated_user(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/repos", super::GITHUB_BASE_API_URL); @@ -19541,7 +20606,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19553,11 +20618,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposListForAuthenticatedUserError::Status422(github_response.to_json()?)), - 304 => Err(ReposListForAuthenticatedUserError::Status304), - 403 => Err(ReposListForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(ReposListForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(ReposListForAuthenticatedUserError::Generic { code }), + 422 => Err(ReposListForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + 304 => Err(ReposListForAuthenticatedUserError::Status304.into()), + 403 => Err(ReposListForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(ReposListForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(ReposListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -19574,7 +20639,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_for_org](https://docs.github.com/rest/repos/repos#list-organization-repositories) /// /// --- - pub async fn list_for_org_async(&self, org: &str, query_params: Option>>) -> Result, ReposListForOrgError> { + pub async fn list_for_org_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/repos", super::GITHUB_BASE_API_URL, org); @@ -19585,12 +20650,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19602,7 +20667,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListForOrgError::Generic { code }), + code => Err(ReposListForOrgError::Generic { code }.into()), } } } @@ -19620,7 +20685,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_org(&self, org: &str, query_params: Option>>) -> Result, ReposListForOrgError> { + pub fn list_for_org(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/repos", super::GITHUB_BASE_API_URL, org); @@ -19637,7 +20702,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19649,7 +20714,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListForOrgError::Generic { code }), + code => Err(ReposListForOrgError::Generic { code }.into()), } } } @@ -19663,7 +20728,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_for_user](https://docs.github.com/rest/repos/repos#list-repositories-for-a-user) /// /// --- - pub async fn list_for_user_async(&self, username: &str, query_params: Option>>) -> Result, ReposListForUserError> { + pub async fn list_for_user_async(&self, username: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/repos", super::GITHUB_BASE_API_URL, username); @@ -19674,12 +20739,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19691,7 +20756,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListForUserError::Generic { code }), + code => Err(ReposListForUserError::Generic { code }.into()), } } } @@ -19706,7 +20771,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_user(&self, username: &str, query_params: Option>>) -> Result, ReposListForUserError> { + pub fn list_for_user(&self, username: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/repos", super::GITHUB_BASE_API_URL, username); @@ -19723,7 +20788,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19735,7 +20800,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListForUserError::Generic { code }), + code => Err(ReposListForUserError::Generic { code }.into()), } } } @@ -19747,7 +20812,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_forks](https://docs.github.com/rest/repos/forks#list-forks) /// /// --- - pub async fn list_forks_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListForksError> { + pub async fn list_forks_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/forks", super::GITHUB_BASE_API_URL, owner, repo); @@ -19758,12 +20823,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19775,8 +20840,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(ReposListForksError::Status400(github_response.to_json_async().await?)), - code => Err(ReposListForksError::Generic { code }), + 400 => Err(ReposListForksError::Status400(github_response.to_json_async().await?).into()), + code => Err(ReposListForksError::Generic { code }.into()), } } } @@ -19789,7 +20854,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_forks(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, ReposListForksError> { + pub fn list_forks(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/forks", super::GITHUB_BASE_API_URL, owner, repo); @@ -19806,7 +20871,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19818,8 +20883,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(ReposListForksError::Status400(github_response.to_json()?)), - code => Err(ReposListForksError::Generic { code }), + 400 => Err(ReposListForksError::Status400(github_response.to_json()?).into()), + code => Err(ReposListForksError::Generic { code }.into()), } } } @@ -19833,7 +20898,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_invitations](https://docs.github.com/rest/collaborators/invitations#list-repository-invitations) /// /// --- - pub async fn list_invitations_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListInvitationsError> { + pub async fn list_invitations_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/invitations", super::GITHUB_BASE_API_URL, owner, repo); @@ -19844,12 +20909,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19861,7 +20926,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListInvitationsError::Generic { code }), + code => Err(ReposListInvitationsError::Generic { code }.into()), } } } @@ -19876,7 +20941,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_invitations(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListInvitationsError> { + pub fn list_invitations(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/invitations", super::GITHUB_BASE_API_URL, owner, repo); @@ -19893,7 +20958,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19905,7 +20970,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListInvitationsError::Generic { code }), + code => Err(ReposListInvitationsError::Generic { code }.into()), } } } @@ -19919,7 +20984,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_invitations_for_authenticated_user](https://docs.github.com/rest/collaborators/invitations#list-repository-invitations-for-the-authenticated-user) /// /// --- - pub async fn list_invitations_for_authenticated_user_async(&self, query_params: Option>) -> Result, ReposListInvitationsForAuthenticatedUserError> { + pub async fn list_invitations_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/repository_invitations", super::GITHUB_BASE_API_URL); @@ -19930,12 +20995,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19947,11 +21012,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(ReposListInvitationsForAuthenticatedUserError::Status304), - 404 => Err(ReposListInvitationsForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(ReposListInvitationsForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(ReposListInvitationsForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(ReposListInvitationsForAuthenticatedUserError::Generic { code }), + 304 => Err(ReposListInvitationsForAuthenticatedUserError::Status304.into()), + 404 => Err(ReposListInvitationsForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(ReposListInvitationsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(ReposListInvitationsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(ReposListInvitationsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -19966,7 +21031,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_invitations_for_authenticated_user(&self, query_params: Option>) -> Result, ReposListInvitationsForAuthenticatedUserError> { + pub fn list_invitations_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/repository_invitations", super::GITHUB_BASE_API_URL); @@ -19983,7 +21048,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -19995,11 +21060,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(ReposListInvitationsForAuthenticatedUserError::Status304), - 404 => Err(ReposListInvitationsForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(ReposListInvitationsForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(ReposListInvitationsForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(ReposListInvitationsForAuthenticatedUserError::Generic { code }), + 304 => Err(ReposListInvitationsForAuthenticatedUserError::Status304.into()), + 404 => Err(ReposListInvitationsForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(ReposListInvitationsForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(ReposListInvitationsForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(ReposListInvitationsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -20013,19 +21078,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_languages](https://docs.github.com/rest/repos/repos#list-repository-languages) /// /// --- - pub async fn list_languages_async(&self, owner: &str, repo: &str) -> Result { + pub async fn list_languages_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/languages", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20037,7 +21102,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListLanguagesError::Generic { code }), + code => Err(ReposListLanguagesError::Generic { code }.into()), } } } @@ -20052,7 +21117,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_languages(&self, owner: &str, repo: &str) -> Result { + pub fn list_languages(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/languages", super::GITHUB_BASE_API_URL, owner, repo); @@ -20064,7 +21129,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20076,7 +21141,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListLanguagesError::Generic { code }), + code => Err(ReposListLanguagesError::Generic { code }.into()), } } } @@ -20092,7 +21157,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_pages_builds](https://docs.github.com/rest/pages/pages#list-apiname-pages-builds) /// /// --- - pub async fn list_pages_builds_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListPagesBuildsError> { + pub async fn list_pages_builds_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pages/builds", super::GITHUB_BASE_API_URL, owner, repo); @@ -20103,12 +21168,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20120,7 +21185,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListPagesBuildsError::Generic { code }), + code => Err(ReposListPagesBuildsError::Generic { code }.into()), } } } @@ -20137,7 +21202,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_pages_builds(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListPagesBuildsError> { + pub fn list_pages_builds(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/pages/builds", super::GITHUB_BASE_API_URL, owner, repo); @@ -20154,7 +21219,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20166,7 +21231,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListPagesBuildsError::Generic { code }), + code => Err(ReposListPagesBuildsError::Generic { code }.into()), } } } @@ -20184,7 +21249,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_public](https://docs.github.com/rest/repos/repos#list-public-repositories) /// /// --- - pub async fn list_public_async(&self, query_params: Option>) -> Result, ReposListPublicError> { + pub async fn list_public_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repositories", super::GITHUB_BASE_API_URL); @@ -20195,12 +21260,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20212,9 +21277,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposListPublicError::Status422(github_response.to_json_async().await?)), - 304 => Err(ReposListPublicError::Status304), - code => Err(ReposListPublicError::Generic { code }), + 422 => Err(ReposListPublicError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(ReposListPublicError::Status304.into()), + code => Err(ReposListPublicError::Generic { code }.into()), } } } @@ -20233,7 +21298,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_public(&self, query_params: Option>) -> Result, ReposListPublicError> { + pub fn list_public(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repositories", super::GITHUB_BASE_API_URL); @@ -20250,7 +21315,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20262,9 +21327,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposListPublicError::Status422(github_response.to_json()?)), - 304 => Err(ReposListPublicError::Status304), - code => Err(ReposListPublicError::Generic { code }), + 422 => Err(ReposListPublicError::Status422(github_response.to_json()?).into()), + 304 => Err(ReposListPublicError::Status304.into()), + code => Err(ReposListPublicError::Generic { code }.into()), } } } @@ -20280,7 +21345,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_pull_requests_associated_with_commit](https://docs.github.com/rest/commits/commits#list-pull-requests-associated-with-a-commit) /// /// --- - pub async fn list_pull_requests_associated_with_commit_async(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option>) -> Result, ReposListPullRequestsAssociatedWithCommitError> { + pub async fn list_pull_requests_associated_with_commit_async(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo, commit_sha); @@ -20291,12 +21356,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20308,8 +21373,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ReposListPullRequestsAssociatedWithCommitError::Status409(github_response.to_json_async().await?)), - code => Err(ReposListPullRequestsAssociatedWithCommitError::Generic { code }), + 409 => Err(ReposListPullRequestsAssociatedWithCommitError::Status409(github_response.to_json_async().await?).into()), + code => Err(ReposListPullRequestsAssociatedWithCommitError::Generic { code }.into()), } } } @@ -20326,7 +21391,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_pull_requests_associated_with_commit(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option>) -> Result, ReposListPullRequestsAssociatedWithCommitError> { + pub fn list_pull_requests_associated_with_commit(&self, owner: &str, repo: &str, commit_sha: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/commits/{}/pulls", super::GITHUB_BASE_API_URL, owner, repo, commit_sha); @@ -20343,7 +21408,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20355,8 +21420,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ReposListPullRequestsAssociatedWithCommitError::Status409(github_response.to_json()?)), - code => Err(ReposListPullRequestsAssociatedWithCommitError::Generic { code }), + 409 => Err(ReposListPullRequestsAssociatedWithCommitError::Status409(github_response.to_json()?).into()), + code => Err(ReposListPullRequestsAssociatedWithCommitError::Generic { code }.into()), } } } @@ -20368,7 +21433,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_release_assets](https://docs.github.com/rest/releases/assets#list-release-assets) /// /// --- - pub async fn list_release_assets_async(&self, owner: &str, repo: &str, release_id: i32, query_params: Option>) -> Result, ReposListReleaseAssetsError> { + pub async fn list_release_assets_async(&self, owner: &str, repo: &str, release_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/releases/{}/assets", super::GITHUB_BASE_API_URL, owner, repo, release_id); @@ -20379,12 +21444,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20396,7 +21461,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListReleaseAssetsError::Generic { code }), + code => Err(ReposListReleaseAssetsError::Generic { code }.into()), } } } @@ -20409,7 +21474,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_release_assets(&self, owner: &str, repo: &str, release_id: i32, query_params: Option>) -> Result, ReposListReleaseAssetsError> { + pub fn list_release_assets(&self, owner: &str, repo: &str, release_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/releases/{}/assets", super::GITHUB_BASE_API_URL, owner, repo, release_id); @@ -20426,7 +21491,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20438,7 +21503,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListReleaseAssetsError::Generic { code }), + code => Err(ReposListReleaseAssetsError::Generic { code }.into()), } } } @@ -20454,7 +21519,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_releases](https://docs.github.com/rest/releases/releases#list-releases) /// /// --- - pub async fn list_releases_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListReleasesError> { + pub async fn list_releases_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/releases", super::GITHUB_BASE_API_URL, owner, repo); @@ -20465,12 +21530,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20482,8 +21547,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposListReleasesError::Status404(github_response.to_json_async().await?)), - code => Err(ReposListReleasesError::Generic { code }), + 404 => Err(ReposListReleasesError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposListReleasesError::Generic { code }.into()), } } } @@ -20500,7 +21565,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_releases(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListReleasesError> { + pub fn list_releases(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/releases", super::GITHUB_BASE_API_URL, owner, repo); @@ -20517,7 +21582,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20529,8 +21594,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposListReleasesError::Status404(github_response.to_json()?)), - code => Err(ReposListReleasesError::Generic { code }), + 404 => Err(ReposListReleasesError::Status404(github_response.to_json()?).into()), + code => Err(ReposListReleasesError::Generic { code }.into()), } } } @@ -20549,19 +21614,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_tag_protection](https://docs.github.com/rest/repos/tags#deprecated---list-tag-protection-states-for-a-repository) /// /// --- - pub async fn list_tag_protection_async(&self, owner: &str, repo: &str) -> Result, ReposListTagProtectionError> { + pub async fn list_tag_protection_async(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/tags/protection", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20573,9 +21638,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposListTagProtectionError::Status403(github_response.to_json_async().await?)), - 404 => Err(ReposListTagProtectionError::Status404(github_response.to_json_async().await?)), - code => Err(ReposListTagProtectionError::Generic { code }), + 403 => Err(ReposListTagProtectionError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ReposListTagProtectionError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposListTagProtectionError::Generic { code }.into()), } } } @@ -20595,7 +21660,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_tag_protection(&self, owner: &str, repo: &str) -> Result, ReposListTagProtectionError> { + pub fn list_tag_protection(&self, owner: &str, repo: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/tags/protection", super::GITHUB_BASE_API_URL, owner, repo); @@ -20607,7 +21672,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20619,9 +21684,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposListTagProtectionError::Status403(github_response.to_json()?)), - 404 => Err(ReposListTagProtectionError::Status404(github_response.to_json()?)), - code => Err(ReposListTagProtectionError::Generic { code }), + 403 => Err(ReposListTagProtectionError::Status403(github_response.to_json()?).into()), + 404 => Err(ReposListTagProtectionError::Status404(github_response.to_json()?).into()), + code => Err(ReposListTagProtectionError::Generic { code }.into()), } } } @@ -20633,7 +21698,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_tags](https://docs.github.com/rest/repos/repos#list-repository-tags) /// /// --- - pub async fn list_tags_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListTagsError> { + pub async fn list_tags_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/tags", super::GITHUB_BASE_API_URL, owner, repo); @@ -20644,12 +21709,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20661,7 +21726,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposListTagsError::Generic { code }), + code => Err(ReposListTagsError::Generic { code }.into()), } } } @@ -20674,7 +21739,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_tags(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListTagsError> { + pub fn list_tags(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/tags", super::GITHUB_BASE_API_URL, owner, repo); @@ -20691,7 +21756,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20703,7 +21768,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposListTagsError::Generic { code }), + code => Err(ReposListTagsError::Generic { code }.into()), } } } @@ -20721,7 +21786,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_teams](https://docs.github.com/rest/repos/repos#list-repository-teams) /// /// --- - pub async fn list_teams_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListTeamsError> { + pub async fn list_teams_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/teams", super::GITHUB_BASE_API_URL, owner, repo); @@ -20732,12 +21797,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20749,8 +21814,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposListTeamsError::Status404(github_response.to_json_async().await?)), - code => Err(ReposListTeamsError::Generic { code }), + 404 => Err(ReposListTeamsError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposListTeamsError::Generic { code }.into()), } } } @@ -20769,7 +21834,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_teams(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListTeamsError> { + pub fn list_teams(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/teams", super::GITHUB_BASE_API_URL, owner, repo); @@ -20786,7 +21851,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20798,8 +21863,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposListTeamsError::Status404(github_response.to_json()?)), - code => Err(ReposListTeamsError::Generic { code }), + 404 => Err(ReposListTeamsError::Status404(github_response.to_json()?).into()), + code => Err(ReposListTeamsError::Generic { code }.into()), } } } @@ -20813,7 +21878,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_webhook_deliveries](https://docs.github.com/rest/repos/webhooks#list-deliveries-for-a-repository-webhook) /// /// --- - pub async fn list_webhook_deliveries_async(&self, owner: &str, repo: &str, hook_id: i32, query_params: Option>>) -> Result, ReposListWebhookDeliveriesError> { + pub async fn list_webhook_deliveries_async(&self, owner: &str, repo: &str, hook_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries", super::GITHUB_BASE_API_URL, owner, repo, hook_id); @@ -20824,12 +21889,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20841,9 +21906,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(ReposListWebhookDeliveriesError::Status400(github_response.to_json_async().await?)), - 422 => Err(ReposListWebhookDeliveriesError::Status422(github_response.to_json_async().await?)), - code => Err(ReposListWebhookDeliveriesError::Generic { code }), + 400 => Err(ReposListWebhookDeliveriesError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(ReposListWebhookDeliveriesError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposListWebhookDeliveriesError::Generic { code }.into()), } } } @@ -20858,7 +21923,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_webhook_deliveries(&self, owner: &str, repo: &str, hook_id: i32, query_params: Option>>) -> Result, ReposListWebhookDeliveriesError> { + pub fn list_webhook_deliveries(&self, owner: &str, repo: &str, hook_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries", super::GITHUB_BASE_API_URL, owner, repo, hook_id); @@ -20875,7 +21940,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20887,9 +21952,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(ReposListWebhookDeliveriesError::Status400(github_response.to_json()?)), - 422 => Err(ReposListWebhookDeliveriesError::Status422(github_response.to_json()?)), - code => Err(ReposListWebhookDeliveriesError::Generic { code }), + 400 => Err(ReposListWebhookDeliveriesError::Status400(github_response.to_json()?).into()), + 422 => Err(ReposListWebhookDeliveriesError::Status422(github_response.to_json()?).into()), + code => Err(ReposListWebhookDeliveriesError::Generic { code }.into()), } } } @@ -20903,7 +21968,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for list_webhooks](https://docs.github.com/rest/repos/webhooks#list-repository-webhooks) /// /// --- - pub async fn list_webhooks_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListWebhooksError> { + pub async fn list_webhooks_async(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/hooks", super::GITHUB_BASE_API_URL, owner, repo); @@ -20914,12 +21979,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20931,8 +21996,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposListWebhooksError::Status404(github_response.to_json_async().await?)), - code => Err(ReposListWebhooksError::Generic { code }), + 404 => Err(ReposListWebhooksError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposListWebhooksError::Generic { code }.into()), } } } @@ -20947,7 +22012,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_webhooks(&self, owner: &str, repo: &str, query_params: Option>) -> Result, ReposListWebhooksError> { + pub fn list_webhooks(&self, owner: &str, repo: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/hooks", super::GITHUB_BASE_API_URL, owner, repo); @@ -20964,7 +22029,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -20976,8 +22041,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposListWebhooksError::Status404(github_response.to_json()?)), - code => Err(ReposListWebhooksError::Generic { code }), + 404 => Err(ReposListWebhooksError::Status404(github_response.to_json()?).into()), + code => Err(ReposListWebhooksError::Generic { code }.into()), } } } @@ -20989,19 +22054,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for merge](https://docs.github.com/rest/branches/branches#merge-a-branch) /// /// --- - pub async fn merge_async(&self, owner: &str, repo: &str, body: PostReposMerge) -> Result { + pub async fn merge_async(&self, owner: &str, repo: &str, body: PostReposMerge) -> Result { let request_uri = format!("{}/repos/{}/{}/merges", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposMerge::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21013,12 +22078,12 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(ReposMergeError::Status204), - 404 => Err(ReposMergeError::Status404), - 409 => Err(ReposMergeError::Status409), - 403 => Err(ReposMergeError::Status403(github_response.to_json_async().await?)), - 422 => Err(ReposMergeError::Status422(github_response.to_json_async().await?)), - code => Err(ReposMergeError::Generic { code }), + 204 => Err(ReposMergeError::Status204.into()), + 404 => Err(ReposMergeError::Status404.into()), + 409 => Err(ReposMergeError::Status409.into()), + 403 => Err(ReposMergeError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(ReposMergeError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposMergeError::Generic { code }.into()), } } } @@ -21031,19 +22096,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn merge(&self, owner: &str, repo: &str, body: PostReposMerge) -> Result { + pub fn merge(&self, owner: &str, repo: &str, body: PostReposMerge) -> Result { let request_uri = format!("{}/repos/{}/{}/merges", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposMerge::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21055,12 +22120,12 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(ReposMergeError::Status204), - 404 => Err(ReposMergeError::Status404), - 409 => Err(ReposMergeError::Status409), - 403 => Err(ReposMergeError::Status403(github_response.to_json()?)), - 422 => Err(ReposMergeError::Status422(github_response.to_json()?)), - code => Err(ReposMergeError::Generic { code }), + 204 => Err(ReposMergeError::Status204.into()), + 404 => Err(ReposMergeError::Status404.into()), + 409 => Err(ReposMergeError::Status409.into()), + 403 => Err(ReposMergeError::Status403(github_response.to_json()?).into()), + 422 => Err(ReposMergeError::Status422(github_response.to_json()?).into()), + code => Err(ReposMergeError::Generic { code }.into()), } } } @@ -21074,19 +22139,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for merge_upstream](https://docs.github.com/rest/branches/branches#sync-a-fork-branch-with-the-upstream-repository) /// /// --- - pub async fn merge_upstream_async(&self, owner: &str, repo: &str, body: PostReposMergeUpstream) -> Result { + pub async fn merge_upstream_async(&self, owner: &str, repo: &str, body: PostReposMergeUpstream) -> Result { let request_uri = format!("{}/repos/{}/{}/merge-upstream", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposMergeUpstream::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21098,9 +22163,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 409 => Err(ReposMergeUpstreamError::Status409), - 422 => Err(ReposMergeUpstreamError::Status422), - code => Err(ReposMergeUpstreamError::Generic { code }), + 409 => Err(ReposMergeUpstreamError::Status409.into()), + 422 => Err(ReposMergeUpstreamError::Status422.into()), + code => Err(ReposMergeUpstreamError::Generic { code }.into()), } } } @@ -21115,19 +22180,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn merge_upstream(&self, owner: &str, repo: &str, body: PostReposMergeUpstream) -> Result { + pub fn merge_upstream(&self, owner: &str, repo: &str, body: PostReposMergeUpstream) -> Result { let request_uri = format!("{}/repos/{}/{}/merge-upstream", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposMergeUpstream::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21139,9 +22204,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 409 => Err(ReposMergeUpstreamError::Status409), - 422 => Err(ReposMergeUpstreamError::Status422), - code => Err(ReposMergeUpstreamError::Generic { code }), + 409 => Err(ReposMergeUpstreamError::Status409.into()), + 422 => Err(ReposMergeUpstreamError::Status422.into()), + code => Err(ReposMergeUpstreamError::Generic { code }.into()), } } } @@ -21155,19 +22220,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for ping_webhook](https://docs.github.com/rest/repos/webhooks#ping-a-repository-webhook) /// /// --- - pub async fn ping_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), ReposPingWebhookError> { + pub async fn ping_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/hooks/{}/pings", super::GITHUB_BASE_API_URL, owner, repo, hook_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21179,8 +22244,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposPingWebhookError::Status404(github_response.to_json_async().await?)), - code => Err(ReposPingWebhookError::Generic { code }), + 404 => Err(ReposPingWebhookError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposPingWebhookError::Generic { code }.into()), } } } @@ -21195,7 +22260,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn ping_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), ReposPingWebhookError> { + pub fn ping_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/hooks/{}/pings", super::GITHUB_BASE_API_URL, owner, repo, hook_id); @@ -21207,7 +22272,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21219,8 +22284,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposPingWebhookError::Status404(github_response.to_json()?)), - code => Err(ReposPingWebhookError::Generic { code }), + 404 => Err(ReposPingWebhookError::Status404(github_response.to_json()?).into()), + code => Err(ReposPingWebhookError::Generic { code }.into()), } } } @@ -21234,19 +22299,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for redeliver_webhook_delivery](https://docs.github.com/rest/repos/webhooks#redeliver-a-delivery-for-a-repository-webhook) /// /// --- - pub async fn redeliver_webhook_delivery_async(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result, ReposRedeliverWebhookDeliveryError> { + pub async fn redeliver_webhook_delivery_async(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries/{}/attempts", super::GITHUB_BASE_API_URL, owner, repo, hook_id, delivery_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21258,9 +22323,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(ReposRedeliverWebhookDeliveryError::Status400(github_response.to_json_async().await?)), - 422 => Err(ReposRedeliverWebhookDeliveryError::Status422(github_response.to_json_async().await?)), - code => Err(ReposRedeliverWebhookDeliveryError::Generic { code }), + 400 => Err(ReposRedeliverWebhookDeliveryError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(ReposRedeliverWebhookDeliveryError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposRedeliverWebhookDeliveryError::Generic { code }.into()), } } } @@ -21275,7 +22340,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn redeliver_webhook_delivery(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result, ReposRedeliverWebhookDeliveryError> { + pub fn redeliver_webhook_delivery(&self, owner: &str, repo: &str, hook_id: i32, delivery_id: i32) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/hooks/{}/deliveries/{}/attempts", super::GITHUB_BASE_API_URL, owner, repo, hook_id, delivery_id); @@ -21287,7 +22352,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21299,9 +22364,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(ReposRedeliverWebhookDeliveryError::Status400(github_response.to_json()?)), - 422 => Err(ReposRedeliverWebhookDeliveryError::Status422(github_response.to_json()?)), - code => Err(ReposRedeliverWebhookDeliveryError::Generic { code }), + 400 => Err(ReposRedeliverWebhookDeliveryError::Status400(github_response.to_json()?).into()), + 422 => Err(ReposRedeliverWebhookDeliveryError::Status422(github_response.to_json()?).into()), + code => Err(ReposRedeliverWebhookDeliveryError::Generic { code }.into()), } } } @@ -21317,19 +22382,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for remove_app_access_restrictions](https://docs.github.com/rest/branches/branch-protection#remove-app-access-restrictions) /// /// --- - pub async fn remove_app_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveAppAccessRestrictions) -> Result, ReposRemoveAppAccessRestrictionsError> { + pub async fn remove_app_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveAppAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteReposRemoveAppAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21341,8 +22406,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposRemoveAppAccessRestrictionsError::Status422(github_response.to_json_async().await?)), - code => Err(ReposRemoveAppAccessRestrictionsError::Generic { code }), + 422 => Err(ReposRemoveAppAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposRemoveAppAccessRestrictionsError::Generic { code }.into()), } } } @@ -21359,19 +22424,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_app_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveAppAccessRestrictions) -> Result, ReposRemoveAppAccessRestrictionsError> { + pub fn remove_app_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveAppAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteReposRemoveAppAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21383,8 +22448,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposRemoveAppAccessRestrictionsError::Status422(github_response.to_json()?)), - code => Err(ReposRemoveAppAccessRestrictionsError::Generic { code }), + 422 => Err(ReposRemoveAppAccessRestrictionsError::Status422(github_response.to_json()?).into()), + code => Err(ReposRemoveAppAccessRestrictionsError::Generic { code }.into()), } } } @@ -21419,19 +22484,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for remove_collaborator](https://docs.github.com/rest/collaborators/collaborators#remove-a-repository-collaborator) /// /// --- - pub async fn remove_collaborator_async(&self, owner: &str, repo: &str, username: &str) -> Result<(), ReposRemoveCollaboratorError> { + pub async fn remove_collaborator_async(&self, owner: &str, repo: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21443,9 +22508,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposRemoveCollaboratorError::Status422(github_response.to_json_async().await?)), - 403 => Err(ReposRemoveCollaboratorError::Status403(github_response.to_json_async().await?)), - code => Err(ReposRemoveCollaboratorError::Generic { code }), + 422 => Err(ReposRemoveCollaboratorError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(ReposRemoveCollaboratorError::Status403(github_response.to_json_async().await?).into()), + code => Err(ReposRemoveCollaboratorError::Generic { code }.into()), } } } @@ -21481,7 +22546,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_collaborator(&self, owner: &str, repo: &str, username: &str) -> Result<(), ReposRemoveCollaboratorError> { + pub fn remove_collaborator(&self, owner: &str, repo: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/collaborators/{}", super::GITHUB_BASE_API_URL, owner, repo, username); @@ -21493,7 +22558,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21505,9 +22570,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposRemoveCollaboratorError::Status422(github_response.to_json()?)), - 403 => Err(ReposRemoveCollaboratorError::Status403(github_response.to_json()?)), - code => Err(ReposRemoveCollaboratorError::Generic { code }), + 422 => Err(ReposRemoveCollaboratorError::Status422(github_response.to_json()?).into()), + 403 => Err(ReposRemoveCollaboratorError::Status403(github_response.to_json()?).into()), + code => Err(ReposRemoveCollaboratorError::Generic { code }.into()), } } } @@ -21521,19 +22586,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for remove_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#remove-status-check-contexts) /// /// --- - pub async fn remove_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveStatusCheckContexts) -> Result, ReposRemoveStatusCheckContextsError> { + pub async fn remove_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveStatusCheckContexts) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteReposRemoveStatusCheckContexts::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21545,9 +22610,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposRemoveStatusCheckContextsError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposRemoveStatusCheckContextsError::Status422(github_response.to_json_async().await?)), - code => Err(ReposRemoveStatusCheckContextsError::Generic { code }), + 404 => Err(ReposRemoveStatusCheckContextsError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposRemoveStatusCheckContextsError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposRemoveStatusCheckContextsError::Generic { code }.into()), } } } @@ -21562,19 +22627,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_status_check_contexts(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveStatusCheckContexts) -> Result, ReposRemoveStatusCheckContextsError> { + pub fn remove_status_check_contexts(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveStatusCheckContexts) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteReposRemoveStatusCheckContexts::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21586,9 +22651,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposRemoveStatusCheckContextsError::Status404(github_response.to_json()?)), - 422 => Err(ReposRemoveStatusCheckContextsError::Status422(github_response.to_json()?)), - code => Err(ReposRemoveStatusCheckContextsError::Generic { code }), + 404 => Err(ReposRemoveStatusCheckContextsError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposRemoveStatusCheckContextsError::Status422(github_response.to_json()?).into()), + code => Err(ReposRemoveStatusCheckContextsError::Generic { code }.into()), } } } @@ -21602,19 +22667,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for remove_status_check_protection](https://docs.github.com/rest/branches/branch-protection#remove-status-check-protection) /// /// --- - pub async fn remove_status_check_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposRemoveStatusCheckProtectionError> { + pub async fn remove_status_check_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21626,7 +22691,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposRemoveStatusCheckProtectionError::Generic { code }), + code => Err(ReposRemoveStatusCheckProtectionError::Generic { code }.into()), } } } @@ -21641,7 +22706,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_status_check_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), ReposRemoveStatusCheckProtectionError> { + pub fn remove_status_check_protection(&self, owner: &str, repo: &str, branch: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -21653,7 +22718,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21665,7 +22730,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposRemoveStatusCheckProtectionError::Generic { code }), + code => Err(ReposRemoveStatusCheckProtectionError::Generic { code }.into()), } } } @@ -21681,19 +22746,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for remove_team_access_restrictions](https://docs.github.com/rest/branches/branch-protection#remove-team-access-restrictions) /// /// --- - pub async fn remove_team_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveTeamAccessRestrictions) -> Result, ReposRemoveTeamAccessRestrictionsError> { + pub async fn remove_team_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveTeamAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteReposRemoveTeamAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21705,8 +22770,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposRemoveTeamAccessRestrictionsError::Status422(github_response.to_json_async().await?)), - code => Err(ReposRemoveTeamAccessRestrictionsError::Generic { code }), + 422 => Err(ReposRemoveTeamAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposRemoveTeamAccessRestrictionsError::Generic { code }.into()), } } } @@ -21723,19 +22788,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_team_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveTeamAccessRestrictions) -> Result, ReposRemoveTeamAccessRestrictionsError> { + pub fn remove_team_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveTeamAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteReposRemoveTeamAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21747,8 +22812,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposRemoveTeamAccessRestrictionsError::Status422(github_response.to_json()?)), - code => Err(ReposRemoveTeamAccessRestrictionsError::Generic { code }), + 422 => Err(ReposRemoveTeamAccessRestrictionsError::Status422(github_response.to_json()?).into()), + code => Err(ReposRemoveTeamAccessRestrictionsError::Generic { code }.into()), } } } @@ -21768,19 +22833,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for remove_user_access_restrictions](https://docs.github.com/rest/branches/branch-protection#remove-user-access-restrictions) /// /// --- - pub async fn remove_user_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveUserAccessRestrictions) -> Result, ReposRemoveUserAccessRestrictionsError> { + pub async fn remove_user_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveUserAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteReposRemoveUserAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21792,8 +22857,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposRemoveUserAccessRestrictionsError::Status422(github_response.to_json_async().await?)), - code => Err(ReposRemoveUserAccessRestrictionsError::Generic { code }), + 422 => Err(ReposRemoveUserAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposRemoveUserAccessRestrictionsError::Generic { code }.into()), } } } @@ -21814,19 +22879,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_user_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveUserAccessRestrictions) -> Result, ReposRemoveUserAccessRestrictionsError> { + pub fn remove_user_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: DeleteReposRemoveUserAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteReposRemoveUserAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21838,8 +22903,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposRemoveUserAccessRestrictionsError::Status422(github_response.to_json()?)), - code => Err(ReposRemoveUserAccessRestrictionsError::Generic { code }), + 422 => Err(ReposRemoveUserAccessRestrictionsError::Status422(github_response.to_json()?).into()), + code => Err(ReposRemoveUserAccessRestrictionsError::Generic { code }.into()), } } } @@ -21860,19 +22925,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for rename_branch](https://docs.github.com/rest/branches/branches#rename-a-branch) /// /// --- - pub async fn rename_branch_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposRenameBranch) -> Result { + pub async fn rename_branch_async(&self, owner: &str, repo: &str, branch: &str, body: PostReposRenameBranch) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/rename", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposRenameBranch::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21884,10 +22949,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposRenameBranchError::Status403(github_response.to_json_async().await?)), - 404 => Err(ReposRenameBranchError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposRenameBranchError::Status422(github_response.to_json_async().await?)), - code => Err(ReposRenameBranchError::Generic { code }), + 403 => Err(ReposRenameBranchError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(ReposRenameBranchError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposRenameBranchError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposRenameBranchError::Generic { code }.into()), } } } @@ -21909,19 +22974,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn rename_branch(&self, owner: &str, repo: &str, branch: &str, body: PostReposRenameBranch) -> Result { + pub fn rename_branch(&self, owner: &str, repo: &str, branch: &str, body: PostReposRenameBranch) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/rename", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposRenameBranch::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21933,10 +22998,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposRenameBranchError::Status403(github_response.to_json()?)), - 404 => Err(ReposRenameBranchError::Status404(github_response.to_json()?)), - 422 => Err(ReposRenameBranchError::Status422(github_response.to_json()?)), - code => Err(ReposRenameBranchError::Generic { code }), + 403 => Err(ReposRenameBranchError::Status403(github_response.to_json()?).into()), + 404 => Err(ReposRenameBranchError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposRenameBranchError::Status422(github_response.to_json()?).into()), + code => Err(ReposRenameBranchError::Generic { code }.into()), } } } @@ -21948,19 +23013,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for replace_all_topics](https://docs.github.com/rest/repos/repos#replace-all-repository-topics) /// /// --- - pub async fn replace_all_topics_async(&self, owner: &str, repo: &str, body: PutReposReplaceAllTopics) -> Result { + 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); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposReplaceAllTopics::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -21972,9 +23037,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposReplaceAllTopicsError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposReplaceAllTopicsError::Status422(github_response.to_json_async().await?)), - code => Err(ReposReplaceAllTopicsError::Generic { code }), + 404 => Err(ReposReplaceAllTopicsError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposReplaceAllTopicsError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposReplaceAllTopicsError::Generic { code }.into()), } } } @@ -21987,19 +23052,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn replace_all_topics(&self, owner: &str, repo: &str, body: PutReposReplaceAllTopics) -> Result { + 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); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposReplaceAllTopics::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22011,9 +23076,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposReplaceAllTopicsError::Status404(github_response.to_json()?)), - 422 => Err(ReposReplaceAllTopicsError::Status422(github_response.to_json()?)), - code => Err(ReposReplaceAllTopicsError::Generic { code }), + 404 => Err(ReposReplaceAllTopicsError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposReplaceAllTopicsError::Status422(github_response.to_json()?).into()), + code => Err(ReposReplaceAllTopicsError::Generic { code }.into()), } } } @@ -22029,19 +23094,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for request_pages_build](https://docs.github.com/rest/pages/pages#request-a-apiname-pages-build) /// /// --- - pub async fn request_pages_build_async(&self, owner: &str, repo: &str) -> Result { + pub async fn request_pages_build_async(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/builds", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22053,7 +23118,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposRequestPagesBuildError::Generic { code }), + code => Err(ReposRequestPagesBuildError::Generic { code }.into()), } } } @@ -22070,7 +23135,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn request_pages_build(&self, owner: &str, repo: &str) -> Result { + pub fn request_pages_build(&self, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/pages/builds", super::GITHUB_BASE_API_URL, owner, repo); @@ -22082,7 +23147,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22094,7 +23159,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposRequestPagesBuildError::Generic { code }), + code => Err(ReposRequestPagesBuildError::Generic { code }.into()), } } } @@ -22110,19 +23175,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for set_admin_branch_protection](https://docs.github.com/rest/branches/branch-protection#set-admin-branch-protection) /// /// --- - pub async fn set_admin_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub async fn set_admin_branch_protection_async(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22134,7 +23199,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposSetAdminBranchProtectionError::Generic { code }), + code => Err(ReposSetAdminBranchProtectionError::Generic { code }.into()), } } } @@ -22151,7 +23216,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_admin_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { + pub fn set_admin_branch_protection(&self, owner: &str, repo: &str, branch: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/enforce_admins", super::GITHUB_BASE_API_URL, owner, repo, branch); @@ -22163,7 +23228,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22175,7 +23240,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposSetAdminBranchProtectionError::Generic { code }), + code => Err(ReposSetAdminBranchProtectionError::Generic { code }.into()), } } } @@ -22191,19 +23256,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for set_app_access_restrictions](https://docs.github.com/rest/branches/branch-protection#set-app-access-restrictions) /// /// --- - pub async fn set_app_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetAppAccessRestrictions) -> Result, ReposSetAppAccessRestrictionsError> { + pub async fn set_app_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetAppAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposSetAppAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22215,8 +23280,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposSetAppAccessRestrictionsError::Status422(github_response.to_json_async().await?)), - code => Err(ReposSetAppAccessRestrictionsError::Generic { code }), + 422 => Err(ReposSetAppAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposSetAppAccessRestrictionsError::Generic { code }.into()), } } } @@ -22233,19 +23298,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_app_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetAppAccessRestrictions) -> Result, ReposSetAppAccessRestrictionsError> { + pub fn set_app_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetAppAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/apps", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposSetAppAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22257,8 +23322,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposSetAppAccessRestrictionsError::Status422(github_response.to_json()?)), - code => Err(ReposSetAppAccessRestrictionsError::Generic { code }), + 422 => Err(ReposSetAppAccessRestrictionsError::Status422(github_response.to_json()?).into()), + code => Err(ReposSetAppAccessRestrictionsError::Generic { code }.into()), } } } @@ -22272,19 +23337,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for set_status_check_contexts](https://docs.github.com/rest/branches/branch-protection#set-status-check-contexts) /// /// --- - pub async fn set_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetStatusCheckContexts) -> Result, ReposSetStatusCheckContextsError> { + pub async fn set_status_check_contexts_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetStatusCheckContexts) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposSetStatusCheckContexts::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22296,9 +23361,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposSetStatusCheckContextsError::Status422(github_response.to_json_async().await?)), - 404 => Err(ReposSetStatusCheckContextsError::Status404(github_response.to_json_async().await?)), - code => Err(ReposSetStatusCheckContextsError::Generic { code }), + 422 => Err(ReposSetStatusCheckContextsError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(ReposSetStatusCheckContextsError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposSetStatusCheckContextsError::Generic { code }.into()), } } } @@ -22313,19 +23378,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_status_check_contexts(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetStatusCheckContexts) -> Result, ReposSetStatusCheckContextsError> { + pub fn set_status_check_contexts(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetStatusCheckContexts) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks/contexts", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposSetStatusCheckContexts::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22337,9 +23402,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposSetStatusCheckContextsError::Status422(github_response.to_json()?)), - 404 => Err(ReposSetStatusCheckContextsError::Status404(github_response.to_json()?)), - code => Err(ReposSetStatusCheckContextsError::Generic { code }), + 422 => Err(ReposSetStatusCheckContextsError::Status422(github_response.to_json()?).into()), + 404 => Err(ReposSetStatusCheckContextsError::Status404(github_response.to_json()?).into()), + code => Err(ReposSetStatusCheckContextsError::Generic { code }.into()), } } } @@ -22355,19 +23420,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for set_team_access_restrictions](https://docs.github.com/rest/branches/branch-protection#set-team-access-restrictions) /// /// --- - pub async fn set_team_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetTeamAccessRestrictions) -> Result, ReposSetTeamAccessRestrictionsError> { + pub async fn set_team_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetTeamAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposSetTeamAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22379,8 +23444,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposSetTeamAccessRestrictionsError::Status422(github_response.to_json_async().await?)), - code => Err(ReposSetTeamAccessRestrictionsError::Generic { code }), + 422 => Err(ReposSetTeamAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposSetTeamAccessRestrictionsError::Generic { code }.into()), } } } @@ -22397,19 +23462,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_team_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetTeamAccessRestrictions) -> Result, ReposSetTeamAccessRestrictionsError> { + pub fn set_team_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetTeamAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/teams", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposSetTeamAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22421,8 +23486,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposSetTeamAccessRestrictionsError::Status422(github_response.to_json()?)), - code => Err(ReposSetTeamAccessRestrictionsError::Generic { code }), + 422 => Err(ReposSetTeamAccessRestrictionsError::Status422(github_response.to_json()?).into()), + code => Err(ReposSetTeamAccessRestrictionsError::Generic { code }.into()), } } } @@ -22442,19 +23507,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for set_user_access_restrictions](https://docs.github.com/rest/branches/branch-protection#set-user-access-restrictions) /// /// --- - pub async fn set_user_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetUserAccessRestrictions) -> Result, ReposSetUserAccessRestrictionsError> { + pub async fn set_user_access_restrictions_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetUserAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposSetUserAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22466,8 +23531,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposSetUserAccessRestrictionsError::Status422(github_response.to_json_async().await?)), - code => Err(ReposSetUserAccessRestrictionsError::Generic { code }), + 422 => Err(ReposSetUserAccessRestrictionsError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposSetUserAccessRestrictionsError::Generic { code }.into()), } } } @@ -22488,19 +23553,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_user_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetUserAccessRestrictions) -> Result, ReposSetUserAccessRestrictionsError> { + pub fn set_user_access_restrictions(&self, owner: &str, repo: &str, branch: &str, body: PutReposSetUserAccessRestrictions) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/restrictions/users", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposSetUserAccessRestrictions::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22512,8 +23577,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposSetUserAccessRestrictionsError::Status422(github_response.to_json()?)), - code => Err(ReposSetUserAccessRestrictionsError::Generic { code }), + 422 => Err(ReposSetUserAccessRestrictionsError::Status422(github_response.to_json()?).into()), + code => Err(ReposSetUserAccessRestrictionsError::Generic { code }.into()), } } } @@ -22530,19 +23595,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for test_push_webhook](https://docs.github.com/rest/repos/webhooks#test-the-push-repository-webhook) /// /// --- - pub async fn test_push_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), ReposTestPushWebhookError> { + pub async fn test_push_webhook_async(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/hooks/{}/tests", super::GITHUB_BASE_API_URL, owner, repo, hook_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22554,8 +23619,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposTestPushWebhookError::Status404(github_response.to_json_async().await?)), - code => Err(ReposTestPushWebhookError::Generic { code }), + 404 => Err(ReposTestPushWebhookError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposTestPushWebhookError::Generic { code }.into()), } } } @@ -22573,7 +23638,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn test_push_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), ReposTestPushWebhookError> { + pub fn test_push_webhook(&self, owner: &str, repo: &str, hook_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/hooks/{}/tests", super::GITHUB_BASE_API_URL, owner, repo, hook_id); @@ -22585,7 +23650,7 @@ impl<'api, C: Client> Repos<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22597,8 +23662,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposTestPushWebhookError::Status404(github_response.to_json()?)), - code => Err(ReposTestPushWebhookError::Generic { code }), + 404 => Err(ReposTestPushWebhookError::Status404(github_response.to_json()?).into()), + code => Err(ReposTestPushWebhookError::Generic { code }.into()), } } } @@ -22612,19 +23677,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for transfer](https://docs.github.com/rest/repos/repos#transfer-a-repository) /// /// --- - pub async fn transfer_async(&self, owner: &str, repo: &str, body: PostReposTransfer) -> Result { + pub async fn transfer_async(&self, owner: &str, repo: &str, body: PostReposTransfer) -> Result { let request_uri = format!("{}/repos/{}/{}/transfer", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposTransfer::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22636,7 +23701,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposTransferError::Generic { code }), + code => Err(ReposTransferError::Generic { code }.into()), } } } @@ -22651,19 +23716,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn transfer(&self, owner: &str, repo: &str, body: PostReposTransfer) -> Result { + pub fn transfer(&self, owner: &str, repo: &str, body: PostReposTransfer) -> Result { let request_uri = format!("{}/repos/{}/{}/transfer", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostReposTransfer::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22675,7 +23740,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposTransferError::Generic { code }), + code => Err(ReposTransferError::Generic { code }.into()), } } } @@ -22689,19 +23754,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update](https://docs.github.com/rest/repos/repos#update-a-repository) /// /// --- - pub async fn update_async(&self, owner: &str, repo: &str, body: PatchReposUpdate) -> Result { + pub async fn update_async(&self, owner: &str, repo: &str, body: PatchReposUpdate) -> Result { let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22713,11 +23778,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 307 => Err(ReposUpdateError::Status307(github_response.to_json_async().await?)), - 403 => Err(ReposUpdateError::Status403(github_response.to_json_async().await?)), - 422 => Err(ReposUpdateError::Status422(github_response.to_json_async().await?)), - 404 => Err(ReposUpdateError::Status404(github_response.to_json_async().await?)), - code => Err(ReposUpdateError::Generic { code }), + 307 => Err(ReposUpdateError::Status307(github_response.to_json_async().await?).into()), + 403 => Err(ReposUpdateError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(ReposUpdateError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(ReposUpdateError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposUpdateError::Generic { code }.into()), } } } @@ -22732,19 +23797,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update(&self, owner: &str, repo: &str, body: PatchReposUpdate) -> Result { + pub fn update(&self, owner: &str, repo: &str, body: PatchReposUpdate) -> Result { let request_uri = format!("{}/repos/{}/{}", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22756,11 +23821,11 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 307 => Err(ReposUpdateError::Status307(github_response.to_json()?)), - 403 => Err(ReposUpdateError::Status403(github_response.to_json()?)), - 422 => Err(ReposUpdateError::Status422(github_response.to_json()?)), - 404 => Err(ReposUpdateError::Status404(github_response.to_json()?)), - code => Err(ReposUpdateError::Generic { code }), + 307 => Err(ReposUpdateError::Status307(github_response.to_json()?).into()), + 403 => Err(ReposUpdateError::Status403(github_response.to_json()?).into()), + 422 => Err(ReposUpdateError::Status422(github_response.to_json()?).into()), + 404 => Err(ReposUpdateError::Status404(github_response.to_json()?).into()), + code => Err(ReposUpdateError::Generic { code }.into()), } } } @@ -22782,19 +23847,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_branch_protection](https://docs.github.com/rest/branches/branch-protection#update-branch-protection) /// /// --- - pub async fn update_branch_protection_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposUpdateBranchProtection) -> Result { + pub async fn update_branch_protection_async(&self, owner: &str, repo: &str, branch: &str, body: PutReposUpdateBranchProtection) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposUpdateBranchProtection::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22806,10 +23871,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(ReposUpdateBranchProtectionError::Status403(github_response.to_json_async().await?)), - 422 => Err(ReposUpdateBranchProtectionError::Status422(github_response.to_json_async().await?)), - 404 => Err(ReposUpdateBranchProtectionError::Status404(github_response.to_json_async().await?)), - code => Err(ReposUpdateBranchProtectionError::Generic { code }), + 403 => Err(ReposUpdateBranchProtectionError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(ReposUpdateBranchProtectionError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(ReposUpdateBranchProtectionError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposUpdateBranchProtectionError::Generic { code }.into()), } } } @@ -22832,19 +23897,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_branch_protection(&self, owner: &str, repo: &str, branch: &str, body: PutReposUpdateBranchProtection) -> Result { + pub fn update_branch_protection(&self, owner: &str, repo: &str, branch: &str, body: PutReposUpdateBranchProtection) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposUpdateBranchProtection::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22856,10 +23921,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(ReposUpdateBranchProtectionError::Status403(github_response.to_json()?)), - 422 => Err(ReposUpdateBranchProtectionError::Status422(github_response.to_json()?)), - 404 => Err(ReposUpdateBranchProtectionError::Status404(github_response.to_json()?)), - code => Err(ReposUpdateBranchProtectionError::Generic { code }), + 403 => Err(ReposUpdateBranchProtectionError::Status403(github_response.to_json()?).into()), + 422 => Err(ReposUpdateBranchProtectionError::Status422(github_response.to_json()?).into()), + 404 => Err(ReposUpdateBranchProtectionError::Status404(github_response.to_json()?).into()), + code => Err(ReposUpdateBranchProtectionError::Generic { code }.into()), } } } @@ -22880,19 +23945,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_commit_comment](https://docs.github.com/rest/commits/comments#update-a-commit-comment) /// /// --- - pub async fn update_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PatchReposUpdateCommitComment) -> Result { + pub async fn update_commit_comment_async(&self, owner: &str, repo: &str, comment_id: i64, body: PatchReposUpdateCommitComment) -> Result { let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateCommitComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22904,8 +23969,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposUpdateCommitCommentError::Status404(github_response.to_json_async().await?)), - code => Err(ReposUpdateCommitCommentError::Generic { code }), + 404 => Err(ReposUpdateCommitCommentError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposUpdateCommitCommentError::Generic { code }.into()), } } } @@ -22927,19 +23992,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_commit_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PatchReposUpdateCommitComment) -> Result { + pub fn update_commit_comment(&self, owner: &str, repo: &str, comment_id: i64, body: PatchReposUpdateCommitComment) -> Result { let request_uri = format!("{}/repos/{}/{}/comments/{}", super::GITHUB_BASE_API_URL, owner, repo, comment_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateCommitComment::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22951,8 +24016,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposUpdateCommitCommentError::Status404(github_response.to_json()?)), - code => Err(ReposUpdateCommitCommentError::Generic { code }), + 404 => Err(ReposUpdateCommitCommentError::Status404(github_response.to_json()?).into()), + code => Err(ReposUpdateCommitCommentError::Generic { code }.into()), } } } @@ -22968,19 +24033,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_deployment_branch_policy](https://docs.github.com/rest/deployments/branch-policies#update-a-deployment-branch-policy) /// /// --- - pub async fn update_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32, body: PutReposUpdateDeploymentBranchPolicy) -> Result { + pub async fn update_deployment_branch_policy_async(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32, body: PutReposUpdateDeploymentBranchPolicy) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposUpdateDeploymentBranchPolicy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -22992,7 +24057,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposUpdateDeploymentBranchPolicyError::Generic { code }), + code => Err(ReposUpdateDeploymentBranchPolicyError::Generic { code }.into()), } } } @@ -23009,19 +24074,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32, body: PutReposUpdateDeploymentBranchPolicy) -> Result { + pub fn update_deployment_branch_policy(&self, owner: &str, repo: &str, environment_name: &str, branch_policy_id: i32, body: PutReposUpdateDeploymentBranchPolicy) -> Result { let request_uri = format!("{}/repos/{}/{}/environments/{}/deployment-branch-policies/{}", super::GITHUB_BASE_API_URL, owner, repo, environment_name, branch_policy_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposUpdateDeploymentBranchPolicy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23033,7 +24098,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposUpdateDeploymentBranchPolicyError::Generic { code }), + code => Err(ReposUpdateDeploymentBranchPolicyError::Generic { code }.into()), } } } @@ -23051,19 +24116,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_information_about_pages_site](https://docs.github.com/rest/pages/pages#update-information-about-a-apiname-pages-site) /// /// --- - pub async fn update_information_about_pages_site_async(&self, owner: &str, repo: &str, body: PutReposUpdateInformationAboutPagesSite) -> Result<(), ReposUpdateInformationAboutPagesSiteError> { + pub async fn update_information_about_pages_site_async(&self, owner: &str, repo: &str, body: PutReposUpdateInformationAboutPagesSite) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposUpdateInformationAboutPagesSite::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23075,10 +24140,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposUpdateInformationAboutPagesSiteError::Status422(github_response.to_json_async().await?)), - 400 => Err(ReposUpdateInformationAboutPagesSiteError::Status400(github_response.to_json_async().await?)), - 409 => Err(ReposUpdateInformationAboutPagesSiteError::Status409(github_response.to_json_async().await?)), - code => Err(ReposUpdateInformationAboutPagesSiteError::Generic { code }), + 422 => Err(ReposUpdateInformationAboutPagesSiteError::Status422(github_response.to_json_async().await?).into()), + 400 => Err(ReposUpdateInformationAboutPagesSiteError::Status400(github_response.to_json_async().await?).into()), + 409 => Err(ReposUpdateInformationAboutPagesSiteError::Status409(github_response.to_json_async().await?).into()), + code => Err(ReposUpdateInformationAboutPagesSiteError::Generic { code }.into()), } } } @@ -23097,19 +24162,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_information_about_pages_site(&self, owner: &str, repo: &str, body: PutReposUpdateInformationAboutPagesSite) -> Result<(), ReposUpdateInformationAboutPagesSiteError> { + pub fn update_information_about_pages_site(&self, owner: &str, repo: &str, body: PutReposUpdateInformationAboutPagesSite) -> Result<(), AdapterError> { let request_uri = format!("{}/repos/{}/{}/pages", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposUpdateInformationAboutPagesSite::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23121,10 +24186,10 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposUpdateInformationAboutPagesSiteError::Status422(github_response.to_json()?)), - 400 => Err(ReposUpdateInformationAboutPagesSiteError::Status400(github_response.to_json()?)), - 409 => Err(ReposUpdateInformationAboutPagesSiteError::Status409(github_response.to_json()?)), - code => Err(ReposUpdateInformationAboutPagesSiteError::Generic { code }), + 422 => Err(ReposUpdateInformationAboutPagesSiteError::Status422(github_response.to_json()?).into()), + 400 => Err(ReposUpdateInformationAboutPagesSiteError::Status400(github_response.to_json()?).into()), + 409 => Err(ReposUpdateInformationAboutPagesSiteError::Status409(github_response.to_json()?).into()), + code => Err(ReposUpdateInformationAboutPagesSiteError::Generic { code }.into()), } } } @@ -23136,19 +24201,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_invitation](https://docs.github.com/rest/collaborators/invitations#update-a-repository-invitation) /// /// --- - pub async fn update_invitation_async(&self, owner: &str, repo: &str, invitation_id: i32, body: PatchReposUpdateInvitation) -> Result { + pub async fn update_invitation_async(&self, owner: &str, repo: &str, invitation_id: i32, body: PatchReposUpdateInvitation) -> Result { let request_uri = format!("{}/repos/{}/{}/invitations/{}", super::GITHUB_BASE_API_URL, owner, repo, invitation_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateInvitation::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23160,7 +24225,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposUpdateInvitationError::Generic { code }), + code => Err(ReposUpdateInvitationError::Generic { code }.into()), } } } @@ -23173,19 +24238,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_invitation(&self, owner: &str, repo: &str, invitation_id: i32, body: PatchReposUpdateInvitation) -> Result { + pub fn update_invitation(&self, owner: &str, repo: &str, invitation_id: i32, body: PatchReposUpdateInvitation) -> Result { let request_uri = format!("{}/repos/{}/{}/invitations/{}", super::GITHUB_BASE_API_URL, owner, repo, invitation_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateInvitation::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23197,7 +24262,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposUpdateInvitationError::Generic { code }), + code => Err(ReposUpdateInvitationError::Generic { code }.into()), } } } @@ -23211,19 +24276,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_org_ruleset](https://docs.github.com/rest/orgs/rules#update-an-organization-repository-ruleset) /// /// --- - pub async fn update_org_ruleset_async(&self, org: &str, ruleset_id: i32, body: PutReposUpdateOrgRuleset) -> Result { + pub async fn update_org_ruleset_async(&self, org: &str, ruleset_id: i32, body: PutReposUpdateOrgRuleset) -> Result { let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposUpdateOrgRuleset::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23235,9 +24300,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposUpdateOrgRulesetError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposUpdateOrgRulesetError::Status500(github_response.to_json_async().await?)), - code => Err(ReposUpdateOrgRulesetError::Generic { code }), + 404 => Err(ReposUpdateOrgRulesetError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposUpdateOrgRulesetError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposUpdateOrgRulesetError::Generic { code }.into()), } } } @@ -23252,19 +24317,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_org_ruleset(&self, org: &str, ruleset_id: i32, body: PutReposUpdateOrgRuleset) -> Result { + pub fn update_org_ruleset(&self, org: &str, ruleset_id: i32, body: PutReposUpdateOrgRuleset) -> Result { let request_uri = format!("{}/orgs/{}/rulesets/{}", super::GITHUB_BASE_API_URL, org, ruleset_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposUpdateOrgRuleset::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23276,9 +24341,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposUpdateOrgRulesetError::Status404(github_response.to_json()?)), - 500 => Err(ReposUpdateOrgRulesetError::Status500(github_response.to_json()?)), - code => Err(ReposUpdateOrgRulesetError::Generic { code }), + 404 => Err(ReposUpdateOrgRulesetError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposUpdateOrgRulesetError::Status500(github_response.to_json()?).into()), + code => Err(ReposUpdateOrgRulesetError::Generic { code }.into()), } } } @@ -23297,19 +24362,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_pull_request_review_protection](https://docs.github.com/rest/branches/branch-protection#update-pull-request-review-protection) /// /// --- - pub async fn update_pull_request_review_protection_async(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdatePullRequestReviewProtection) -> Result { + pub async fn update_pull_request_review_protection_async(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdatePullRequestReviewProtection) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdatePullRequestReviewProtection::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23321,8 +24386,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposUpdatePullRequestReviewProtectionError::Status422(github_response.to_json_async().await?)), - code => Err(ReposUpdatePullRequestReviewProtectionError::Generic { code }), + 422 => Err(ReposUpdatePullRequestReviewProtectionError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposUpdatePullRequestReviewProtectionError::Generic { code }.into()), } } } @@ -23342,19 +24407,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_pull_request_review_protection(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdatePullRequestReviewProtection) -> Result { + pub fn update_pull_request_review_protection(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdatePullRequestReviewProtection) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_pull_request_reviews", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdatePullRequestReviewProtection::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23366,8 +24431,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposUpdatePullRequestReviewProtectionError::Status422(github_response.to_json()?)), - code => Err(ReposUpdatePullRequestReviewProtectionError::Generic { code }), + 422 => Err(ReposUpdatePullRequestReviewProtectionError::Status422(github_response.to_json()?).into()), + code => Err(ReposUpdatePullRequestReviewProtectionError::Generic { code }.into()), } } } @@ -23381,19 +24446,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_release](https://docs.github.com/rest/releases/releases#update-a-release) /// /// --- - pub async fn update_release_async(&self, owner: &str, repo: &str, release_id: i32, body: PatchReposUpdateRelease) -> Result { + pub async fn update_release_async(&self, owner: &str, repo: &str, release_id: i32, body: PatchReposUpdateRelease) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateRelease::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23405,8 +24470,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposUpdateReleaseError::Status404(github_response.to_json_async().await?)), - code => Err(ReposUpdateReleaseError::Generic { code }), + 404 => Err(ReposUpdateReleaseError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposUpdateReleaseError::Generic { code }.into()), } } } @@ -23421,19 +24486,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_release(&self, owner: &str, repo: &str, release_id: i32, body: PatchReposUpdateRelease) -> Result { + pub fn update_release(&self, owner: &str, repo: &str, release_id: i32, body: PatchReposUpdateRelease) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/{}", super::GITHUB_BASE_API_URL, owner, repo, release_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateRelease::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23445,8 +24510,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposUpdateReleaseError::Status404(github_response.to_json()?)), - code => Err(ReposUpdateReleaseError::Generic { code }), + 404 => Err(ReposUpdateReleaseError::Status404(github_response.to_json()?).into()), + code => Err(ReposUpdateReleaseError::Generic { code }.into()), } } } @@ -23460,19 +24525,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_release_asset](https://docs.github.com/rest/releases/assets#update-a-release-asset) /// /// --- - pub async fn update_release_asset_async(&self, owner: &str, repo: &str, asset_id: i32, body: PatchReposUpdateReleaseAsset) -> Result { + pub async fn update_release_asset_async(&self, owner: &str, repo: &str, asset_id: i32, body: PatchReposUpdateReleaseAsset) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateReleaseAsset::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23484,7 +24549,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposUpdateReleaseAssetError::Generic { code }), + code => Err(ReposUpdateReleaseAssetError::Generic { code }.into()), } } } @@ -23499,19 +24564,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_release_asset(&self, owner: &str, repo: &str, asset_id: i32, body: PatchReposUpdateReleaseAsset) -> Result { + pub fn update_release_asset(&self, owner: &str, repo: &str, asset_id: i32, body: PatchReposUpdateReleaseAsset) -> Result { let request_uri = format!("{}/repos/{}/{}/releases/assets/{}", super::GITHUB_BASE_API_URL, owner, repo, asset_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateReleaseAsset::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23523,7 +24588,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposUpdateReleaseAssetError::Generic { code }), + code => Err(ReposUpdateReleaseAssetError::Generic { code }.into()), } } } @@ -23537,19 +24602,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_repo_ruleset](https://docs.github.com/rest/repos/rules#update-a-repository-ruleset) /// /// --- - pub async fn update_repo_ruleset_async(&self, owner: &str, repo: &str, ruleset_id: i32, body: PutReposUpdateRepoRuleset) -> Result { + pub async fn update_repo_ruleset_async(&self, owner: &str, repo: &str, ruleset_id: i32, body: PutReposUpdateRepoRuleset) -> Result { let request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, ruleset_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposUpdateRepoRuleset::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23561,9 +24626,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposUpdateRepoRulesetError::Status404(github_response.to_json_async().await?)), - 500 => Err(ReposUpdateRepoRulesetError::Status500(github_response.to_json_async().await?)), - code => Err(ReposUpdateRepoRulesetError::Generic { code }), + 404 => Err(ReposUpdateRepoRulesetError::Status404(github_response.to_json_async().await?).into()), + 500 => Err(ReposUpdateRepoRulesetError::Status500(github_response.to_json_async().await?).into()), + code => Err(ReposUpdateRepoRulesetError::Generic { code }.into()), } } } @@ -23578,19 +24643,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_repo_ruleset(&self, owner: &str, repo: &str, ruleset_id: i32, body: PutReposUpdateRepoRuleset) -> Result { + pub fn update_repo_ruleset(&self, owner: &str, repo: &str, ruleset_id: i32, body: PutReposUpdateRepoRuleset) -> Result { let request_uri = format!("{}/repos/{}/{}/rulesets/{}", super::GITHUB_BASE_API_URL, owner, repo, ruleset_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutReposUpdateRepoRuleset::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23602,9 +24667,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposUpdateRepoRulesetError::Status404(github_response.to_json()?)), - 500 => Err(ReposUpdateRepoRulesetError::Status500(github_response.to_json()?)), - code => Err(ReposUpdateRepoRulesetError::Generic { code }), + 404 => Err(ReposUpdateRepoRulesetError::Status404(github_response.to_json()?).into()), + 500 => Err(ReposUpdateRepoRulesetError::Status500(github_response.to_json()?).into()), + code => Err(ReposUpdateRepoRulesetError::Generic { code }.into()), } } } @@ -23620,19 +24685,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_status_check_protection](https://docs.github.com/rest/branches/branch-protection#update-status-check-protection) /// /// --- - pub async fn update_status_check_protection_async(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdateStatusCheckProtection) -> Result { + pub async fn update_status_check_protection_async(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdateStatusCheckProtection) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateStatusCheckProtection::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23644,9 +24709,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(ReposUpdateStatusCheckProtectionError::Status404(github_response.to_json_async().await?)), - 422 => Err(ReposUpdateStatusCheckProtectionError::Status422(github_response.to_json_async().await?)), - code => Err(ReposUpdateStatusCheckProtectionError::Generic { code }), + 404 => Err(ReposUpdateStatusCheckProtectionError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(ReposUpdateStatusCheckProtectionError::Status422(github_response.to_json_async().await?).into()), + code => Err(ReposUpdateStatusCheckProtectionError::Generic { code }.into()), } } } @@ -23663,19 +24728,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_status_check_protection(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdateStatusCheckProtection) -> Result { + pub fn update_status_check_protection(&self, owner: &str, repo: &str, branch: &str, body: PatchReposUpdateStatusCheckProtection) -> Result { let request_uri = format!("{}/repos/{}/{}/branches/{}/protection/required_status_checks", super::GITHUB_BASE_API_URL, owner, repo, branch); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateStatusCheckProtection::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23687,9 +24752,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(ReposUpdateStatusCheckProtectionError::Status404(github_response.to_json()?)), - 422 => Err(ReposUpdateStatusCheckProtectionError::Status422(github_response.to_json()?)), - code => Err(ReposUpdateStatusCheckProtectionError::Generic { code }), + 404 => Err(ReposUpdateStatusCheckProtectionError::Status404(github_response.to_json()?).into()), + 422 => Err(ReposUpdateStatusCheckProtectionError::Status422(github_response.to_json()?).into()), + code => Err(ReposUpdateStatusCheckProtectionError::Generic { code }.into()), } } } @@ -23703,19 +24768,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_webhook](https://docs.github.com/rest/repos/webhooks#update-a-repository-webhook) /// /// --- - pub async fn update_webhook_async(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhook) -> Result { + pub async fn update_webhook_async(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhook) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, hook_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateWebhook::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23727,9 +24792,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposUpdateWebhookError::Status422(github_response.to_json_async().await?)), - 404 => Err(ReposUpdateWebhookError::Status404(github_response.to_json_async().await?)), - code => Err(ReposUpdateWebhookError::Generic { code }), + 422 => Err(ReposUpdateWebhookError::Status422(github_response.to_json_async().await?).into()), + 404 => Err(ReposUpdateWebhookError::Status404(github_response.to_json_async().await?).into()), + code => Err(ReposUpdateWebhookError::Generic { code }.into()), } } } @@ -23744,19 +24809,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_webhook(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhook) -> Result { + pub fn update_webhook(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhook) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks/{}", super::GITHUB_BASE_API_URL, owner, repo, hook_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateWebhook::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23768,9 +24833,9 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposUpdateWebhookError::Status422(github_response.to_json()?)), - 404 => Err(ReposUpdateWebhookError::Status404(github_response.to_json()?)), - code => Err(ReposUpdateWebhookError::Generic { code }), + 422 => Err(ReposUpdateWebhookError::Status422(github_response.to_json()?).into()), + 404 => Err(ReposUpdateWebhookError::Status404(github_response.to_json()?).into()), + code => Err(ReposUpdateWebhookError::Generic { code }.into()), } } } @@ -23786,19 +24851,19 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for update_webhook_config_for_repo](https://docs.github.com/rest/repos/webhooks#update-a-webhook-configuration-for-a-repository) /// /// --- - pub async fn update_webhook_config_for_repo_async(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhookConfigForRepo) -> Result { + pub async fn update_webhook_config_for_repo_async(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhookConfigForRepo) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, owner, repo, hook_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateWebhookConfigForRepo::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23810,7 +24875,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(ReposUpdateWebhookConfigForRepoError::Generic { code }), + code => Err(ReposUpdateWebhookConfigForRepoError::Generic { code }.into()), } } } @@ -23827,19 +24892,19 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_webhook_config_for_repo(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhookConfigForRepo) -> Result { + pub fn update_webhook_config_for_repo(&self, owner: &str, repo: &str, hook_id: i32, body: PatchReposUpdateWebhookConfigForRepo) -> Result { let request_uri = format!("{}/repos/{}/{}/hooks/{}/config", super::GITHUB_BASE_API_URL, owner, repo, hook_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchReposUpdateWebhookConfigForRepo::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23851,7 +24916,7 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(ReposUpdateWebhookConfigForRepoError::Generic { code }), + code => Err(ReposUpdateWebhookConfigForRepoError::Generic { code }.into()), } } } @@ -23883,7 +24948,7 @@ impl<'api, C: Client> Repos<'api, C> { /// [GitHub API docs for upload_release_asset](https://docs.github.com/rest/releases/assets#upload-a-release-asset) /// /// --- - pub async fn upload_release_asset_async(&self, owner: &str, repo: &str, release_id: i32, query_params: impl Into>, body: std::vec::Vec) -> Result { + pub async fn upload_release_asset_async(&self, owner: &str, repo: &str, release_id: i32, query_params: impl Into>, body: std::vec::Vec) -> Result { let mut request_uri = format!("{}/repos/{}/{}/releases/{}/assets", super::GITHUB_BASE_API_URL, owner, repo, release_id); @@ -23892,12 +24957,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: Some(body.into()), + body: Some(C::from_json::>(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23909,8 +24974,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(ReposUploadReleaseAssetError::Status422), - code => Err(ReposUploadReleaseAssetError::Generic { code }), + 422 => Err(ReposUploadReleaseAssetError::Status422.into()), + code => Err(ReposUploadReleaseAssetError::Generic { code }.into()), } } } @@ -23943,7 +25008,7 @@ impl<'api, C: Client> Repos<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn upload_release_asset(&self, owner: &str, repo: &str, release_id: i32, query_params: impl Into>, body: std::vec::Vec) -> Result { + pub fn upload_release_asset(&self, owner: &str, repo: &str, release_id: i32, query_params: impl Into>, body: std::vec::Vec) -> Result { let mut request_uri = format!("{}/repos/{}/{}/releases/{}/assets", super::GITHUB_BASE_API_URL, owner, repo, release_id); @@ -23953,12 +25018,12 @@ impl<'api, C: Client> Repos<'api, C> { let req = GitHubRequest { uri: request_uri, - body: Some(body.into()), + body: Some(C::from_json::>(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -23970,8 +25035,8 @@ impl<'api, C: Client> Repos<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(ReposUploadReleaseAssetError::Status422), - code => Err(ReposUploadReleaseAssetError::Generic { code }), + 422 => Err(ReposUploadReleaseAssetError::Status422.into()), + code => Err(ReposUploadReleaseAssetError::Generic { code }.into()), } } } diff --git a/src/endpoints/search.rs b/src/endpoints/search.rs index 59f7a0f..f76f840 100644 --- a/src/endpoints/search.rs +++ b/src/endpoints/search.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Search<'api, C: Client> { +pub struct Search<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Search { +pub fn new(client: &C) -> Search where AdapterError: From<::Err> { Search { client } } /// Errors for the [Search code](Search::code_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SearchCodeError { - #[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("Service unavailable")] @@ -55,38 +45,51 @@ pub enum SearchCodeError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SearchCodeError) -> Self { + let (description, status_code) = match err { + SearchCodeError::Status304 => (String::from("Not modified"), 304), + SearchCodeError::Status503(_) => (String::from("Service unavailable"), 503), + SearchCodeError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + SearchCodeError::Status403(_) => (String::from("Forbidden"), 403), + SearchCodeError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Search commits](Search::commits_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SearchCommitsError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SearchCommitsError) -> Self { + let (description, status_code) = match err { + SearchCommitsError::Status304 => (String::from("Not modified"), 304), + SearchCommitsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Search issues and pull requests](Search::issues_and_pull_requests_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SearchIssuesAndPullRequestsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Service unavailable")] Status503(PostCodespacesCreateForAuthenticatedUserResponse503), #[error("Validation failed, or the endpoint has been spammed.")] @@ -99,19 +102,27 @@ pub enum SearchIssuesAndPullRequestsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SearchIssuesAndPullRequestsError) -> Self { + let (description, status_code) = match err { + SearchIssuesAndPullRequestsError::Status503(_) => (String::from("Service unavailable"), 503), + SearchIssuesAndPullRequestsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + SearchIssuesAndPullRequestsError::Status304 => (String::from("Not modified"), 304), + SearchIssuesAndPullRequestsError::Status403(_) => (String::from("Forbidden"), 403), + SearchIssuesAndPullRequestsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Search labels](Search::labels_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SearchLabelsError { - #[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("Resource not found")] @@ -124,19 +135,27 @@ pub enum SearchLabelsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SearchLabelsError) -> Self { + let (description, status_code) = match err { + SearchLabelsError::Status304 => (String::from("Not modified"), 304), + SearchLabelsError::Status404(_) => (String::from("Resource not found"), 404), + SearchLabelsError::Status403(_) => (String::from("Forbidden"), 403), + SearchLabelsError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + SearchLabelsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Search repositories](Search::repos_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SearchReposError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Service unavailable")] Status503(PostCodespacesCreateForAuthenticatedUserResponse503), #[error("Validation failed, or the endpoint has been spammed.")] @@ -147,38 +166,50 @@ pub enum SearchReposError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SearchReposError) -> Self { + let (description, status_code) = match err { + SearchReposError::Status503(_) => (String::from("Service unavailable"), 503), + SearchReposError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + SearchReposError::Status304 => (String::from("Not modified"), 304), + SearchReposError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Search topics](Search::topics_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SearchTopicsError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SearchTopicsError) -> Self { + let (description, status_code) = match err { + SearchTopicsError::Status304 => (String::from("Not modified"), 304), + SearchTopicsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Search users](Search::users_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SearchUsersError { - #[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("Service unavailable")] @@ -189,6 +220,23 @@ pub enum SearchUsersError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SearchUsersError) -> Self { + let (description, status_code) = match err { + SearchUsersError::Status304 => (String::from("Not modified"), 304), + SearchUsersError::Status503(_) => (String::from("Service unavailable"), 503), + SearchUsersError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + SearchUsersError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [Search code](Search::code_async()) endpoint. #[derive(Default, Serialize)] @@ -773,7 +821,7 @@ impl<'enc> From<&'enc PerPage> for SearchUsersParams<'enc> { } } -impl<'api, C: Client> Search<'api, C> { +impl<'api, C: Client> Search<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Search code @@ -802,7 +850,7 @@ impl<'api, C: Client> Search<'api, C> { /// [GitHub API docs for code](https://docs.github.com/rest/search/search#search-code) /// /// --- - pub async fn code_async(&self, query_params: impl Into>) -> Result { + pub async fn code_async(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/code", super::GITHUB_BASE_API_URL); @@ -811,12 +859,12 @@ impl<'api, C: Client> Search<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -828,11 +876,11 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(SearchCodeError::Status304), - 503 => Err(SearchCodeError::Status503(github_response.to_json_async().await?)), - 422 => Err(SearchCodeError::Status422(github_response.to_json_async().await?)), - 403 => Err(SearchCodeError::Status403(github_response.to_json_async().await?)), - code => Err(SearchCodeError::Generic { code }), + 304 => Err(SearchCodeError::Status304.into()), + 503 => Err(SearchCodeError::Status503(github_response.to_json_async().await?).into()), + 422 => Err(SearchCodeError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(SearchCodeError::Status403(github_response.to_json_async().await?).into()), + code => Err(SearchCodeError::Generic { code }.into()), } } } @@ -866,7 +914,7 @@ impl<'api, C: Client> Search<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn code(&self, query_params: impl Into>) -> Result { + pub fn code(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/code", super::GITHUB_BASE_API_URL); @@ -881,7 +929,7 @@ impl<'api, C: Client> Search<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -893,11 +941,11 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(SearchCodeError::Status304), - 503 => Err(SearchCodeError::Status503(github_response.to_json()?)), - 422 => Err(SearchCodeError::Status422(github_response.to_json()?)), - 403 => Err(SearchCodeError::Status403(github_response.to_json()?)), - code => Err(SearchCodeError::Generic { code }), + 304 => Err(SearchCodeError::Status304.into()), + 503 => Err(SearchCodeError::Status503(github_response.to_json()?).into()), + 422 => Err(SearchCodeError::Status422(github_response.to_json()?).into()), + 403 => Err(SearchCodeError::Status403(github_response.to_json()?).into()), + code => Err(SearchCodeError::Generic { code }.into()), } } } @@ -918,7 +966,7 @@ impl<'api, C: Client> Search<'api, C> { /// [GitHub API docs for commits](https://docs.github.com/rest/search/search#search-commits) /// /// --- - pub async fn commits_async(&self, query_params: impl Into>) -> Result { + pub async fn commits_async(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/commits", super::GITHUB_BASE_API_URL); @@ -927,12 +975,12 @@ impl<'api, C: Client> Search<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -944,8 +992,8 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(SearchCommitsError::Status304), - code => Err(SearchCommitsError::Generic { code }), + 304 => Err(SearchCommitsError::Status304.into()), + code => Err(SearchCommitsError::Generic { code }.into()), } } } @@ -967,7 +1015,7 @@ impl<'api, C: Client> Search<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn commits(&self, query_params: impl Into>) -> Result { + pub fn commits(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/commits", super::GITHUB_BASE_API_URL); @@ -982,7 +1030,7 @@ impl<'api, C: Client> Search<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -994,8 +1042,8 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(SearchCommitsError::Status304), - code => Err(SearchCommitsError::Generic { code }), + 304 => Err(SearchCommitsError::Status304.into()), + code => Err(SearchCommitsError::Generic { code }.into()), } } } @@ -1021,7 +1069,7 @@ impl<'api, C: Client> Search<'api, C> { /// [GitHub API docs for issues_and_pull_requests](https://docs.github.com/rest/search/search#search-issues-and-pull-requests) /// /// --- - pub async fn issues_and_pull_requests_async(&self, query_params: impl Into>) -> Result { + pub async fn issues_and_pull_requests_async(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/issues", super::GITHUB_BASE_API_URL); @@ -1030,12 +1078,12 @@ impl<'api, C: Client> Search<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1047,11 +1095,11 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 503 => Err(SearchIssuesAndPullRequestsError::Status503(github_response.to_json_async().await?)), - 422 => Err(SearchIssuesAndPullRequestsError::Status422(github_response.to_json_async().await?)), - 304 => Err(SearchIssuesAndPullRequestsError::Status304), - 403 => Err(SearchIssuesAndPullRequestsError::Status403(github_response.to_json_async().await?)), - code => Err(SearchIssuesAndPullRequestsError::Generic { code }), + 503 => Err(SearchIssuesAndPullRequestsError::Status503(github_response.to_json_async().await?).into()), + 422 => Err(SearchIssuesAndPullRequestsError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(SearchIssuesAndPullRequestsError::Status304.into()), + 403 => Err(SearchIssuesAndPullRequestsError::Status403(github_response.to_json_async().await?).into()), + code => Err(SearchIssuesAndPullRequestsError::Generic { code }.into()), } } } @@ -1078,7 +1126,7 @@ impl<'api, C: Client> Search<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn issues_and_pull_requests(&self, query_params: impl Into>) -> Result { + pub fn issues_and_pull_requests(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/issues", super::GITHUB_BASE_API_URL); @@ -1093,7 +1141,7 @@ impl<'api, C: Client> Search<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1105,11 +1153,11 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 503 => Err(SearchIssuesAndPullRequestsError::Status503(github_response.to_json()?)), - 422 => Err(SearchIssuesAndPullRequestsError::Status422(github_response.to_json()?)), - 304 => Err(SearchIssuesAndPullRequestsError::Status304), - 403 => Err(SearchIssuesAndPullRequestsError::Status403(github_response.to_json()?)), - code => Err(SearchIssuesAndPullRequestsError::Generic { code }), + 503 => Err(SearchIssuesAndPullRequestsError::Status503(github_response.to_json()?).into()), + 422 => Err(SearchIssuesAndPullRequestsError::Status422(github_response.to_json()?).into()), + 304 => Err(SearchIssuesAndPullRequestsError::Status304.into()), + 403 => Err(SearchIssuesAndPullRequestsError::Status403(github_response.to_json()?).into()), + code => Err(SearchIssuesAndPullRequestsError::Generic { code }.into()), } } } @@ -1131,7 +1179,7 @@ impl<'api, C: Client> Search<'api, C> { /// [GitHub API docs for labels](https://docs.github.com/rest/search/search#search-labels) /// /// --- - pub async fn labels_async(&self, query_params: impl Into>) -> Result { + pub async fn labels_async(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/labels", super::GITHUB_BASE_API_URL); @@ -1140,12 +1188,12 @@ impl<'api, C: Client> Search<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1157,11 +1205,11 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(SearchLabelsError::Status304), - 404 => Err(SearchLabelsError::Status404(github_response.to_json_async().await?)), - 403 => Err(SearchLabelsError::Status403(github_response.to_json_async().await?)), - 422 => Err(SearchLabelsError::Status422(github_response.to_json_async().await?)), - code => Err(SearchLabelsError::Generic { code }), + 304 => Err(SearchLabelsError::Status304.into()), + 404 => Err(SearchLabelsError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(SearchLabelsError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(SearchLabelsError::Status422(github_response.to_json_async().await?).into()), + code => Err(SearchLabelsError::Generic { code }.into()), } } } @@ -1184,7 +1232,7 @@ impl<'api, C: Client> Search<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn labels(&self, query_params: impl Into>) -> Result { + pub fn labels(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/labels", super::GITHUB_BASE_API_URL); @@ -1199,7 +1247,7 @@ impl<'api, C: Client> Search<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1211,11 +1259,11 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(SearchLabelsError::Status304), - 404 => Err(SearchLabelsError::Status404(github_response.to_json()?)), - 403 => Err(SearchLabelsError::Status403(github_response.to_json()?)), - 422 => Err(SearchLabelsError::Status422(github_response.to_json()?)), - code => Err(SearchLabelsError::Generic { code }), + 304 => Err(SearchLabelsError::Status304.into()), + 404 => Err(SearchLabelsError::Status404(github_response.to_json()?).into()), + 403 => Err(SearchLabelsError::Status403(github_response.to_json()?).into()), + 422 => Err(SearchLabelsError::Status422(github_response.to_json()?).into()), + code => Err(SearchLabelsError::Generic { code }.into()), } } } @@ -1237,7 +1285,7 @@ impl<'api, C: Client> Search<'api, C> { /// [GitHub API docs for repos](https://docs.github.com/rest/search/search#search-repositories) /// /// --- - pub async fn repos_async(&self, query_params: impl Into>) -> Result { + pub async fn repos_async(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/repositories", super::GITHUB_BASE_API_URL); @@ -1246,12 +1294,12 @@ impl<'api, C: Client> Search<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1263,10 +1311,10 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 503 => Err(SearchReposError::Status503(github_response.to_json_async().await?)), - 422 => Err(SearchReposError::Status422(github_response.to_json_async().await?)), - 304 => Err(SearchReposError::Status304), - code => Err(SearchReposError::Generic { code }), + 503 => Err(SearchReposError::Status503(github_response.to_json_async().await?).into()), + 422 => Err(SearchReposError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(SearchReposError::Status304.into()), + code => Err(SearchReposError::Generic { code }.into()), } } } @@ -1289,7 +1337,7 @@ impl<'api, C: Client> Search<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn repos(&self, query_params: impl Into>) -> Result { + pub fn repos(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/repositories", super::GITHUB_BASE_API_URL); @@ -1304,7 +1352,7 @@ impl<'api, C: Client> Search<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1316,10 +1364,10 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 503 => Err(SearchReposError::Status503(github_response.to_json()?)), - 422 => Err(SearchReposError::Status422(github_response.to_json()?)), - 304 => Err(SearchReposError::Status304), - code => Err(SearchReposError::Generic { code }), + 503 => Err(SearchReposError::Status503(github_response.to_json()?).into()), + 422 => Err(SearchReposError::Status422(github_response.to_json()?).into()), + 304 => Err(SearchReposError::Status304.into()), + code => Err(SearchReposError::Generic { code }.into()), } } } @@ -1341,7 +1389,7 @@ impl<'api, C: Client> Search<'api, C> { /// [GitHub API docs for topics](https://docs.github.com/rest/search/search#search-topics) /// /// --- - pub async fn topics_async(&self, query_params: impl Into>) -> Result { + pub async fn topics_async(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/topics", super::GITHUB_BASE_API_URL); @@ -1350,12 +1398,12 @@ impl<'api, C: Client> Search<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1367,8 +1415,8 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(SearchTopicsError::Status304), - code => Err(SearchTopicsError::Generic { code }), + 304 => Err(SearchTopicsError::Status304.into()), + code => Err(SearchTopicsError::Generic { code }.into()), } } } @@ -1391,7 +1439,7 @@ impl<'api, C: Client> Search<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn topics(&self, query_params: impl Into>) -> Result { + pub fn topics(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/topics", super::GITHUB_BASE_API_URL); @@ -1406,7 +1454,7 @@ impl<'api, C: Client> Search<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1418,8 +1466,8 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(SearchTopicsError::Status304), - code => Err(SearchTopicsError::Generic { code }), + 304 => Err(SearchTopicsError::Status304.into()), + code => Err(SearchTopicsError::Generic { code }.into()), } } } @@ -1443,7 +1491,7 @@ impl<'api, C: Client> Search<'api, C> { /// [GitHub API docs for users](https://docs.github.com/rest/search/search#search-users) /// /// --- - pub async fn users_async(&self, query_params: impl Into>) -> Result { + pub async fn users_async(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/users", super::GITHUB_BASE_API_URL); @@ -1452,12 +1500,12 @@ impl<'api, C: Client> Search<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1469,10 +1517,10 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(SearchUsersError::Status304), - 503 => Err(SearchUsersError::Status503(github_response.to_json_async().await?)), - 422 => Err(SearchUsersError::Status422(github_response.to_json_async().await?)), - code => Err(SearchUsersError::Generic { code }), + 304 => Err(SearchUsersError::Status304.into()), + 503 => Err(SearchUsersError::Status503(github_response.to_json_async().await?).into()), + 422 => Err(SearchUsersError::Status422(github_response.to_json_async().await?).into()), + code => Err(SearchUsersError::Generic { code }.into()), } } } @@ -1497,7 +1545,7 @@ impl<'api, C: Client> Search<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn users(&self, query_params: impl Into>) -> Result { + pub fn users(&self, query_params: impl Into>) -> Result { let mut request_uri = format!("{}/search/users", super::GITHUB_BASE_API_URL); @@ -1512,7 +1560,7 @@ impl<'api, C: Client> Search<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1524,10 +1572,10 @@ impl<'api, C: Client> Search<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(SearchUsersError::Status304), - 503 => Err(SearchUsersError::Status503(github_response.to_json()?)), - 422 => Err(SearchUsersError::Status422(github_response.to_json()?)), - code => Err(SearchUsersError::Generic { code }), + 304 => Err(SearchUsersError::Status304.into()), + 503 => Err(SearchUsersError::Status503(github_response.to_json()?).into()), + 422 => Err(SearchUsersError::Status422(github_response.to_json()?).into()), + code => Err(SearchUsersError::Generic { code }.into()), } } } diff --git a/src/endpoints/secret_scanning.rs b/src/endpoints/secret_scanning.rs index 1dc6ac2..a1d23c0 100644 --- a/src/endpoints/secret_scanning.rs +++ b/src/endpoints/secret_scanning.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct SecretScanning<'api, C: Client> { +pub struct SecretScanning<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> SecretScanning { +pub fn new(client: &C) -> SecretScanning where AdapterError: From<::Err> { SecretScanning { client } } /// Errors for the [Create a push protection bypass](SecretScanning::create_push_protection_bypass_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecretScanningCreatePushProtectionBypassError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("User does not have enough permissions to perform this action.")] Status403, #[error("Placeholder ID not found, or push protection is disabled on this repository.")] @@ -55,19 +45,27 @@ pub enum SecretScanningCreatePushProtectionBypassError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecretScanningCreatePushProtectionBypassError) -> Self { + let (description, status_code) = match err { + SecretScanningCreatePushProtectionBypassError::Status403 => (String::from("User does not have enough permissions to perform this action."), 403), + SecretScanningCreatePushProtectionBypassError::Status404 => (String::from("Placeholder ID not found, or push protection is disabled on this repository."), 404), + SecretScanningCreatePushProtectionBypassError::Status422 => (String::from("Bad request, input data missing or incorrect."), 422), + SecretScanningCreatePushProtectionBypassError::Status503(_) => (String::from("Service unavailable"), 503), + SecretScanningCreatePushProtectionBypassError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a secret scanning alert](SecretScanning::get_alert_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecretScanningGetAlertError { - #[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("Repository is public, or secret scanning is disabled for the repository, or the resource is not found")] @@ -78,19 +76,26 @@ pub enum SecretScanningGetAlertError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecretScanningGetAlertError) -> Self { + let (description, status_code) = match err { + SecretScanningGetAlertError::Status304 => (String::from("Not modified"), 304), + SecretScanningGetAlertError::Status404 => (String::from("Repository is public, or secret scanning is disabled for the repository, or the resource is not found"), 404), + SecretScanningGetAlertError::Status503(_) => (String::from("Service unavailable"), 503), + SecretScanningGetAlertError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List secret scanning alerts for an enterprise](SecretScanning::list_alerts_for_enterprise_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecretScanningListAlertsForEnterpriseError { - #[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("Service unavailable")] @@ -99,19 +104,25 @@ pub enum SecretScanningListAlertsForEnterpriseError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecretScanningListAlertsForEnterpriseError) -> Self { + let (description, status_code) = match err { + SecretScanningListAlertsForEnterpriseError::Status404(_) => (String::from("Resource not found"), 404), + SecretScanningListAlertsForEnterpriseError::Status503(_) => (String::from("Service unavailable"), 503), + SecretScanningListAlertsForEnterpriseError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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)] - 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("Service unavailable")] @@ -120,19 +131,25 @@ pub enum SecretScanningListAlertsForOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecretScanningListAlertsForOrgError) -> Self { + let (description, status_code) = match err { + SecretScanningListAlertsForOrgError::Status404(_) => (String::from("Resource not found"), 404), + SecretScanningListAlertsForOrgError::Status503(_) => (String::from("Service unavailable"), 503), + SecretScanningListAlertsForOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List secret scanning alerts for a repository](SecretScanning::list_alerts_for_repo_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecretScanningListAlertsForRepoError { - #[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")] Status404, #[error("Service unavailable")] @@ -141,19 +158,25 @@ pub enum SecretScanningListAlertsForRepoError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecretScanningListAlertsForRepoError) -> Self { + let (description, status_code) = match err { + SecretScanningListAlertsForRepoError::Status404 => (String::from("Repository is public or secret scanning is disabled for the repository"), 404), + SecretScanningListAlertsForRepoError::Status503(_) => (String::from("Service unavailable"), 503), + SecretScanningListAlertsForRepoError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// 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")] @@ -162,19 +185,25 @@ pub enum SecretScanningListLocationsForAlertError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecretScanningListLocationsForAlertError) -> Self { + let (description, status_code) = match err { + SecretScanningListLocationsForAlertError::Status404 => (String::from("Repository is public, or secret scanning is disabled for the repository, or the resource is not found"), 404), + SecretScanningListLocationsForAlertError::Status503(_) => (String::from("Service unavailable"), 503), + SecretScanningListLocationsForAlertError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a secret scanning alert](SecretScanning::update_alert_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecretScanningUpdateAlertError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad request, resolution comment is invalid or the resolution was not changed.")] Status400, #[error("Repository is public, or secret scanning is disabled for the repository, or the resource is not found")] @@ -187,6 +216,24 @@ pub enum SecretScanningUpdateAlertError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecretScanningUpdateAlertError) -> Self { + let (description, status_code) = match err { + SecretScanningUpdateAlertError::Status400 => (String::from("Bad request, resolution comment is invalid or the resolution was not changed."), 400), + SecretScanningUpdateAlertError::Status404 => (String::from("Repository is public, or secret scanning is disabled for the repository, or the resource is not found"), 404), + SecretScanningUpdateAlertError::Status422 => (String::from("State does not match the resolution or resolution comment"), 422), + SecretScanningUpdateAlertError::Status503(_) => (String::from("Service unavailable"), 503), + SecretScanningUpdateAlertError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List secret scanning alerts for an enterprise](SecretScanning::list_alerts_for_enterprise_async()) endpoint. #[derive(Default, Serialize)] @@ -793,7 +840,7 @@ impl<'enc> From<&'enc PerPage> for SecretScanningListLocationsForAlertParams { } } -impl<'api, C: Client> SecretScanning<'api, C> { +impl<'api, C: Client> SecretScanning<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Create a push protection bypass @@ -807,19 +854,19 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// [GitHub API docs for create_push_protection_bypass](https://docs.github.com/rest/secret-scanning/secret-scanning#create-a-push-protection-bypass) /// /// --- - pub async fn create_push_protection_bypass_async(&self, owner: &str, repo: &str, body: PostSecretScanningCreatePushProtectionBypass) -> Result { + pub async fn create_push_protection_bypass_async(&self, owner: &str, repo: &str, body: PostSecretScanningCreatePushProtectionBypass) -> Result { let request_uri = format!("{}/repos/{}/{}/secret-scanning/push-protection-bypasses", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostSecretScanningCreatePushProtectionBypass::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -831,11 +878,11 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(SecretScanningCreatePushProtectionBypassError::Status403), - 404 => Err(SecretScanningCreatePushProtectionBypassError::Status404), - 422 => Err(SecretScanningCreatePushProtectionBypassError::Status422), - 503 => Err(SecretScanningCreatePushProtectionBypassError::Status503(github_response.to_json_async().await?)), - code => Err(SecretScanningCreatePushProtectionBypassError::Generic { code }), + 403 => Err(SecretScanningCreatePushProtectionBypassError::Status403.into()), + 404 => Err(SecretScanningCreatePushProtectionBypassError::Status404.into()), + 422 => Err(SecretScanningCreatePushProtectionBypassError::Status422.into()), + 503 => Err(SecretScanningCreatePushProtectionBypassError::Status503(github_response.to_json_async().await?).into()), + code => Err(SecretScanningCreatePushProtectionBypassError::Generic { code }.into()), } } } @@ -854,19 +901,19 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_push_protection_bypass(&self, owner: &str, repo: &str, body: PostSecretScanningCreatePushProtectionBypass) -> Result { + pub fn create_push_protection_bypass(&self, owner: &str, repo: &str, body: PostSecretScanningCreatePushProtectionBypass) -> Result { let request_uri = format!("{}/repos/{}/{}/secret-scanning/push-protection-bypasses", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostSecretScanningCreatePushProtectionBypass::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -878,11 +925,11 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(SecretScanningCreatePushProtectionBypassError::Status403), - 404 => Err(SecretScanningCreatePushProtectionBypassError::Status404), - 422 => Err(SecretScanningCreatePushProtectionBypassError::Status422), - 503 => Err(SecretScanningCreatePushProtectionBypassError::Status503(github_response.to_json()?)), - code => Err(SecretScanningCreatePushProtectionBypassError::Generic { code }), + 403 => Err(SecretScanningCreatePushProtectionBypassError::Status403.into()), + 404 => Err(SecretScanningCreatePushProtectionBypassError::Status404.into()), + 422 => Err(SecretScanningCreatePushProtectionBypassError::Status422.into()), + 503 => Err(SecretScanningCreatePushProtectionBypassError::Status503(github_response.to_json()?).into()), + code => Err(SecretScanningCreatePushProtectionBypassError::Generic { code }.into()), } } } @@ -900,19 +947,19 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// [GitHub API docs for get_alert](https://docs.github.com/rest/secret-scanning/secret-scanning#get-a-secret-scanning-alert) /// /// --- - pub async fn get_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { + pub async fn get_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { let request_uri = format!("{}/repos/{}/{}/secret-scanning/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -924,10 +971,10 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(SecretScanningGetAlertError::Status304), - 404 => Err(SecretScanningGetAlertError::Status404), - 503 => Err(SecretScanningGetAlertError::Status503(github_response.to_json_async().await?)), - code => Err(SecretScanningGetAlertError::Generic { code }), + 304 => Err(SecretScanningGetAlertError::Status304.into()), + 404 => Err(SecretScanningGetAlertError::Status404.into()), + 503 => Err(SecretScanningGetAlertError::Status503(github_response.to_json_async().await?).into()), + code => Err(SecretScanningGetAlertError::Generic { code }.into()), } } } @@ -946,7 +993,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { + pub fn get_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber) -> Result { let request_uri = format!("{}/repos/{}/{}/secret-scanning/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); @@ -958,7 +1005,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -970,10 +1017,10 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(SecretScanningGetAlertError::Status304), - 404 => Err(SecretScanningGetAlertError::Status404), - 503 => Err(SecretScanningGetAlertError::Status503(github_response.to_json()?)), - code => Err(SecretScanningGetAlertError::Generic { code }), + 304 => Err(SecretScanningGetAlertError::Status304.into()), + 404 => Err(SecretScanningGetAlertError::Status404.into()), + 503 => Err(SecretScanningGetAlertError::Status503(github_response.to_json()?).into()), + code => Err(SecretScanningGetAlertError::Generic { code }.into()), } } } @@ -993,7 +1040,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// [GitHub API docs for list_alerts_for_enterprise](https://docs.github.com/rest/secret-scanning/secret-scanning#list-secret-scanning-alerts-for-an-enterprise) /// /// --- - pub async fn list_alerts_for_enterprise_async(&self, enterprise: &str, query_params: Option>>) -> Result, SecretScanningListAlertsForEnterpriseError> { + pub async fn list_alerts_for_enterprise_async(&self, enterprise: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/enterprises/{}/secret-scanning/alerts", super::GITHUB_BASE_API_URL, enterprise); @@ -1004,12 +1051,12 @@ impl<'api, C: Client> SecretScanning<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1021,9 +1068,9 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(SecretScanningListAlertsForEnterpriseError::Status404(github_response.to_json_async().await?)), - 503 => Err(SecretScanningListAlertsForEnterpriseError::Status503(github_response.to_json_async().await?)), - code => Err(SecretScanningListAlertsForEnterpriseError::Generic { code }), + 404 => Err(SecretScanningListAlertsForEnterpriseError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(SecretScanningListAlertsForEnterpriseError::Status503(github_response.to_json_async().await?).into()), + code => Err(SecretScanningListAlertsForEnterpriseError::Generic { code }.into()), } } } @@ -1044,7 +1091,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_alerts_for_enterprise(&self, enterprise: &str, query_params: Option>>) -> Result, SecretScanningListAlertsForEnterpriseError> { + pub fn list_alerts_for_enterprise(&self, enterprise: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/enterprises/{}/secret-scanning/alerts", super::GITHUB_BASE_API_URL, enterprise); @@ -1061,7 +1108,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1073,9 +1120,9 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(SecretScanningListAlertsForEnterpriseError::Status404(github_response.to_json()?)), - 503 => Err(SecretScanningListAlertsForEnterpriseError::Status503(github_response.to_json()?)), - code => Err(SecretScanningListAlertsForEnterpriseError::Generic { code }), + 404 => Err(SecretScanningListAlertsForEnterpriseError::Status404(github_response.to_json()?).into()), + 503 => Err(SecretScanningListAlertsForEnterpriseError::Status503(github_response.to_json()?).into()), + code => Err(SecretScanningListAlertsForEnterpriseError::Generic { code }.into()), } } } @@ -1093,7 +1140,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// [GitHub API docs for list_alerts_for_org](https://docs.github.com/rest/secret-scanning/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> { + pub async fn list_alerts_for_org_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/secret-scanning/alerts", super::GITHUB_BASE_API_URL, org); @@ -1104,12 +1151,12 @@ impl<'api, C: Client> SecretScanning<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1121,9 +1168,9 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(SecretScanningListAlertsForOrgError::Status404(github_response.to_json_async().await?)), - 503 => Err(SecretScanningListAlertsForOrgError::Status503(github_response.to_json_async().await?)), - code => Err(SecretScanningListAlertsForOrgError::Generic { code }), + 404 => Err(SecretScanningListAlertsForOrgError::Status404(github_response.to_json_async().await?).into()), + 503 => Err(SecretScanningListAlertsForOrgError::Status503(github_response.to_json_async().await?).into()), + code => Err(SecretScanningListAlertsForOrgError::Generic { code }.into()), } } } @@ -1142,7 +1189,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_alerts_for_org(&self, org: &str, query_params: Option>>) -> Result, SecretScanningListAlertsForOrgError> { + pub fn list_alerts_for_org(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/secret-scanning/alerts", super::GITHUB_BASE_API_URL, org); @@ -1159,7 +1206,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1171,9 +1218,9 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(SecretScanningListAlertsForOrgError::Status404(github_response.to_json()?)), - 503 => Err(SecretScanningListAlertsForOrgError::Status503(github_response.to_json()?)), - code => Err(SecretScanningListAlertsForOrgError::Generic { code }), + 404 => Err(SecretScanningListAlertsForOrgError::Status404(github_response.to_json()?).into()), + 503 => Err(SecretScanningListAlertsForOrgError::Status503(github_response.to_json()?).into()), + code => Err(SecretScanningListAlertsForOrgError::Generic { code }.into()), } } } @@ -1191,7 +1238,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// [GitHub API docs for list_alerts_for_repo](https://docs.github.com/rest/secret-scanning/secret-scanning#list-secret-scanning-alerts-for-a-repository) /// /// --- - pub async fn list_alerts_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, SecretScanningListAlertsForRepoError> { + pub async fn list_alerts_for_repo_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/secret-scanning/alerts", super::GITHUB_BASE_API_URL, owner, repo); @@ -1202,12 +1249,12 @@ impl<'api, C: Client> SecretScanning<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1219,9 +1266,9 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(SecretScanningListAlertsForRepoError::Status404), - 503 => Err(SecretScanningListAlertsForRepoError::Status503(github_response.to_json_async().await?)), - code => Err(SecretScanningListAlertsForRepoError::Generic { code }), + 404 => Err(SecretScanningListAlertsForRepoError::Status404.into()), + 503 => Err(SecretScanningListAlertsForRepoError::Status503(github_response.to_json_async().await?).into()), + code => Err(SecretScanningListAlertsForRepoError::Generic { code }.into()), } } } @@ -1240,7 +1287,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_alerts_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, SecretScanningListAlertsForRepoError> { + pub fn list_alerts_for_repo(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/secret-scanning/alerts", super::GITHUB_BASE_API_URL, owner, repo); @@ -1257,7 +1304,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1269,9 +1316,9 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(SecretScanningListAlertsForRepoError::Status404), - 503 => Err(SecretScanningListAlertsForRepoError::Status503(github_response.to_json()?)), - code => Err(SecretScanningListAlertsForRepoError::Generic { code }), + 404 => Err(SecretScanningListAlertsForRepoError::Status404.into()), + 503 => Err(SecretScanningListAlertsForRepoError::Status503(github_response.to_json()?).into()), + code => Err(SecretScanningListAlertsForRepoError::Generic { code }.into()), } } } @@ -1289,7 +1336,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// [GitHub API docs for list_locations_for_alert](https://docs.github.com/rest/secret-scanning/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> { + pub async fn list_locations_for_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/secret-scanning/alerts/{}/locations", super::GITHUB_BASE_API_URL, owner, repo, alert_number); @@ -1300,12 +1347,12 @@ impl<'api, C: Client> SecretScanning<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1317,9 +1364,9 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(SecretScanningListLocationsForAlertError::Status404), - 503 => Err(SecretScanningListLocationsForAlertError::Status503(github_response.to_json_async().await?)), - code => Err(SecretScanningListLocationsForAlertError::Generic { code }), + 404 => Err(SecretScanningListLocationsForAlertError::Status404.into()), + 503 => Err(SecretScanningListLocationsForAlertError::Status503(github_response.to_json_async().await?).into()), + code => Err(SecretScanningListLocationsForAlertError::Generic { code }.into()), } } } @@ -1338,7 +1385,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_locations_for_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber, query_params: Option>) -> Result, SecretScanningListLocationsForAlertError> { + pub fn list_locations_for_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/secret-scanning/alerts/{}/locations", super::GITHUB_BASE_API_URL, owner, repo, alert_number); @@ -1355,7 +1402,7 @@ impl<'api, C: Client> SecretScanning<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1367,9 +1414,9 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(SecretScanningListLocationsForAlertError::Status404), - 503 => Err(SecretScanningListLocationsForAlertError::Status503(github_response.to_json()?)), - code => Err(SecretScanningListLocationsForAlertError::Generic { code }), + 404 => Err(SecretScanningListLocationsForAlertError::Status404.into()), + 503 => Err(SecretScanningListLocationsForAlertError::Status503(github_response.to_json()?).into()), + code => Err(SecretScanningListLocationsForAlertError::Generic { code }.into()), } } } @@ -1387,19 +1434,19 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// [GitHub API docs for update_alert](https://docs.github.com/rest/secret-scanning/secret-scanning#update-a-secret-scanning-alert) /// /// --- - pub async fn update_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchSecretScanningUpdateAlert) -> Result { + pub async fn update_alert_async(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchSecretScanningUpdateAlert) -> Result { let request_uri = format!("{}/repos/{}/{}/secret-scanning/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchSecretScanningUpdateAlert::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1411,11 +1458,11 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(SecretScanningUpdateAlertError::Status400), - 404 => Err(SecretScanningUpdateAlertError::Status404), - 422 => Err(SecretScanningUpdateAlertError::Status422), - 503 => Err(SecretScanningUpdateAlertError::Status503(github_response.to_json_async().await?)), - code => Err(SecretScanningUpdateAlertError::Generic { code }), + 400 => Err(SecretScanningUpdateAlertError::Status400.into()), + 404 => Err(SecretScanningUpdateAlertError::Status404.into()), + 422 => Err(SecretScanningUpdateAlertError::Status422.into()), + 503 => Err(SecretScanningUpdateAlertError::Status503(github_response.to_json_async().await?).into()), + code => Err(SecretScanningUpdateAlertError::Generic { code }.into()), } } } @@ -1434,19 +1481,19 @@ impl<'api, C: Client> SecretScanning<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchSecretScanningUpdateAlert) -> Result { + pub fn update_alert(&self, owner: &str, repo: &str, alert_number: AlertNumber, body: PatchSecretScanningUpdateAlert) -> Result { let request_uri = format!("{}/repos/{}/{}/secret-scanning/alerts/{}", super::GITHUB_BASE_API_URL, owner, repo, alert_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchSecretScanningUpdateAlert::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1458,11 +1505,11 @@ impl<'api, C: Client> SecretScanning<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(SecretScanningUpdateAlertError::Status400), - 404 => Err(SecretScanningUpdateAlertError::Status404), - 422 => Err(SecretScanningUpdateAlertError::Status422), - 503 => Err(SecretScanningUpdateAlertError::Status503(github_response.to_json()?)), - code => Err(SecretScanningUpdateAlertError::Generic { code }), + 400 => Err(SecretScanningUpdateAlertError::Status400.into()), + 404 => Err(SecretScanningUpdateAlertError::Status404.into()), + 422 => Err(SecretScanningUpdateAlertError::Status422.into()), + 503 => Err(SecretScanningUpdateAlertError::Status503(github_response.to_json()?).into()), + code => Err(SecretScanningUpdateAlertError::Generic { code }.into()), } } } diff --git a/src/endpoints/security_advisories.rs b/src/endpoints/security_advisories.rs index d82637a..fe708ad 100644 --- a/src/endpoints/security_advisories.rs +++ b/src/endpoints/security_advisories.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct SecurityAdvisories<'api, C: Client> { +pub struct SecurityAdvisories<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> SecurityAdvisories { +pub fn new(client: &C) -> SecurityAdvisories where AdapterError: From<::Err> { SecurityAdvisories { client } } /// Errors for the [Create a temporary private fork](SecurityAdvisories::create_fork_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecurityAdvisoriesCreateForkError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -55,19 +45,27 @@ pub enum SecurityAdvisoriesCreateForkError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecurityAdvisoriesCreateForkError) -> Self { + let (description, status_code) = match err { + SecurityAdvisoriesCreateForkError::Status400(_) => (String::from("Bad Request"), 400), + SecurityAdvisoriesCreateForkError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + SecurityAdvisoriesCreateForkError::Status403(_) => (String::from("Forbidden"), 403), + SecurityAdvisoriesCreateForkError::Status404(_) => (String::from("Resource not found"), 404), + SecurityAdvisoriesCreateForkError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Privately report a security vulnerability](SecurityAdvisories::create_private_vulnerability_report_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecurityAdvisoriesCreatePrivateVulnerabilityReportError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -78,19 +76,26 @@ pub enum SecurityAdvisoriesCreatePrivateVulnerabilityReportError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecurityAdvisoriesCreatePrivateVulnerabilityReportError) -> Self { + let (description, status_code) = match err { + SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status403(_) => (String::from("Forbidden"), 403), + SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status404(_) => (String::from("Resource not found"), 404), + SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a repository security advisory](SecurityAdvisories::create_repository_advisory_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecurityAdvisoriesCreateRepositoryAdvisoryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -101,19 +106,26 @@ pub enum SecurityAdvisoriesCreateRepositoryAdvisoryError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecurityAdvisoriesCreateRepositoryAdvisoryError) -> Self { + let (description, status_code) = match err { + SecurityAdvisoriesCreateRepositoryAdvisoryError::Status403(_) => (String::from("Forbidden"), 403), + SecurityAdvisoriesCreateRepositoryAdvisoryError::Status404(_) => (String::from("Resource not found"), 404), + SecurityAdvisoriesCreateRepositoryAdvisoryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + SecurityAdvisoriesCreateRepositoryAdvisoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Request a CVE for a repository security advisory](SecurityAdvisories::create_repository_advisory_cve_request_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Forbidden")] @@ -126,38 +138,51 @@ pub enum SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError) -> Self { + let (description, status_code) = match err { + SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status400(_) => (String::from("Bad Request"), 400), + SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status403(_) => (String::from("Forbidden"), 403), + SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status404(_) => (String::from("Resource not found"), 404), + SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a global security advisory](SecurityAdvisories::get_global_advisory_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecurityAdvisoriesGetGlobalAdvisoryError { - #[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 }, } +impl From for AdapterError { + fn from(err: SecurityAdvisoriesGetGlobalAdvisoryError) -> Self { + let (description, status_code) = match err { + SecurityAdvisoriesGetGlobalAdvisoryError::Status404(_) => (String::from("Resource not found"), 404), + SecurityAdvisoriesGetGlobalAdvisoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a repository security advisory](SecurityAdvisories::get_repository_advisory_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecurityAdvisoriesGetRepositoryAdvisoryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -166,19 +191,25 @@ pub enum SecurityAdvisoriesGetRepositoryAdvisoryError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecurityAdvisoriesGetRepositoryAdvisoryError) -> Self { + let (description, status_code) = match err { + SecurityAdvisoriesGetRepositoryAdvisoryError::Status403(_) => (String::from("Forbidden"), 403), + SecurityAdvisoriesGetRepositoryAdvisoryError::Status404(_) => (String::from("Resource not found"), 404), + SecurityAdvisoriesGetRepositoryAdvisoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List global security advisories](SecurityAdvisories::list_global_advisories_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecurityAdvisoriesListGlobalAdvisoriesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Too many requests")] Status429(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -187,19 +218,25 @@ pub enum SecurityAdvisoriesListGlobalAdvisoriesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecurityAdvisoriesListGlobalAdvisoriesError) -> Self { + let (description, status_code) = match err { + SecurityAdvisoriesListGlobalAdvisoriesError::Status429(_) => (String::from("Too many requests"), 429), + SecurityAdvisoriesListGlobalAdvisoriesError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + SecurityAdvisoriesListGlobalAdvisoriesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository security advisories for an organization](SecurityAdvisories::list_org_repository_advisories_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecurityAdvisoriesListOrgRepositoryAdvisoriesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Resource not found")] @@ -208,19 +245,25 @@ pub enum SecurityAdvisoriesListOrgRepositoryAdvisoriesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecurityAdvisoriesListOrgRepositoryAdvisoriesError) -> Self { + let (description, status_code) = match err { + SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Status400(_) => (String::from("Bad Request"), 400), + SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Status404(_) => (String::from("Resource not found"), 404), + SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List repository security advisories](SecurityAdvisories::list_repository_advisories_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecurityAdvisoriesListRepositoryAdvisoriesError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Bad Request")] Status400(BasicError), #[error("Resource not found")] @@ -229,19 +272,25 @@ pub enum SecurityAdvisoriesListRepositoryAdvisoriesError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecurityAdvisoriesListRepositoryAdvisoriesError) -> Self { + let (description, status_code) = match err { + SecurityAdvisoriesListRepositoryAdvisoriesError::Status400(_) => (String::from("Bad Request"), 400), + SecurityAdvisoriesListRepositoryAdvisoriesError::Status404(_) => (String::from("Resource not found"), 404), + SecurityAdvisoriesListRepositoryAdvisoriesError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a repository security advisory](SecurityAdvisories::update_repository_advisory_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum SecurityAdvisoriesUpdateRepositoryAdvisoryError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Resource not found")] @@ -252,6 +301,23 @@ pub enum SecurityAdvisoriesUpdateRepositoryAdvisoryError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: SecurityAdvisoriesUpdateRepositoryAdvisoryError) -> Self { + let (description, status_code) = match err { + SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status403(_) => (String::from("Forbidden"), 403), + SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status404(_) => (String::from("Resource not found"), 404), + SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + SecurityAdvisoriesUpdateRepositoryAdvisoryError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List global security advisories](SecurityAdvisories::list_global_advisories_async()) endpoint. #[derive(Default, Serialize)] @@ -923,7 +989,7 @@ impl<'req> SecurityAdvisoriesListRepositoryAdvisoriesParams<'req> { } -impl<'api, C: Client> SecurityAdvisories<'api, C> { +impl<'api, C: Client> SecurityAdvisories<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Create a temporary private fork @@ -936,19 +1002,19 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// [GitHub API docs for create_fork](https://docs.github.com/rest/security-advisories/repository-advisories#create-a-temporary-private-fork) /// /// --- - pub async fn create_fork_async(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result { + pub async fn create_fork_async(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/security-advisories/{}/forks", super::GITHUB_BASE_API_URL, owner, repo, ghsa_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -960,11 +1026,11 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(SecurityAdvisoriesCreateForkError::Status400(github_response.to_json_async().await?)), - 422 => Err(SecurityAdvisoriesCreateForkError::Status422(github_response.to_json_async().await?)), - 403 => Err(SecurityAdvisoriesCreateForkError::Status403(github_response.to_json_async().await?)), - 404 => Err(SecurityAdvisoriesCreateForkError::Status404(github_response.to_json_async().await?)), - code => Err(SecurityAdvisoriesCreateForkError::Generic { code }), + 400 => Err(SecurityAdvisoriesCreateForkError::Status400(github_response.to_json_async().await?).into()), + 422 => Err(SecurityAdvisoriesCreateForkError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(SecurityAdvisoriesCreateForkError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(SecurityAdvisoriesCreateForkError::Status404(github_response.to_json_async().await?).into()), + code => Err(SecurityAdvisoriesCreateForkError::Generic { code }.into()), } } } @@ -982,7 +1048,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_fork(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result { + pub fn create_fork(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/security-advisories/{}/forks", super::GITHUB_BASE_API_URL, owner, repo, ghsa_id); @@ -994,7 +1060,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1006,11 +1072,11 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(SecurityAdvisoriesCreateForkError::Status400(github_response.to_json()?)), - 422 => Err(SecurityAdvisoriesCreateForkError::Status422(github_response.to_json()?)), - 403 => Err(SecurityAdvisoriesCreateForkError::Status403(github_response.to_json()?)), - 404 => Err(SecurityAdvisoriesCreateForkError::Status404(github_response.to_json()?)), - code => Err(SecurityAdvisoriesCreateForkError::Generic { code }), + 400 => Err(SecurityAdvisoriesCreateForkError::Status400(github_response.to_json()?).into()), + 422 => Err(SecurityAdvisoriesCreateForkError::Status422(github_response.to_json()?).into()), + 403 => Err(SecurityAdvisoriesCreateForkError::Status403(github_response.to_json()?).into()), + 404 => Err(SecurityAdvisoriesCreateForkError::Status404(github_response.to_json()?).into()), + code => Err(SecurityAdvisoriesCreateForkError::Generic { code }.into()), } } } @@ -1025,19 +1091,19 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// [GitHub API docs for create_private_vulnerability_report](https://docs.github.com/rest/security-advisories/repository-advisories#privately-report-a-security-vulnerability) /// /// --- - pub async fn create_private_vulnerability_report_async(&self, owner: &str, repo: &str, body: PostSecurityAdvisoriesCreatePrivateVulnerabilityReport) -> Result { + pub async fn create_private_vulnerability_report_async(&self, owner: &str, repo: &str, body: PostSecurityAdvisoriesCreatePrivateVulnerabilityReport) -> Result { let request_uri = format!("{}/repos/{}/{}/security-advisories/reports", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostSecurityAdvisoriesCreatePrivateVulnerabilityReport::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1049,10 +1115,10 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status403(github_response.to_json_async().await?)), - 404 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status404(github_response.to_json_async().await?)), - 422 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status422(github_response.to_json_async().await?)), - code => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Generic { code }), + 403 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status422(github_response.to_json_async().await?).into()), + code => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Generic { code }.into()), } } } @@ -1068,19 +1134,19 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_private_vulnerability_report(&self, owner: &str, repo: &str, body: PostSecurityAdvisoriesCreatePrivateVulnerabilityReport) -> Result { + pub fn create_private_vulnerability_report(&self, owner: &str, repo: &str, body: PostSecurityAdvisoriesCreatePrivateVulnerabilityReport) -> Result { let request_uri = format!("{}/repos/{}/{}/security-advisories/reports", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostSecurityAdvisoriesCreatePrivateVulnerabilityReport::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1092,10 +1158,10 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status403(github_response.to_json()?)), - 404 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status404(github_response.to_json()?)), - 422 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status422(github_response.to_json()?)), - code => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Generic { code }), + 403 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status403(github_response.to_json()?).into()), + 404 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status404(github_response.to_json()?).into()), + 422 => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Status422(github_response.to_json()?).into()), + code => Err(SecurityAdvisoriesCreatePrivateVulnerabilityReportError::Generic { code }.into()), } } } @@ -1113,19 +1179,19 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// [GitHub API docs for create_repository_advisory](https://docs.github.com/rest/security-advisories/repository-advisories#create-a-repository-security-advisory) /// /// --- - pub async fn create_repository_advisory_async(&self, owner: &str, repo: &str, body: PostSecurityAdvisoriesCreateRepositoryAdvisory) -> Result { + pub async fn create_repository_advisory_async(&self, owner: &str, repo: &str, body: PostSecurityAdvisoriesCreateRepositoryAdvisory) -> Result { let request_uri = format!("{}/repos/{}/{}/security-advisories", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostSecurityAdvisoriesCreateRepositoryAdvisory::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1137,10 +1203,10 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status403(github_response.to_json_async().await?)), - 404 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status404(github_response.to_json_async().await?)), - 422 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status422(github_response.to_json_async().await?)), - code => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Generic { code }), + 403 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status422(github_response.to_json_async().await?).into()), + code => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Generic { code }.into()), } } } @@ -1159,19 +1225,19 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_repository_advisory(&self, owner: &str, repo: &str, body: PostSecurityAdvisoriesCreateRepositoryAdvisory) -> Result { + pub fn create_repository_advisory(&self, owner: &str, repo: &str, body: PostSecurityAdvisoriesCreateRepositoryAdvisory) -> Result { let request_uri = format!("{}/repos/{}/{}/security-advisories", super::GITHUB_BASE_API_URL, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PostSecurityAdvisoriesCreateRepositoryAdvisory::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1183,10 +1249,10 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status403(github_response.to_json()?)), - 404 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status404(github_response.to_json()?)), - 422 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status422(github_response.to_json()?)), - code => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Generic { code }), + 403 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status403(github_response.to_json()?).into()), + 404 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status404(github_response.to_json()?).into()), + 422 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Status422(github_response.to_json()?).into()), + code => Err(SecurityAdvisoriesCreateRepositoryAdvisoryError::Generic { code }.into()), } } } @@ -1206,19 +1272,19 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// [GitHub API docs for create_repository_advisory_cve_request](https://docs.github.com/rest/security-advisories/repository-advisories#request-a-cve-for-a-repository-security-advisory) /// /// --- - pub async fn create_repository_advisory_cve_request_async(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result, SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError> { + pub async fn create_repository_advisory_cve_request_async(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/security-advisories/{}/cve", super::GITHUB_BASE_API_URL, owner, repo, ghsa_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1230,11 +1296,11 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status400(github_response.to_json_async().await?)), - 403 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status403(github_response.to_json_async().await?)), - 404 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status404(github_response.to_json_async().await?)), - 422 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status422(github_response.to_json_async().await?)), - code => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Generic { code }), + 400 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status400(github_response.to_json_async().await?).into()), + 403 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status422(github_response.to_json_async().await?).into()), + code => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Generic { code }.into()), } } } @@ -1255,7 +1321,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_repository_advisory_cve_request(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result, SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError> { + pub fn create_repository_advisory_cve_request(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result, AdapterError> { let request_uri = format!("{}/repos/{}/{}/security-advisories/{}/cve", super::GITHUB_BASE_API_URL, owner, repo, ghsa_id); @@ -1267,7 +1333,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1279,11 +1345,11 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status400(github_response.to_json()?)), - 403 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status403(github_response.to_json()?)), - 404 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status404(github_response.to_json()?)), - 422 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status422(github_response.to_json()?)), - code => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Generic { code }), + 400 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status400(github_response.to_json()?).into()), + 403 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status403(github_response.to_json()?).into()), + 404 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status404(github_response.to_json()?).into()), + 422 => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Status422(github_response.to_json()?).into()), + code => Err(SecurityAdvisoriesCreateRepositoryAdvisoryCveRequestError::Generic { code }.into()), } } } @@ -1297,19 +1363,19 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// [GitHub API docs for get_global_advisory](https://docs.github.com/rest/security-advisories/global-advisories#get-a-global-security-advisory) /// /// --- - pub async fn get_global_advisory_async(&self, ghsa_id: &str) -> Result { + pub async fn get_global_advisory_async(&self, ghsa_id: &str) -> Result { let request_uri = format!("{}/advisories/{}", super::GITHUB_BASE_API_URL, ghsa_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1321,8 +1387,8 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(SecurityAdvisoriesGetGlobalAdvisoryError::Status404(github_response.to_json_async().await?)), - code => Err(SecurityAdvisoriesGetGlobalAdvisoryError::Generic { code }), + 404 => Err(SecurityAdvisoriesGetGlobalAdvisoryError::Status404(github_response.to_json_async().await?).into()), + code => Err(SecurityAdvisoriesGetGlobalAdvisoryError::Generic { code }.into()), } } } @@ -1337,7 +1403,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_global_advisory(&self, ghsa_id: &str) -> Result { + pub fn get_global_advisory(&self, ghsa_id: &str) -> Result { let request_uri = format!("{}/advisories/{}", super::GITHUB_BASE_API_URL, ghsa_id); @@ -1349,7 +1415,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1361,8 +1427,8 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(SecurityAdvisoriesGetGlobalAdvisoryError::Status404(github_response.to_json()?)), - code => Err(SecurityAdvisoriesGetGlobalAdvisoryError::Generic { code }), + 404 => Err(SecurityAdvisoriesGetGlobalAdvisoryError::Status404(github_response.to_json()?).into()), + code => Err(SecurityAdvisoriesGetGlobalAdvisoryError::Generic { code }.into()), } } } @@ -1383,19 +1449,19 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// [GitHub API docs for get_repository_advisory](https://docs.github.com/rest/security-advisories/repository-advisories#get-a-repository-security-advisory) /// /// --- - pub async fn get_repository_advisory_async(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result { + pub async fn get_repository_advisory_async(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/security-advisories/{}", super::GITHUB_BASE_API_URL, owner, repo, ghsa_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1407,9 +1473,9 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Status403(github_response.to_json_async().await?)), - 404 => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Status404(github_response.to_json_async().await?)), - code => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Generic { code }), + 403 => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Status404(github_response.to_json_async().await?).into()), + code => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Generic { code }.into()), } } } @@ -1431,7 +1497,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_repository_advisory(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result { + pub fn get_repository_advisory(&self, owner: &str, repo: &str, ghsa_id: &str) -> Result { let request_uri = format!("{}/repos/{}/{}/security-advisories/{}", super::GITHUB_BASE_API_URL, owner, repo, ghsa_id); @@ -1443,7 +1509,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1455,9 +1521,9 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Status403(github_response.to_json()?)), - 404 => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Status404(github_response.to_json()?)), - code => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Generic { code }), + 403 => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Status403(github_response.to_json()?).into()), + 404 => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Status404(github_response.to_json()?).into()), + code => Err(SecurityAdvisoriesGetRepositoryAdvisoryError::Generic { code }.into()), } } } @@ -1473,7 +1539,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// [GitHub API docs for list_global_advisories](https://docs.github.com/rest/security-advisories/global-advisories#list-global-security-advisories) /// /// --- - pub async fn list_global_advisories_async(&self, query_params: Option>>) -> Result, SecurityAdvisoriesListGlobalAdvisoriesError> { + pub async fn list_global_advisories_async(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/advisories", super::GITHUB_BASE_API_URL); @@ -1484,12 +1550,12 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1501,9 +1567,9 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 429 => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Status429(github_response.to_json_async().await?)), - 422 => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Status422(github_response.to_json_async().await?)), - code => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Generic { code }), + 429 => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Status429(github_response.to_json_async().await?).into()), + 422 => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Status422(github_response.to_json_async().await?).into()), + code => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Generic { code }.into()), } } } @@ -1520,7 +1586,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_global_advisories(&self, query_params: Option>>) -> Result, SecurityAdvisoriesListGlobalAdvisoriesError> { + pub fn list_global_advisories(&self, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/advisories", super::GITHUB_BASE_API_URL); @@ -1537,7 +1603,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1549,9 +1615,9 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 429 => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Status429(github_response.to_json()?)), - 422 => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Status422(github_response.to_json()?)), - code => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Generic { code }), + 429 => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Status429(github_response.to_json()?).into()), + 422 => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Status422(github_response.to_json()?).into()), + code => Err(SecurityAdvisoriesListGlobalAdvisoriesError::Generic { code }.into()), } } } @@ -1569,7 +1635,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// [GitHub API docs for list_org_repository_advisories](https://docs.github.com/rest/security-advisories/repository-advisories#list-repository-security-advisories-for-an-organization) /// /// --- - pub async fn list_org_repository_advisories_async(&self, org: &str, query_params: Option>>) -> Result, SecurityAdvisoriesListOrgRepositoryAdvisoriesError> { + pub async fn list_org_repository_advisories_async(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/security-advisories", super::GITHUB_BASE_API_URL, org); @@ -1580,12 +1646,12 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1597,9 +1663,9 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Status400(github_response.to_json_async().await?)), - 404 => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Status404(github_response.to_json_async().await?)), - code => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Generic { code }), + 400 => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Status400(github_response.to_json_async().await?).into()), + 404 => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Status404(github_response.to_json_async().await?).into()), + code => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Generic { code }.into()), } } } @@ -1618,7 +1684,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_org_repository_advisories(&self, org: &str, query_params: Option>>) -> Result, SecurityAdvisoriesListOrgRepositoryAdvisoriesError> { + pub fn list_org_repository_advisories(&self, org: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/security-advisories", super::GITHUB_BASE_API_URL, org); @@ -1635,7 +1701,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1647,9 +1713,9 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Status400(github_response.to_json()?)), - 404 => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Status404(github_response.to_json()?)), - code => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Generic { code }), + 400 => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Status400(github_response.to_json()?).into()), + 404 => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Status404(github_response.to_json()?).into()), + code => Err(SecurityAdvisoriesListOrgRepositoryAdvisoriesError::Generic { code }.into()), } } } @@ -1667,7 +1733,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// [GitHub API docs for list_repository_advisories](https://docs.github.com/rest/security-advisories/repository-advisories#list-repository-security-advisories) /// /// --- - pub async fn list_repository_advisories_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, SecurityAdvisoriesListRepositoryAdvisoriesError> { + pub async fn list_repository_advisories_async(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/security-advisories", super::GITHUB_BASE_API_URL, owner, repo); @@ -1678,12 +1744,12 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1695,9 +1761,9 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 400 => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Status400(github_response.to_json_async().await?)), - 404 => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Status404(github_response.to_json_async().await?)), - code => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Generic { code }), + 400 => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Status400(github_response.to_json_async().await?).into()), + 404 => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Status404(github_response.to_json_async().await?).into()), + code => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Generic { code }.into()), } } } @@ -1716,7 +1782,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repository_advisories(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, SecurityAdvisoriesListRepositoryAdvisoriesError> { + pub fn list_repository_advisories(&self, owner: &str, repo: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/repos/{}/{}/security-advisories", super::GITHUB_BASE_API_URL, owner, repo); @@ -1733,7 +1799,7 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1745,9 +1811,9 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 400 => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Status400(github_response.to_json()?)), - 404 => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Status404(github_response.to_json()?)), - code => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Generic { code }), + 400 => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Status400(github_response.to_json()?).into()), + 404 => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Status404(github_response.to_json()?).into()), + code => Err(SecurityAdvisoriesListRepositoryAdvisoriesError::Generic { code }.into()), } } } @@ -1766,19 +1832,19 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// [GitHub API docs for update_repository_advisory](https://docs.github.com/rest/security-advisories/repository-advisories#update-a-repository-security-advisory) /// /// --- - pub async fn update_repository_advisory_async(&self, owner: &str, repo: &str, ghsa_id: &str, body: PatchSecurityAdvisoriesUpdateRepositoryAdvisory) -> Result { + pub async fn update_repository_advisory_async(&self, owner: &str, repo: &str, ghsa_id: &str, body: PatchSecurityAdvisoriesUpdateRepositoryAdvisory) -> Result { let request_uri = format!("{}/repos/{}/{}/security-advisories/{}", super::GITHUB_BASE_API_URL, owner, repo, ghsa_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchSecurityAdvisoriesUpdateRepositoryAdvisory::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1790,10 +1856,10 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status403(github_response.to_json_async().await?)), - 404 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status404(github_response.to_json_async().await?)), - 422 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status422(github_response.to_json_async().await?)), - code => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Generic { code }), + 403 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status422(github_response.to_json_async().await?).into()), + code => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Generic { code }.into()), } } } @@ -1813,19 +1879,19 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_repository_advisory(&self, owner: &str, repo: &str, ghsa_id: &str, body: PatchSecurityAdvisoriesUpdateRepositoryAdvisory) -> Result { + pub fn update_repository_advisory(&self, owner: &str, repo: &str, ghsa_id: &str, body: PatchSecurityAdvisoriesUpdateRepositoryAdvisory) -> Result { let request_uri = format!("{}/repos/{}/{}/security-advisories/{}", super::GITHUB_BASE_API_URL, owner, repo, ghsa_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchSecurityAdvisoriesUpdateRepositoryAdvisory::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1837,10 +1903,10 @@ impl<'api, C: Client> SecurityAdvisories<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status403(github_response.to_json()?)), - 404 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status404(github_response.to_json()?)), - 422 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status422(github_response.to_json()?)), - code => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Generic { code }), + 403 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status403(github_response.to_json()?).into()), + 404 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status404(github_response.to_json()?).into()), + 422 => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Status422(github_response.to_json()?).into()), + code => Err(SecurityAdvisoriesUpdateRepositoryAdvisoryError::Generic { code }.into()), } } } diff --git a/src/endpoints/teams.rs b/src/endpoints/teams.rs index e1dea60..2e84bbb 100644 --- a/src/endpoints/teams.rs +++ b/src/endpoints/teams.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Teams<'api, C: Client> { +pub struct Teams<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Teams { +pub fn new(client: &C) -> Teams where AdapterError: From<::Err> { Teams { client } } /// Errors for the [Add team member (Legacy)](Teams::add_member_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsAddMemberLegacyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if team synchronization is set up")] Status404, #[error("Unprocessable Entity if you attempt to add an organization to a team or you attempt to add a user to a team when they are not a member of at least one other team in the same organization")] @@ -53,19 +43,26 @@ pub enum TeamsAddMemberLegacyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsAddMemberLegacyError) -> Self { + let (description, status_code) = match err { + TeamsAddMemberLegacyError::Status404 => (String::from("Not Found if team synchronization is set up"), 404), + TeamsAddMemberLegacyError::Status422 => (String::from("Unprocessable Entity if you attempt to add an organization to a team or you attempt to add a user to a team when they are not a member of at least one other team in the same organization"), 422), + TeamsAddMemberLegacyError::Status403(_) => (String::from("Forbidden"), 403), + TeamsAddMemberLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add or update team membership for a user](Teams::add_or_update_membership_for_user_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsAddOrUpdateMembershipForUserInOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden if team synchronization is set up")] Status403, #[error("Unprocessable Entity if you attempt to add an organization to a team")] @@ -74,19 +71,25 @@ pub enum TeamsAddOrUpdateMembershipForUserInOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsAddOrUpdateMembershipForUserInOrgError) -> Self { + let (description, status_code) = match err { + TeamsAddOrUpdateMembershipForUserInOrgError::Status403 => (String::from("Forbidden if team synchronization is set up"), 403), + TeamsAddOrUpdateMembershipForUserInOrgError::Status422 => (String::from("Unprocessable Entity if you attempt to add an organization to a team"), 422), + TeamsAddOrUpdateMembershipForUserInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add or update team membership for a user (Legacy)](Teams::add_or_update_membership_for_user_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsAddOrUpdateMembershipForUserLegacyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden if team synchronization is set up")] Status403, #[error("Unprocessable Entity if you attempt to add an organization to a team")] @@ -97,38 +100,50 @@ pub enum TeamsAddOrUpdateMembershipForUserLegacyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsAddOrUpdateMembershipForUserLegacyError) -> Self { + let (description, status_code) = match err { + TeamsAddOrUpdateMembershipForUserLegacyError::Status403 => (String::from("Forbidden if team synchronization is set up"), 403), + TeamsAddOrUpdateMembershipForUserLegacyError::Status422 => (String::from("Unprocessable Entity if you attempt to add an organization to a team"), 422), + TeamsAddOrUpdateMembershipForUserLegacyError::Status404(_) => (String::from("Resource not found"), 404), + TeamsAddOrUpdateMembershipForUserLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add or update team project permissions](Teams::add_or_update_project_permissions_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsAddOrUpdateProjectPermissionsInOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden if the project is not owned by the organization")] Status403(PutTeamsAddOrUpdateProjectPermissionsLegacyResponse403), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsAddOrUpdateProjectPermissionsInOrgError) -> Self { + let (description, status_code) = match err { + TeamsAddOrUpdateProjectPermissionsInOrgError::Status403(_) => (String::from("Forbidden if the project is not owned by the organization"), 403), + TeamsAddOrUpdateProjectPermissionsInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add or update team project permissions (Legacy)](Teams::add_or_update_project_permissions_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsAddOrUpdateProjectPermissionsLegacyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden if the project is not owned by the organization")] Status403(PutTeamsAddOrUpdateProjectPermissionsLegacyResponse403), #[error("Resource not found")] @@ -139,36 +154,47 @@ pub enum TeamsAddOrUpdateProjectPermissionsLegacyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsAddOrUpdateProjectPermissionsLegacyError) -> Self { + let (description, status_code) = match err { + TeamsAddOrUpdateProjectPermissionsLegacyError::Status403(_) => (String::from("Forbidden if the project is not owned by the organization"), 403), + TeamsAddOrUpdateProjectPermissionsLegacyError::Status404(_) => (String::from("Resource not found"), 404), + TeamsAddOrUpdateProjectPermissionsLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + TeamsAddOrUpdateProjectPermissionsLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add or update team repository permissions](Teams::add_or_update_repo_permissions_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsAddOrUpdateRepoPermissionsInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsAddOrUpdateRepoPermissionsInOrgError) -> Self { + let (description, status_code) = match err { + TeamsAddOrUpdateRepoPermissionsInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add or update team repository permissions (Legacy)](Teams::add_or_update_repo_permissions_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsAddOrUpdateRepoPermissionsLegacyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Validation failed, or the endpoint has been spammed.")] @@ -177,57 +203,73 @@ pub enum TeamsAddOrUpdateRepoPermissionsLegacyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsAddOrUpdateRepoPermissionsLegacyError) -> Self { + let (description, status_code) = match err { + TeamsAddOrUpdateRepoPermissionsLegacyError::Status403(_) => (String::from("Forbidden"), 403), + TeamsAddOrUpdateRepoPermissionsLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + TeamsAddOrUpdateRepoPermissionsLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check team permissions for a project](Teams::check_permissions_for_project_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsCheckPermissionsForProjectInOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if project is not managed by this team")] Status404, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsCheckPermissionsForProjectInOrgError) -> Self { + let (description, status_code) = match err { + TeamsCheckPermissionsForProjectInOrgError::Status404 => (String::from("Not Found if project is not managed by this team"), 404), + TeamsCheckPermissionsForProjectInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check team permissions for a project (Legacy)](Teams::check_permissions_for_project_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsCheckPermissionsForProjectLegacyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if project is not managed by this team")] Status404, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsCheckPermissionsForProjectLegacyError) -> Self { + let (description, status_code) = match err { + TeamsCheckPermissionsForProjectLegacyError::Status404 => (String::from("Not Found if project is not managed by this team"), 404), + TeamsCheckPermissionsForProjectLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check team permissions for a repository](Teams::check_permissions_for_repo_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsCheckPermissionsForRepoInOrgError { - #[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 team has permission for the repository. This is the response when the repository media type hasn't been provded in the Accept header.")] Status204, #[error("Not Found if team does not have permission for the repository")] @@ -236,19 +278,25 @@ pub enum TeamsCheckPermissionsForRepoInOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsCheckPermissionsForRepoInOrgError) -> Self { + let (description, status_code) = match err { + TeamsCheckPermissionsForRepoInOrgError::Status204 => (String::from("Response if team has permission for the repository. This is the response when the repository media type hasn't been provded in the Accept header."), 204), + TeamsCheckPermissionsForRepoInOrgError::Status404 => (String::from("Not Found if team does not have permission for the repository"), 404), + TeamsCheckPermissionsForRepoInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check team permissions for a repository (Legacy)](Teams::check_permissions_for_repo_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsCheckPermissionsForRepoLegacyError { - #[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 repository is managed by this team")] Status204, #[error("Not Found if repository is not managed by this team")] @@ -257,19 +305,25 @@ pub enum TeamsCheckPermissionsForRepoLegacyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsCheckPermissionsForRepoLegacyError) -> Self { + let (description, status_code) = match err { + TeamsCheckPermissionsForRepoLegacyError::Status204 => (String::from("Response if repository is managed by this team"), 204), + TeamsCheckPermissionsForRepoLegacyError::Status404 => (String::from("Not Found if repository is not managed by this team"), 404), + TeamsCheckPermissionsForRepoLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a team](Teams::create_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsCreateError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Forbidden")] @@ -278,172 +332,214 @@ pub enum TeamsCreateError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsCreateError) -> Self { + let (description, status_code) = match err { + TeamsCreateError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + TeamsCreateError::Status403(_) => (String::from("Forbidden"), 403), + TeamsCreateError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a discussion comment](Teams::create_discussion_comment_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsCreateDiscussionCommentInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsCreateDiscussionCommentInOrgError) -> Self { + let (description, status_code) = match err { + TeamsCreateDiscussionCommentInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a discussion comment (Legacy)](Teams::create_discussion_comment_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsCreateDiscussionCommentLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsCreateDiscussionCommentLegacyError) -> Self { + let (description, status_code) = match err { + TeamsCreateDiscussionCommentLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a discussion](Teams::create_discussion_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsCreateDiscussionInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsCreateDiscussionInOrgError) -> Self { + let (description, status_code) = match err { + TeamsCreateDiscussionInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a discussion (Legacy)](Teams::create_discussion_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsCreateDiscussionLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsCreateDiscussionLegacyError) -> Self { + let (description, status_code) = match err { + TeamsCreateDiscussionLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a discussion comment](Teams::delete_discussion_comment_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsDeleteDiscussionCommentInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsDeleteDiscussionCommentInOrgError) -> Self { + let (description, status_code) = match err { + TeamsDeleteDiscussionCommentInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a discussion comment (Legacy)](Teams::delete_discussion_comment_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsDeleteDiscussionCommentLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsDeleteDiscussionCommentLegacyError) -> Self { + let (description, status_code) = match err { + TeamsDeleteDiscussionCommentLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a discussion](Teams::delete_discussion_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsDeleteDiscussionInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsDeleteDiscussionInOrgError) -> Self { + let (description, status_code) = match err { + TeamsDeleteDiscussionInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a discussion (Legacy)](Teams::delete_discussion_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsDeleteDiscussionLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsDeleteDiscussionLegacyError) -> Self { + let (description, status_code) = match err { + TeamsDeleteDiscussionLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a team](Teams::delete_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsDeleteInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsDeleteInOrgError) -> Self { + let (description, status_code) = match err { + TeamsDeleteInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a team (Legacy)](Teams::delete_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsDeleteLegacyError { - #[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, or the endpoint has been spammed.")] @@ -452,218 +548,274 @@ pub enum TeamsDeleteLegacyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsDeleteLegacyError) -> Self { + let (description, status_code) = match err { + TeamsDeleteLegacyError::Status404(_) => (String::from("Resource not found"), 404), + TeamsDeleteLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + TeamsDeleteLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a team by name](Teams::get_by_name_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsGetByNameError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsGetByNameError) -> Self { + let (description, status_code) = match err { + TeamsGetByNameError::Status404(_) => (String::from("Resource not found"), 404), + TeamsGetByNameError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a discussion comment](Teams::get_discussion_comment_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsGetDiscussionCommentInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsGetDiscussionCommentInOrgError) -> Self { + let (description, status_code) = match err { + TeamsGetDiscussionCommentInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a discussion comment (Legacy)](Teams::get_discussion_comment_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsGetDiscussionCommentLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsGetDiscussionCommentLegacyError) -> Self { + let (description, status_code) = match err { + TeamsGetDiscussionCommentLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a discussion](Teams::get_discussion_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsGetDiscussionInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsGetDiscussionInOrgError) -> Self { + let (description, status_code) = match err { + TeamsGetDiscussionInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a discussion (Legacy)](Teams::get_discussion_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsGetDiscussionLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsGetDiscussionLegacyError) -> Self { + let (description, status_code) = match err { + TeamsGetDiscussionLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a team (Legacy)](Teams::get_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsGetLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsGetLegacyError) -> Self { + let (description, status_code) = match err { + TeamsGetLegacyError::Status404(_) => (String::from("Resource not found"), 404), + TeamsGetLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get team member (Legacy)](Teams::get_member_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsGetMemberLegacyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("if user is not a member")] Status404, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsGetMemberLegacyError) -> Self { + let (description, status_code) = match err { + TeamsGetMemberLegacyError::Status404 => (String::from("if user is not a member"), 404), + TeamsGetMemberLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get team membership for a user](Teams::get_membership_for_user_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsGetMembershipForUserInOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("if user has no team membership")] Status404, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsGetMembershipForUserInOrgError) -> Self { + let (description, status_code) = match err { + TeamsGetMembershipForUserInOrgError::Status404 => (String::from("if user has no team membership"), 404), + TeamsGetMembershipForUserInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get team membership for a user (Legacy)](Teams::get_membership_for_user_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsGetMembershipForUserLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsGetMembershipForUserLegacyError) -> Self { + let (description, status_code) = match err { + TeamsGetMembershipForUserLegacyError::Status404(_) => (String::from("Resource not found"), 404), + TeamsGetMembershipForUserLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List teams](Teams::list_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden")] Status403(BasicError), #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsListError) -> Self { + let (description, status_code) = match err { + TeamsListError::Status403(_) => (String::from("Forbidden"), 403), + TeamsListError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List child teams](Teams::list_child_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListChildInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListChildInOrgError) -> Self { + let (description, status_code) = match err { + TeamsListChildInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List child teams (Legacy)](Teams::list_child_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListChildLegacyError { - #[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("Forbidden")] @@ -674,87 +826,110 @@ pub enum TeamsListChildLegacyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsListChildLegacyError) -> Self { + let (description, status_code) = match err { + TeamsListChildLegacyError::Status404(_) => (String::from("Resource not found"), 404), + TeamsListChildLegacyError::Status403(_) => (String::from("Forbidden"), 403), + TeamsListChildLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + TeamsListChildLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List discussion comments](Teams::list_discussion_comments_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListDiscussionCommentsInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListDiscussionCommentsInOrgError) -> Self { + let (description, status_code) = match err { + TeamsListDiscussionCommentsInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List discussion comments (Legacy)](Teams::list_discussion_comments_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListDiscussionCommentsLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListDiscussionCommentsLegacyError) -> Self { + let (description, status_code) = match err { + TeamsListDiscussionCommentsLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List discussions](Teams::list_discussions_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListDiscussionsInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListDiscussionsInOrgError) -> Self { + let (description, status_code) = match err { + TeamsListDiscussionsInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List discussions (Legacy)](Teams::list_discussions_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListDiscussionsLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListDiscussionsLegacyError) -> Self { + let (description, status_code) = match err { + TeamsListDiscussionsLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List teams for the authenticated user](Teams::list_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListForAuthenticatedUserError { - #[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("Resource not found")] @@ -765,235 +940,296 @@ pub enum TeamsListForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsListForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + TeamsListForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + TeamsListForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + TeamsListForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + TeamsListForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List team members](Teams::list_members_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListMembersInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListMembersInOrgError) -> Self { + let (description, status_code) = match err { + TeamsListMembersInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List team members (Legacy)](Teams::list_members_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListMembersLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListMembersLegacyError) -> Self { + let (description, status_code) = match err { + TeamsListMembersLegacyError::Status404(_) => (String::from("Resource not found"), 404), + TeamsListMembersLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List pending team invitations](Teams::list_pending_invitations_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListPendingInvitationsInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListPendingInvitationsInOrgError) -> Self { + let (description, status_code) = match err { + TeamsListPendingInvitationsInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List pending team invitations (Legacy)](Teams::list_pending_invitations_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListPendingInvitationsLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListPendingInvitationsLegacyError) -> Self { + let (description, status_code) = match err { + TeamsListPendingInvitationsLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List team projects](Teams::list_projects_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListProjectsInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListProjectsInOrgError) -> Self { + let (description, status_code) = match err { + TeamsListProjectsInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List team projects (Legacy)](Teams::list_projects_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListProjectsLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListProjectsLegacyError) -> Self { + let (description, status_code) = match err { + TeamsListProjectsLegacyError::Status404(_) => (String::from("Resource not found"), 404), + TeamsListProjectsLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List team repositories](Teams::list_repos_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListReposInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListReposInOrgError) -> Self { + let (description, status_code) = match err { + TeamsListReposInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List team repositories (Legacy)](Teams::list_repos_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsListReposLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsListReposLegacyError) -> Self { + let (description, status_code) = match err { + TeamsListReposLegacyError::Status404(_) => (String::from("Resource not found"), 404), + TeamsListReposLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove team member (Legacy)](Teams::remove_member_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsRemoveMemberLegacyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Not Found if team synchronization is setup")] Status404, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsRemoveMemberLegacyError) -> Self { + let (description, status_code) = match err { + TeamsRemoveMemberLegacyError::Status404 => (String::from("Not Found if team synchronization is setup"), 404), + TeamsRemoveMemberLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove team membership for a user](Teams::remove_membership_for_user_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsRemoveMembershipForUserInOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Forbidden if team synchronization is set up")] Status403, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsRemoveMembershipForUserInOrgError) -> Self { + let (description, status_code) = match err { + TeamsRemoveMembershipForUserInOrgError::Status403 => (String::from("Forbidden if team synchronization is set up"), 403), + TeamsRemoveMembershipForUserInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove team membership for a user (Legacy)](Teams::remove_membership_for_user_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsRemoveMembershipForUserLegacyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("if team synchronization is set up")] Status403, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsRemoveMembershipForUserLegacyError) -> Self { + let (description, status_code) = match err { + TeamsRemoveMembershipForUserLegacyError::Status403 => (String::from("if team synchronization is set up"), 403), + TeamsRemoveMembershipForUserLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove a project from a team](Teams::remove_project_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsRemoveProjectInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsRemoveProjectInOrgError) -> Self { + let (description, status_code) = match err { + TeamsRemoveProjectInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove a project from a team (Legacy)](Teams::remove_project_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsRemoveProjectLegacyError { - #[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, or the endpoint has been spammed.")] @@ -1002,121 +1238,151 @@ pub enum TeamsRemoveProjectLegacyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsRemoveProjectLegacyError) -> Self { + let (description, status_code) = match err { + TeamsRemoveProjectLegacyError::Status404(_) => (String::from("Resource not found"), 404), + TeamsRemoveProjectLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + TeamsRemoveProjectLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove a repository from a team](Teams::remove_repo_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsRemoveRepoInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsRemoveRepoInOrgError) -> Self { + let (description, status_code) = match err { + TeamsRemoveRepoInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Remove a repository from a team (Legacy)](Teams::remove_repo_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsRemoveRepoLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsRemoveRepoLegacyError) -> Self { + let (description, status_code) = match err { + TeamsRemoveRepoLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a discussion comment](Teams::update_discussion_comment_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsUpdateDiscussionCommentInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsUpdateDiscussionCommentInOrgError) -> Self { + let (description, status_code) = match err { + TeamsUpdateDiscussionCommentInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a discussion comment (Legacy)](Teams::update_discussion_comment_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsUpdateDiscussionCommentLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsUpdateDiscussionCommentLegacyError) -> Self { + let (description, status_code) = match err { + TeamsUpdateDiscussionCommentLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a discussion](Teams::update_discussion_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsUpdateDiscussionInOrgError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsUpdateDiscussionInOrgError) -> Self { + let (description, status_code) = match err { + TeamsUpdateDiscussionInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a discussion (Legacy)](Teams::update_discussion_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsUpdateDiscussionLegacyError { - #[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 }, } +impl From for AdapterError { + fn from(err: TeamsUpdateDiscussionLegacyError) -> Self { + let (description, status_code) = match err { + TeamsUpdateDiscussionLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a team](Teams::update_in_org_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsUpdateInOrgError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status201(TeamFull), #[error("Resource not found")] @@ -1129,19 +1395,27 @@ pub enum TeamsUpdateInOrgError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsUpdateInOrgError) -> Self { + let (description, status_code) = match err { + TeamsUpdateInOrgError::Status201(_) => (String::from("Response"), 201), + TeamsUpdateInOrgError::Status404(_) => (String::from("Resource not found"), 404), + TeamsUpdateInOrgError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + TeamsUpdateInOrgError::Status403(_) => (String::from("Forbidden"), 403), + TeamsUpdateInOrgError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update a team (Legacy)](Teams::update_legacy_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum TeamsUpdateLegacyError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status201(TeamFull), #[error("Resource not found")] @@ -1154,6 +1428,24 @@ pub enum TeamsUpdateLegacyError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: TeamsUpdateLegacyError) -> Self { + let (description, status_code) = match err { + TeamsUpdateLegacyError::Status201(_) => (String::from("Response"), 201), + TeamsUpdateLegacyError::Status404(_) => (String::from("Resource not found"), 404), + TeamsUpdateLegacyError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + TeamsUpdateLegacyError::Status403(_) => (String::from("Forbidden"), 403), + TeamsUpdateLegacyError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [List teams](Teams::list_async()) endpoint. #[derive(Default, Serialize)] @@ -1889,7 +2181,7 @@ impl<'enc> From<&'enc PerPage> for TeamsListReposLegacyParams { } } -impl<'api, C: Client> Teams<'api, C> { +impl<'api, C: Client> Teams<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Add team member (Legacy) @@ -1910,19 +2202,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for add_member_legacy](https://docs.github.com/rest/teams/members#add-team-member-legacy) /// /// --- - pub async fn add_member_legacy_async(&self, team_id: i32, username: &str) -> Result<(), TeamsAddMemberLegacyError> { + pub async fn add_member_legacy_async(&self, team_id: i32, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1934,10 +2226,10 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsAddMemberLegacyError::Status404), - 422 => Err(TeamsAddMemberLegacyError::Status422), - 403 => Err(TeamsAddMemberLegacyError::Status403(github_response.to_json_async().await?)), - code => Err(TeamsAddMemberLegacyError::Generic { code }), + 404 => Err(TeamsAddMemberLegacyError::Status404.into()), + 422 => Err(TeamsAddMemberLegacyError::Status422.into()), + 403 => Err(TeamsAddMemberLegacyError::Status403(github_response.to_json_async().await?).into()), + code => Err(TeamsAddMemberLegacyError::Generic { code }.into()), } } } @@ -1963,7 +2255,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_member_legacy(&self, team_id: i32, username: &str) -> Result<(), TeamsAddMemberLegacyError> { + pub fn add_member_legacy(&self, team_id: i32, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username); @@ -1975,7 +2267,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1987,10 +2279,10 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsAddMemberLegacyError::Status404), - 422 => Err(TeamsAddMemberLegacyError::Status422), - 403 => Err(TeamsAddMemberLegacyError::Status403(github_response.to_json()?)), - code => Err(TeamsAddMemberLegacyError::Generic { code }), + 404 => Err(TeamsAddMemberLegacyError::Status404.into()), + 422 => Err(TeamsAddMemberLegacyError::Status422.into()), + 403 => Err(TeamsAddMemberLegacyError::Status403(github_response.to_json()?).into()), + code => Err(TeamsAddMemberLegacyError::Generic { code }.into()), } } } @@ -2016,19 +2308,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for add_or_update_membership_for_user_in_org](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user) /// /// --- - pub async fn add_or_update_membership_for_user_in_org_async(&self, org: &str, team_slug: &str, username: &str, body: PutTeamsAddOrUpdateMembershipForUserInOrg) -> Result { + pub async fn add_or_update_membership_for_user_in_org_async(&self, org: &str, team_slug: &str, username: &str, body: PutTeamsAddOrUpdateMembershipForUserInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateMembershipForUserInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2040,9 +2332,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status403), - 422 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status422), - code => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Generic { code }), + 403 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status403.into()), + 422 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status422.into()), + code => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Generic { code }.into()), } } } @@ -2069,19 +2361,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_or_update_membership_for_user_in_org(&self, org: &str, team_slug: &str, username: &str, body: PutTeamsAddOrUpdateMembershipForUserInOrg) -> Result { + pub fn add_or_update_membership_for_user_in_org(&self, org: &str, team_slug: &str, username: &str, body: PutTeamsAddOrUpdateMembershipForUserInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateMembershipForUserInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2093,9 +2385,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status403), - 422 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status422), - code => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Generic { code }), + 403 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status403.into()), + 422 => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Status422.into()), + code => Err(TeamsAddOrUpdateMembershipForUserInOrgError::Generic { code }.into()), } } } @@ -2121,19 +2413,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for add_or_update_membership_for_user_legacy](https://docs.github.com/rest/teams/members#add-or-update-team-membership-for-a-user-legacy) /// /// --- - pub async fn add_or_update_membership_for_user_legacy_async(&self, team_id: i32, username: &str, body: PutTeamsAddOrUpdateMembershipForUserLegacy) -> Result { + pub async fn add_or_update_membership_for_user_legacy_async(&self, team_id: i32, username: &str, body: PutTeamsAddOrUpdateMembershipForUserLegacy) -> Result { let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateMembershipForUserLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2145,10 +2437,10 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status403), - 422 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status422), - 404 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status404(github_response.to_json_async().await?)), - code => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Generic { code }), + 403 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status403.into()), + 422 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status422.into()), + 404 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status404(github_response.to_json_async().await?).into()), + code => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Generic { code }.into()), } } } @@ -2175,19 +2467,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_or_update_membership_for_user_legacy(&self, team_id: i32, username: &str, body: PutTeamsAddOrUpdateMembershipForUserLegacy) -> Result { + pub fn add_or_update_membership_for_user_legacy(&self, team_id: i32, username: &str, body: PutTeamsAddOrUpdateMembershipForUserLegacy) -> Result { let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateMembershipForUserLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2199,10 +2491,10 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status403), - 422 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status422), - 404 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status404(github_response.to_json()?)), - code => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Generic { code }), + 403 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status403.into()), + 422 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status422.into()), + 404 => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Status404(github_response.to_json()?).into()), + code => Err(TeamsAddOrUpdateMembershipForUserLegacyError::Generic { code }.into()), } } } @@ -2219,19 +2511,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for add_or_update_project_permissions_in_org](https://docs.github.com/rest/teams/teams#add-or-update-team-project-permissions) /// /// --- - pub async fn add_or_update_project_permissions_in_org_async(&self, org: &str, team_slug: &str, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsInOrg) -> Result<(), TeamsAddOrUpdateProjectPermissionsInOrgError> { + pub async fn add_or_update_project_permissions_in_org_async(&self, org: &str, team_slug: &str, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsInOrg) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateProjectPermissionsInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2243,8 +2535,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Status403(github_response.to_json_async().await?)), - code => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Generic { code }), + 403 => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Status403(github_response.to_json_async().await?).into()), + code => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Generic { code }.into()), } } } @@ -2262,19 +2554,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_or_update_project_permissions_in_org(&self, org: &str, team_slug: &str, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsInOrg) -> Result<(), TeamsAddOrUpdateProjectPermissionsInOrgError> { + pub fn add_or_update_project_permissions_in_org(&self, org: &str, team_slug: &str, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsInOrg) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateProjectPermissionsInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2286,8 +2578,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Status403(github_response.to_json()?)), - code => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Generic { code }), + 403 => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Status403(github_response.to_json()?).into()), + code => Err(TeamsAddOrUpdateProjectPermissionsInOrgError::Generic { code }.into()), } } } @@ -2304,19 +2596,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for add_or_update_project_permissions_legacy](https://docs.github.com/rest/teams/teams#add-or-update-team-project-permissions-legacy) /// /// --- - pub async fn add_or_update_project_permissions_legacy_async(&self, team_id: i32, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsLegacy) -> Result<(), TeamsAddOrUpdateProjectPermissionsLegacyError> { + pub async fn add_or_update_project_permissions_legacy_async(&self, team_id: i32, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsLegacy) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateProjectPermissionsLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2328,10 +2620,10 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status403(github_response.to_json_async().await?)), - 404 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status404(github_response.to_json_async().await?)), - 422 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status422(github_response.to_json_async().await?)), - code => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Generic { code }), + 403 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status403(github_response.to_json_async().await?).into()), + 404 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status422(github_response.to_json_async().await?).into()), + code => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Generic { code }.into()), } } } @@ -2349,19 +2641,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_or_update_project_permissions_legacy(&self, team_id: i32, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsLegacy) -> Result<(), TeamsAddOrUpdateProjectPermissionsLegacyError> { + pub fn add_or_update_project_permissions_legacy(&self, team_id: i32, project_id: i32, body: PutTeamsAddOrUpdateProjectPermissionsLegacy) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateProjectPermissionsLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2373,10 +2665,10 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status403(github_response.to_json()?)), - 404 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status404(github_response.to_json()?)), - 422 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status422(github_response.to_json()?)), - code => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Generic { code }), + 403 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status403(github_response.to_json()?).into()), + 404 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status404(github_response.to_json()?).into()), + 422 => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Status422(github_response.to_json()?).into()), + code => Err(TeamsAddOrUpdateProjectPermissionsLegacyError::Generic { code }.into()), } } } @@ -2395,19 +2687,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for add_or_update_repo_permissions_in_org](https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions) /// /// --- - pub async fn add_or_update_repo_permissions_in_org_async(&self, org: &str, team_slug: &str, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsInOrg) -> Result<(), TeamsAddOrUpdateRepoPermissionsInOrgError> { + pub async fn add_or_update_repo_permissions_in_org_async(&self, org: &str, team_slug: &str, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsInOrg) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateRepoPermissionsInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2419,7 +2711,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsAddOrUpdateRepoPermissionsInOrgError::Generic { code }), + code => Err(TeamsAddOrUpdateRepoPermissionsInOrgError::Generic { code }.into()), } } } @@ -2439,19 +2731,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_or_update_repo_permissions_in_org(&self, org: &str, team_slug: &str, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsInOrg) -> Result<(), TeamsAddOrUpdateRepoPermissionsInOrgError> { + pub fn add_or_update_repo_permissions_in_org(&self, org: &str, team_slug: &str, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsInOrg) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateRepoPermissionsInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2463,7 +2755,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsAddOrUpdateRepoPermissionsInOrgError::Generic { code }), + code => Err(TeamsAddOrUpdateRepoPermissionsInOrgError::Generic { code }.into()), } } } @@ -2482,19 +2774,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for add_or_update_repo_permissions_legacy](https://docs.github.com/rest/teams/teams#add-or-update-team-repository-permissions-legacy) /// /// --- - pub async fn add_or_update_repo_permissions_legacy_async(&self, team_id: i32, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsLegacy) -> Result<(), TeamsAddOrUpdateRepoPermissionsLegacyError> { + pub async fn add_or_update_repo_permissions_legacy_async(&self, team_id: i32, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsLegacy) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateRepoPermissionsLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2506,9 +2798,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status403(github_response.to_json_async().await?)), - 422 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status422(github_response.to_json_async().await?)), - code => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Generic { code }), + 403 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status422(github_response.to_json_async().await?).into()), + code => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Generic { code }.into()), } } } @@ -2528,19 +2820,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_or_update_repo_permissions_legacy(&self, team_id: i32, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsLegacy) -> Result<(), TeamsAddOrUpdateRepoPermissionsLegacyError> { + pub fn add_or_update_repo_permissions_legacy(&self, team_id: i32, owner: &str, repo: &str, body: PutTeamsAddOrUpdateRepoPermissionsLegacy) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo); let req = GitHubRequest { uri: request_uri, - body: Some(PutTeamsAddOrUpdateRepoPermissionsLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2552,9 +2844,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status403(github_response.to_json()?)), - 422 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status422(github_response.to_json()?)), - code => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Generic { code }), + 403 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status403(github_response.to_json()?).into()), + 422 => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Status422(github_response.to_json()?).into()), + code => Err(TeamsAddOrUpdateRepoPermissionsLegacyError::Generic { code }.into()), } } } @@ -2571,19 +2863,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for check_permissions_for_project_in_org](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-project) /// /// --- - pub async fn check_permissions_for_project_in_org_async(&self, org: &str, team_slug: &str, project_id: i32) -> Result { + pub async fn check_permissions_for_project_in_org_async(&self, org: &str, team_slug: &str, project_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2595,8 +2887,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsCheckPermissionsForProjectInOrgError::Status404), - code => Err(TeamsCheckPermissionsForProjectInOrgError::Generic { code }), + 404 => Err(TeamsCheckPermissionsForProjectInOrgError::Status404.into()), + code => Err(TeamsCheckPermissionsForProjectInOrgError::Generic { code }.into()), } } } @@ -2614,7 +2906,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_permissions_for_project_in_org(&self, org: &str, team_slug: &str, project_id: i32) -> Result { + pub fn check_permissions_for_project_in_org(&self, org: &str, team_slug: &str, project_id: i32) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id); @@ -2626,7 +2918,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2638,8 +2930,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsCheckPermissionsForProjectInOrgError::Status404), - code => Err(TeamsCheckPermissionsForProjectInOrgError::Generic { code }), + 404 => Err(TeamsCheckPermissionsForProjectInOrgError::Status404.into()), + code => Err(TeamsCheckPermissionsForProjectInOrgError::Generic { code }.into()), } } } @@ -2656,19 +2948,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for check_permissions_for_project_legacy](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-project-legacy) /// /// --- - pub async fn check_permissions_for_project_legacy_async(&self, team_id: i32, project_id: i32) -> Result { + pub async fn check_permissions_for_project_legacy_async(&self, team_id: i32, project_id: i32) -> Result { let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2680,8 +2972,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsCheckPermissionsForProjectLegacyError::Status404), - code => Err(TeamsCheckPermissionsForProjectLegacyError::Generic { code }), + 404 => Err(TeamsCheckPermissionsForProjectLegacyError::Status404.into()), + code => Err(TeamsCheckPermissionsForProjectLegacyError::Generic { code }.into()), } } } @@ -2699,7 +2991,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_permissions_for_project_legacy(&self, team_id: i32, project_id: i32) -> Result { + pub fn check_permissions_for_project_legacy(&self, team_id: i32, project_id: i32) -> Result { let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id); @@ -2711,7 +3003,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2723,8 +3015,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsCheckPermissionsForProjectLegacyError::Status404), - code => Err(TeamsCheckPermissionsForProjectLegacyError::Generic { code }), + 404 => Err(TeamsCheckPermissionsForProjectLegacyError::Status404.into()), + code => Err(TeamsCheckPermissionsForProjectLegacyError::Generic { code }.into()), } } } @@ -2747,19 +3039,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for check_permissions_for_repo_in_org](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository) /// /// --- - pub async fn check_permissions_for_repo_in_org_async(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result { + pub async fn check_permissions_for_repo_in_org_async(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2771,9 +3063,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(TeamsCheckPermissionsForRepoInOrgError::Status204), - 404 => Err(TeamsCheckPermissionsForRepoInOrgError::Status404), - code => Err(TeamsCheckPermissionsForRepoInOrgError::Generic { code }), + 204 => Err(TeamsCheckPermissionsForRepoInOrgError::Status204.into()), + 404 => Err(TeamsCheckPermissionsForRepoInOrgError::Status404.into()), + code => Err(TeamsCheckPermissionsForRepoInOrgError::Generic { code }.into()), } } } @@ -2797,7 +3089,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_permissions_for_repo_in_org(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result { + pub fn check_permissions_for_repo_in_org(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo); @@ -2809,7 +3101,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2821,9 +3113,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(TeamsCheckPermissionsForRepoInOrgError::Status204), - 404 => Err(TeamsCheckPermissionsForRepoInOrgError::Status404), - code => Err(TeamsCheckPermissionsForRepoInOrgError::Generic { code }), + 204 => Err(TeamsCheckPermissionsForRepoInOrgError::Status204.into()), + 404 => Err(TeamsCheckPermissionsForRepoInOrgError::Status404.into()), + code => Err(TeamsCheckPermissionsForRepoInOrgError::Generic { code }.into()), } } } @@ -2843,19 +3135,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for check_permissions_for_repo_legacy](https://docs.github.com/rest/teams/teams#check-team-permissions-for-a-repository-legacy) /// /// --- - pub async fn check_permissions_for_repo_legacy_async(&self, team_id: i32, owner: &str, repo: &str) -> Result { + pub async fn check_permissions_for_repo_legacy_async(&self, team_id: i32, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2867,9 +3159,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 204 => Err(TeamsCheckPermissionsForRepoLegacyError::Status204), - 404 => Err(TeamsCheckPermissionsForRepoLegacyError::Status404), - code => Err(TeamsCheckPermissionsForRepoLegacyError::Generic { code }), + 204 => Err(TeamsCheckPermissionsForRepoLegacyError::Status204.into()), + 404 => Err(TeamsCheckPermissionsForRepoLegacyError::Status404.into()), + code => Err(TeamsCheckPermissionsForRepoLegacyError::Generic { code }.into()), } } } @@ -2890,7 +3182,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_permissions_for_repo_legacy(&self, team_id: i32, owner: &str, repo: &str) -> Result { + pub fn check_permissions_for_repo_legacy(&self, team_id: i32, owner: &str, repo: &str) -> Result { let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo); @@ -2902,7 +3194,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2914,9 +3206,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 204 => Err(TeamsCheckPermissionsForRepoLegacyError::Status204), - 404 => Err(TeamsCheckPermissionsForRepoLegacyError::Status404), - code => Err(TeamsCheckPermissionsForRepoLegacyError::Generic { code }), + 204 => Err(TeamsCheckPermissionsForRepoLegacyError::Status204.into()), + 404 => Err(TeamsCheckPermissionsForRepoLegacyError::Status404.into()), + code => Err(TeamsCheckPermissionsForRepoLegacyError::Generic { code }.into()), } } } @@ -2932,19 +3224,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for create](https://docs.github.com/rest/teams/teams#create-a-team) /// /// --- - pub async fn create_async(&self, org: &str, body: PostTeamsCreate) -> Result { + pub async fn create_async(&self, org: &str, body: PostTeamsCreate) -> Result { let request_uri = format!("{}/orgs/{}/teams", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostTeamsCreate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2956,9 +3248,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(TeamsCreateError::Status422(github_response.to_json_async().await?)), - 403 => Err(TeamsCreateError::Status403(github_response.to_json_async().await?)), - code => Err(TeamsCreateError::Generic { code }), + 422 => Err(TeamsCreateError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(TeamsCreateError::Status403(github_response.to_json_async().await?).into()), + code => Err(TeamsCreateError::Generic { code }.into()), } } } @@ -2975,19 +3267,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create(&self, org: &str, body: PostTeamsCreate) -> Result { + pub fn create(&self, org: &str, body: PostTeamsCreate) -> Result { let request_uri = format!("{}/orgs/{}/teams", super::GITHUB_BASE_API_URL, org); let req = GitHubRequest { uri: request_uri, - body: Some(PostTeamsCreate::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2999,9 +3291,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(TeamsCreateError::Status422(github_response.to_json()?)), - 403 => Err(TeamsCreateError::Status403(github_response.to_json()?)), - code => Err(TeamsCreateError::Generic { code }), + 422 => Err(TeamsCreateError::Status422(github_response.to_json()?).into()), + 403 => Err(TeamsCreateError::Status403(github_response.to_json()?).into()), + code => Err(TeamsCreateError::Generic { code }.into()), } } } @@ -3022,19 +3314,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for create_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#create-a-discussion-comment) /// /// --- - pub async fn create_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, body: PostTeamsCreateDiscussionCommentInOrg) -> Result { + pub async fn create_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, body: PostTeamsCreateDiscussionCommentInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostTeamsCreateDiscussionCommentInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3046,7 +3338,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsCreateDiscussionCommentInOrgError::Generic { code }), + code => Err(TeamsCreateDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -3068,19 +3360,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, body: PostTeamsCreateDiscussionCommentInOrg) -> Result { + pub fn create_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, body: PostTeamsCreateDiscussionCommentInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostTeamsCreateDiscussionCommentInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3092,7 +3384,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsCreateDiscussionCommentInOrgError::Generic { code }), + code => Err(TeamsCreateDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -3113,19 +3405,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for create_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#create-a-discussion-comment-legacy) /// /// --- - pub async fn create_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, body: PostTeamsCreateDiscussionCommentLegacy) -> Result { + pub async fn create_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, body: PostTeamsCreateDiscussionCommentLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, team_id, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostTeamsCreateDiscussionCommentLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3137,7 +3429,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsCreateDiscussionCommentLegacyError::Generic { code }), + code => Err(TeamsCreateDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -3159,19 +3451,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, body: PostTeamsCreateDiscussionCommentLegacy) -> Result { + pub fn create_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, body: PostTeamsCreateDiscussionCommentLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, team_id, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PostTeamsCreateDiscussionCommentLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3183,7 +3475,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsCreateDiscussionCommentLegacyError::Generic { code }), + code => Err(TeamsCreateDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -3204,19 +3496,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for create_discussion_in_org](https://docs.github.com/rest/teams/discussions#create-a-discussion) /// /// --- - pub async fn create_discussion_in_org_async(&self, org: &str, team_slug: &str, body: PostTeamsCreateDiscussionInOrg) -> Result { + pub async fn create_discussion_in_org_async(&self, org: &str, team_slug: &str, body: PostTeamsCreateDiscussionInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, org, team_slug); let req = GitHubRequest { uri: request_uri, - body: Some(PostTeamsCreateDiscussionInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3228,7 +3520,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsCreateDiscussionInOrgError::Generic { code }), + code => Err(TeamsCreateDiscussionInOrgError::Generic { code }.into()), } } } @@ -3250,19 +3542,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_discussion_in_org(&self, org: &str, team_slug: &str, body: PostTeamsCreateDiscussionInOrg) -> Result { + pub fn create_discussion_in_org(&self, org: &str, team_slug: &str, body: PostTeamsCreateDiscussionInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, org, team_slug); let req = GitHubRequest { uri: request_uri, - body: Some(PostTeamsCreateDiscussionInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3274,7 +3566,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsCreateDiscussionInOrgError::Generic { code }), + code => Err(TeamsCreateDiscussionInOrgError::Generic { code }.into()), } } } @@ -3295,19 +3587,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for create_discussion_legacy](https://docs.github.com/rest/teams/discussions#create-a-discussion-legacy) /// /// --- - pub async fn create_discussion_legacy_async(&self, team_id: i32, body: PostTeamsCreateDiscussionLegacy) -> Result { + pub async fn create_discussion_legacy_async(&self, team_id: i32, body: PostTeamsCreateDiscussionLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, team_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostTeamsCreateDiscussionLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3319,7 +3611,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsCreateDiscussionLegacyError::Generic { code }), + code => Err(TeamsCreateDiscussionLegacyError::Generic { code }.into()), } } } @@ -3341,19 +3633,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_discussion_legacy(&self, team_id: i32, body: PostTeamsCreateDiscussionLegacy) -> Result { + pub fn create_discussion_legacy(&self, team_id: i32, body: PostTeamsCreateDiscussionLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, team_id); let req = GitHubRequest { uri: request_uri, - body: Some(PostTeamsCreateDiscussionLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3365,7 +3657,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsCreateDiscussionLegacyError::Generic { code }), + code => Err(TeamsCreateDiscussionLegacyError::Generic { code }.into()), } } } @@ -3384,19 +3676,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for delete_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#delete-a-discussion-comment) /// /// --- - pub async fn delete_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result<(), TeamsDeleteDiscussionCommentInOrgError> { + pub async fn delete_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3408,7 +3700,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsDeleteDiscussionCommentInOrgError::Generic { code }), + code => Err(TeamsDeleteDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -3428,7 +3720,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result<(), TeamsDeleteDiscussionCommentInOrgError> { + pub fn delete_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number); @@ -3440,7 +3732,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3452,7 +3744,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsDeleteDiscussionCommentInOrgError::Generic { code }), + code => Err(TeamsDeleteDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -3471,19 +3763,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for delete_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#delete-a-discussion-comment-legacy) /// /// --- - pub async fn delete_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result<(), TeamsDeleteDiscussionCommentLegacyError> { + pub async fn delete_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3495,7 +3787,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsDeleteDiscussionCommentLegacyError::Generic { code }), + code => Err(TeamsDeleteDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -3515,7 +3807,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result<(), TeamsDeleteDiscussionCommentLegacyError> { + pub fn delete_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number); @@ -3527,7 +3819,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3539,7 +3831,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsDeleteDiscussionCommentLegacyError::Generic { code }), + code => Err(TeamsDeleteDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -3558,19 +3850,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for delete_discussion_in_org](https://docs.github.com/rest/teams/discussions#delete-a-discussion) /// /// --- - pub async fn delete_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result<(), TeamsDeleteDiscussionInOrgError> { + pub async fn delete_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3582,7 +3874,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsDeleteDiscussionInOrgError::Generic { code }), + code => Err(TeamsDeleteDiscussionInOrgError::Generic { code }.into()), } } } @@ -3602,7 +3894,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result<(), TeamsDeleteDiscussionInOrgError> { + pub fn delete_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); @@ -3614,7 +3906,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3626,7 +3918,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsDeleteDiscussionInOrgError::Generic { code }), + code => Err(TeamsDeleteDiscussionInOrgError::Generic { code }.into()), } } } @@ -3645,19 +3937,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for delete_discussion_legacy](https://docs.github.com/rest/teams/discussions#delete-a-discussion-legacy) /// /// --- - pub async fn delete_discussion_legacy_async(&self, team_id: i32, discussion_number: i32) -> Result<(), TeamsDeleteDiscussionLegacyError> { + pub async fn delete_discussion_legacy_async(&self, team_id: i32, discussion_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3669,7 +3961,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsDeleteDiscussionLegacyError::Generic { code }), + code => Err(TeamsDeleteDiscussionLegacyError::Generic { code }.into()), } } } @@ -3689,7 +3981,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_discussion_legacy(&self, team_id: i32, discussion_number: i32) -> Result<(), TeamsDeleteDiscussionLegacyError> { + pub fn delete_discussion_legacy(&self, team_id: i32, discussion_number: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number); @@ -3701,7 +3993,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3713,7 +4005,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsDeleteDiscussionLegacyError::Generic { code }), + code => Err(TeamsDeleteDiscussionLegacyError::Generic { code }.into()), } } } @@ -3732,19 +4024,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for delete_in_org](https://docs.github.com/rest/teams/teams#delete-a-team) /// /// --- - pub async fn delete_in_org_async(&self, org: &str, team_slug: &str) -> Result<(), TeamsDeleteInOrgError> { + pub async fn delete_in_org_async(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3756,7 +4048,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsDeleteInOrgError::Generic { code }), + code => Err(TeamsDeleteInOrgError::Generic { code }.into()), } } } @@ -3776,7 +4068,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_in_org(&self, org: &str, team_slug: &str) -> Result<(), TeamsDeleteInOrgError> { + pub fn delete_in_org(&self, org: &str, team_slug: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); @@ -3788,7 +4080,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3800,7 +4092,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsDeleteInOrgError::Generic { code }), + code => Err(TeamsDeleteInOrgError::Generic { code }.into()), } } } @@ -3819,19 +4111,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for delete_legacy](https://docs.github.com/rest/teams/teams#delete-a-team-legacy) /// /// --- - pub async fn delete_legacy_async(&self, team_id: i32) -> Result<(), TeamsDeleteLegacyError> { + pub async fn delete_legacy_async(&self, team_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3843,9 +4135,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsDeleteLegacyError::Status404(github_response.to_json_async().await?)), - 422 => Err(TeamsDeleteLegacyError::Status422(github_response.to_json_async().await?)), - code => Err(TeamsDeleteLegacyError::Generic { code }), + 404 => Err(TeamsDeleteLegacyError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(TeamsDeleteLegacyError::Status422(github_response.to_json_async().await?).into()), + code => Err(TeamsDeleteLegacyError::Generic { code }.into()), } } } @@ -3865,7 +4157,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_legacy(&self, team_id: i32) -> Result<(), TeamsDeleteLegacyError> { + pub fn delete_legacy(&self, team_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id); @@ -3877,7 +4169,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3889,9 +4181,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsDeleteLegacyError::Status404(github_response.to_json()?)), - 422 => Err(TeamsDeleteLegacyError::Status422(github_response.to_json()?)), - code => Err(TeamsDeleteLegacyError::Generic { code }), + 404 => Err(TeamsDeleteLegacyError::Status404(github_response.to_json()?).into()), + 422 => Err(TeamsDeleteLegacyError::Status422(github_response.to_json()?).into()), + code => Err(TeamsDeleteLegacyError::Generic { code }.into()), } } } @@ -3908,19 +4200,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for get_by_name](https://docs.github.com/rest/teams/teams#get-a-team-by-name) /// /// --- - pub async fn get_by_name_async(&self, org: &str, team_slug: &str) -> Result { + pub async fn get_by_name_async(&self, org: &str, team_slug: &str) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3932,8 +4224,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsGetByNameError::Status404(github_response.to_json_async().await?)), - code => Err(TeamsGetByNameError::Generic { code }), + 404 => Err(TeamsGetByNameError::Status404(github_response.to_json_async().await?).into()), + code => Err(TeamsGetByNameError::Generic { code }.into()), } } } @@ -3951,7 +4243,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_by_name(&self, org: &str, team_slug: &str) -> Result { + pub fn get_by_name(&self, org: &str, team_slug: &str) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); @@ -3963,7 +4255,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3975,8 +4267,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsGetByNameError::Status404(github_response.to_json()?)), - code => Err(TeamsGetByNameError::Generic { code }), + 404 => Err(TeamsGetByNameError::Status404(github_response.to_json()?).into()), + code => Err(TeamsGetByNameError::Generic { code }.into()), } } } @@ -3995,19 +4287,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for get_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#get-a-discussion-comment) /// /// --- - pub async fn get_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result { + pub async fn get_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4019,7 +4311,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsGetDiscussionCommentInOrgError::Generic { code }), + code => Err(TeamsGetDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -4039,7 +4331,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result { + pub fn get_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number); @@ -4051,7 +4343,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4063,7 +4355,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsGetDiscussionCommentInOrgError::Generic { code }), + code => Err(TeamsGetDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -4082,19 +4374,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for get_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#get-a-discussion-comment-legacy) /// /// --- - pub async fn get_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result { + pub async fn get_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4106,7 +4398,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsGetDiscussionCommentLegacyError::Generic { code }), + code => Err(TeamsGetDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -4126,7 +4418,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result { + pub fn get_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number); @@ -4138,7 +4430,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4150,7 +4442,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsGetDiscussionCommentLegacyError::Generic { code }), + code => Err(TeamsGetDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -4169,19 +4461,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for get_discussion_in_org](https://docs.github.com/rest/teams/discussions#get-a-discussion) /// /// --- - pub async fn get_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result { + pub async fn get_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4193,7 +4485,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsGetDiscussionInOrgError::Generic { code }), + code => Err(TeamsGetDiscussionInOrgError::Generic { code }.into()), } } } @@ -4213,7 +4505,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result { + pub fn get_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); @@ -4225,7 +4517,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4237,7 +4529,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsGetDiscussionInOrgError::Generic { code }), + code => Err(TeamsGetDiscussionInOrgError::Generic { code }.into()), } } } @@ -4256,19 +4548,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for get_discussion_legacy](https://docs.github.com/rest/teams/discussions#get-a-discussion-legacy) /// /// --- - pub async fn get_discussion_legacy_async(&self, team_id: i32, discussion_number: i32) -> Result { + pub async fn get_discussion_legacy_async(&self, team_id: i32, discussion_number: i32) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4280,7 +4572,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsGetDiscussionLegacyError::Generic { code }), + code => Err(TeamsGetDiscussionLegacyError::Generic { code }.into()), } } } @@ -4300,7 +4592,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_discussion_legacy(&self, team_id: i32, discussion_number: i32) -> Result { + pub fn get_discussion_legacy(&self, team_id: i32, discussion_number: i32) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number); @@ -4312,7 +4604,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4324,7 +4616,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsGetDiscussionLegacyError::Generic { code }), + code => Err(TeamsGetDiscussionLegacyError::Generic { code }.into()), } } } @@ -4339,19 +4631,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for get_legacy](https://docs.github.com/rest/teams/teams#get-a-team-legacy) /// /// --- - pub async fn get_legacy_async(&self, team_id: i32) -> Result { + pub async fn get_legacy_async(&self, team_id: i32) -> Result { let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4363,8 +4655,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsGetLegacyError::Status404(github_response.to_json_async().await?)), - code => Err(TeamsGetLegacyError::Generic { code }), + 404 => Err(TeamsGetLegacyError::Status404(github_response.to_json_async().await?).into()), + code => Err(TeamsGetLegacyError::Generic { code }.into()), } } } @@ -4380,7 +4672,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_legacy(&self, team_id: i32) -> Result { + pub fn get_legacy(&self, team_id: i32) -> Result { let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id); @@ -4392,7 +4684,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4404,8 +4696,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsGetLegacyError::Status404(github_response.to_json()?)), - code => Err(TeamsGetLegacyError::Generic { code }), + 404 => Err(TeamsGetLegacyError::Status404(github_response.to_json()?).into()), + code => Err(TeamsGetLegacyError::Generic { code }.into()), } } } @@ -4423,19 +4715,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for get_member_legacy](https://docs.github.com/rest/teams/members#get-team-member-legacy) /// /// --- - pub async fn get_member_legacy_async(&self, team_id: i32, username: &str) -> Result<(), TeamsGetMemberLegacyError> { + pub async fn get_member_legacy_async(&self, team_id: i32, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4447,8 +4739,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsGetMemberLegacyError::Status404), - code => Err(TeamsGetMemberLegacyError::Generic { code }), + 404 => Err(TeamsGetMemberLegacyError::Status404.into()), + code => Err(TeamsGetMemberLegacyError::Generic { code }.into()), } } } @@ -4467,7 +4759,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_member_legacy(&self, team_id: i32, username: &str) -> Result<(), TeamsGetMemberLegacyError> { + pub fn get_member_legacy(&self, team_id: i32, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username); @@ -4479,7 +4771,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4491,8 +4783,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsGetMemberLegacyError::Status404), - code => Err(TeamsGetMemberLegacyError::Generic { code }), + 404 => Err(TeamsGetMemberLegacyError::Status404.into()), + code => Err(TeamsGetMemberLegacyError::Generic { code }.into()), } } } @@ -4516,19 +4808,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for get_membership_for_user_in_org](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user) /// /// --- - pub async fn get_membership_for_user_in_org_async(&self, org: &str, team_slug: &str, username: &str) -> Result { + pub async fn get_membership_for_user_in_org_async(&self, org: &str, team_slug: &str, username: &str) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4540,8 +4832,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsGetMembershipForUserInOrgError::Status404), - code => Err(TeamsGetMembershipForUserInOrgError::Generic { code }), + 404 => Err(TeamsGetMembershipForUserInOrgError::Status404.into()), + code => Err(TeamsGetMembershipForUserInOrgError::Generic { code }.into()), } } } @@ -4566,7 +4858,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_membership_for_user_in_org(&self, org: &str, team_slug: &str, username: &str) -> Result { + pub fn get_membership_for_user_in_org(&self, org: &str, team_slug: &str, username: &str) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username); @@ -4578,7 +4870,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4590,8 +4882,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsGetMembershipForUserInOrgError::Status404), - code => Err(TeamsGetMembershipForUserInOrgError::Generic { code }), + 404 => Err(TeamsGetMembershipForUserInOrgError::Status404.into()), + code => Err(TeamsGetMembershipForUserInOrgError::Generic { code }.into()), } } } @@ -4615,19 +4907,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for get_membership_for_user_legacy](https://docs.github.com/rest/teams/members#get-team-membership-for-a-user-legacy) /// /// --- - pub async fn get_membership_for_user_legacy_async(&self, team_id: i32, username: &str) -> Result { + pub async fn get_membership_for_user_legacy_async(&self, team_id: i32, username: &str) -> Result { let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4639,8 +4931,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsGetMembershipForUserLegacyError::Status404(github_response.to_json_async().await?)), - code => Err(TeamsGetMembershipForUserLegacyError::Generic { code }), + 404 => Err(TeamsGetMembershipForUserLegacyError::Status404(github_response.to_json_async().await?).into()), + code => Err(TeamsGetMembershipForUserLegacyError::Generic { code }.into()), } } } @@ -4665,7 +4957,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_membership_for_user_legacy(&self, team_id: i32, username: &str) -> Result { + pub fn get_membership_for_user_legacy(&self, team_id: i32, username: &str) -> Result { let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username); @@ -4677,7 +4969,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4689,8 +4981,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsGetMembershipForUserLegacyError::Status404(github_response.to_json()?)), - code => Err(TeamsGetMembershipForUserLegacyError::Generic { code }), + 404 => Err(TeamsGetMembershipForUserLegacyError::Status404(github_response.to_json()?).into()), + code => Err(TeamsGetMembershipForUserLegacyError::Generic { code }.into()), } } } @@ -4704,7 +4996,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list](https://docs.github.com/rest/teams/teams#list-teams) /// /// --- - pub async fn list_async(&self, org: &str, query_params: Option>) -> Result, TeamsListError> { + pub async fn list_async(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams", super::GITHUB_BASE_API_URL, org); @@ -4715,12 +5007,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4732,8 +5024,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(TeamsListError::Status403(github_response.to_json_async().await?)), - code => Err(TeamsListError::Generic { code }), + 403 => Err(TeamsListError::Status403(github_response.to_json_async().await?).into()), + code => Err(TeamsListError::Generic { code }.into()), } } } @@ -4748,7 +5040,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list(&self, org: &str, query_params: Option>) -> Result, TeamsListError> { + pub fn list(&self, org: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams", super::GITHUB_BASE_API_URL, org); @@ -4765,7 +5057,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4777,8 +5069,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(TeamsListError::Status403(github_response.to_json()?)), - code => Err(TeamsListError::Generic { code }), + 403 => Err(TeamsListError::Status403(github_response.to_json()?).into()), + code => Err(TeamsListError::Generic { code }.into()), } } } @@ -4795,7 +5087,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_child_in_org](https://docs.github.com/rest/teams/teams#list-child-teams) /// /// --- - pub async fn list_child_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, TeamsListChildInOrgError> { + pub async fn list_child_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/teams", super::GITHUB_BASE_API_URL, org, team_slug); @@ -4806,12 +5098,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4823,7 +5115,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsListChildInOrgError::Generic { code }), + code => Err(TeamsListChildInOrgError::Generic { code }.into()), } } } @@ -4841,7 +5133,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_child_in_org(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, TeamsListChildInOrgError> { + pub fn list_child_in_org(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/teams", super::GITHUB_BASE_API_URL, org, team_slug); @@ -4858,7 +5150,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4870,7 +5162,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsListChildInOrgError::Generic { code }), + code => Err(TeamsListChildInOrgError::Generic { code }.into()), } } } @@ -4885,7 +5177,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_child_legacy](https://docs.github.com/rest/teams/teams#list-child-teams-legacy) /// /// --- - pub async fn list_child_legacy_async(&self, team_id: i32, query_params: Option>) -> Result, TeamsListChildLegacyError> { + pub async fn list_child_legacy_async(&self, team_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/teams", super::GITHUB_BASE_API_URL, team_id); @@ -4896,12 +5188,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4913,10 +5205,10 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsListChildLegacyError::Status404(github_response.to_json_async().await?)), - 403 => Err(TeamsListChildLegacyError::Status403(github_response.to_json_async().await?)), - 422 => Err(TeamsListChildLegacyError::Status422(github_response.to_json_async().await?)), - code => Err(TeamsListChildLegacyError::Generic { code }), + 404 => Err(TeamsListChildLegacyError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(TeamsListChildLegacyError::Status403(github_response.to_json_async().await?).into()), + 422 => Err(TeamsListChildLegacyError::Status422(github_response.to_json_async().await?).into()), + code => Err(TeamsListChildLegacyError::Generic { code }.into()), } } } @@ -4932,7 +5224,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_child_legacy(&self, team_id: i32, query_params: Option>) -> Result, TeamsListChildLegacyError> { + pub fn list_child_legacy(&self, team_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/teams", super::GITHUB_BASE_API_URL, team_id); @@ -4949,7 +5241,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4961,10 +5253,10 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsListChildLegacyError::Status404(github_response.to_json()?)), - 403 => Err(TeamsListChildLegacyError::Status403(github_response.to_json()?)), - 422 => Err(TeamsListChildLegacyError::Status422(github_response.to_json()?)), - code => Err(TeamsListChildLegacyError::Generic { code }), + 404 => Err(TeamsListChildLegacyError::Status404(github_response.to_json()?).into()), + 403 => Err(TeamsListChildLegacyError::Status403(github_response.to_json()?).into()), + 422 => Err(TeamsListChildLegacyError::Status422(github_response.to_json()?).into()), + code => Err(TeamsListChildLegacyError::Generic { code }.into()), } } } @@ -4983,7 +5275,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_discussion_comments_in_org](https://docs.github.com/rest/teams/discussion-comments#list-discussion-comments) /// /// --- - pub async fn list_discussion_comments_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, query_params: Option>>) -> Result, TeamsListDiscussionCommentsInOrgError> { + pub async fn list_discussion_comments_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); @@ -4994,12 +5286,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5011,7 +5303,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsListDiscussionCommentsInOrgError::Generic { code }), + code => Err(TeamsListDiscussionCommentsInOrgError::Generic { code }.into()), } } } @@ -5031,7 +5323,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_discussion_comments_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, query_params: Option>>) -> Result, TeamsListDiscussionCommentsInOrgError> { + pub fn list_discussion_comments_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); @@ -5048,7 +5340,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5060,7 +5352,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsListDiscussionCommentsInOrgError::Generic { code }), + code => Err(TeamsListDiscussionCommentsInOrgError::Generic { code }.into()), } } } @@ -5079,7 +5371,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_discussion_comments_legacy](https://docs.github.com/rest/teams/discussion-comments#list-discussion-comments-legacy) /// /// --- - pub async fn list_discussion_comments_legacy_async(&self, team_id: i32, discussion_number: i32, query_params: Option>>) -> Result, TeamsListDiscussionCommentsLegacyError> { + pub async fn list_discussion_comments_legacy_async(&self, team_id: i32, discussion_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, team_id, discussion_number); @@ -5090,12 +5382,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5107,7 +5399,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsListDiscussionCommentsLegacyError::Generic { code }), + code => Err(TeamsListDiscussionCommentsLegacyError::Generic { code }.into()), } } } @@ -5127,7 +5419,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_discussion_comments_legacy(&self, team_id: i32, discussion_number: i32, query_params: Option>>) -> Result, TeamsListDiscussionCommentsLegacyError> { + pub fn list_discussion_comments_legacy(&self, team_id: i32, discussion_number: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/discussions/{}/comments", super::GITHUB_BASE_API_URL, team_id, discussion_number); @@ -5144,7 +5436,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5156,7 +5448,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsListDiscussionCommentsLegacyError::Generic { code }), + code => Err(TeamsListDiscussionCommentsLegacyError::Generic { code }.into()), } } } @@ -5175,7 +5467,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_discussions_in_org](https://docs.github.com/rest/teams/discussions#list-discussions) /// /// --- - pub async fn list_discussions_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, TeamsListDiscussionsInOrgError> { + pub async fn list_discussions_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, org, team_slug); @@ -5186,12 +5478,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5203,7 +5495,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsListDiscussionsInOrgError::Generic { code }), + code => Err(TeamsListDiscussionsInOrgError::Generic { code }.into()), } } } @@ -5223,7 +5515,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_discussions_in_org(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, TeamsListDiscussionsInOrgError> { + pub fn list_discussions_in_org(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, org, team_slug); @@ -5240,7 +5532,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5252,7 +5544,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsListDiscussionsInOrgError::Generic { code }), + code => Err(TeamsListDiscussionsInOrgError::Generic { code }.into()), } } } @@ -5271,7 +5563,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_discussions_legacy](https://docs.github.com/rest/teams/discussions#list-discussions-legacy) /// /// --- - pub async fn list_discussions_legacy_async(&self, team_id: i32, query_params: Option>>) -> Result, TeamsListDiscussionsLegacyError> { + pub async fn list_discussions_legacy_async(&self, team_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, team_id); @@ -5282,12 +5574,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5299,7 +5591,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsListDiscussionsLegacyError::Generic { code }), + code => Err(TeamsListDiscussionsLegacyError::Generic { code }.into()), } } } @@ -5319,7 +5611,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_discussions_legacy(&self, team_id: i32, query_params: Option>>) -> Result, TeamsListDiscussionsLegacyError> { + pub fn list_discussions_legacy(&self, team_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/discussions", super::GITHUB_BASE_API_URL, team_id); @@ -5336,7 +5628,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5348,7 +5640,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsListDiscussionsLegacyError::Generic { code }), + code => Err(TeamsListDiscussionsLegacyError::Generic { code }.into()), } } } @@ -5367,7 +5659,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_for_authenticated_user](https://docs.github.com/rest/teams/teams#list-teams-for-the-authenticated-user) /// /// --- - pub async fn list_for_authenticated_user_async(&self, query_params: Option>) -> Result, TeamsListForAuthenticatedUserError> { + pub async fn list_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/teams", super::GITHUB_BASE_API_URL); @@ -5378,12 +5670,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5395,10 +5687,10 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(TeamsListForAuthenticatedUserError::Status304), - 404 => Err(TeamsListForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(TeamsListForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - code => Err(TeamsListForAuthenticatedUserError::Generic { code }), + 304 => Err(TeamsListForAuthenticatedUserError::Status304.into()), + 404 => Err(TeamsListForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(TeamsListForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + code => Err(TeamsListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5418,7 +5710,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_for_authenticated_user(&self, query_params: Option>) -> Result, TeamsListForAuthenticatedUserError> { + pub fn list_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/teams", super::GITHUB_BASE_API_URL); @@ -5435,7 +5727,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5447,10 +5739,10 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(TeamsListForAuthenticatedUserError::Status304), - 404 => Err(TeamsListForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(TeamsListForAuthenticatedUserError::Status403(github_response.to_json()?)), - code => Err(TeamsListForAuthenticatedUserError::Generic { code }), + 304 => Err(TeamsListForAuthenticatedUserError::Status304.into()), + 404 => Err(TeamsListForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(TeamsListForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + code => Err(TeamsListForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5466,7 +5758,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_members_in_org](https://docs.github.com/rest/teams/members#list-team-members) /// /// --- - pub async fn list_members_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, TeamsListMembersInOrgError> { + pub async fn list_members_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/members", super::GITHUB_BASE_API_URL, org, team_slug); @@ -5477,12 +5769,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5494,7 +5786,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsListMembersInOrgError::Generic { code }), + code => Err(TeamsListMembersInOrgError::Generic { code }.into()), } } } @@ -5511,7 +5803,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_members_in_org(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, TeamsListMembersInOrgError> { + pub fn list_members_in_org(&self, org: &str, team_slug: &str, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/members", super::GITHUB_BASE_API_URL, org, team_slug); @@ -5528,7 +5820,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5540,7 +5832,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsListMembersInOrgError::Generic { code }), + code => Err(TeamsListMembersInOrgError::Generic { code }.into()), } } } @@ -5557,7 +5849,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_members_legacy](https://docs.github.com/rest/teams/members#list-team-members-legacy) /// /// --- - pub async fn list_members_legacy_async(&self, team_id: i32, query_params: Option>>) -> Result, TeamsListMembersLegacyError> { + pub async fn list_members_legacy_async(&self, team_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/members", super::GITHUB_BASE_API_URL, team_id); @@ -5568,12 +5860,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5585,8 +5877,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsListMembersLegacyError::Status404(github_response.to_json_async().await?)), - code => Err(TeamsListMembersLegacyError::Generic { code }), + 404 => Err(TeamsListMembersLegacyError::Status404(github_response.to_json_async().await?).into()), + code => Err(TeamsListMembersLegacyError::Generic { code }.into()), } } } @@ -5604,7 +5896,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_members_legacy(&self, team_id: i32, query_params: Option>>) -> Result, TeamsListMembersLegacyError> { + pub fn list_members_legacy(&self, team_id: i32, query_params: Option>>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/members", super::GITHUB_BASE_API_URL, team_id); @@ -5621,7 +5913,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5633,8 +5925,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsListMembersLegacyError::Status404(github_response.to_json()?)), - code => Err(TeamsListMembersLegacyError::Generic { code }), + 404 => Err(TeamsListMembersLegacyError::Status404(github_response.to_json()?).into()), + code => Err(TeamsListMembersLegacyError::Generic { code }.into()), } } } @@ -5651,7 +5943,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_pending_invitations_in_org](https://docs.github.com/rest/teams/members#list-pending-team-invitations) /// /// --- - pub async fn list_pending_invitations_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, TeamsListPendingInvitationsInOrgError> { + pub async fn list_pending_invitations_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/invitations", super::GITHUB_BASE_API_URL, org, team_slug); @@ -5662,12 +5954,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5679,7 +5971,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsListPendingInvitationsInOrgError::Generic { code }), + code => Err(TeamsListPendingInvitationsInOrgError::Generic { code }.into()), } } } @@ -5697,7 +5989,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_pending_invitations_in_org(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, TeamsListPendingInvitationsInOrgError> { + pub fn list_pending_invitations_in_org(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/invitations", super::GITHUB_BASE_API_URL, org, team_slug); @@ -5714,7 +6006,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5726,7 +6018,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsListPendingInvitationsInOrgError::Generic { code }), + code => Err(TeamsListPendingInvitationsInOrgError::Generic { code }.into()), } } } @@ -5743,7 +6035,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_pending_invitations_legacy](https://docs.github.com/rest/teams/members#list-pending-team-invitations-legacy) /// /// --- - pub async fn list_pending_invitations_legacy_async(&self, team_id: i32, query_params: Option>) -> Result, TeamsListPendingInvitationsLegacyError> { + pub async fn list_pending_invitations_legacy_async(&self, team_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/invitations", super::GITHUB_BASE_API_URL, team_id); @@ -5754,12 +6046,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5771,7 +6063,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsListPendingInvitationsLegacyError::Generic { code }), + code => Err(TeamsListPendingInvitationsLegacyError::Generic { code }.into()), } } } @@ -5789,7 +6081,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_pending_invitations_legacy(&self, team_id: i32, query_params: Option>) -> Result, TeamsListPendingInvitationsLegacyError> { + pub fn list_pending_invitations_legacy(&self, team_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/invitations", super::GITHUB_BASE_API_URL, team_id); @@ -5806,7 +6098,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5818,7 +6110,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsListPendingInvitationsLegacyError::Generic { code }), + code => Err(TeamsListPendingInvitationsLegacyError::Generic { code }.into()), } } } @@ -5835,7 +6127,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_projects_in_org](https://docs.github.com/rest/teams/teams#list-team-projects) /// /// --- - pub async fn list_projects_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, TeamsListProjectsInOrgError> { + pub async fn list_projects_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/projects", super::GITHUB_BASE_API_URL, org, team_slug); @@ -5846,12 +6138,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5863,7 +6155,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsListProjectsInOrgError::Generic { code }), + code => Err(TeamsListProjectsInOrgError::Generic { code }.into()), } } } @@ -5881,7 +6173,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_projects_in_org(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, TeamsListProjectsInOrgError> { + pub fn list_projects_in_org(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/projects", super::GITHUB_BASE_API_URL, org, team_slug); @@ -5898,7 +6190,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5910,7 +6202,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsListProjectsInOrgError::Generic { code }), + code => Err(TeamsListProjectsInOrgError::Generic { code }.into()), } } } @@ -5927,7 +6219,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_projects_legacy](https://docs.github.com/rest/teams/teams#list-team-projects-legacy) /// /// --- - pub async fn list_projects_legacy_async(&self, team_id: i32, query_params: Option>) -> Result, TeamsListProjectsLegacyError> { + pub async fn list_projects_legacy_async(&self, team_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/projects", super::GITHUB_BASE_API_URL, team_id); @@ -5938,12 +6230,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5955,8 +6247,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsListProjectsLegacyError::Status404(github_response.to_json_async().await?)), - code => Err(TeamsListProjectsLegacyError::Generic { code }), + 404 => Err(TeamsListProjectsLegacyError::Status404(github_response.to_json_async().await?).into()), + code => Err(TeamsListProjectsLegacyError::Generic { code }.into()), } } } @@ -5974,7 +6266,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_projects_legacy(&self, team_id: i32, query_params: Option>) -> Result, TeamsListProjectsLegacyError> { + pub fn list_projects_legacy(&self, team_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/projects", super::GITHUB_BASE_API_URL, team_id); @@ -5991,7 +6283,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6003,8 +6295,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsListProjectsLegacyError::Status404(github_response.to_json()?)), - code => Err(TeamsListProjectsLegacyError::Generic { code }), + 404 => Err(TeamsListProjectsLegacyError::Status404(github_response.to_json()?).into()), + code => Err(TeamsListProjectsLegacyError::Generic { code }.into()), } } } @@ -6021,7 +6313,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_repos_in_org](https://docs.github.com/rest/teams/teams#list-team-repositories) /// /// --- - pub async fn list_repos_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, TeamsListReposInOrgError> { + pub async fn list_repos_in_org_async(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/repos", super::GITHUB_BASE_API_URL, org, team_slug); @@ -6032,12 +6324,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6049,7 +6341,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsListReposInOrgError::Generic { code }), + code => Err(TeamsListReposInOrgError::Generic { code }.into()), } } } @@ -6067,7 +6359,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repos_in_org(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, TeamsListReposInOrgError> { + pub fn list_repos_in_org(&self, org: &str, team_slug: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/orgs/{}/teams/{}/repos", super::GITHUB_BASE_API_URL, org, team_slug); @@ -6084,7 +6376,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6096,7 +6388,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsListReposInOrgError::Generic { code }), + code => Err(TeamsListReposInOrgError::Generic { code }.into()), } } } @@ -6111,7 +6403,7 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for list_repos_legacy](https://docs.github.com/rest/teams/teams#list-team-repositories-legacy) /// /// --- - pub async fn list_repos_legacy_async(&self, team_id: i32, query_params: Option>) -> Result, TeamsListReposLegacyError> { + pub async fn list_repos_legacy_async(&self, team_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/repos", super::GITHUB_BASE_API_URL, team_id); @@ -6122,12 +6414,12 @@ impl<'api, C: Client> Teams<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6139,8 +6431,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsListReposLegacyError::Status404(github_response.to_json_async().await?)), - code => Err(TeamsListReposLegacyError::Generic { code }), + 404 => Err(TeamsListReposLegacyError::Status404(github_response.to_json_async().await?).into()), + code => Err(TeamsListReposLegacyError::Generic { code }.into()), } } } @@ -6156,7 +6448,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_repos_legacy(&self, team_id: i32, query_params: Option>) -> Result, TeamsListReposLegacyError> { + pub fn list_repos_legacy(&self, team_id: i32, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/teams/{}/repos", super::GITHUB_BASE_API_URL, team_id); @@ -6173,7 +6465,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6185,8 +6477,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsListReposLegacyError::Status404(github_response.to_json()?)), - code => Err(TeamsListReposLegacyError::Generic { code }), + 404 => Err(TeamsListReposLegacyError::Status404(github_response.to_json()?).into()), + code => Err(TeamsListReposLegacyError::Generic { code }.into()), } } } @@ -6209,19 +6501,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for remove_member_legacy](https://docs.github.com/rest/teams/members#remove-team-member-legacy) /// /// --- - pub async fn remove_member_legacy_async(&self, team_id: i32, username: &str) -> Result<(), TeamsRemoveMemberLegacyError> { + pub async fn remove_member_legacy_async(&self, team_id: i32, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6233,8 +6525,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsRemoveMemberLegacyError::Status404), - code => Err(TeamsRemoveMemberLegacyError::Generic { code }), + 404 => Err(TeamsRemoveMemberLegacyError::Status404.into()), + code => Err(TeamsRemoveMemberLegacyError::Generic { code }.into()), } } } @@ -6258,7 +6550,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_member_legacy(&self, team_id: i32, username: &str) -> Result<(), TeamsRemoveMemberLegacyError> { + pub fn remove_member_legacy(&self, team_id: i32, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/members/{}", super::GITHUB_BASE_API_URL, team_id, username); @@ -6270,7 +6562,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6282,8 +6574,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsRemoveMemberLegacyError::Status404), - code => Err(TeamsRemoveMemberLegacyError::Generic { code }), + 404 => Err(TeamsRemoveMemberLegacyError::Status404.into()), + code => Err(TeamsRemoveMemberLegacyError::Generic { code }.into()), } } } @@ -6305,19 +6597,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for remove_membership_for_user_in_org](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user) /// /// --- - pub async fn remove_membership_for_user_in_org_async(&self, org: &str, team_slug: &str, username: &str) -> Result<(), TeamsRemoveMembershipForUserInOrgError> { + pub async fn remove_membership_for_user_in_org_async(&self, org: &str, team_slug: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6329,8 +6621,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(TeamsRemoveMembershipForUserInOrgError::Status403), - code => Err(TeamsRemoveMembershipForUserInOrgError::Generic { code }), + 403 => Err(TeamsRemoveMembershipForUserInOrgError::Status403.into()), + code => Err(TeamsRemoveMembershipForUserInOrgError::Generic { code }.into()), } } } @@ -6353,7 +6645,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_membership_for_user_in_org(&self, org: &str, team_slug: &str, username: &str) -> Result<(), TeamsRemoveMembershipForUserInOrgError> { + pub fn remove_membership_for_user_in_org(&self, org: &str, team_slug: &str, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, org, team_slug, username); @@ -6365,7 +6657,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6377,8 +6669,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(TeamsRemoveMembershipForUserInOrgError::Status403), - code => Err(TeamsRemoveMembershipForUserInOrgError::Generic { code }), + 403 => Err(TeamsRemoveMembershipForUserInOrgError::Status403.into()), + code => Err(TeamsRemoveMembershipForUserInOrgError::Generic { code }.into()), } } } @@ -6400,19 +6692,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for remove_membership_for_user_legacy](https://docs.github.com/rest/teams/members#remove-team-membership-for-a-user-legacy) /// /// --- - pub async fn remove_membership_for_user_legacy_async(&self, team_id: i32, username: &str) -> Result<(), TeamsRemoveMembershipForUserLegacyError> { + pub async fn remove_membership_for_user_legacy_async(&self, team_id: i32, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6424,8 +6716,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 403 => Err(TeamsRemoveMembershipForUserLegacyError::Status403), - code => Err(TeamsRemoveMembershipForUserLegacyError::Generic { code }), + 403 => Err(TeamsRemoveMembershipForUserLegacyError::Status403.into()), + code => Err(TeamsRemoveMembershipForUserLegacyError::Generic { code }.into()), } } } @@ -6448,7 +6740,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_membership_for_user_legacy(&self, team_id: i32, username: &str) -> Result<(), TeamsRemoveMembershipForUserLegacyError> { + pub fn remove_membership_for_user_legacy(&self, team_id: i32, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/memberships/{}", super::GITHUB_BASE_API_URL, team_id, username); @@ -6460,7 +6752,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6472,8 +6764,8 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 403 => Err(TeamsRemoveMembershipForUserLegacyError::Status403), - code => Err(TeamsRemoveMembershipForUserLegacyError::Generic { code }), + 403 => Err(TeamsRemoveMembershipForUserLegacyError::Status403.into()), + code => Err(TeamsRemoveMembershipForUserLegacyError::Generic { code }.into()), } } } @@ -6490,19 +6782,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for remove_project_in_org](https://docs.github.com/rest/teams/teams#remove-a-project-from-a-team) /// /// --- - pub async fn remove_project_in_org_async(&self, org: &str, team_slug: &str, project_id: i32) -> Result<(), TeamsRemoveProjectInOrgError> { + pub async fn remove_project_in_org_async(&self, org: &str, team_slug: &str, project_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6514,7 +6806,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsRemoveProjectInOrgError::Generic { code }), + code => Err(TeamsRemoveProjectInOrgError::Generic { code }.into()), } } } @@ -6532,7 +6824,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_project_in_org(&self, org: &str, team_slug: &str, project_id: i32) -> Result<(), TeamsRemoveProjectInOrgError> { + pub fn remove_project_in_org(&self, org: &str, team_slug: &str, project_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, org, team_slug, project_id); @@ -6544,7 +6836,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6556,7 +6848,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsRemoveProjectInOrgError::Generic { code }), + code => Err(TeamsRemoveProjectInOrgError::Generic { code }.into()), } } } @@ -6573,19 +6865,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for remove_project_legacy](https://docs.github.com/rest/teams/teams#remove-a-project-from-a-team-legacy) /// /// --- - pub async fn remove_project_legacy_async(&self, team_id: i32, project_id: i32) -> Result<(), TeamsRemoveProjectLegacyError> { + pub async fn remove_project_legacy_async(&self, team_id: i32, project_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6597,9 +6889,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(TeamsRemoveProjectLegacyError::Status404(github_response.to_json_async().await?)), - 422 => Err(TeamsRemoveProjectLegacyError::Status422(github_response.to_json_async().await?)), - code => Err(TeamsRemoveProjectLegacyError::Generic { code }), + 404 => Err(TeamsRemoveProjectLegacyError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(TeamsRemoveProjectLegacyError::Status422(github_response.to_json_async().await?).into()), + code => Err(TeamsRemoveProjectLegacyError::Generic { code }.into()), } } } @@ -6617,7 +6909,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_project_legacy(&self, team_id: i32, project_id: i32) -> Result<(), TeamsRemoveProjectLegacyError> { + pub fn remove_project_legacy(&self, team_id: i32, project_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/projects/{}", super::GITHUB_BASE_API_URL, team_id, project_id); @@ -6629,7 +6921,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6641,9 +6933,9 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(TeamsRemoveProjectLegacyError::Status404(github_response.to_json()?)), - 422 => Err(TeamsRemoveProjectLegacyError::Status422(github_response.to_json()?)), - code => Err(TeamsRemoveProjectLegacyError::Generic { code }), + 404 => Err(TeamsRemoveProjectLegacyError::Status404(github_response.to_json()?).into()), + 422 => Err(TeamsRemoveProjectLegacyError::Status422(github_response.to_json()?).into()), + code => Err(TeamsRemoveProjectLegacyError::Generic { code }.into()), } } } @@ -6660,19 +6952,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for remove_repo_in_org](https://docs.github.com/rest/teams/teams#remove-a-repository-from-a-team) /// /// --- - pub async fn remove_repo_in_org_async(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result<(), TeamsRemoveRepoInOrgError> { + pub async fn remove_repo_in_org_async(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6684,7 +6976,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsRemoveRepoInOrgError::Generic { code }), + code => Err(TeamsRemoveRepoInOrgError::Generic { code }.into()), } } } @@ -6702,7 +6994,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_repo_in_org(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result<(), TeamsRemoveRepoInOrgError> { + pub fn remove_repo_in_org(&self, org: &str, team_slug: &str, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/orgs/{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, org, team_slug, owner, repo); @@ -6714,7 +7006,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6726,7 +7018,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsRemoveRepoInOrgError::Generic { code }), + code => Err(TeamsRemoveRepoInOrgError::Generic { code }.into()), } } } @@ -6743,19 +7035,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for remove_repo_legacy](https://docs.github.com/rest/teams/teams#remove-a-repository-from-a-team-legacy) /// /// --- - pub async fn remove_repo_legacy_async(&self, team_id: i32, owner: &str, repo: &str) -> Result<(), TeamsRemoveRepoLegacyError> { + pub async fn remove_repo_legacy_async(&self, team_id: i32, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6767,7 +7059,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsRemoveRepoLegacyError::Generic { code }), + code => Err(TeamsRemoveRepoLegacyError::Generic { code }.into()), } } } @@ -6785,7 +7077,7 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn remove_repo_legacy(&self, team_id: i32, owner: &str, repo: &str) -> Result<(), TeamsRemoveRepoLegacyError> { + pub fn remove_repo_legacy(&self, team_id: i32, owner: &str, repo: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/teams/{}/repos/{}/{}", super::GITHUB_BASE_API_URL, team_id, owner, repo); @@ -6797,7 +7089,7 @@ impl<'api, C: Client> Teams<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6809,7 +7101,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsRemoveRepoLegacyError::Generic { code }), + code => Err(TeamsRemoveRepoLegacyError::Generic { code }.into()), } } } @@ -6828,19 +7120,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for update_discussion_comment_in_org](https://docs.github.com/rest/teams/discussion-comments#update-a-discussion-comment) /// /// --- - pub async fn update_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentInOrg) -> Result { + pub async fn update_discussion_comment_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateDiscussionCommentInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6852,7 +7144,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsUpdateDiscussionCommentInOrgError::Generic { code }), + code => Err(TeamsUpdateDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -6872,19 +7164,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentInOrg) -> Result { + pub fn update_discussion_comment_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateDiscussionCommentInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6896,7 +7188,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsUpdateDiscussionCommentInOrgError::Generic { code }), + code => Err(TeamsUpdateDiscussionCommentInOrgError::Generic { code }.into()), } } } @@ -6915,19 +7207,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for update_discussion_comment_legacy](https://docs.github.com/rest/teams/discussion-comments#update-a-discussion-comment-legacy) /// /// --- - pub async fn update_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentLegacy) -> Result { + pub async fn update_discussion_comment_legacy_async(&self, team_id: i32, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateDiscussionCommentLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6939,7 +7231,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsUpdateDiscussionCommentLegacyError::Generic { code }), + code => Err(TeamsUpdateDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -6959,19 +7251,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentLegacy) -> Result { + pub fn update_discussion_comment_legacy(&self, team_id: i32, discussion_number: i32, comment_number: i32, body: PatchTeamsUpdateDiscussionCommentLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}/comments/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number, comment_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateDiscussionCommentLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -6983,7 +7275,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsUpdateDiscussionCommentLegacyError::Generic { code }), + code => Err(TeamsUpdateDiscussionCommentLegacyError::Generic { code }.into()), } } } @@ -7002,19 +7294,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for update_discussion_in_org](https://docs.github.com/rest/teams/discussions#update-a-discussion) /// /// --- - pub async fn update_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, body: PatchTeamsUpdateDiscussionInOrg) -> Result { + pub async fn update_discussion_in_org_async(&self, org: &str, team_slug: &str, discussion_number: i32, body: PatchTeamsUpdateDiscussionInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateDiscussionInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7026,7 +7318,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsUpdateDiscussionInOrgError::Generic { code }), + code => Err(TeamsUpdateDiscussionInOrgError::Generic { code }.into()), } } } @@ -7046,19 +7338,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, body: PatchTeamsUpdateDiscussionInOrg) -> Result { + pub fn update_discussion_in_org(&self, org: &str, team_slug: &str, discussion_number: i32, body: PatchTeamsUpdateDiscussionInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, org, team_slug, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateDiscussionInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7070,7 +7362,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsUpdateDiscussionInOrgError::Generic { code }), + code => Err(TeamsUpdateDiscussionInOrgError::Generic { code }.into()), } } } @@ -7089,19 +7381,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for update_discussion_legacy](https://docs.github.com/rest/teams/discussions#update-a-discussion-legacy) /// /// --- - pub async fn update_discussion_legacy_async(&self, team_id: i32, discussion_number: i32, body: PatchTeamsUpdateDiscussionLegacy) -> Result { + pub async fn update_discussion_legacy_async(&self, team_id: i32, discussion_number: i32, body: PatchTeamsUpdateDiscussionLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateDiscussionLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7113,7 +7405,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(TeamsUpdateDiscussionLegacyError::Generic { code }), + code => Err(TeamsUpdateDiscussionLegacyError::Generic { code }.into()), } } } @@ -7133,19 +7425,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_discussion_legacy(&self, team_id: i32, discussion_number: i32, body: PatchTeamsUpdateDiscussionLegacy) -> Result { + pub fn update_discussion_legacy(&self, team_id: i32, discussion_number: i32, body: PatchTeamsUpdateDiscussionLegacy) -> Result { let request_uri = format!("{}/teams/{}/discussions/{}", super::GITHUB_BASE_API_URL, team_id, discussion_number); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateDiscussionLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7157,7 +7449,7 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(TeamsUpdateDiscussionLegacyError::Generic { code }), + code => Err(TeamsUpdateDiscussionLegacyError::Generic { code }.into()), } } } @@ -7174,19 +7466,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for update_in_org](https://docs.github.com/rest/teams/teams#update-a-team) /// /// --- - pub async fn update_in_org_async(&self, org: &str, team_slug: &str, body: PatchTeamsUpdateInOrg) -> Result { + pub async fn update_in_org_async(&self, org: &str, team_slug: &str, body: PatchTeamsUpdateInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7198,11 +7490,11 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(TeamsUpdateInOrgError::Status201(github_response.to_json_async().await?)), - 404 => Err(TeamsUpdateInOrgError::Status404(github_response.to_json_async().await?)), - 422 => Err(TeamsUpdateInOrgError::Status422(github_response.to_json_async().await?)), - 403 => Err(TeamsUpdateInOrgError::Status403(github_response.to_json_async().await?)), - code => Err(TeamsUpdateInOrgError::Generic { code }), + 201 => Err(TeamsUpdateInOrgError::Status201(github_response.to_json_async().await?).into()), + 404 => Err(TeamsUpdateInOrgError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(TeamsUpdateInOrgError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(TeamsUpdateInOrgError::Status403(github_response.to_json_async().await?).into()), + code => Err(TeamsUpdateInOrgError::Generic { code }.into()), } } } @@ -7220,19 +7512,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_in_org(&self, org: &str, team_slug: &str, body: PatchTeamsUpdateInOrg) -> Result { + pub fn update_in_org(&self, org: &str, team_slug: &str, body: PatchTeamsUpdateInOrg) -> Result { let request_uri = format!("{}/orgs/{}/teams/{}", super::GITHUB_BASE_API_URL, org, team_slug); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateInOrg::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7244,11 +7536,11 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(TeamsUpdateInOrgError::Status201(github_response.to_json()?)), - 404 => Err(TeamsUpdateInOrgError::Status404(github_response.to_json()?)), - 422 => Err(TeamsUpdateInOrgError::Status422(github_response.to_json()?)), - 403 => Err(TeamsUpdateInOrgError::Status403(github_response.to_json()?)), - code => Err(TeamsUpdateInOrgError::Generic { code }), + 201 => Err(TeamsUpdateInOrgError::Status201(github_response.to_json()?).into()), + 404 => Err(TeamsUpdateInOrgError::Status404(github_response.to_json()?).into()), + 422 => Err(TeamsUpdateInOrgError::Status422(github_response.to_json()?).into()), + 403 => Err(TeamsUpdateInOrgError::Status403(github_response.to_json()?).into()), + code => Err(TeamsUpdateInOrgError::Generic { code }.into()), } } } @@ -7268,19 +7560,19 @@ impl<'api, C: Client> Teams<'api, C> { /// [GitHub API docs for update_legacy](https://docs.github.com/rest/teams/teams#update-a-team-legacy) /// /// --- - pub async fn update_legacy_async(&self, team_id: i32, body: PatchTeamsUpdateLegacy) -> Result { + pub async fn update_legacy_async(&self, team_id: i32, body: PatchTeamsUpdateLegacy) -> Result { let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7292,11 +7584,11 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(TeamsUpdateLegacyError::Status201(github_response.to_json_async().await?)), - 404 => Err(TeamsUpdateLegacyError::Status404(github_response.to_json_async().await?)), - 422 => Err(TeamsUpdateLegacyError::Status422(github_response.to_json_async().await?)), - 403 => Err(TeamsUpdateLegacyError::Status403(github_response.to_json_async().await?)), - code => Err(TeamsUpdateLegacyError::Generic { code }), + 201 => Err(TeamsUpdateLegacyError::Status201(github_response.to_json_async().await?).into()), + 404 => Err(TeamsUpdateLegacyError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(TeamsUpdateLegacyError::Status422(github_response.to_json_async().await?).into()), + 403 => Err(TeamsUpdateLegacyError::Status403(github_response.to_json_async().await?).into()), + code => Err(TeamsUpdateLegacyError::Generic { code }.into()), } } } @@ -7317,19 +7609,19 @@ impl<'api, C: Client> Teams<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_legacy(&self, team_id: i32, body: PatchTeamsUpdateLegacy) -> Result { + pub fn update_legacy(&self, team_id: i32, body: PatchTeamsUpdateLegacy) -> Result { let request_uri = format!("{}/teams/{}", super::GITHUB_BASE_API_URL, team_id); let req = GitHubRequest { uri: request_uri, - body: Some(PatchTeamsUpdateLegacy::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -7341,11 +7633,11 @@ impl<'api, C: Client> Teams<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(TeamsUpdateLegacyError::Status201(github_response.to_json()?)), - 404 => Err(TeamsUpdateLegacyError::Status404(github_response.to_json()?)), - 422 => Err(TeamsUpdateLegacyError::Status422(github_response.to_json()?)), - 403 => Err(TeamsUpdateLegacyError::Status403(github_response.to_json()?)), - code => Err(TeamsUpdateLegacyError::Generic { code }), + 201 => Err(TeamsUpdateLegacyError::Status201(github_response.to_json()?).into()), + 404 => Err(TeamsUpdateLegacyError::Status404(github_response.to_json()?).into()), + 422 => Err(TeamsUpdateLegacyError::Status422(github_response.to_json()?).into()), + 403 => Err(TeamsUpdateLegacyError::Status403(github_response.to_json()?).into()), + code => Err(TeamsUpdateLegacyError::Generic { code }.into()), } } } diff --git a/src/endpoints/users.rs b/src/endpoints/users.rs index a562807..5dab2fc 100644 --- a/src/endpoints/users.rs +++ b/src/endpoints/users.rs @@ -14,7 +14,7 @@ use serde::Deserialize; -use crate::adapters::{AdapterError, Client, FromJson, GitHubRequest, GitHubRequestBuilder, GitHubResponseExt}; +use crate::adapters::{AdapterError, Client, GitHubRequest, GitHubResponseExt}; use crate::models::*; use super::PerPage; @@ -22,27 +22,17 @@ use super::PerPage; use std::collections::HashMap; use serde_json::value::Value; -pub struct Users<'api, C: Client> { +pub struct Users<'api, C: Client> where AdapterError: From<::Err> { client: &'api C } -pub fn new>(client: &C) -> Users { +pub fn new(client: &C) -> Users where AdapterError: From<::Err> { Users { client } } /// Errors for the [Add an email address for the authenticated user](Users::add_email_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersAddEmailForAuthenticatedUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -57,19 +47,28 @@ pub enum UsersAddEmailForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersAddEmailForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersAddEmailForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersAddEmailForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersAddEmailForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersAddEmailForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersAddEmailForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersAddEmailForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Add social accounts for the authenticated user](Users::add_social_account_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersAddSocialAccountForAuthenticatedUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -84,19 +83,28 @@ pub enum UsersAddSocialAccountForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersAddSocialAccountForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersAddSocialAccountForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersAddSocialAccountForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersAddSocialAccountForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersAddSocialAccountForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersAddSocialAccountForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersAddSocialAccountForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Block a user](Users::block_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersBlockError { - #[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("Resource not found")] @@ -111,19 +119,28 @@ pub enum UsersBlockError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersBlockError) -> Self { + let (description, status_code) = match err { + UsersBlockError::Status304 => (String::from("Not modified"), 304), + UsersBlockError::Status404(_) => (String::from("Resource not found"), 404), + UsersBlockError::Status403(_) => (String::from("Forbidden"), 403), + UsersBlockError::Status401(_) => (String::from("Requires authentication"), 401), + UsersBlockError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersBlockError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check if a user is blocked by the authenticated user](Users::check_blocked_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersCheckBlockedError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("If the user is not blocked")] Status404(BasicError), #[error("Not modified")] @@ -136,38 +153,51 @@ pub enum UsersCheckBlockedError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersCheckBlockedError) -> Self { + let (description, status_code) = match err { + UsersCheckBlockedError::Status404(_) => (String::from("If the user is not blocked"), 404), + UsersCheckBlockedError::Status304 => (String::from("Not modified"), 304), + UsersCheckBlockedError::Status403(_) => (String::from("Forbidden"), 403), + UsersCheckBlockedError::Status401(_) => (String::from("Requires authentication"), 401), + UsersCheckBlockedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check if a user follows another user](Users::check_following_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersCheckFollowingForUserError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("if the user does not follow the target user")] Status404, #[error("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersCheckFollowingForUserError) -> Self { + let (description, status_code) = match err { + UsersCheckFollowingForUserError::Status404 => (String::from("if the user does not follow the target user"), 404), + UsersCheckFollowingForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Check if a person is followed by the authenticated user](Users::check_person_is_followed_by_authenticated_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersCheckPersonIsFollowedByAuthenticatedError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("if the person is not followed by the authenticated user")] Status404(BasicError), #[error("Not modified")] @@ -180,19 +210,27 @@ pub enum UsersCheckPersonIsFollowedByAuthenticatedError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersCheckPersonIsFollowedByAuthenticatedError) -> Self { + let (description, status_code) = match err { + UsersCheckPersonIsFollowedByAuthenticatedError::Status404(_) => (String::from("if the person is not followed by the authenticated user"), 404), + UsersCheckPersonIsFollowedByAuthenticatedError::Status304 => (String::from("Not modified"), 304), + UsersCheckPersonIsFollowedByAuthenticatedError::Status403(_) => (String::from("Forbidden"), 403), + UsersCheckPersonIsFollowedByAuthenticatedError::Status401(_) => (String::from("Requires authentication"), 401), + UsersCheckPersonIsFollowedByAuthenticatedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a GPG key for the authenticated user](Users::create_gpg_key_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersCreateGpgKeyForAuthenticatedUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -207,19 +245,28 @@ pub enum UsersCreateGpgKeyForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersCreateGpgKeyForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersCreateGpgKeyForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersCreateGpgKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersCreateGpgKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersCreateGpgKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersCreateGpgKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersCreateGpgKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a public SSH key for the authenticated user](Users::create_public_ssh_key_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersCreatePublicSshKeyForAuthenticatedUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -234,19 +281,28 @@ pub enum UsersCreatePublicSshKeyForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersCreatePublicSshKeyForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersCreatePublicSshKeyForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersCreatePublicSshKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersCreatePublicSshKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersCreatePublicSshKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersCreatePublicSshKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersCreatePublicSshKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Create a SSH signing key for the authenticated user](Users::create_ssh_signing_key_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersCreateSshSigningKeyForAuthenticatedUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -261,19 +317,28 @@ pub enum UsersCreateSshSigningKeyForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersCreateSshSigningKeyForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersCreateSshSigningKeyForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersCreateSshSigningKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersCreateSshSigningKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersCreateSshSigningKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersCreateSshSigningKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersCreateSshSigningKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an email address for the authenticated user](Users::delete_email_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersDeleteEmailForAuthenticatedUserError { - #[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("Resource not found")] @@ -288,19 +353,28 @@ pub enum UsersDeleteEmailForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersDeleteEmailForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersDeleteEmailForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersDeleteEmailForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersDeleteEmailForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersDeleteEmailForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersDeleteEmailForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersDeleteEmailForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a GPG key for the authenticated user](Users::delete_gpg_key_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersDeleteGpgKeyForAuthenticatedUserError { - #[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, or the endpoint has been spammed.")] @@ -315,19 +389,28 @@ pub enum UsersDeleteGpgKeyForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersDeleteGpgKeyForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersDeleteGpgKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersDeleteGpgKeyForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersDeleteGpgKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersDeleteGpgKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersDeleteGpgKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersDeleteGpgKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete a public SSH key for the authenticated user](Users::delete_public_ssh_key_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersDeletePublicSshKeyForAuthenticatedUserError { - #[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("Resource not found")] @@ -340,19 +423,27 @@ pub enum UsersDeletePublicSshKeyForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersDeletePublicSshKeyForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersDeletePublicSshKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersDeletePublicSshKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersDeletePublicSshKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersDeletePublicSshKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersDeletePublicSshKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete social accounts for the authenticated user](Users::delete_social_account_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersDeleteSocialAccountForAuthenticatedUserError { - #[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, or the endpoint has been spammed.")] Status422(ValidationError), #[error("Not modified")] @@ -367,19 +458,28 @@ pub enum UsersDeleteSocialAccountForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersDeleteSocialAccountForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersDeleteSocialAccountForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersDeleteSocialAccountForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersDeleteSocialAccountForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersDeleteSocialAccountForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersDeleteSocialAccountForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersDeleteSocialAccountForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Delete an SSH signing key for the authenticated user](Users::delete_ssh_signing_key_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersDeleteSshSigningKeyForAuthenticatedUserError { - #[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("Resource not found")] @@ -392,19 +492,27 @@ pub enum UsersDeleteSshSigningKeyForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersDeleteSshSigningKeyForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersDeleteSshSigningKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersDeleteSshSigningKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersDeleteSshSigningKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersDeleteSshSigningKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersDeleteSshSigningKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Follow a user](Users::follow_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersFollowError { - #[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("Resource not found")] @@ -417,19 +525,27 @@ pub enum UsersFollowError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersFollowError) -> Self { + let (description, status_code) = match err { + UsersFollowError::Status304 => (String::from("Not modified"), 304), + UsersFollowError::Status404(_) => (String::from("Resource not found"), 404), + UsersFollowError::Status403(_) => (String::from("Forbidden"), 403), + UsersFollowError::Status401(_) => (String::from("Requires authentication"), 401), + UsersFollowError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get the authenticated user](Users::get_authenticated_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersGetAuthenticatedError { - #[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("Forbidden")] @@ -440,57 +556,74 @@ pub enum UsersGetAuthenticatedError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersGetAuthenticatedError) -> Self { + let (description, status_code) = match err { + UsersGetAuthenticatedError::Status304 => (String::from("Not modified"), 304), + UsersGetAuthenticatedError::Status403(_) => (String::from("Forbidden"), 403), + UsersGetAuthenticatedError::Status401(_) => (String::from("Requires authentication"), 401), + UsersGetAuthenticatedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a user using their ID](Users::get_by_id_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersGetByIdError { - #[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 }, } +impl From for AdapterError { + fn from(err: UsersGetByIdError) -> Self { + let (description, status_code) = match err { + UsersGetByIdError::Status404(_) => (String::from("Resource not found"), 404), + UsersGetByIdError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a user](Users::get_by_username_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersGetByUsernameError { - #[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 }, } +impl From for AdapterError { + fn from(err: UsersGetByUsernameError) -> Self { + let (description, status_code) = match err { + UsersGetByUsernameError::Status404(_) => (String::from("Resource not found"), 404), + UsersGetByUsernameError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get contextual information for a user](Users::get_context_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersGetContextForUserError { - #[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, or the endpoint has been spammed.")] @@ -499,19 +632,25 @@ pub enum UsersGetContextForUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersGetContextForUserError) -> Self { + let (description, status_code) = match err { + UsersGetContextForUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersGetContextForUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersGetContextForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a GPG key for the authenticated user](Users::get_gpg_key_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersGetGpgKeyForAuthenticatedUserError { - #[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("Not modified")] @@ -524,19 +663,27 @@ pub enum UsersGetGpgKeyForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersGetGpgKeyForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersGetGpgKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersGetGpgKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersGetGpgKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersGetGpgKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersGetGpgKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get a public SSH key for the authenticated user](Users::get_public_ssh_key_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersGetPublicSshKeyForAuthenticatedUserError { - #[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("Not modified")] @@ -549,19 +696,27 @@ pub enum UsersGetPublicSshKeyForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersGetPublicSshKeyForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersGetPublicSshKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersGetPublicSshKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersGetPublicSshKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersGetPublicSshKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersGetPublicSshKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Get an SSH signing key for the authenticated user](Users::get_ssh_signing_key_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersGetSshSigningKeyForAuthenticatedUserError { - #[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("Not modified")] @@ -574,38 +729,51 @@ pub enum UsersGetSshSigningKeyForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersGetSshSigningKeyForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersGetSshSigningKeyForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersGetSshSigningKeyForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersGetSshSigningKeyForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersGetSshSigningKeyForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersGetSshSigningKeyForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List users](Users::list_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListError { - #[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("Status code: {}", code)] Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersListError) -> Self { + let (description, status_code) = match err { + UsersListError::Status304 => (String::from("Not modified"), 304), + UsersListError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List attestations](Users::list_attestations_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListAttestationsError { - #[error(transparent)] - AdapterError(#[from] AdapterError), - #[error(transparent)] - SerdeJson(#[from] serde_json::Error), - #[error(transparent)] - SerdeUrl(#[from] serde_urlencoded::ser::Error), - - - // -- endpoint errors - #[error("Response")] Status201(EmptyObject), #[error("Response")] @@ -616,19 +784,26 @@ pub enum UsersListAttestationsError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersListAttestationsError) -> Self { + let (description, status_code) = match err { + UsersListAttestationsError::Status201(_) => (String::from("Response"), 201), + UsersListAttestationsError::Status204 => (String::from("Response"), 204), + UsersListAttestationsError::Status404(_) => (String::from("Resource not found"), 404), + UsersListAttestationsError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List users blocked by the authenticated user](Users::list_blocked_by_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListBlockedByAuthenticatedUserError { - #[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("Resource not found")] @@ -641,19 +816,27 @@ pub enum UsersListBlockedByAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersListBlockedByAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersListBlockedByAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersListBlockedByAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersListBlockedByAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersListBlockedByAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersListBlockedByAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List email addresses for the authenticated user](Users::list_emails_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListEmailsForAuthenticatedUserError { - #[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("Resource not found")] @@ -666,19 +849,27 @@ pub enum UsersListEmailsForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersListEmailsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersListEmailsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersListEmailsForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersListEmailsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersListEmailsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersListEmailsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List the people the authenticated user follows](Users::list_followed_by_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListFollowedByAuthenticatedUserError { - #[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("Forbidden")] @@ -689,19 +880,26 @@ pub enum UsersListFollowedByAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersListFollowedByAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersListFollowedByAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersListFollowedByAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersListFollowedByAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersListFollowedByAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List followers of the authenticated user](Users::list_followers_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListFollowersForAuthenticatedUserError { - #[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("Forbidden")] @@ -712,53 +910,68 @@ pub enum UsersListFollowersForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersListFollowersForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersListFollowersForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersListFollowersForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersListFollowersForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersListFollowersForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List followers of a user](Users::list_followers_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListFollowersForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: UsersListFollowersForUserError) -> Self { + let (description, status_code) = match err { + UsersListFollowersForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List the people a user follows](Users::list_following_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListFollowingForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: UsersListFollowingForUserError) -> Self { + let (description, status_code) = match err { + UsersListFollowingForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List GPG keys for the authenticated user](Users::list_gpg_keys_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListGpgKeysForAuthenticatedUserError { - #[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("Resource not found")] @@ -771,36 +984,48 @@ pub enum UsersListGpgKeysForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersListGpgKeysForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersListGpgKeysForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersListGpgKeysForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersListGpgKeysForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersListGpgKeysForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersListGpgKeysForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List GPG keys for a user](Users::list_gpg_keys_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListGpgKeysForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: UsersListGpgKeysForUserError) -> Self { + let (description, status_code) = match err { + UsersListGpgKeysForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List public email addresses for the authenticated user](Users::list_public_emails_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListPublicEmailsForAuthenticatedUserError { - #[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("Resource not found")] @@ -813,36 +1038,48 @@ pub enum UsersListPublicEmailsForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersListPublicEmailsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersListPublicEmailsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersListPublicEmailsForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersListPublicEmailsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersListPublicEmailsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersListPublicEmailsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List public keys for a user](Users::list_public_keys_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListPublicKeysForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: UsersListPublicKeysForUserError) -> Self { + let (description, status_code) = match err { + UsersListPublicKeysForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List public SSH keys for the authenticated user](Users::list_public_ssh_keys_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListPublicSshKeysForAuthenticatedUserError { - #[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("Resource not found")] @@ -855,19 +1092,27 @@ pub enum UsersListPublicSshKeysForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersListPublicSshKeysForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersListPublicSshKeysForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersListPublicSshKeysForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersListPublicSshKeysForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersListPublicSshKeysForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersListPublicSshKeysForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List social accounts for the authenticated user](Users::list_social_accounts_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListSocialAccountsForAuthenticatedUserError { - #[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("Resource not found")] @@ -880,36 +1125,48 @@ pub enum UsersListSocialAccountsForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersListSocialAccountsForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersListSocialAccountsForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersListSocialAccountsForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersListSocialAccountsForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersListSocialAccountsForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersListSocialAccountsForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List social accounts for a user](Users::list_social_accounts_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListSocialAccountsForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: UsersListSocialAccountsForUserError) -> Self { + let (description, status_code) = match err { + UsersListSocialAccountsForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List SSH signing keys for the authenticated user](Users::list_ssh_signing_keys_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListSshSigningKeysForAuthenticatedUserError { - #[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("Resource not found")] @@ -922,36 +1179,48 @@ pub enum UsersListSshSigningKeysForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersListSshSigningKeysForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersListSshSigningKeysForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersListSshSigningKeysForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersListSshSigningKeysForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersListSshSigningKeysForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersListSshSigningKeysForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [List SSH signing keys for a user](Users::list_ssh_signing_keys_for_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersListSshSigningKeysForUserError { - #[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 }, } +impl From for AdapterError { + fn from(err: UsersListSshSigningKeysForUserError) -> Self { + let (description, status_code) = match err { + UsersListSshSigningKeysForUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Set primary email visibility for the authenticated user](Users::set_primary_email_visibility_for_authenticated_user_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersSetPrimaryEmailVisibilityForAuthenticatedUserError { - #[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("Resource not found")] @@ -966,19 +1235,28 @@ pub enum UsersSetPrimaryEmailVisibilityForAuthenticatedUserError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersSetPrimaryEmailVisibilityForAuthenticatedUserError) -> Self { + let (description, status_code) = match err { + UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status304 => (String::from("Not modified"), 304), + UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status404(_) => (String::from("Resource not found"), 404), + UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status403(_) => (String::from("Forbidden"), 403), + UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status401(_) => (String::from("Requires authentication"), 401), + UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Unblock a user](Users::unblock_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersUnblockError { - #[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("Forbidden")] @@ -991,19 +1269,27 @@ pub enum UsersUnblockError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersUnblockError) -> Self { + let (description, status_code) = match err { + UsersUnblockError::Status304 => (String::from("Not modified"), 304), + UsersUnblockError::Status403(_) => (String::from("Forbidden"), 403), + UsersUnblockError::Status401(_) => (String::from("Requires authentication"), 401), + UsersUnblockError::Status404(_) => (String::from("Resource not found"), 404), + UsersUnblockError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Unfollow a user](Users::unfollow_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersUnfollowError { - #[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("Resource not found")] @@ -1016,19 +1302,27 @@ pub enum UsersUnfollowError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersUnfollowError) -> Self { + let (description, status_code) = match err { + UsersUnfollowError::Status304 => (String::from("Not modified"), 304), + UsersUnfollowError::Status404(_) => (String::from("Resource not found"), 404), + UsersUnfollowError::Status403(_) => (String::from("Forbidden"), 403), + UsersUnfollowError::Status401(_) => (String::from("Requires authentication"), 401), + UsersUnfollowError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Errors for the [Update the authenticated user](Users::update_authenticated_async()) endpoint. #[derive(Debug, thiserror::Error)] pub enum UsersUpdateAuthenticatedError { - #[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("Resource not found")] @@ -1043,6 +1337,25 @@ pub enum UsersUpdateAuthenticatedError { Generic { code: u16 }, } +impl From for AdapterError { + fn from(err: UsersUpdateAuthenticatedError) -> Self { + let (description, status_code) = match err { + UsersUpdateAuthenticatedError::Status304 => (String::from("Not modified"), 304), + UsersUpdateAuthenticatedError::Status404(_) => (String::from("Resource not found"), 404), + UsersUpdateAuthenticatedError::Status403(_) => (String::from("Forbidden"), 403), + UsersUpdateAuthenticatedError::Status401(_) => (String::from("Requires authentication"), 401), + UsersUpdateAuthenticatedError::Status422(_) => (String::from("Validation failed, or the endpoint has been spammed."), 422), + UsersUpdateAuthenticatedError::Generic { code } => (String::from("Generic"), code) + }; + + Self::Endpoint { + description, + status_code, + source: Some(Box::new(err)) + } + } +} + /// Query parameters for the [Get contextual information for a user](Users::get_context_for_user_async()) endpoint. #[derive(Default, Serialize)] @@ -1751,7 +2064,7 @@ impl<'enc> From<&'enc PerPage> for UsersListSshSigningKeysForUserParams { } } -impl<'api, C: Client> Users<'api, C> { +impl<'api, C: Client> Users<'api, C> where AdapterError: From<::Err> { /// --- /// /// # Add an email address for the authenticated user @@ -1761,19 +2074,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for add_email_for_authenticated_user](https://docs.github.com/rest/users/emails#add-an-email-address-for-the-authenticated-user) /// /// --- - pub async fn add_email_for_authenticated_user_async(&self, body: PostUsersAddEmailForAuthenticatedUser) -> Result, UsersAddEmailForAuthenticatedUserError> { + pub async fn add_email_for_authenticated_user_async(&self, body: PostUsersAddEmailForAuthenticatedUser) -> Result, AdapterError> { let request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostUsersAddEmailForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1785,12 +2098,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(UsersAddEmailForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - 304 => Err(UsersAddEmailForAuthenticatedUserError::Status304), - 404 => Err(UsersAddEmailForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersAddEmailForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersAddEmailForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersAddEmailForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersAddEmailForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(UsersAddEmailForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersAddEmailForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersAddEmailForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersAddEmailForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersAddEmailForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1805,19 +2118,19 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_email_for_authenticated_user(&self, body: PostUsersAddEmailForAuthenticatedUser) -> Result, UsersAddEmailForAuthenticatedUserError> { + pub fn add_email_for_authenticated_user(&self, body: PostUsersAddEmailForAuthenticatedUser) -> Result, AdapterError> { let request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostUsersAddEmailForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1829,12 +2142,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(UsersAddEmailForAuthenticatedUserError::Status422(github_response.to_json()?)), - 304 => Err(UsersAddEmailForAuthenticatedUserError::Status304), - 404 => Err(UsersAddEmailForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersAddEmailForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersAddEmailForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersAddEmailForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersAddEmailForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + 304 => Err(UsersAddEmailForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersAddEmailForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersAddEmailForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersAddEmailForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersAddEmailForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1850,19 +2163,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for add_social_account_for_authenticated_user](https://docs.github.com/rest/users/social-accounts#add-social-accounts-for-the-authenticated-user) /// /// --- - pub async fn add_social_account_for_authenticated_user_async(&self, body: PostUsersAddSocialAccountForAuthenticatedUser) -> Result, UsersAddSocialAccountForAuthenticatedUserError> { + pub async fn add_social_account_for_authenticated_user_async(&self, body: PostUsersAddSocialAccountForAuthenticatedUser) -> Result, AdapterError> { let request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostUsersAddSocialAccountForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1874,12 +2187,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - 304 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status304), - 404 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersAddSocialAccountForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersAddSocialAccountForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1896,19 +2209,19 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn add_social_account_for_authenticated_user(&self, body: PostUsersAddSocialAccountForAuthenticatedUser) -> Result, UsersAddSocialAccountForAuthenticatedUserError> { + pub fn add_social_account_for_authenticated_user(&self, body: PostUsersAddSocialAccountForAuthenticatedUser) -> Result, AdapterError> { let request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostUsersAddSocialAccountForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1920,12 +2233,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status422(github_response.to_json()?)), - 304 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status304), - 404 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersAddSocialAccountForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + 304 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersAddSocialAccountForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersAddSocialAccountForAuthenticatedUserError::Generic { code }.into()), } } } @@ -1939,19 +2252,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for block](https://docs.github.com/rest/users/blocking#block-a-user) /// /// --- - pub async fn block_async(&self, username: &str) -> Result<(), UsersBlockError> { + pub async fn block_async(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/blocks/{}", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -1963,12 +2276,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersBlockError::Status304), - 404 => Err(UsersBlockError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersBlockError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersBlockError::Status401(github_response.to_json_async().await?)), - 422 => Err(UsersBlockError::Status422(github_response.to_json_async().await?)), - code => Err(UsersBlockError::Generic { code }), + 304 => Err(UsersBlockError::Status304.into()), + 404 => Err(UsersBlockError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersBlockError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersBlockError::Status401(github_response.to_json_async().await?).into()), + 422 => Err(UsersBlockError::Status422(github_response.to_json_async().await?).into()), + code => Err(UsersBlockError::Generic { code }.into()), } } } @@ -1983,7 +2296,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn block(&self, username: &str) -> Result<(), UsersBlockError> { + pub fn block(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/blocks/{}", super::GITHUB_BASE_API_URL, username); @@ -1995,7 +2308,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2007,12 +2320,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersBlockError::Status304), - 404 => Err(UsersBlockError::Status404(github_response.to_json()?)), - 403 => Err(UsersBlockError::Status403(github_response.to_json()?)), - 401 => Err(UsersBlockError::Status401(github_response.to_json()?)), - 422 => Err(UsersBlockError::Status422(github_response.to_json()?)), - code => Err(UsersBlockError::Generic { code }), + 304 => Err(UsersBlockError::Status304.into()), + 404 => Err(UsersBlockError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersBlockError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersBlockError::Status401(github_response.to_json()?).into()), + 422 => Err(UsersBlockError::Status422(github_response.to_json()?).into()), + code => Err(UsersBlockError::Generic { code }.into()), } } } @@ -2026,19 +2339,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for check_blocked](https://docs.github.com/rest/users/blocking#check-if-a-user-is-blocked-by-the-authenticated-user) /// /// --- - pub async fn check_blocked_async(&self, username: &str) -> Result<(), UsersCheckBlockedError> { + pub async fn check_blocked_async(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/blocks/{}", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2050,11 +2363,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(UsersCheckBlockedError::Status404(github_response.to_json_async().await?)), - 304 => Err(UsersCheckBlockedError::Status304), - 403 => Err(UsersCheckBlockedError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersCheckBlockedError::Status401(github_response.to_json_async().await?)), - code => Err(UsersCheckBlockedError::Generic { code }), + 404 => Err(UsersCheckBlockedError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(UsersCheckBlockedError::Status304.into()), + 403 => Err(UsersCheckBlockedError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersCheckBlockedError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersCheckBlockedError::Generic { code }.into()), } } } @@ -2069,7 +2382,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_blocked(&self, username: &str) -> Result<(), UsersCheckBlockedError> { + pub fn check_blocked(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/blocks/{}", super::GITHUB_BASE_API_URL, username); @@ -2081,7 +2394,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2093,11 +2406,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(UsersCheckBlockedError::Status404(github_response.to_json()?)), - 304 => Err(UsersCheckBlockedError::Status304), - 403 => Err(UsersCheckBlockedError::Status403(github_response.to_json()?)), - 401 => Err(UsersCheckBlockedError::Status401(github_response.to_json()?)), - code => Err(UsersCheckBlockedError::Generic { code }), + 404 => Err(UsersCheckBlockedError::Status404(github_response.to_json()?).into()), + 304 => Err(UsersCheckBlockedError::Status304.into()), + 403 => Err(UsersCheckBlockedError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersCheckBlockedError::Status401(github_response.to_json()?).into()), + code => Err(UsersCheckBlockedError::Generic { code }.into()), } } } @@ -2109,19 +2422,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for check_following_for_user](https://docs.github.com/rest/users/followers#check-if-a-user-follows-another-user) /// /// --- - pub async fn check_following_for_user_async(&self, username: &str, target_user: &str) -> Result<(), UsersCheckFollowingForUserError> { + pub async fn check_following_for_user_async(&self, username: &str, target_user: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/users/{}/following/{}", super::GITHUB_BASE_API_URL, username, target_user); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2133,8 +2446,8 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(UsersCheckFollowingForUserError::Status404), - code => Err(UsersCheckFollowingForUserError::Generic { code }), + 404 => Err(UsersCheckFollowingForUserError::Status404.into()), + code => Err(UsersCheckFollowingForUserError::Generic { code }.into()), } } } @@ -2147,7 +2460,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_following_for_user(&self, username: &str, target_user: &str) -> Result<(), UsersCheckFollowingForUserError> { + pub fn check_following_for_user(&self, username: &str, target_user: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/users/{}/following/{}", super::GITHUB_BASE_API_URL, username, target_user); @@ -2159,7 +2472,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2171,8 +2484,8 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(UsersCheckFollowingForUserError::Status404), - code => Err(UsersCheckFollowingForUserError::Generic { code }), + 404 => Err(UsersCheckFollowingForUserError::Status404.into()), + code => Err(UsersCheckFollowingForUserError::Generic { code }.into()), } } } @@ -2184,19 +2497,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for check_person_is_followed_by_authenticated](https://docs.github.com/rest/users/followers#check-if-a-person-is-followed-by-the-authenticated-user) /// /// --- - pub async fn check_person_is_followed_by_authenticated_async(&self, username: &str) -> Result<(), UsersCheckPersonIsFollowedByAuthenticatedError> { + pub async fn check_person_is_followed_by_authenticated_async(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/following/{}", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2208,11 +2521,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status404(github_response.to_json_async().await?)), - 304 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status304), - 403 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status401(github_response.to_json_async().await?)), - code => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Generic { code }), + 404 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status304.into()), + 403 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Generic { code }.into()), } } } @@ -2225,7 +2538,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn check_person_is_followed_by_authenticated(&self, username: &str) -> Result<(), UsersCheckPersonIsFollowedByAuthenticatedError> { + pub fn check_person_is_followed_by_authenticated(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/following/{}", super::GITHUB_BASE_API_URL, username); @@ -2237,7 +2550,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2249,11 +2562,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status404(github_response.to_json()?)), - 304 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status304), - 403 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status403(github_response.to_json()?)), - 401 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status401(github_response.to_json()?)), - code => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Generic { code }), + 404 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status404(github_response.to_json()?).into()), + 304 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status304.into()), + 403 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Status401(github_response.to_json()?).into()), + code => Err(UsersCheckPersonIsFollowedByAuthenticatedError::Generic { code }.into()), } } } @@ -2269,19 +2582,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for create_gpg_key_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#create-a-gpg-key-for-the-authenticated-user) /// /// --- - pub async fn create_gpg_key_for_authenticated_user_async(&self, body: PostUsersCreateGpgKeyForAuthenticatedUser) -> Result { + pub async fn create_gpg_key_for_authenticated_user_async(&self, body: PostUsersCreateGpgKeyForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/gpg_keys", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostUsersCreateGpgKeyForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2293,12 +2606,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - 304 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status304), - 404 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersCreateGpgKeyForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersCreateGpgKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2315,19 +2628,19 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_gpg_key_for_authenticated_user(&self, body: PostUsersCreateGpgKeyForAuthenticatedUser) -> Result { + pub fn create_gpg_key_for_authenticated_user(&self, body: PostUsersCreateGpgKeyForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/gpg_keys", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostUsersCreateGpgKeyForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2339,12 +2652,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status422(github_response.to_json()?)), - 304 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status304), - 404 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersCreateGpgKeyForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + 304 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersCreateGpgKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersCreateGpgKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2360,19 +2673,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for create_public_ssh_key_for_authenticated_user](https://docs.github.com/rest/users/keys#create-a-public-ssh-key-for-the-authenticated-user) /// /// --- - pub async fn create_public_ssh_key_for_authenticated_user_async(&self, body: PostUsersCreatePublicSshKeyForAuthenticatedUser) -> Result { + pub async fn create_public_ssh_key_for_authenticated_user_async(&self, body: PostUsersCreatePublicSshKeyForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/keys", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostUsersCreatePublicSshKeyForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2384,12 +2697,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - 304 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status304), - 404 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2406,19 +2719,19 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_public_ssh_key_for_authenticated_user(&self, body: PostUsersCreatePublicSshKeyForAuthenticatedUser) -> Result { + pub fn create_public_ssh_key_for_authenticated_user(&self, body: PostUsersCreatePublicSshKeyForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/keys", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostUsersCreatePublicSshKeyForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2430,12 +2743,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status422(github_response.to_json()?)), - 304 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status304), - 404 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + 304 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersCreatePublicSshKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2451,19 +2764,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for create_ssh_signing_key_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#create-a-ssh-signing-key-for-the-authenticated-user) /// /// --- - pub async fn create_ssh_signing_key_for_authenticated_user_async(&self, body: PostUsersCreateSshSigningKeyForAuthenticatedUser) -> Result { + pub async fn create_ssh_signing_key_for_authenticated_user_async(&self, body: PostUsersCreateSshSigningKeyForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/ssh_signing_keys", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostUsersCreateSshSigningKeyForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2475,12 +2788,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - 304 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status304), - 404 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2497,19 +2810,19 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn create_ssh_signing_key_for_authenticated_user(&self, body: PostUsersCreateSshSigningKeyForAuthenticatedUser) -> Result { + pub fn create_ssh_signing_key_for_authenticated_user(&self, body: PostUsersCreateSshSigningKeyForAuthenticatedUser) -> Result { let request_uri = format!("{}/user/ssh_signing_keys", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PostUsersCreateSshSigningKeyForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "POST", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2521,12 +2834,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status422(github_response.to_json()?)), - 304 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status304), - 404 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + 304 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersCreateSshSigningKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2540,19 +2853,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for delete_email_for_authenticated_user](https://docs.github.com/rest/users/emails#delete-an-email-address-for-the-authenticated-user) /// /// --- - pub async fn delete_email_for_authenticated_user_async(&self, body: DeleteUsersDeleteEmailForAuthenticatedUser) -> Result<(), UsersDeleteEmailForAuthenticatedUserError> { + pub async fn delete_email_for_authenticated_user_async(&self, body: DeleteUsersDeleteEmailForAuthenticatedUser) -> Result<(), AdapterError> { let request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteUsersDeleteEmailForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2564,12 +2877,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersDeleteEmailForAuthenticatedUserError::Status304), - 404 => Err(UsersDeleteEmailForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersDeleteEmailForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersDeleteEmailForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 422 => Err(UsersDeleteEmailForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - code => Err(UsersDeleteEmailForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersDeleteEmailForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersDeleteEmailForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersDeleteEmailForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersDeleteEmailForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 422 => Err(UsersDeleteEmailForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(UsersDeleteEmailForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2584,19 +2897,19 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_email_for_authenticated_user(&self, body: DeleteUsersDeleteEmailForAuthenticatedUser) -> Result<(), UsersDeleteEmailForAuthenticatedUserError> { + pub fn delete_email_for_authenticated_user(&self, body: DeleteUsersDeleteEmailForAuthenticatedUser) -> Result<(), AdapterError> { let request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteUsersDeleteEmailForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2608,12 +2921,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersDeleteEmailForAuthenticatedUserError::Status304), - 404 => Err(UsersDeleteEmailForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersDeleteEmailForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersDeleteEmailForAuthenticatedUserError::Status401(github_response.to_json()?)), - 422 => Err(UsersDeleteEmailForAuthenticatedUserError::Status422(github_response.to_json()?)), - code => Err(UsersDeleteEmailForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersDeleteEmailForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersDeleteEmailForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersDeleteEmailForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersDeleteEmailForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 422 => Err(UsersDeleteEmailForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + code => Err(UsersDeleteEmailForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2629,19 +2942,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for delete_gpg_key_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#delete-a-gpg-key-for-the-authenticated-user) /// /// --- - pub async fn delete_gpg_key_for_authenticated_user_async(&self, gpg_key_id: i32) -> Result<(), UsersDeleteGpgKeyForAuthenticatedUserError> { + pub async fn delete_gpg_key_for_authenticated_user_async(&self, gpg_key_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/gpg_keys/{}", super::GITHUB_BASE_API_URL, gpg_key_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2653,12 +2966,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 422 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - 304 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status304), - 403 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Generic { code }), + 404 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status304.into()), + 403 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2675,7 +2988,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_gpg_key_for_authenticated_user(&self, gpg_key_id: i32) -> Result<(), UsersDeleteGpgKeyForAuthenticatedUserError> { + pub fn delete_gpg_key_for_authenticated_user(&self, gpg_key_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/gpg_keys/{}", super::GITHUB_BASE_API_URL, gpg_key_id); @@ -2687,7 +3000,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2699,12 +3012,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status404(github_response.to_json()?)), - 422 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status422(github_response.to_json()?)), - 304 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status304), - 403 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Generic { code }), + 404 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 422 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + 304 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status304.into()), + 403 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersDeleteGpgKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2720,19 +3033,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for delete_public_ssh_key_for_authenticated_user](https://docs.github.com/rest/users/keys#delete-a-public-ssh-key-for-the-authenticated-user) /// /// --- - pub async fn delete_public_ssh_key_for_authenticated_user_async(&self, key_id: i32) -> Result<(), UsersDeletePublicSshKeyForAuthenticatedUserError> { + pub async fn delete_public_ssh_key_for_authenticated_user_async(&self, key_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/keys/{}", super::GITHUB_BASE_API_URL, key_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2744,11 +3057,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status304), - 404 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2765,7 +3078,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_public_ssh_key_for_authenticated_user(&self, key_id: i32) -> Result<(), UsersDeletePublicSshKeyForAuthenticatedUserError> { + pub fn delete_public_ssh_key_for_authenticated_user(&self, key_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/keys/{}", super::GITHUB_BASE_API_URL, key_id); @@ -2777,7 +3090,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2789,11 +3102,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status304), - 404 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersDeletePublicSshKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2809,19 +3122,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for delete_social_account_for_authenticated_user](https://docs.github.com/rest/users/social-accounts#delete-social-accounts-for-the-authenticated-user) /// /// --- - pub async fn delete_social_account_for_authenticated_user_async(&self, body: DeleteUsersDeleteSocialAccountForAuthenticatedUser) -> Result<(), UsersDeleteSocialAccountForAuthenticatedUserError> { + pub async fn delete_social_account_for_authenticated_user_async(&self, body: DeleteUsersDeleteSocialAccountForAuthenticatedUser) -> Result<(), AdapterError> { let request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteUsersDeleteSocialAccountForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2833,12 +3146,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 422 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - 304 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status304), - 404 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + 304 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2855,19 +3168,19 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_social_account_for_authenticated_user(&self, body: DeleteUsersDeleteSocialAccountForAuthenticatedUser) -> Result<(), UsersDeleteSocialAccountForAuthenticatedUserError> { + pub fn delete_social_account_for_authenticated_user(&self, body: DeleteUsersDeleteSocialAccountForAuthenticatedUser) -> Result<(), AdapterError> { let request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(DeleteUsersDeleteSocialAccountForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2879,12 +3192,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 422 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status422(github_response.to_json()?)), - 304 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status304), - 404 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Generic { code }), + 422 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + 304 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersDeleteSocialAccountForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2900,19 +3213,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for delete_ssh_signing_key_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#delete-an-ssh-signing-key-for-the-authenticated-user) /// /// --- - pub async fn delete_ssh_signing_key_for_authenticated_user_async(&self, ssh_signing_key_id: i32) -> Result<(), UsersDeleteSshSigningKeyForAuthenticatedUserError> { + pub async fn delete_ssh_signing_key_for_authenticated_user_async(&self, ssh_signing_key_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/ssh_signing_keys/{}", super::GITHUB_BASE_API_URL, ssh_signing_key_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2924,11 +3237,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status304), - 404 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2945,7 +3258,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn delete_ssh_signing_key_for_authenticated_user(&self, ssh_signing_key_id: i32) -> Result<(), UsersDeleteSshSigningKeyForAuthenticatedUserError> { + pub fn delete_ssh_signing_key_for_authenticated_user(&self, ssh_signing_key_id: i32) -> Result<(), AdapterError> { let request_uri = format!("{}/user/ssh_signing_keys/{}", super::GITHUB_BASE_API_URL, ssh_signing_key_id); @@ -2957,7 +3270,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -2969,11 +3282,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status304), - 404 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersDeleteSshSigningKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -2989,19 +3302,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for follow](https://docs.github.com/rest/users/followers#follow-a-user) /// /// --- - pub async fn follow_async(&self, username: &str) -> Result<(), UsersFollowError> { + pub async fn follow_async(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/following/{}", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "PUT", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3013,11 +3326,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersFollowError::Status304), - 404 => Err(UsersFollowError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersFollowError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersFollowError::Status401(github_response.to_json_async().await?)), - code => Err(UsersFollowError::Generic { code }), + 304 => Err(UsersFollowError::Status304.into()), + 404 => Err(UsersFollowError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersFollowError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersFollowError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersFollowError::Generic { code }.into()), } } } @@ -3034,7 +3347,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn follow(&self, username: &str) -> Result<(), UsersFollowError> { + pub fn follow(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/following/{}", super::GITHUB_BASE_API_URL, username); @@ -3046,7 +3359,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3058,11 +3371,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersFollowError::Status304), - 404 => Err(UsersFollowError::Status404(github_response.to_json()?)), - 403 => Err(UsersFollowError::Status403(github_response.to_json()?)), - 401 => Err(UsersFollowError::Status401(github_response.to_json()?)), - code => Err(UsersFollowError::Generic { code }), + 304 => Err(UsersFollowError::Status304.into()), + 404 => Err(UsersFollowError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersFollowError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersFollowError::Status401(github_response.to_json()?).into()), + code => Err(UsersFollowError::Generic { code }.into()), } } } @@ -3076,19 +3389,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for get_authenticated](https://docs.github.com/rest/users/users#get-the-authenticated-user) /// /// --- - pub async fn get_authenticated_async(&self) -> Result { + pub async fn get_authenticated_async(&self) -> Result { let request_uri = format!("{}/user", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3100,10 +3413,10 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersGetAuthenticatedError::Status304), - 403 => Err(UsersGetAuthenticatedError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersGetAuthenticatedError::Status401(github_response.to_json_async().await?)), - code => Err(UsersGetAuthenticatedError::Generic { code }), + 304 => Err(UsersGetAuthenticatedError::Status304.into()), + 403 => Err(UsersGetAuthenticatedError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersGetAuthenticatedError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersGetAuthenticatedError::Generic { code }.into()), } } } @@ -3118,7 +3431,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_authenticated(&self) -> Result { + pub fn get_authenticated(&self) -> Result { let request_uri = format!("{}/user", super::GITHUB_BASE_API_URL); @@ -3130,7 +3443,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3142,10 +3455,10 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersGetAuthenticatedError::Status304), - 403 => Err(UsersGetAuthenticatedError::Status403(github_response.to_json()?)), - 401 => Err(UsersGetAuthenticatedError::Status401(github_response.to_json()?)), - code => Err(UsersGetAuthenticatedError::Generic { code }), + 304 => Err(UsersGetAuthenticatedError::Status304.into()), + 403 => Err(UsersGetAuthenticatedError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersGetAuthenticatedError::Status401(github_response.to_json()?).into()), + code => Err(UsersGetAuthenticatedError::Generic { code }.into()), } } } @@ -3163,19 +3476,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for get_by_id](https://docs.github.com/rest/users/users#get-a-user-using-their-id) /// /// --- - pub async fn get_by_id_async(&self, account_id: i32) -> Result { + pub async fn get_by_id_async(&self, account_id: i32) -> Result { let request_uri = format!("{}/user/{}", super::GITHUB_BASE_API_URL, account_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3187,8 +3500,8 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(UsersGetByIdError::Status404(github_response.to_json_async().await?)), - code => Err(UsersGetByIdError::Generic { code }), + 404 => Err(UsersGetByIdError::Status404(github_response.to_json_async().await?).into()), + code => Err(UsersGetByIdError::Generic { code }.into()), } } } @@ -3207,7 +3520,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_by_id(&self, account_id: i32) -> Result { + pub fn get_by_id(&self, account_id: i32) -> Result { let request_uri = format!("{}/user/{}", super::GITHUB_BASE_API_URL, account_id); @@ -3219,7 +3532,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3231,8 +3544,8 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(UsersGetByIdError::Status404(github_response.to_json()?)), - code => Err(UsersGetByIdError::Generic { code }), + 404 => Err(UsersGetByIdError::Status404(github_response.to_json()?).into()), + code => Err(UsersGetByIdError::Generic { code }.into()), } } } @@ -3250,19 +3563,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for get_by_username](https://docs.github.com/rest/users/users#get-a-user) /// /// --- - pub async fn get_by_username_async(&self, username: &str) -> Result { + pub async fn get_by_username_async(&self, username: &str) -> Result { let request_uri = format!("{}/users/{}", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3274,8 +3587,8 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(UsersGetByUsernameError::Status404(github_response.to_json_async().await?)), - code => Err(UsersGetByUsernameError::Generic { code }), + 404 => Err(UsersGetByUsernameError::Status404(github_response.to_json_async().await?).into()), + code => Err(UsersGetByUsernameError::Generic { code }.into()), } } } @@ -3294,7 +3607,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_by_username(&self, username: &str) -> Result { + pub fn get_by_username(&self, username: &str) -> Result { let request_uri = format!("{}/users/{}", super::GITHUB_BASE_API_URL, username); @@ -3306,7 +3619,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3318,8 +3631,8 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(UsersGetByUsernameError::Status404(github_response.to_json()?)), - code => Err(UsersGetByUsernameError::Generic { code }), + 404 => Err(UsersGetByUsernameError::Status404(github_response.to_json()?).into()), + code => Err(UsersGetByUsernameError::Generic { code }.into()), } } } @@ -3337,7 +3650,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for get_context_for_user](https://docs.github.com/rest/users/users#get-contextual-information-for-a-user) /// /// --- - pub async fn get_context_for_user_async(&self, username: &str, query_params: Option>>) -> Result { + pub async fn get_context_for_user_async(&self, username: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/users/{}/hovercard", super::GITHUB_BASE_API_URL, username); @@ -3348,12 +3661,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3365,9 +3678,9 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(UsersGetContextForUserError::Status404(github_response.to_json_async().await?)), - 422 => Err(UsersGetContextForUserError::Status422(github_response.to_json_async().await?)), - code => Err(UsersGetContextForUserError::Generic { code }), + 404 => Err(UsersGetContextForUserError::Status404(github_response.to_json_async().await?).into()), + 422 => Err(UsersGetContextForUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(UsersGetContextForUserError::Generic { code }.into()), } } } @@ -3386,7 +3699,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_context_for_user(&self, username: &str, query_params: Option>>) -> Result { + pub fn get_context_for_user(&self, username: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/users/{}/hovercard", super::GITHUB_BASE_API_URL, username); @@ -3403,7 +3716,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3415,9 +3728,9 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(UsersGetContextForUserError::Status404(github_response.to_json()?)), - 422 => Err(UsersGetContextForUserError::Status422(github_response.to_json()?)), - code => Err(UsersGetContextForUserError::Generic { code }), + 404 => Err(UsersGetContextForUserError::Status404(github_response.to_json()?).into()), + 422 => Err(UsersGetContextForUserError::Status422(github_response.to_json()?).into()), + code => Err(UsersGetContextForUserError::Generic { code }.into()), } } } @@ -3433,19 +3746,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for get_gpg_key_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#get-a-gpg-key-for-the-authenticated-user) /// /// --- - pub async fn get_gpg_key_for_authenticated_user_async(&self, gpg_key_id: i32) -> Result { + pub async fn get_gpg_key_for_authenticated_user_async(&self, gpg_key_id: i32) -> Result { let request_uri = format!("{}/user/gpg_keys/{}", super::GITHUB_BASE_API_URL, gpg_key_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3457,11 +3770,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 304 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status304), - 403 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersGetGpgKeyForAuthenticatedUserError::Generic { code }), + 404 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status304.into()), + 403 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersGetGpgKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3478,7 +3791,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_gpg_key_for_authenticated_user(&self, gpg_key_id: i32) -> Result { + pub fn get_gpg_key_for_authenticated_user(&self, gpg_key_id: i32) -> Result { let request_uri = format!("{}/user/gpg_keys/{}", super::GITHUB_BASE_API_URL, gpg_key_id); @@ -3490,7 +3803,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3502,11 +3815,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status404(github_response.to_json()?)), - 304 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status304), - 403 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersGetGpgKeyForAuthenticatedUserError::Generic { code }), + 404 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 304 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status304.into()), + 403 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersGetGpgKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersGetGpgKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3522,19 +3835,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for get_public_ssh_key_for_authenticated_user](https://docs.github.com/rest/users/keys#get-a-public-ssh-key-for-the-authenticated-user) /// /// --- - pub async fn get_public_ssh_key_for_authenticated_user_async(&self, key_id: i32) -> Result { + pub async fn get_public_ssh_key_for_authenticated_user_async(&self, key_id: i32) -> Result { let request_uri = format!("{}/user/keys/{}", super::GITHUB_BASE_API_URL, key_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3546,11 +3859,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 304 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status304), - 403 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Generic { code }), + 404 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status304.into()), + 403 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3567,7 +3880,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_public_ssh_key_for_authenticated_user(&self, key_id: i32) -> Result { + pub fn get_public_ssh_key_for_authenticated_user(&self, key_id: i32) -> Result { let request_uri = format!("{}/user/keys/{}", super::GITHUB_BASE_API_URL, key_id); @@ -3579,7 +3892,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3591,11 +3904,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json()?)), - 304 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status304), - 403 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Generic { code }), + 404 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 304 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status304.into()), + 403 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersGetPublicSshKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3611,19 +3924,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for get_ssh_signing_key_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#get-an-ssh-signing-key-for-the-authenticated-user) /// /// --- - pub async fn get_ssh_signing_key_for_authenticated_user_async(&self, ssh_signing_key_id: i32) -> Result { + pub async fn get_ssh_signing_key_for_authenticated_user_async(&self, ssh_signing_key_id: i32) -> Result { let request_uri = format!("{}/user/ssh_signing_keys/{}", super::GITHUB_BASE_API_URL, ssh_signing_key_id); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3635,11 +3948,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 404 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 304 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status304), - 403 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Generic { code }), + 404 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 304 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status304.into()), + 403 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3656,7 +3969,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn get_ssh_signing_key_for_authenticated_user(&self, ssh_signing_key_id: i32) -> Result { + pub fn get_ssh_signing_key_for_authenticated_user(&self, ssh_signing_key_id: i32) -> Result { let request_uri = format!("{}/user/ssh_signing_keys/{}", super::GITHUB_BASE_API_URL, ssh_signing_key_id); @@ -3668,7 +3981,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3680,11 +3993,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 404 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json()?)), - 304 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status304), - 403 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Generic { code }), + 404 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 304 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status304.into()), + 403 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersGetSshSigningKeyForAuthenticatedUserError::Generic { code }.into()), } } } @@ -3700,7 +4013,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list](https://docs.github.com/rest/users/users#list-users) /// /// --- - pub async fn list_async(&self, query_params: Option>) -> Result, UsersListError> { + pub async fn list_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users", super::GITHUB_BASE_API_URL); @@ -3711,12 +4024,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3728,8 +4041,8 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersListError::Status304), - code => Err(UsersListError::Generic { code }), + 304 => Err(UsersListError::Status304.into()), + code => Err(UsersListError::Generic { code }.into()), } } } @@ -3746,7 +4059,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list(&self, query_params: Option>) -> Result, UsersListError> { + pub fn list(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users", super::GITHUB_BASE_API_URL); @@ -3763,7 +4076,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3775,8 +4088,8 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersListError::Status304), - code => Err(UsersListError::Generic { code }), + 304 => Err(UsersListError::Status304.into()), + code => Err(UsersListError::Generic { code }.into()), } } } @@ -3794,7 +4107,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_attestations](https://docs.github.com/rest/users/attestations#list-attestations) /// /// --- - pub async fn list_attestations_async(&self, username: &str, subject_digest: &str, query_params: Option>>) -> Result { + pub async fn list_attestations_async(&self, username: &str, subject_digest: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/users/{}/attestations/{}", super::GITHUB_BASE_API_URL, username, subject_digest); @@ -3805,12 +4118,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3822,10 +4135,10 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 201 => Err(UsersListAttestationsError::Status201(github_response.to_json_async().await?)), - 204 => Err(UsersListAttestationsError::Status204), - 404 => Err(UsersListAttestationsError::Status404(github_response.to_json_async().await?)), - code => Err(UsersListAttestationsError::Generic { code }), + 201 => Err(UsersListAttestationsError::Status201(github_response.to_json_async().await?).into()), + 204 => Err(UsersListAttestationsError::Status204.into()), + 404 => Err(UsersListAttestationsError::Status404(github_response.to_json_async().await?).into()), + code => Err(UsersListAttestationsError::Generic { code }.into()), } } } @@ -3844,7 +4157,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_attestations(&self, username: &str, subject_digest: &str, query_params: Option>>) -> Result { + pub fn list_attestations(&self, username: &str, subject_digest: &str, query_params: Option>>) -> Result { let mut request_uri = format!("{}/users/{}/attestations/{}", super::GITHUB_BASE_API_URL, username, subject_digest); @@ -3861,7 +4174,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3873,10 +4186,10 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 201 => Err(UsersListAttestationsError::Status201(github_response.to_json()?)), - 204 => Err(UsersListAttestationsError::Status204), - 404 => Err(UsersListAttestationsError::Status404(github_response.to_json()?)), - code => Err(UsersListAttestationsError::Generic { code }), + 201 => Err(UsersListAttestationsError::Status201(github_response.to_json()?).into()), + 204 => Err(UsersListAttestationsError::Status204.into()), + 404 => Err(UsersListAttestationsError::Status404(github_response.to_json()?).into()), + code => Err(UsersListAttestationsError::Generic { code }.into()), } } } @@ -3890,7 +4203,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_blocked_by_authenticated_user](https://docs.github.com/rest/users/blocking#list-users-blocked-by-the-authenticated-user) /// /// --- - pub async fn list_blocked_by_authenticated_user_async(&self, query_params: Option>) -> Result, UsersListBlockedByAuthenticatedUserError> { + pub async fn list_blocked_by_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/blocks", super::GITHUB_BASE_API_URL); @@ -3901,12 +4214,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3918,11 +4231,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersListBlockedByAuthenticatedUserError::Status304), - 404 => Err(UsersListBlockedByAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersListBlockedByAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersListBlockedByAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersListBlockedByAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListBlockedByAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListBlockedByAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersListBlockedByAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersListBlockedByAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersListBlockedByAuthenticatedUserError::Generic { code }.into()), } } } @@ -3937,7 +4250,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_blocked_by_authenticated_user(&self, query_params: Option>) -> Result, UsersListBlockedByAuthenticatedUserError> { + pub fn list_blocked_by_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/blocks", super::GITHUB_BASE_API_URL); @@ -3954,7 +4267,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -3966,11 +4279,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersListBlockedByAuthenticatedUserError::Status304), - 404 => Err(UsersListBlockedByAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersListBlockedByAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersListBlockedByAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersListBlockedByAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListBlockedByAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListBlockedByAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersListBlockedByAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersListBlockedByAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersListBlockedByAuthenticatedUserError::Generic { code }.into()), } } } @@ -3987,7 +4300,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_emails_for_authenticated_user](https://docs.github.com/rest/users/emails#list-email-addresses-for-the-authenticated-user) /// /// --- - pub async fn list_emails_for_authenticated_user_async(&self, query_params: Option>) -> Result, UsersListEmailsForAuthenticatedUserError> { + pub async fn list_emails_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL); @@ -3998,12 +4311,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4015,11 +4328,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersListEmailsForAuthenticatedUserError::Status304), - 404 => Err(UsersListEmailsForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersListEmailsForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersListEmailsForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersListEmailsForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListEmailsForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListEmailsForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersListEmailsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersListEmailsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersListEmailsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4037,7 +4350,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_emails_for_authenticated_user(&self, query_params: Option>) -> Result, UsersListEmailsForAuthenticatedUserError> { + pub fn list_emails_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/emails", super::GITHUB_BASE_API_URL); @@ -4054,7 +4367,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4066,11 +4379,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersListEmailsForAuthenticatedUserError::Status304), - 404 => Err(UsersListEmailsForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersListEmailsForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersListEmailsForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersListEmailsForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListEmailsForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListEmailsForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersListEmailsForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersListEmailsForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersListEmailsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4084,7 +4397,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_followed_by_authenticated_user](https://docs.github.com/rest/users/followers#list-the-people-the-authenticated-user-follows) /// /// --- - pub async fn list_followed_by_authenticated_user_async(&self, query_params: Option>) -> Result, UsersListFollowedByAuthenticatedUserError> { + pub async fn list_followed_by_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/following", super::GITHUB_BASE_API_URL); @@ -4095,12 +4408,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4112,10 +4425,10 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersListFollowedByAuthenticatedUserError::Status304), - 403 => Err(UsersListFollowedByAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersListFollowedByAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersListFollowedByAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListFollowedByAuthenticatedUserError::Status304.into()), + 403 => Err(UsersListFollowedByAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersListFollowedByAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersListFollowedByAuthenticatedUserError::Generic { code }.into()), } } } @@ -4130,7 +4443,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_followed_by_authenticated_user(&self, query_params: Option>) -> Result, UsersListFollowedByAuthenticatedUserError> { + pub fn list_followed_by_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/following", super::GITHUB_BASE_API_URL); @@ -4147,7 +4460,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4159,10 +4472,10 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersListFollowedByAuthenticatedUserError::Status304), - 403 => Err(UsersListFollowedByAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersListFollowedByAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersListFollowedByAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListFollowedByAuthenticatedUserError::Status304.into()), + 403 => Err(UsersListFollowedByAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersListFollowedByAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersListFollowedByAuthenticatedUserError::Generic { code }.into()), } } } @@ -4176,7 +4489,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_followers_for_authenticated_user](https://docs.github.com/rest/users/followers#list-followers-of-the-authenticated-user) /// /// --- - pub async fn list_followers_for_authenticated_user_async(&self, query_params: Option>) -> Result, UsersListFollowersForAuthenticatedUserError> { + pub async fn list_followers_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/followers", super::GITHUB_BASE_API_URL); @@ -4187,12 +4500,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4204,10 +4517,10 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersListFollowersForAuthenticatedUserError::Status304), - 403 => Err(UsersListFollowersForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersListFollowersForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersListFollowersForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListFollowersForAuthenticatedUserError::Status304.into()), + 403 => Err(UsersListFollowersForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersListFollowersForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersListFollowersForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4222,7 +4535,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_followers_for_authenticated_user(&self, query_params: Option>) -> Result, UsersListFollowersForAuthenticatedUserError> { + pub fn list_followers_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/followers", super::GITHUB_BASE_API_URL); @@ -4239,7 +4552,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4251,10 +4564,10 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersListFollowersForAuthenticatedUserError::Status304), - 403 => Err(UsersListFollowersForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersListFollowersForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersListFollowersForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListFollowersForAuthenticatedUserError::Status304.into()), + 403 => Err(UsersListFollowersForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersListFollowersForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersListFollowersForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4268,7 +4581,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_followers_for_user](https://docs.github.com/rest/users/followers#list-followers-of-a-user) /// /// --- - pub async fn list_followers_for_user_async(&self, username: &str, query_params: Option>) -> Result, UsersListFollowersForUserError> { + pub async fn list_followers_for_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/followers", super::GITHUB_BASE_API_URL, username); @@ -4279,12 +4592,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4296,7 +4609,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(UsersListFollowersForUserError::Generic { code }), + code => Err(UsersListFollowersForUserError::Generic { code }.into()), } } } @@ -4311,7 +4624,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_followers_for_user(&self, username: &str, query_params: Option>) -> Result, UsersListFollowersForUserError> { + pub fn list_followers_for_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/followers", super::GITHUB_BASE_API_URL, username); @@ -4328,7 +4641,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4340,7 +4653,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(UsersListFollowersForUserError::Generic { code }), + code => Err(UsersListFollowersForUserError::Generic { code }.into()), } } } @@ -4354,7 +4667,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_following_for_user](https://docs.github.com/rest/users/followers#list-the-people-a-user-follows) /// /// --- - pub async fn list_following_for_user_async(&self, username: &str, query_params: Option>) -> Result, UsersListFollowingForUserError> { + pub async fn list_following_for_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/following", super::GITHUB_BASE_API_URL, username); @@ -4365,12 +4678,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4382,7 +4695,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(UsersListFollowingForUserError::Generic { code }), + code => Err(UsersListFollowingForUserError::Generic { code }.into()), } } } @@ -4397,7 +4710,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_following_for_user(&self, username: &str, query_params: Option>) -> Result, UsersListFollowingForUserError> { + pub fn list_following_for_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/following", super::GITHUB_BASE_API_URL, username); @@ -4414,7 +4727,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4426,7 +4739,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(UsersListFollowingForUserError::Generic { code }), + code => Err(UsersListFollowingForUserError::Generic { code }.into()), } } } @@ -4442,7 +4755,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_gpg_keys_for_authenticated_user](https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-the-authenticated-user) /// /// --- - pub async fn list_gpg_keys_for_authenticated_user_async(&self, query_params: Option>) -> Result, UsersListGpgKeysForAuthenticatedUserError> { + pub async fn list_gpg_keys_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/gpg_keys", super::GITHUB_BASE_API_URL); @@ -4453,12 +4766,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4470,11 +4783,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersListGpgKeysForAuthenticatedUserError::Status304), - 404 => Err(UsersListGpgKeysForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersListGpgKeysForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersListGpgKeysForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersListGpgKeysForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListGpgKeysForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListGpgKeysForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersListGpgKeysForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersListGpgKeysForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersListGpgKeysForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4491,7 +4804,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_gpg_keys_for_authenticated_user(&self, query_params: Option>) -> Result, UsersListGpgKeysForAuthenticatedUserError> { + pub fn list_gpg_keys_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/gpg_keys", super::GITHUB_BASE_API_URL); @@ -4508,7 +4821,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4520,11 +4833,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersListGpgKeysForAuthenticatedUserError::Status304), - 404 => Err(UsersListGpgKeysForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersListGpgKeysForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersListGpgKeysForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersListGpgKeysForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListGpgKeysForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListGpgKeysForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersListGpgKeysForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersListGpgKeysForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersListGpgKeysForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4538,7 +4851,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_gpg_keys_for_user](https://docs.github.com/rest/users/gpg-keys#list-gpg-keys-for-a-user) /// /// --- - pub async fn list_gpg_keys_for_user_async(&self, username: &str, query_params: Option>) -> Result, UsersListGpgKeysForUserError> { + pub async fn list_gpg_keys_for_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/gpg_keys", super::GITHUB_BASE_API_URL, username); @@ -4549,12 +4862,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4566,7 +4879,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(UsersListGpgKeysForUserError::Generic { code }), + code => Err(UsersListGpgKeysForUserError::Generic { code }.into()), } } } @@ -4581,7 +4894,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_gpg_keys_for_user(&self, username: &str, query_params: Option>) -> Result, UsersListGpgKeysForUserError> { + pub fn list_gpg_keys_for_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/gpg_keys", super::GITHUB_BASE_API_URL, username); @@ -4598,7 +4911,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4610,7 +4923,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(UsersListGpgKeysForUserError::Generic { code }), + code => Err(UsersListGpgKeysForUserError::Generic { code }.into()), } } } @@ -4628,7 +4941,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_public_emails_for_authenticated_user](https://docs.github.com/rest/users/emails#list-public-email-addresses-for-the-authenticated-user) /// /// --- - pub async fn list_public_emails_for_authenticated_user_async(&self, query_params: Option>) -> Result, UsersListPublicEmailsForAuthenticatedUserError> { + pub async fn list_public_emails_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/public_emails", super::GITHUB_BASE_API_URL); @@ -4639,12 +4952,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4656,11 +4969,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status304), - 404 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersListPublicEmailsForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersListPublicEmailsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4679,7 +4992,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_public_emails_for_authenticated_user(&self, query_params: Option>) -> Result, UsersListPublicEmailsForAuthenticatedUserError> { + pub fn list_public_emails_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/public_emails", super::GITHUB_BASE_API_URL); @@ -4696,7 +5009,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4708,11 +5021,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status304), - 404 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersListPublicEmailsForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersListPublicEmailsForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersListPublicEmailsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4726,7 +5039,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_public_keys_for_user](https://docs.github.com/rest/users/keys#list-public-keys-for-a-user) /// /// --- - pub async fn list_public_keys_for_user_async(&self, username: &str, query_params: Option>) -> Result, UsersListPublicKeysForUserError> { + pub async fn list_public_keys_for_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/keys", super::GITHUB_BASE_API_URL, username); @@ -4737,12 +5050,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4754,7 +5067,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(UsersListPublicKeysForUserError::Generic { code }), + code => Err(UsersListPublicKeysForUserError::Generic { code }.into()), } } } @@ -4769,7 +5082,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_public_keys_for_user(&self, username: &str, query_params: Option>) -> Result, UsersListPublicKeysForUserError> { + pub fn list_public_keys_for_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/keys", super::GITHUB_BASE_API_URL, username); @@ -4786,7 +5099,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4798,7 +5111,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(UsersListPublicKeysForUserError::Generic { code }), + code => Err(UsersListPublicKeysForUserError::Generic { code }.into()), } } } @@ -4814,7 +5127,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_public_ssh_keys_for_authenticated_user](https://docs.github.com/rest/users/keys#list-public-ssh-keys-for-the-authenticated-user) /// /// --- - pub async fn list_public_ssh_keys_for_authenticated_user_async(&self, query_params: Option>) -> Result, UsersListPublicSshKeysForAuthenticatedUserError> { + pub async fn list_public_ssh_keys_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/keys", super::GITHUB_BASE_API_URL); @@ -4825,12 +5138,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4842,11 +5155,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status304), - 404 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersListPublicSshKeysForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersListPublicSshKeysForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4863,7 +5176,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_public_ssh_keys_for_authenticated_user(&self, query_params: Option>) -> Result, UsersListPublicSshKeysForAuthenticatedUserError> { + pub fn list_public_ssh_keys_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/keys", super::GITHUB_BASE_API_URL); @@ -4880,7 +5193,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4892,11 +5205,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status304), - 404 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersListPublicSshKeysForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersListPublicSshKeysForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersListPublicSshKeysForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4910,7 +5223,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_social_accounts_for_authenticated_user](https://docs.github.com/rest/users/social-accounts#list-social-accounts-for-the-authenticated-user) /// /// --- - pub async fn list_social_accounts_for_authenticated_user_async(&self, query_params: Option>) -> Result, UsersListSocialAccountsForAuthenticatedUserError> { + pub async fn list_social_accounts_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL); @@ -4921,12 +5234,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4938,11 +5251,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status304), - 404 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersListSocialAccountsForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersListSocialAccountsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -4957,7 +5270,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_social_accounts_for_authenticated_user(&self, query_params: Option>) -> Result, UsersListSocialAccountsForAuthenticatedUserError> { + pub fn list_social_accounts_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/social_accounts", super::GITHUB_BASE_API_URL); @@ -4974,7 +5287,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -4986,11 +5299,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status304), - 404 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersListSocialAccountsForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersListSocialAccountsForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersListSocialAccountsForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5004,7 +5317,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_social_accounts_for_user](https://docs.github.com/rest/users/social-accounts#list-social-accounts-for-a-user) /// /// --- - pub async fn list_social_accounts_for_user_async(&self, username: &str, query_params: Option>) -> Result, UsersListSocialAccountsForUserError> { + pub async fn list_social_accounts_for_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/social_accounts", super::GITHUB_BASE_API_URL, username); @@ -5015,12 +5328,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5032,7 +5345,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(UsersListSocialAccountsForUserError::Generic { code }), + code => Err(UsersListSocialAccountsForUserError::Generic { code }.into()), } } } @@ -5047,7 +5360,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_social_accounts_for_user(&self, username: &str, query_params: Option>) -> Result, UsersListSocialAccountsForUserError> { + pub fn list_social_accounts_for_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/social_accounts", super::GITHUB_BASE_API_URL, username); @@ -5064,7 +5377,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5076,7 +5389,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(UsersListSocialAccountsForUserError::Generic { code }), + code => Err(UsersListSocialAccountsForUserError::Generic { code }.into()), } } } @@ -5092,7 +5405,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_ssh_signing_keys_for_authenticated_user](https://docs.github.com/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-the-authenticated-user) /// /// --- - pub async fn list_ssh_signing_keys_for_authenticated_user_async(&self, query_params: Option>) -> Result, UsersListSshSigningKeysForAuthenticatedUserError> { + pub async fn list_ssh_signing_keys_for_authenticated_user_async(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/ssh_signing_keys", super::GITHUB_BASE_API_URL); @@ -5103,12 +5416,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5120,11 +5433,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status304), - 404 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - code => Err(UsersListSshSigningKeysForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersListSshSigningKeysForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5141,7 +5454,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_ssh_signing_keys_for_authenticated_user(&self, query_params: Option>) -> Result, UsersListSshSigningKeysForAuthenticatedUserError> { + pub fn list_ssh_signing_keys_for_authenticated_user(&self, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/user/ssh_signing_keys", super::GITHUB_BASE_API_URL); @@ -5158,7 +5471,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5170,11 +5483,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status304), - 404 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status401(github_response.to_json()?)), - code => Err(UsersListSshSigningKeysForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersListSshSigningKeysForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + code => Err(UsersListSshSigningKeysForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5188,7 +5501,7 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for list_ssh_signing_keys_for_user](https://docs.github.com/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-a-user) /// /// --- - pub async fn list_ssh_signing_keys_for_user_async(&self, username: &str, query_params: Option>) -> Result, UsersListSshSigningKeysForUserError> { + pub async fn list_ssh_signing_keys_for_user_async(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/ssh_signing_keys", super::GITHUB_BASE_API_URL, username); @@ -5199,12 +5512,12 @@ impl<'api, C: Client> Users<'api, C> { let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "GET", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5216,7 +5529,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - code => Err(UsersListSshSigningKeysForUserError::Generic { code }), + code => Err(UsersListSshSigningKeysForUserError::Generic { code }.into()), } } } @@ -5231,7 +5544,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn list_ssh_signing_keys_for_user(&self, username: &str, query_params: Option>) -> Result, UsersListSshSigningKeysForUserError> { + pub fn list_ssh_signing_keys_for_user(&self, username: &str, query_params: Option>) -> Result, AdapterError> { let mut request_uri = format!("{}/users/{}/ssh_signing_keys", super::GITHUB_BASE_API_URL, username); @@ -5248,7 +5561,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5260,7 +5573,7 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - code => Err(UsersListSshSigningKeysForUserError::Generic { code }), + code => Err(UsersListSshSigningKeysForUserError::Generic { code }.into()), } } } @@ -5274,19 +5587,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for set_primary_email_visibility_for_authenticated_user](https://docs.github.com/rest/users/emails#set-primary-email-visibility-for-the-authenticated-user) /// /// --- - pub async fn set_primary_email_visibility_for_authenticated_user_async(&self, body: PatchUsersSetPrimaryEmailVisibilityForAuthenticatedUser) -> Result, UsersSetPrimaryEmailVisibilityForAuthenticatedUserError> { + pub async fn set_primary_email_visibility_for_authenticated_user_async(&self, body: PatchUsersSetPrimaryEmailVisibilityForAuthenticatedUser) -> Result, AdapterError> { let request_uri = format!("{}/user/email/visibility", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PatchUsersSetPrimaryEmailVisibilityForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5298,12 +5611,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status304), - 404 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status401(github_response.to_json_async().await?)), - 422 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status422(github_response.to_json_async().await?)), - code => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status401(github_response.to_json_async().await?).into()), + 422 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status422(github_response.to_json_async().await?).into()), + code => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5318,19 +5631,19 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn set_primary_email_visibility_for_authenticated_user(&self, body: PatchUsersSetPrimaryEmailVisibilityForAuthenticatedUser) -> Result, UsersSetPrimaryEmailVisibilityForAuthenticatedUserError> { + pub fn set_primary_email_visibility_for_authenticated_user(&self, body: PatchUsersSetPrimaryEmailVisibilityForAuthenticatedUser) -> Result, AdapterError> { let request_uri = format!("{}/user/email/visibility", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PatchUsersSetPrimaryEmailVisibilityForAuthenticatedUser::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5342,12 +5655,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status304), - 404 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status404(github_response.to_json()?)), - 403 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status403(github_response.to_json()?)), - 401 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status401(github_response.to_json()?)), - 422 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status422(github_response.to_json()?)), - code => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Generic { code }), + 304 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status304.into()), + 404 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status401(github_response.to_json()?).into()), + 422 => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Status422(github_response.to_json()?).into()), + code => Err(UsersSetPrimaryEmailVisibilityForAuthenticatedUserError::Generic { code }.into()), } } } @@ -5361,19 +5674,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for unblock](https://docs.github.com/rest/users/blocking#unblock-a-user) /// /// --- - pub async fn unblock_async(&self, username: &str) -> Result<(), UsersUnblockError> { + pub async fn unblock_async(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/blocks/{}", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5385,11 +5698,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersUnblockError::Status304), - 403 => Err(UsersUnblockError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersUnblockError::Status401(github_response.to_json_async().await?)), - 404 => Err(UsersUnblockError::Status404(github_response.to_json_async().await?)), - code => Err(UsersUnblockError::Generic { code }), + 304 => Err(UsersUnblockError::Status304.into()), + 403 => Err(UsersUnblockError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersUnblockError::Status401(github_response.to_json_async().await?).into()), + 404 => Err(UsersUnblockError::Status404(github_response.to_json_async().await?).into()), + code => Err(UsersUnblockError::Generic { code }.into()), } } } @@ -5404,7 +5717,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn unblock(&self, username: &str) -> Result<(), UsersUnblockError> { + pub fn unblock(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/blocks/{}", super::GITHUB_BASE_API_URL, username); @@ -5416,7 +5729,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5428,11 +5741,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersUnblockError::Status304), - 403 => Err(UsersUnblockError::Status403(github_response.to_json()?)), - 401 => Err(UsersUnblockError::Status401(github_response.to_json()?)), - 404 => Err(UsersUnblockError::Status404(github_response.to_json()?)), - code => Err(UsersUnblockError::Generic { code }), + 304 => Err(UsersUnblockError::Status304.into()), + 403 => Err(UsersUnblockError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersUnblockError::Status401(github_response.to_json()?).into()), + 404 => Err(UsersUnblockError::Status404(github_response.to_json()?).into()), + code => Err(UsersUnblockError::Generic { code }.into()), } } } @@ -5446,19 +5759,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for unfollow](https://docs.github.com/rest/users/followers#unfollow-a-user) /// /// --- - pub async fn unfollow_async(&self, username: &str) -> Result<(), UsersUnfollowError> { + pub async fn unfollow_async(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/following/{}", super::GITHUB_BASE_API_URL, username); let req = GitHubRequest { uri: request_uri, - body: None, + body: None::, method: "DELETE", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5470,11 +5783,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersUnfollowError::Status304), - 404 => Err(UsersUnfollowError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersUnfollowError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersUnfollowError::Status401(github_response.to_json_async().await?)), - code => Err(UsersUnfollowError::Generic { code }), + 304 => Err(UsersUnfollowError::Status304.into()), + 404 => Err(UsersUnfollowError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersUnfollowError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersUnfollowError::Status401(github_response.to_json_async().await?).into()), + code => Err(UsersUnfollowError::Generic { code }.into()), } } } @@ -5489,7 +5802,7 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn unfollow(&self, username: &str) -> Result<(), UsersUnfollowError> { + pub fn unfollow(&self, username: &str) -> Result<(), AdapterError> { let request_uri = format!("{}/user/following/{}", super::GITHUB_BASE_API_URL, username); @@ -5501,7 +5814,7 @@ impl<'api, C: Client> Users<'api, C> { headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5513,11 +5826,11 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersUnfollowError::Status304), - 404 => Err(UsersUnfollowError::Status404(github_response.to_json()?)), - 403 => Err(UsersUnfollowError::Status403(github_response.to_json()?)), - 401 => Err(UsersUnfollowError::Status401(github_response.to_json()?)), - code => Err(UsersUnfollowError::Generic { code }), + 304 => Err(UsersUnfollowError::Status304.into()), + 404 => Err(UsersUnfollowError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersUnfollowError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersUnfollowError::Status401(github_response.to_json()?).into()), + code => Err(UsersUnfollowError::Generic { code }.into()), } } } @@ -5531,19 +5844,19 @@ impl<'api, C: Client> Users<'api, C> { /// [GitHub API docs for update_authenticated](https://docs.github.com/rest/users/users#update-the-authenticated-user) /// /// --- - pub async fn update_authenticated_async(&self, body: PatchUsersUpdateAuthenticated) -> Result { + pub async fn update_authenticated_async(&self, body: PatchUsersUpdateAuthenticated) -> Result { let request_uri = format!("{}/user", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PatchUsersUpdateAuthenticated::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5555,12 +5868,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json_async().await?) } else { match github_response.status_code() { - 304 => Err(UsersUpdateAuthenticatedError::Status304), - 404 => Err(UsersUpdateAuthenticatedError::Status404(github_response.to_json_async().await?)), - 403 => Err(UsersUpdateAuthenticatedError::Status403(github_response.to_json_async().await?)), - 401 => Err(UsersUpdateAuthenticatedError::Status401(github_response.to_json_async().await?)), - 422 => Err(UsersUpdateAuthenticatedError::Status422(github_response.to_json_async().await?)), - code => Err(UsersUpdateAuthenticatedError::Generic { code }), + 304 => Err(UsersUpdateAuthenticatedError::Status304.into()), + 404 => Err(UsersUpdateAuthenticatedError::Status404(github_response.to_json_async().await?).into()), + 403 => Err(UsersUpdateAuthenticatedError::Status403(github_response.to_json_async().await?).into()), + 401 => Err(UsersUpdateAuthenticatedError::Status401(github_response.to_json_async().await?).into()), + 422 => Err(UsersUpdateAuthenticatedError::Status422(github_response.to_json_async().await?).into()), + code => Err(UsersUpdateAuthenticatedError::Generic { code }.into()), } } } @@ -5575,19 +5888,19 @@ impl<'api, C: Client> Users<'api, C> { /// /// --- #[cfg(not(target_arch = "wasm32"))] - pub fn update_authenticated(&self, body: PatchUsersUpdateAuthenticated) -> Result { + pub fn update_authenticated(&self, body: PatchUsersUpdateAuthenticated) -> Result { let request_uri = format!("{}/user", super::GITHUB_BASE_API_URL); let req = GitHubRequest { uri: request_uri, - body: Some(PatchUsersUpdateAuthenticated::from_json(body)?), + body: Some(C::from_json::(body)?), method: "PATCH", headers: vec![] }; - let request = GitHubRequestBuilder::build(req, self.client)?; + let request = self.client.build(req)?; // -- @@ -5599,12 +5912,12 @@ impl<'api, C: Client> Users<'api, C> { Ok(github_response.to_json()?) } else { match github_response.status_code() { - 304 => Err(UsersUpdateAuthenticatedError::Status304), - 404 => Err(UsersUpdateAuthenticatedError::Status404(github_response.to_json()?)), - 403 => Err(UsersUpdateAuthenticatedError::Status403(github_response.to_json()?)), - 401 => Err(UsersUpdateAuthenticatedError::Status401(github_response.to_json()?)), - 422 => Err(UsersUpdateAuthenticatedError::Status422(github_response.to_json()?)), - code => Err(UsersUpdateAuthenticatedError::Generic { code }), + 304 => Err(UsersUpdateAuthenticatedError::Status304.into()), + 404 => Err(UsersUpdateAuthenticatedError::Status404(github_response.to_json()?).into()), + 403 => Err(UsersUpdateAuthenticatedError::Status403(github_response.to_json()?).into()), + 401 => Err(UsersUpdateAuthenticatedError::Status401(github_response.to_json()?).into()), + 422 => Err(UsersUpdateAuthenticatedError::Status422(github_response.to_json()?).into()), + code => Err(UsersUpdateAuthenticatedError::Generic { code }.into()), } } } diff --git a/src/lib.rs b/src/lib.rs index 3721fc3..72fb233 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,12 +6,12 @@ //! //! This client API is generated from the [upstream OpenAPI //! specification](https://github.com/github/rest-api-description/). The library currently supports -//! webassembly and both tokio and non-tokio based asynchronous requests and minimal dependency blocking +//! webassembly and both tokio and non-tokio based asynchronous requests and minimal dependency blocking //! synchronous requests with a choice of different clients, enabled through cargo features: //! //! - `isahc` feature (*sync* and non-tokio based *async*): [Isahc HTTP client](https://github.com/sagebind/isahc) //! - `reqwest` feature (*async*) [Reqwest client](https://github.com/seanmonstar/reqwest) -//! - `ureq` feature (*sync*) [Ureq client](https://github.com/algesten/ureq) +//! - `ureq` feature (*sync*) [Ureq client](https://github.com/algesten/ureq) //! //! # Install //! @@ -19,19 +19,19 @@ //! //! ```nocompile //! [dependencies] -//! roctogen = "*" +//! roctogen = "0.12" //! ``` //! //! # API //! ## Documentation //! //! [API docs](https://docs.rs/roctogen/latest). -//! +//! //! [Endpoints](https://docs.rs/roctogen/latest/roctogen/endpoints/index.html). //! //! Supported endpoints: //! --- -//! +//! //! - [Meta](https://docs.rs/roctogen/latest/roctogen/endpoints/meta/struct.Meta.html) //! - [Issues](https://docs.rs/roctogen/latest/roctogen/endpoints/issues/struct.Issues.html) //! - [Licenses](https://docs.rs/roctogen/latest/roctogen/endpoints/licenses/struct.Licenses.html) @@ -75,12 +75,13 @@ //! //! ```no_run //! use roctogen::api::{self, repos}; -//! use roctogen::{adapters::client, auth::Auth}; +//! use roctogen::adapters::client; +//! use roctogen::auth::Auth; //! //! let auth = Auth::None; -//! let client = client(&auth).expect("Cannot create client"); +//! let client = client(&auth).expect("Cannot create new client"); //! let per_page = api::PerPage::new(10); -//! +//! //! let mut params: repos::ReposListCommitsParams = per_page.as_ref().into(); //! params = params.author("fussybeaver").page(2); //! @@ -114,7 +115,15 @@ //! ## Client adapters //! //! Building on non-`wasm` targets generally requires adopting a feature for the desired -//! client adapter. +//! client adapter. +//! +//! ### Isahc +//! +//! Compiling for the [`isahc`](https://github.com/sagebind/isahc) client required the `isahc` feature: +//! +//! ```nocompile +//! $ cargo build --features isahc +//! ``` //! //! ### Reqwest //! @@ -135,7 +144,7 @@ //! # GitHub preview features //! //! GitHub supports a phased rollout of non-stable endpoints behind header flags. These are -//! supported in this library through cargo feature flags. +//! supported in this library through cargo feature flags. //! //! ```nocompile //! $ cargo build --features squirrel-girl @@ -152,14 +161,14 @@ //! $ mvn -D org.slf4j.simpleLogger.defaultLogLevel=info clean compiler:compile generate-resources //! ``` //! -//! # Tests +//! # Tests //! //! Beware, tests that are not run with the `mock` feature are currently still doing real HTTP requests to the GitHub API. //! //! Run the wasm tests: //! //! ```nocompile -//! $ wasm-pack test --firefox --headless +//! $ wasm-pack test --firefox --headless //! ``` //! //! Run the sync tests: @@ -184,7 +193,10 @@ //! $ docker run -d --name wiremock -p 8080:8080 -v $PWD/tests/stubs:/home/wiremock -u (id -u):(id -g) rodolpheche/wiremock --verbose --proxy-all="https://api.github.com" --record-mappings //! ``` //! -#![allow(missing_docs, unused_imports)] +#![allow( + missing_docs, + unused_imports, +)] #[macro_use] extern crate serde_derive; @@ -196,10 +208,13 @@ pub mod endpoints; pub mod models; pub mod auth { - + #[derive(Clone, Debug)] pub enum Auth { - Basic { user: String, pass: String }, + Basic { + user: String, + pass: String, + }, Token(String), Bearer(String), None, diff --git a/src/models.rs b/src/models.rs index deade51..bedaacd 100644 --- a/src/models.rs +++ b/src/models.rs @@ -1299,39 +1299,39 @@ impl std::str::FromStr for AllowedActions { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum AnyOfbody170Source { - AnyOfbody170SourceVariant0(String), - AnyOfbody170SourceVariant1(HashMap), +pub enum AnyOfbody174Source { + AnyOfbody174SourceVariant0(String), + AnyOfbody174SourceVariant1(HashMap), } -impl From for AnyOfbody170Source { +impl From for AnyOfbody174Source { fn from(value: String) -> Self { - AnyOfbody170Source::AnyOfbody170SourceVariant0(value) + AnyOfbody174Source::AnyOfbody174SourceVariant0(value) } } -impl From> for AnyOfbody170Source { +impl From> for AnyOfbody174Source { fn from(value: HashMap) -> Self { - AnyOfbody170Source::AnyOfbody170SourceVariant1(value) + AnyOfbody174Source::AnyOfbody174SourceVariant1(value) } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum AnyOfbody217SelectedRepositoryIdsItems { - AnyOfbody217SelectedRepositoryIdsItemsVariant0(i32), - AnyOfbody217SelectedRepositoryIdsItemsVariant1(String), +pub enum AnyOfbody221SelectedRepositoryIdsItems { + AnyOfbody221SelectedRepositoryIdsItemsVariant0(i32), + AnyOfbody221SelectedRepositoryIdsItemsVariant1(String), } -impl From for AnyOfbody217SelectedRepositoryIdsItems { +impl From for AnyOfbody221SelectedRepositoryIdsItems { fn from(value: i32) -> Self { - AnyOfbody217SelectedRepositoryIdsItems::AnyOfbody217SelectedRepositoryIdsItemsVariant0(value) + AnyOfbody221SelectedRepositoryIdsItems::AnyOfbody221SelectedRepositoryIdsItemsVariant0(value) } } -impl From for AnyOfbody217SelectedRepositoryIdsItems { +impl From for AnyOfbody221SelectedRepositoryIdsItems { fn from(value: String) -> Self { - AnyOfbody217SelectedRepositoryIdsItems::AnyOfbody217SelectedRepositoryIdsItemsVariant1(value) + AnyOfbody221SelectedRepositoryIdsItems::AnyOfbody221SelectedRepositoryIdsItemsVariant1(value) } } @@ -2582,6 +2582,77 @@ pub struct PatchGistsUpdateComment { pub body: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PatchReposUpdatePullRequestReviewProtection { + #[serde(skip_serializing_if="Option::is_none")] + pub dismissal_restrictions: Option, + /// Set to `true` if you want to automatically dismiss approving reviews when someone pushes a new commit. + #[serde(skip_serializing_if="Option::is_none")] + pub dismiss_stale_reviews: Option, + /// Blocks merging pull requests until [code owners](https://docs.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 or 0 to not require reviewers. + #[serde(skip_serializing_if="Option::is_none")] + pub required_approving_review_count: Option, + /// Whether the most recent push must be approved by someone other than the person who pushed it. Default: `false` + #[serde(skip_serializing_if="Option::is_none")] + pub require_last_push_approval: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub bypass_pull_request_allowances: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PatchReposUpdateStatusCheckProtection { + /// Require branches to be up to date before merging. + #[serde(skip_serializing_if="Option::is_none")] + pub strict: Option, + /// **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)] +#[serde(untagged)] +pub enum PutReposSetStatusCheckContexts { + PutReposSetStatusCheckContextsVariant0(HashMap>), + PutReposSetStatusCheckContextsVariant1(Vec), +} + +impl From>> for PutReposSetStatusCheckContexts { + fn from(value: HashMap>) -> Self { + PutReposSetStatusCheckContexts::PutReposSetStatusCheckContextsVariant0(value) + } +} + +impl From> for PutReposSetStatusCheckContexts { + fn from(value: Vec) -> Self { + PutReposSetStatusCheckContexts::PutReposSetStatusCheckContextsVariant1(value) + } +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PostReposAddStatusCheckContexts { + PostReposAddStatusCheckContextsVariant0(HashMap>), + PostReposAddStatusCheckContextsVariant1(Vec), +} + +impl From>> for PostReposAddStatusCheckContexts { + fn from(value: HashMap>) -> Self { + PostReposAddStatusCheckContexts::PostReposAddStatusCheckContextsVariant0(value) + } +} + +impl From> for PostReposAddStatusCheckContexts { + fn from(value: Vec) -> Self { + PostReposAddStatusCheckContexts::PostReposAddStatusCheckContextsVariant1(value) + } +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteReposRemoveStatusCheckContexts { @@ -2660,6 +2731,19 @@ impl From> for PostReposAddTeamAccessRestrictions { } } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostMarkdownRender { + /// The Markdown text to render in HTML. + #[serde(skip_serializing_if="Option::is_none")] + pub text: Option, + /// The rendering mode. + #[serde(skip_serializing_if="Option::is_none")] + pub mode: Option, + /// 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, +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum DeleteReposRemoveTeamAccessRestrictions { @@ -2700,19 +2784,6 @@ pub struct DeleteReposRemoveUserAccessRestrictions { pub users: Option>, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostMarkdownRender { - /// The Markdown text to render in HTML. - #[serde(skip_serializing_if="Option::is_none")] - pub text: Option, - /// The rendering mode. - #[serde(skip_serializing_if="Option::is_none")] - pub mode: Option, - /// 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, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostReposRenameBranch { /// The new name of the branch. @@ -2768,6 +2839,16 @@ pub struct PatchCodeScanningUpdateAlert { pub dismissed_comment: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutActivityMarkNotificationsAsRead { + /// 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. + #[serde(skip_serializing_if="Option::is_none")] + pub last_read_at: Option>, + /// Whether the notification has been read. + #[serde(skip_serializing_if="Option::is_none")] + pub read: Option, +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum PostCodeScanningCreateVariantAnalysis { @@ -2859,16 +2940,6 @@ pub struct PutCodespacesCreateOrUpdateRepoSecret { pub key_id: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutActivityMarkNotificationsAsRead { - /// 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. - #[serde(skip_serializing_if="Option::is_none")] - pub last_read_at: Option>, - /// Whether the notification has been read. - #[serde(skip_serializing_if="Option::is_none")] - pub read: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutReposAddCollaborator { /// The permission to grant the collaborator. **Only valid on organization-owned repositories.** We accept the following permissions to be set: `pull`, `triage`, `push`, `maintain`, `admin` and you can also specify a custom repository role name, if the owning organization has defined any. @@ -2943,6 +3014,13 @@ pub struct DeleteReposDeleteFile { pub author: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutActivitySetThreadSubscription { + /// Whether to block all notifications from a thread. + #[serde(skip_serializing_if="Option::is_none")] + pub ignored: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchDependabotUpdateAlert { /// The state of the Dependabot alert. A `dismissed_reason` must be provided when setting the state to `dismissed`. @@ -2982,7 +3060,7 @@ pub struct PostReposCreateDeployment { #[serde(skip_serializing_if="Option::is_none")] pub required_contexts: Option>, #[serde(skip_serializing_if="Option::is_none")] - pub payload: Option, + pub payload: Option, /// Name for the target deployment environment (e.g., `production`, `staging`, `qa`). #[serde(skip_serializing_if="Option::is_none")] pub environment: Option, @@ -3022,13 +3100,6 @@ pub struct PostReposCreateDeploymentStatus { pub auto_inactive: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutActivitySetThreadSubscription { - /// Whether to block all notifications from a thread. - #[serde(skip_serializing_if="Option::is_none")] - pub ignored: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostReposCreateDispatchEvent { /// A custom webhook event name. Must be 100 characters or fewer. @@ -3089,60 +3160,6 @@ pub struct PatchActionsUpdateEnvironmentVariable { pub value: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostReposCreateFork { - /// Optional parameter to specify the organization name if forking into an organization. - #[serde(skip_serializing_if="Option::is_none")] - pub organization: Option, - /// When forking from an existing repository, a new name for the fork. - #[serde(skip_serializing_if="Option::is_none")] - pub name: Option, - /// When forking from an existing repository, fork with only the default branch. - #[serde(skip_serializing_if="Option::is_none")] - pub default_branch_only: Option, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostGitCreateBlob { - /// The new blob's content. - #[serde(skip_serializing_if="Option::is_none")] - pub content: Option, - /// The encoding used for `content`. Currently, `\"utf-8\"` and `\"base64\"` are supported. - #[serde(skip_serializing_if="Option::is_none")] - pub encoding: Option, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostGitCreateCommit { - /// The commit message - #[serde(skip_serializing_if="Option::is_none")] - pub message: Option, - /// The SHA of the tree object this commit points to - #[serde(skip_serializing_if="Option::is_none")] - pub tree: Option, - /// The full SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided; for a merge commit, an array of more than one should be provided. - #[serde(skip_serializing_if="Option::is_none")] - pub parents: Option>, - #[serde(skip_serializing_if="Option::is_none")] - pub author: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub committer: Option, - /// The [PGP signature](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) of the commit. GitHub adds the signature to the `gpgsig` header of the created commit. For a commit signature to be verifiable by Git or GitHub, it must be an ASCII-armored detached PGP signature over the string commit as it would be written to the object database. To pass a `signature` parameter, you need to first manually create a valid PGP signature, which can be complicated. You may find it easier to [use the command line](https://git-scm.com/book/id/v2/Git-Tools-Signing-Your-Work) to create signed commits. - #[serde(skip_serializing_if="Option::is_none")] - pub signature: 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. - #[serde(rename = "ref")] - #[serde(skip_serializing_if="Option::is_none")] - pub git_ref: Option, - /// The SHA1 value for this reference. - #[serde(skip_serializing_if="Option::is_none")] - pub sha: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchOrgsUpdate { /// Billing email address. This address is not publicized. @@ -3233,6 +3250,60 @@ pub struct PatchOrgsUpdate { pub secret_scanning_push_protection_custom_link: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostReposCreateFork { + /// Optional parameter to specify the organization name if forking into an organization. + #[serde(skip_serializing_if="Option::is_none")] + pub organization: Option, + /// When forking from an existing repository, a new name for the fork. + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + /// When forking from an existing repository, fork with only the default branch. + #[serde(skip_serializing_if="Option::is_none")] + pub default_branch_only: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostGitCreateBlob { + /// The new blob's content. + #[serde(skip_serializing_if="Option::is_none")] + pub content: Option, + /// The encoding used for `content`. Currently, `\"utf-8\"` and `\"base64\"` are supported. + #[serde(skip_serializing_if="Option::is_none")] + pub encoding: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostGitCreateCommit { + /// The commit message + #[serde(skip_serializing_if="Option::is_none")] + pub message: Option, + /// The SHA of the tree object this commit points to + #[serde(skip_serializing_if="Option::is_none")] + pub tree: Option, + /// The full SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided; for a merge commit, an array of more than one should be provided. + #[serde(skip_serializing_if="Option::is_none")] + pub parents: Option>, + #[serde(skip_serializing_if="Option::is_none")] + pub author: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub committer: Option, + /// The [PGP signature](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) of the commit. GitHub adds the signature to the `gpgsig` header of the created commit. For a commit signature to be verifiable by Git or GitHub, it must be an ASCII-armored detached PGP signature over the string commit as it would be written to the object database. To pass a `signature` parameter, you need to first manually create a valid PGP signature, which can be complicated. You may find it easier to [use the command line](https://git-scm.com/book/id/v2/Git-Tools-Signing-Your-Work) to create signed commits. + #[serde(skip_serializing_if="Option::is_none")] + pub signature: 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. + #[serde(rename = "ref")] + #[serde(skip_serializing_if="Option::is_none")] + pub git_ref: Option, + /// The SHA1 value for this reference. + #[serde(skip_serializing_if="Option::is_none")] + pub sha: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchGitUpdateRef { /// The SHA1 value to set this reference to @@ -3317,6 +3388,14 @@ pub struct PatchReposUpdateWebhookConfigForRepo { pub insecure_ssl: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutActionsSetGithubActionsPermissionsOrganization { + #[serde(skip_serializing_if="Option::is_none")] + pub enabled_repositories: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub allowed_actions: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutMigrationsStartImport { /// The URL of the originating repository. @@ -3369,14 +3448,6 @@ pub struct PatchMigrationsSetLfsPreference { pub use_lfs: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutActionsSetGithubActionsPermissionsOrganization { - #[serde(skip_serializing_if="Option::is_none")] - pub enabled_repositories: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub allowed_actions: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchReposUpdateInvitation { /// The permissions that the associated user will have on the repository. Valid values are `read`, `write`, `maintain`, `triage`, and `admin`. @@ -3388,7 +3459,7 @@ pub struct PatchReposUpdateInvitation { pub struct PostIssuesCreate { /// The title of the issue. #[serde(skip_serializing_if="Option::is_none")] - pub title: Option, + pub title: Option, /// The contents of the issue. #[serde(skip_serializing_if="Option::is_none")] pub body: Option, @@ -3396,10 +3467,10 @@ pub struct PostIssuesCreate { #[serde(skip_serializing_if="Option::is_none")] pub assignee: Option, #[serde(skip_serializing_if="Option::is_none")] - pub milestone: Option, + pub milestone: Option, /// Labels to associate with this issue. _NOTE: Only users with push access can set labels for new issues. Labels are silently dropped otherwise._ #[serde(skip_serializing_if="Option::is_none")] - pub labels: Option>, + pub labels: Option>, /// Logins for Users to assign to this issue. _NOTE: Only users with push access can set assignees for new issues. Assignees are silently dropped otherwise._ #[serde(skip_serializing_if="Option::is_none")] pub assignees: Option>, @@ -3423,7 +3494,7 @@ pub struct PostReactionsCreateForIssueComment { pub struct PatchIssuesUpdate { /// The title of the issue. #[serde(skip_serializing_if="Option::is_none")] - pub title: Option, + pub title: Option, /// The contents of the issue. #[serde(skip_serializing_if="Option::is_none")] pub body: Option, @@ -3437,10 +3508,10 @@ pub struct PatchIssuesUpdate { #[serde(skip_serializing_if="Option::is_none")] pub state_reason: Option, #[serde(skip_serializing_if="Option::is_none")] - pub milestone: Option, + pub milestone: Option, /// Labels to associate with this issue. Pass one or more labels to _replace_ the set of labels on this issue. Send an empty array (`[]`) to clear all labels from the issue. Only users with push access can set labels for issues. Without push access to the repository, label changes are silently dropped. #[serde(skip_serializing_if="Option::is_none")] - pub labels: Option>, + pub labels: Option>, /// Usernames to assign to this issue. Pass one or more user logins to _replace_ the set of assignees on this issue. Send an empty array (`[]`) to clear all assignees from the issue. Only users with push access can set assignees for new issues. Without push access to the repository, assignee changes are silently dropped. #[serde(skip_serializing_if="Option::is_none")] pub assignees: Option>, @@ -3453,6 +3524,13 @@ pub struct PostIssuesAddAssignees { pub assignees: Option>, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutActionsSetSelectedRepositoriesEnabledGithubActionsOrganization { + /// List of repository IDs to enable for GitHub Actions. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_repository_ids: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct DeleteIssuesRemoveAssignees { /// Usernames of assignees to remove from an issue. _NOTE: Only users with push access can remove assignees from an issue. Assignees are silently ignored otherwise._ @@ -3533,13 +3611,6 @@ impl From for PostIssuesAddLabels { } } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutActionsSetSelectedRepositoriesEnabledGithubActionsOrganization { - /// List of repository IDs to enable for GitHub Actions. - #[serde(skip_serializing_if="Option::is_none")] - pub selected_repository_ids: Option>, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutIssuesLock { /// The reason for locking the issue or pull request conversation. Lock will fail if you don't use one of these reasons: * `off-topic` * `too heated` * `resolved` * `spam` @@ -3600,6 +3671,31 @@ pub struct PostReposMergeUpstream { pub branch: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostActionsCreateSelfHostedRunnerGroupForOrg { + /// Name of the runner group. + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + /// Visibility of a runner group. You can select all repositories, select individual repositories, or limit access to private repositories. + #[serde(skip_serializing_if="Option::is_none")] + pub visibility: Option, + /// List of repository IDs that can access the runner group. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_repository_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, + /// If `true`, the runner group will be restricted to running only the workflows specified in the `selected_workflows` array. + #[serde(skip_serializing_if="Option::is_none")] + pub restricted_to_workflows: Option, + /// List of workflows the runner group should be allowed to run. This setting will be ignored unless `restricted_to_workflows` is set to `true`. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_workflows: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostReposMerge { /// The name of the base branch that the head will be merged into. @@ -3652,22 +3748,6 @@ pub struct PutActivityMarkRepoNotificationsAsRead { pub last_read_at: Option>, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostActionsGenerateRunnerJitconfigForOrg { - /// The name of the new runner. - #[serde(skip_serializing_if="Option::is_none")] - pub name: Option, - /// The ID of the runner group to register the runner to. - #[serde(skip_serializing_if="Option::is_none")] - pub runner_group_id: Option, - /// The names of the custom labels to add to the runner. **Minimum items**: 1. **Maximum items**: 100. - #[serde(skip_serializing_if="Option::is_none")] - pub labels: Option>, - /// The working directory to be used for job execution, relative to the runner install directory. - #[serde(skip_serializing_if="Option::is_none")] - pub work_folder: Option, -} - #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum PutReposUpdateInformationAboutPagesSite { @@ -3774,6 +3854,25 @@ pub struct PostPullsCreate { pub issue: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PatchActionsUpdateSelfHostedRunnerGroupForOrg { + /// Name of the runner group. + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + /// Visibility of a runner group. You can select all repositories, select individual repositories, or all private repositories. + #[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, + /// If `true`, the runner group will be restricted to running only the workflows specified in the `selected_workflows` array. + #[serde(skip_serializing_if="Option::is_none")] + pub restricted_to_workflows: Option, + /// List of workflows the runner group should be allowed to run. This setting will be ignored unless `restricted_to_workflows` is set to `true`. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_workflows: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchPullsUpdateReviewComment { /// The text of the reply to the review comment. @@ -3841,13 +3940,6 @@ pub struct PostCodespacesCreateWithPrForAuthenticatedUser { pub retention_period_minutes: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -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 labels: Option>, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostPullsCreateReviewComment { /// The text of the review comment. @@ -3951,6 +4043,13 @@ pub struct PostPullsCreateReview { pub comments: Option>, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutActionsSetRepoAccessToSelfHostedRunnerGroupInOrg { + /// List of repository IDs that can access the runner group. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_repository_ids: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutPullsUpdateReview { /// The body text of the pull request review. @@ -3984,13 +4083,6 @@ pub struct PutPullsUpdateBranch { pub expected_head_sha: 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)] pub struct PostReposCreateRelease { /// The name of the tag. @@ -4105,6 +4197,20 @@ pub struct PostReposCreateRepoRuleset { pub rules: 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, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutActionsSetSelfHostedRunnersInGroupForOrg { + /// 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 PutReposUpdateRepoRuleset { /// The name of the ruleset. @@ -4144,42 +4250,19 @@ pub struct PostSecretScanningCreatePushProtectionBypass { } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostReposCreateCommitStatus { - /// The state of the status. - #[serde(skip_serializing_if="Option::is_none")] - pub state: Option, - /// The target URL to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the source of the status. For example, if your continuous integration system is posting build status, you would want to provide the deep link for the build output for this specific SHA: `http://ci.example.com/user/repo/build/sha` - #[serde(skip_serializing_if="Option::is_none")] - pub target_url: Option, - /// A short description of the status. - #[serde(skip_serializing_if="Option::is_none")] - pub description: Option, - /// A string label to differentiate this status from the status of other systems. This field is case-insensitive. - #[serde(skip_serializing_if="Option::is_none")] - pub context: 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, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutActionsCreateOrUpdateOrgSecret { - /// 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 organization public key](https://docs.github.com/rest/actions/secrets#get-an-organization-public-key) endpoint. +pub struct PostReposCreateCommitStatus { + /// The state of the status. #[serde(skip_serializing_if="Option::is_none")] - pub encrypted_value: Option, - /// ID of the key you used to encrypt the secret. + pub state: Option, + /// The target URL to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the source of the status. For example, if your continuous integration system is posting build status, you would want to provide the deep link for the build output for this specific SHA: `http://ci.example.com/user/repo/build/sha` #[serde(skip_serializing_if="Option::is_none")] - pub key_id: Option, - /// Which type of organization repositories have access to the organization secret. `selected` means only the repositories specified by `selected_repository_ids` can access the secret. + pub target_url: Option, + /// A short description of the status. #[serde(skip_serializing_if="Option::is_none")] - pub visibility: Option, - /// An array of repository ids that can access the organization secret. You can only provide a list of repository ids when the `visibility` is set to `selected`. You can manage the list of selected repositories using the [List selected repositories for an organization secret](https://docs.github.com/rest/actions/secrets#list-selected-repositories-for-an-organization-secret), [Set selected repositories for an organization secret](https://docs.github.com/rest/actions/secrets#set-selected-repositories-for-an-organization-secret), and [Remove selected repository from an organization secret](https://docs.github.com/rest/actions/secrets#remove-selected-repository-from-an-organization-secret) endpoints. + pub description: Option, + /// A string label to differentiate this status from the status of other systems. This field is case-insensitive. #[serde(skip_serializing_if="Option::is_none")] - pub selected_repository_ids: Option>, + pub context: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -4260,6 +4343,22 @@ pub struct PatchTeamsUpdateLegacy { pub parent_team_id: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostActionsGenerateRunnerJitconfigForOrg { + /// The name of the new runner. + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + /// The ID of the runner group to register the runner to. + #[serde(skip_serializing_if="Option::is_none")] + pub runner_group_id: Option, + /// The names of the custom labels to add to the runner. **Minimum items**: 1. **Maximum items**: 100. + #[serde(skip_serializing_if="Option::is_none")] + pub labels: Option>, + /// The working directory to be used for job execution, relative to the runner install directory. + #[serde(skip_serializing_if="Option::is_none")] + pub work_folder: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostTeamsCreateDiscussionLegacy { /// The discussion post's title. @@ -4297,13 +4396,6 @@ pub struct PatchTeamsUpdateDiscussionCommentLegacy { pub body: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutActionsSetSelectedReposForOrgSecret { - /// An array of repository ids that can access the organization secret. You can only provide a list of repository ids when the `visibility` is set to `selected`. You can add and remove individual repositories using the [Add selected repository to an organization secret](https://docs.github.com/rest/actions/secrets#add-selected-repository-to-an-organization-secret) and [Remove selected repository from an organization secret](https://docs.github.com/rest/actions/secrets#remove-selected-repository-from-an-organization-secret) endpoints. - #[serde(skip_serializing_if="Option::is_none")] - pub selected_repository_ids: Option>, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostReactionsCreateForTeamDiscussionCommentLegacy { /// The [reaction type](https://docs.github.com/rest/reactions/reactions#about-reactions) to add to the team discussion comment. @@ -4367,6 +4459,13 @@ pub struct PatchUsersUpdateAuthenticated { pub bio: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +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 labels: Option>, +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum PostCodespacesCreateForAuthenticatedUser { @@ -4389,7 +4488,7 @@ pub struct PutCodespacesCreateOrUpdateSecretForAuthenticatedUser { 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/codespaces/secrets#list-selected-repositories-for-a-user-secret), [Set selected repositories for a user secret](https://docs.github.com/rest/codespaces/secrets#set-selected-repositories-for-a-user-secret), and [Remove a selected repository from a user secret](https://docs.github.com/rest/codespaces/secrets#remove-a-selected-repository-from-a-user-secret) endpoints. #[serde(skip_serializing_if="Option::is_none")] - pub selected_repository_ids: Option>, + pub selected_repository_ids: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -4412,22 +4511,6 @@ pub struct PatchCodespacesUpdateForAuthenticatedUser { pub recent_folders: Option>, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostActionsCreateOrgVariable { - /// The name of the variable. - #[serde(skip_serializing_if="Option::is_none")] - pub name: Option, - /// The value of the variable. - #[serde(skip_serializing_if="Option::is_none")] - pub value: Option, - /// The type of repositories in the organization that can access the variable. `selected` means only the repositories specified by `selected_repository_ids` can access the variable. - #[serde(skip_serializing_if="Option::is_none")] - pub visibility: Option, - /// An array of repository ids that can access the organization variable. You can only provide a list of repository ids when the `visibility` is set to `selected`. - #[serde(skip_serializing_if="Option::is_none")] - pub selected_repository_ids: Option>, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostCodespacesPublishForAuthenticatedUser { /// A name for the new repository. @@ -4517,6 +4600,13 @@ pub struct PostUsersCreatePublicSshKeyForAuthenticatedUser { pub key: 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)] pub struct PatchOrgsUpdateMembershipForAuthenticatedUser { /// The state that the membership should be in. Only `\"active\"` will be accepted. @@ -4637,22 +4727,6 @@ pub struct PostReposCreateForAuthenticatedUser { pub is_template: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PatchActionsUpdateOrgVariable { - /// The name of the variable. - #[serde(skip_serializing_if="Option::is_none")] - pub name: Option, - /// The value of the variable. - #[serde(skip_serializing_if="Option::is_none")] - pub value: Option, - /// The type of repositories in the organization that can access the variable. `selected` means only the repositories specified by `selected_repository_ids` can access the variable. - #[serde(skip_serializing_if="Option::is_none")] - pub visibility: Option, - /// An array of repository ids that can access the organization variable. You can only provide a list of repository ids when the `visibility` is set to `selected`. - #[serde(skip_serializing_if="Option::is_none")] - pub selected_repository_ids: Option>, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostUsersAddSocialAccountForAuthenticatedUser { /// Full URLs for the social media profiles to add. @@ -4677,6 +4751,61 @@ pub struct PostUsersCreateSshSigningKeyForAuthenticatedUser { pub key: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutActionsCreateOrUpdateOrgSecret { + /// 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 organization public key](https://docs.github.com/rest/actions/secrets#get-an-organization-public-key) 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, + /// Which type of organization repositories have access to the organization secret. `selected` means only the repositories specified by `selected_repository_ids` can access the secret. + #[serde(skip_serializing_if="Option::is_none")] + pub visibility: Option, + /// An array of repository ids that can access the organization secret. You can only provide a list of repository ids when the `visibility` is set to `selected`. You can manage the list of selected repositories using the [List selected repositories for an organization secret](https://docs.github.com/rest/actions/secrets#list-selected-repositories-for-an-organization-secret), [Set selected repositories for an organization secret](https://docs.github.com/rest/actions/secrets#set-selected-repositories-for-an-organization-secret), and [Remove selected repository from an organization secret](https://docs.github.com/rest/actions/secrets#remove-selected-repository-from-an-organization-secret) endpoints. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_repository_ids: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutActionsSetSelectedReposForOrgSecret { + /// An array of repository ids that can access the organization secret. You can only provide a list of repository ids when the `visibility` is set to `selected`. You can add and remove individual repositories using the [Add selected repository to an organization secret](https://docs.github.com/rest/actions/secrets#add-selected-repository-to-an-organization-secret) and [Remove selected repository from an organization secret](https://docs.github.com/rest/actions/secrets#remove-selected-repository-from-an-organization-secret) endpoints. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_repository_ids: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostActionsCreateOrgVariable { + /// The name of the variable. + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + /// The value of the variable. + #[serde(skip_serializing_if="Option::is_none")] + pub value: Option, + /// The type of repositories in the organization that can access the variable. `selected` means only the repositories specified by `selected_repository_ids` can access the variable. + #[serde(skip_serializing_if="Option::is_none")] + pub visibility: Option, + /// An array of repository ids that can access the organization variable. You can only provide a list of repository ids when the `visibility` is set to `selected`. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_repository_ids: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PatchActionsUpdateOrgVariable { + /// The name of the variable. + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + /// The value of the variable. + #[serde(skip_serializing_if="Option::is_none")] + pub value: Option, + /// The type of repositories in the organization that can access the variable. `selected` means only the repositories specified by `selected_repository_ids` can access the variable. + #[serde(skip_serializing_if="Option::is_none")] + pub visibility: Option, + /// An array of repository ids that can access the organization variable. You can only provide a list of repository ids when the `visibility` is set to `selected`. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_repository_ids: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutActionsSetSelectedReposForOrgVariable { /// The IDs of the repositories that can access the organization variable. @@ -4732,6 +4861,13 @@ pub struct PostCodeSecurityCreateConfiguration { pub enforcement: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostAppsCheckToken { + /// The access_token of the OAuth or GitHub application. + #[serde(skip_serializing_if="Option::is_none")] + pub access_token: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct DeleteCodeSecurityDetachConfiguration { /// An array of repository IDs to detach from configurations. @@ -4804,13 +4940,6 @@ pub struct PutCodeSecuritySetConfigurationAsDefault { pub default_for_new_repos: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostAppsCheckToken { - /// The access_token of the OAuth or GitHub application. - #[serde(skip_serializing_if="Option::is_none")] - pub access_token: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutCodespacesSetCodespacesAccess { /// Which users can access codespaces in the organization. `disabled` means that no users can access codespaces in the organization. @@ -4865,6 +4994,13 @@ pub struct PostCopilotAddCopilotSeatsForTeams { pub selected_teams: 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 DeleteCopilotCancelCopilotSeatAssignmentForTeams { /// The names of teams from which to revoke access to GitHub Copilot. @@ -4902,13 +5038,6 @@ pub struct PutDependabotCreateOrUpdateOrgSecret { pub selected_repository_ids: 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 PutDependabotSetSelectedReposForOrgSecret { /// An array of repository ids that can access the organization secret. You can only provide a list of repository ids when the `visibility` is set to `selected`. You can add and remove individual repositories using the [Set selected repositories for an organization secret](https://docs.github.com/rest/dependabot/secrets#set-selected-repositories-for-an-organization-secret) and [Remove selected repository from an organization secret](https://docs.github.com/rest/dependabot/secrets#remove-selected-repository-from-an-organization-secret) endpoints. @@ -4980,6 +5109,13 @@ pub struct PutOrgsSetMembershipForUser { pub role: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PatchAppsResetToken { + /// The access_token of the OAuth or GitHub application. + #[serde(skip_serializing_if="Option::is_none")] + pub access_token: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostMigrationsStartForOrg { /// A list of arrays indicating which repositories should be migrated. @@ -5042,13 +5178,6 @@ pub struct PostOrgsReviewPatGrantRequest { pub reason: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PatchAppsResetToken { - /// The access_token of the OAuth or GitHub application. - #[serde(skip_serializing_if="Option::is_none")] - pub access_token: Option, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostOrgsUpdatePatAccesses { /// Action to apply to the fine-grained personal access token. @@ -5093,7 +5222,7 @@ pub struct PutOrgsCreateOrUpdateCustomProperty { pub required: Option, /// Default value of the property #[serde(skip_serializing_if="Option::is_none")] - pub default_value: Option, + pub default_value: Option, /// Short description of the property #[serde(skip_serializing_if="Option::is_none")] pub description: Option, @@ -5112,6 +5241,27 @@ pub struct PatchOrgsCreateOrUpdateCustomPropertiesValuesForRepos { pub properties: Option>, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PostAppsScopeToken { + /// The 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 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 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 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 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 PostReposCreateInOrg { /// The name of the repository. @@ -5259,27 +5409,6 @@ pub struct PostTeamsCreate { pub parent_team_id: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PostAppsScopeToken { - /// The 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 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 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 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 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 PatchTeamsUpdateInOrg { /// The name of the team. @@ -5346,6 +5475,18 @@ pub struct PostReactionsCreateForTeamDiscussionCommentInOrg { pub content: 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 PostReactionsCreateForTeamDiscussionInOrg { /// The [reaction type](https://docs.github.com/rest/reactions/reactions#about-reactions) to add to the team discussion. @@ -5362,28 +5503,16 @@ pub struct PutTeamsAddOrUpdateMembershipForUserInOrg { #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutTeamsAddOrUpdateProjectPermissionsInOrg { - /// The permission to grant to the team for this project. Default: the team's `permission` attribute will be used to determine what permission to grant the team on this project. Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling this endpoint. For more information, see \"[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method).\" - #[serde(skip_serializing_if="Option::is_none")] - pub permission: Option, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PutTeamsAddOrUpdateRepoPermissionsInOrg { - /// The permission to grant the team on this repository. We accept the following permissions to be set: `pull`, `triage`, `push`, `maintain`, `admin` and you can also specify a custom repository role name, 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, -} - -#[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 + /// The permission to grant to the team for this project. Default: the team's `permission` attribute will be used to determine what permission to grant the team on this project. Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling this endpoint. For more information, see \"[HTTP method](https://docs.github.com/rest/guides/getting-started-with-the-rest-api#http-method).\" #[serde(skip_serializing_if="Option::is_none")] - pub files: Option>, + pub permission: Option, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PutTeamsAddOrUpdateRepoPermissionsInOrg { + /// The permission to grant the team on this repository. We accept the following permissions to be set: `pull`, `triage`, `push`, `maintain`, `admin` and you can also specify a custom repository role name, 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 public: Option, + pub permission: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -5439,6 +5568,16 @@ pub struct PostProjectsMoveColumn { pub position: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct PatchGistsUpdate { + /// The description of the gist. + #[serde(skip_serializing_if="Option::is_none")] + pub description: Option, + /// The gist files to be updated, renamed, or deleted. Each `key` must match the current filename (including extension) of the targeted gist file. For example: `hello.py`. To delete a file, set the whole file to null. For example: `hello.py : null`. The file will also be deleted if the specified object does not contain at least one of `content` or `filename`. + #[serde(skip_serializing_if="Option::is_none")] + pub files: Option>, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PatchProjectsUpdate { /// Name of the project @@ -5550,16 +5689,6 @@ pub struct PatchReposUpdate { pub web_commit_signoff_required: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PatchGistsUpdate { - /// The description of the gist. - #[serde(skip_serializing_if="Option::is_none")] - pub description: Option, - /// The gist files to be updated, renamed, or deleted. Each `key` must match the current filename (including extension) of the targeted gist file. For example: `hello.py`. To delete a file, set the whole file to null. For example: `hello.py : null`. The file will also be deleted if the specified object does not contain at least one of `content` or `filename`. - #[serde(skip_serializing_if="Option::is_none")] - pub files: Option>, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PostActionsReRunJobForWorkflowRun { /// Whether to enable debug logging for the re-run. @@ -5624,6 +5753,13 @@ impl From for PostActionsReviewCustomGatesForRun } } +#[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 PostActionsReviewPendingDeploymentsForRun { /// The list of environment ids to approve or reject @@ -5661,13 +5797,6 @@ pub struct PutActionsCreateOrUpdateRepoSecret { pub key_id: 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 PostActionsCreateRepoVariable { /// The name of the variable. @@ -5752,77 +5881,6 @@ pub struct PutReposUpdateBranchProtection { pub allow_fork_syncing: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PatchReposUpdatePullRequestReviewProtection { - #[serde(skip_serializing_if="Option::is_none")] - pub dismissal_restrictions: Option, - /// Set to `true` if you want to automatically dismiss approving reviews when someone pushes a new commit. - #[serde(skip_serializing_if="Option::is_none")] - pub dismiss_stale_reviews: Option, - /// Blocks merging pull requests until [code owners](https://docs.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 or 0 to not require reviewers. - #[serde(skip_serializing_if="Option::is_none")] - pub required_approving_review_count: Option, - /// Whether the most recent push must be approved by someone other than the person who pushed it. Default: `false` - #[serde(skip_serializing_if="Option::is_none")] - pub require_last_push_approval: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub bypass_pull_request_allowances: Option, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct PatchReposUpdateStatusCheckProtection { - /// Require branches to be up to date before merging. - #[serde(skip_serializing_if="Option::is_none")] - pub strict: Option, - /// **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)] -#[serde(untagged)] -pub enum PutReposSetStatusCheckContexts { - PutReposSetStatusCheckContextsVariant0(HashMap>), - PutReposSetStatusCheckContextsVariant1(Vec), -} - -impl From>> for PutReposSetStatusCheckContexts { - fn from(value: HashMap>) -> Self { - PutReposSetStatusCheckContexts::PutReposSetStatusCheckContextsVariant0(value) - } -} - -impl From> for PutReposSetStatusCheckContexts { - fn from(value: Vec) -> Self { - PutReposSetStatusCheckContexts::PutReposSetStatusCheckContextsVariant1(value) - } -} - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(untagged)] -pub enum PostReposAddStatusCheckContexts { - PostReposAddStatusCheckContextsVariant0(HashMap>), - PostReposAddStatusCheckContextsVariant1(Vec), -} - -impl From>> for PostReposAddStatusCheckContexts { - fn from(value: HashMap>) -> Self { - PostReposAddStatusCheckContexts::PostReposAddStatusCheckContextsVariant0(value) - } -} - -impl From> for PostReposAddStatusCheckContexts { - fn from(value: Vec) -> Self { - PostReposAddStatusCheckContexts::PostReposAddStatusCheckContextsVariant1(value) - } -} - /// Branch Protection #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct BranchProtection { @@ -11806,6 +11864,36 @@ pub struct GetAppsListReposAccessibleToInstallationResponse200 { pub repository_selection: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct GetCodespacesListRepositoriesForSecretForAuthenticatedUserResponse200 { + #[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 GetActionsListOrgVariablesResponse200 { + #[serde(skip_serializing_if="Option::is_none")] + pub total_count: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub variables: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct GetReposListAttestationsResponse200 { + #[serde(skip_serializing_if="Option::is_none")] + pub attestations: Option>, +} + +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct InlineResponse20012Attestations { + #[serde(skip_serializing_if="Option::is_none")] + pub bundle: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub repository_id: Option, +} + #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct PutCodeSecuritySetConfigurationAsDefaultResponse200 { /// Specifies which types of repository this security configuration is applied to by default. @@ -11863,6 +11951,14 @@ pub struct GetAppsListInstallationsForAuthenticatedUserResponse200 { pub installations: Option>, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct GetActionsGetActionsCacheUsageByRepoForOrgResponse200 { + #[serde(skip_serializing_if="Option::is_none")] + pub total_count: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub repository_cache_usages: Option>, +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum GetInteractionsGetRestrictionsForAuthenticatedUserResponse200 { @@ -11900,14 +11996,6 @@ pub struct GetActionsListWorkflowRunArtifactsResponse200 { pub artifacts: Option>, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetActionsGetActionsCacheUsageByRepoForOrgResponse200 { - #[serde(skip_serializing_if="Option::is_none")] - pub total_count: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub repository_cache_usages: Option>, -} - #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct GetActionsListEnvironmentSecretsResponse200 { #[serde(skip_serializing_if="Option::is_none")] @@ -11961,11 +12049,11 @@ pub struct GetCodespacesListDevcontainersInRepositoryForAuthenticatedUserRespons #[serde(skip_serializing_if="Option::is_none")] pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] - pub devcontainers: Option>, + pub devcontainers: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct InlineResponse20026Devcontainers { +pub struct InlineResponse20029Devcontainers { #[serde(skip_serializing_if="Option::is_none")] pub path: Option, #[serde(skip_serializing_if="Option::is_none")] @@ -11974,6 +12062,14 @@ pub struct InlineResponse20026Devcontainers { pub display_name: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct GetActionsListSelectedRepositoriesEnabledGithubActionsOrganizationResponse200 { + #[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 GetCodespacesCodespaceMachinesForAuthenticatedUserResponse200 { #[serde(skip_serializing_if="Option::is_none")] @@ -11987,11 +12083,11 @@ pub struct GetCodespacesPreFlightWithRepoForAuthenticatedUserResponse200 { #[serde(skip_serializing_if="Option::is_none")] pub billable_owner: Option, #[serde(skip_serializing_if="Option::is_none")] - pub defaults: Option, + pub defaults: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct InlineResponse20028Defaults { +pub struct InlineResponse20031Defaults { #[serde(skip_serializing_if="Option::is_none")] pub location: Option, #[serde(skip_serializing_if="Option::is_none")] @@ -12006,14 +12102,6 @@ pub struct GetCodespacesListRepoSecretsResponse200 { pub secrets: Option>, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetActionsListSelectedRepositoriesEnabledGithubActionsOrganizationResponse200 { - #[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 GetChecksListSuitesForRefResponse200 { #[serde(skip_serializing_if="Option::is_none")] @@ -12024,34 +12112,34 @@ pub struct GetChecksListSuitesForRefResponse200 { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum InlineResponse20031 { - InlineResponse20031Variant0(ContentDirectory), - InlineResponse20031Variant1(ContentFile), - InlineResponse20031Variant2(ContentSymlink), - InlineResponse20031Variant3(ContentSubmodule), +pub enum InlineResponse20034 { + InlineResponse20034Variant0(ContentDirectory), + InlineResponse20034Variant1(ContentFile), + InlineResponse20034Variant2(ContentSymlink), + InlineResponse20034Variant3(ContentSubmodule), } -impl From for InlineResponse20031 { +impl From for InlineResponse20034 { fn from(value: ContentDirectory) -> Self { - InlineResponse20031::InlineResponse20031Variant0(value) + InlineResponse20034::InlineResponse20034Variant0(value) } } -impl From for InlineResponse20031 { +impl From for InlineResponse20034 { fn from(value: ContentFile) -> Self { - InlineResponse20031::InlineResponse20031Variant1(value) + InlineResponse20034::InlineResponse20034Variant1(value) } } -impl From for InlineResponse20031 { +impl From for InlineResponse20034 { fn from(value: ContentSymlink) -> Self { - InlineResponse20031::InlineResponse20031Variant2(value) + InlineResponse20034::InlineResponse20034Variant2(value) } } -impl From for InlineResponse20031 { +impl From for InlineResponse20034 { fn from(value: ContentSubmodule) -> Self { - InlineResponse20031::InlineResponse20031Variant3(value) + InlineResponse20034::InlineResponse20034Variant3(value) } } @@ -12099,6 +12187,14 @@ pub struct GetReposListCustomDeploymentRuleIntegrationsResponse200 { pub available_custom_deployment_protection_rule_integrations: Option>, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct GetActionsListSelfHostedRunnerGroupsForOrgResponse200 { + #[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 GetReposCheckPrivateVulnerabilityReportingResponse200 { /// Whether or not private vulnerability reporting is enabled for the repository. @@ -12135,14 +12231,6 @@ pub struct GetSearchCodeResponse200 { pub items: 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 GetSearchCommitsResponse200 { #[serde(skip_serializing_if="Option::is_none")] @@ -12222,6 +12310,14 @@ impl From for GetUsersGetByUsernameResponse200 { } } +#[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 GetCodespacesListSecretsForAuthenticatedUserResponse200 { #[serde(skip_serializing_if="Option::is_none")] @@ -12243,25 +12339,17 @@ pub struct GetAppsListInstallationReposForAuthenticatedUserResponse200 { #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct GetUsersListAttestationsResponse200 { #[serde(skip_serializing_if="Option::is_none")] - pub attestations: Option>, + pub attestations: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct InlineResponse20049Attestations { +pub struct InlineResponse20052Attestations { #[serde(skip_serializing_if="Option::is_none")] pub bundle: Option, #[serde(skip_serializing_if="Option::is_none")] pub repository_id: Option, } -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct DeleteActionsRemoveCustomLabelFromSelfHostedRunnerForRepoResponse200 { - #[serde(skip_serializing_if="Option::is_none")] - pub total_count: Option, - #[serde(skip_serializing_if="Option::is_none")] - pub labels: Option>, -} - #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] pub enum GetActivityListReposStarredByUserResponse200 { @@ -12282,41 +12370,35 @@ impl From> for GetActivityListReposStarredByUserResponse200 { } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetActionsListOrgSecretsResponse200 { +pub struct GetActionsListSelfHostedRunnersInGroupForOrgResponse200 { #[serde(skip_serializing_if="Option::is_none")] - pub total_count: Option, + pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] - pub secrets: Option>, + pub runners: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetCodespacesListRepositoriesForSecretForAuthenticatedUserResponse200 { +pub struct GetActionsListSelfHostedRunnersForRepoResponse200 { #[serde(skip_serializing_if="Option::is_none")] pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] - pub repositories: Option>, + pub runners: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetActionsListOrgVariablesResponse200 { +pub struct DeleteActionsRemoveCustomLabelFromSelfHostedRunnerForRepoResponse200 { #[serde(skip_serializing_if="Option::is_none")] pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] - pub variables: Option>, -} - -#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct GetReposListAttestationsResponse200 { - #[serde(skip_serializing_if="Option::is_none")] - pub attestations: Option>, + pub labels: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] -pub struct InlineResponse2009Attestations { +pub struct GetActionsListOrgSecretsResponse200 { #[serde(skip_serializing_if="Option::is_none")] - pub bundle: Option, + pub total_count: Option, #[serde(skip_serializing_if="Option::is_none")] - pub repository_id: Option, + pub secrets: Option>, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] @@ -16599,153 +16681,153 @@ impl From> for OneOfSimplePullRequestRequestedReviewersIt #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum OneOfbody128Payload { - OneOfbody128PayloadVariant0(HashMap>), - OneOfbody128PayloadVariant1(String), +pub enum OneOfbody132Payload { + OneOfbody132PayloadVariant0(HashMap>), + OneOfbody132PayloadVariant1(String), } -impl From>> for OneOfbody128Payload { +impl From>> for OneOfbody132Payload { fn from(value: HashMap>) -> Self { - OneOfbody128Payload::OneOfbody128PayloadVariant0(value) + OneOfbody132Payload::OneOfbody132PayloadVariant0(value) } } -impl From for OneOfbody128Payload { +impl From for OneOfbody132Payload { fn from(value: String) -> Self { - OneOfbody128Payload::OneOfbody128PayloadVariant1(value) + OneOfbody132Payload::OneOfbody132PayloadVariant1(value) } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum OneOfbody151LabelsItems { - OneOfbody151LabelsItemsVariant0(String), - OneOfbody151LabelsItemsVariant1(HashMap), +pub enum OneOfbody155LabelsItems { + OneOfbody155LabelsItemsVariant0(String), + OneOfbody155LabelsItemsVariant1(HashMap), } -impl From for OneOfbody151LabelsItems { +impl From for OneOfbody155LabelsItems { fn from(value: String) -> Self { - OneOfbody151LabelsItems::OneOfbody151LabelsItemsVariant0(value) + OneOfbody155LabelsItems::OneOfbody155LabelsItemsVariant0(value) } } -impl From> for OneOfbody151LabelsItems { +impl From> for OneOfbody155LabelsItems { fn from(value: HashMap) -> Self { - OneOfbody151LabelsItems::OneOfbody151LabelsItemsVariant1(value) + OneOfbody155LabelsItems::OneOfbody155LabelsItemsVariant1(value) } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum OneOfbody151Milestone { - OneOfbody151MilestoneVariant0(String), - OneOfbody151MilestoneVariant1(i32), +pub enum OneOfbody155Milestone { + OneOfbody155MilestoneVariant0(String), + OneOfbody155MilestoneVariant1(i32), } -impl From for OneOfbody151Milestone { +impl From for OneOfbody155Milestone { fn from(value: String) -> Self { - OneOfbody151Milestone::OneOfbody151MilestoneVariant0(value) + OneOfbody155Milestone::OneOfbody155MilestoneVariant0(value) } } -impl From for OneOfbody151Milestone { +impl From for OneOfbody155Milestone { fn from(value: i32) -> Self { - OneOfbody151Milestone::OneOfbody151MilestoneVariant1(value) + OneOfbody155Milestone::OneOfbody155MilestoneVariant1(value) } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum OneOfbody151Title { - OneOfbody151TitleVariant0(String), - OneOfbody151TitleVariant1(i32), +pub enum OneOfbody155Title { + OneOfbody155TitleVariant0(String), + OneOfbody155TitleVariant1(i32), } -impl From for OneOfbody151Title { +impl From for OneOfbody155Title { fn from(value: String) -> Self { - OneOfbody151Title::OneOfbody151TitleVariant0(value) + OneOfbody155Title::OneOfbody155TitleVariant0(value) } } -impl From for OneOfbody151Title { +impl From for OneOfbody155Title { fn from(value: i32) -> Self { - OneOfbody151Title::OneOfbody151TitleVariant1(value) + OneOfbody155Title::OneOfbody155TitleVariant1(value) } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum OneOfbody154LabelsItems { - OneOfbody154LabelsItemsVariant0(String), - OneOfbody154LabelsItemsVariant1(HashMap), +pub enum OneOfbody158LabelsItems { + OneOfbody158LabelsItemsVariant0(String), + OneOfbody158LabelsItemsVariant1(HashMap), } -impl From for OneOfbody154LabelsItems { +impl From for OneOfbody158LabelsItems { fn from(value: String) -> Self { - OneOfbody154LabelsItems::OneOfbody154LabelsItemsVariant0(value) + OneOfbody158LabelsItems::OneOfbody158LabelsItemsVariant0(value) } } -impl From> for OneOfbody154LabelsItems { +impl From> for OneOfbody158LabelsItems { fn from(value: HashMap) -> Self { - OneOfbody154LabelsItems::OneOfbody154LabelsItemsVariant1(value) + OneOfbody158LabelsItems::OneOfbody158LabelsItemsVariant1(value) } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum OneOfbody154Milestone { - OneOfbody154MilestoneVariant0(String), - OneOfbody154MilestoneVariant1(i32), +pub enum OneOfbody158Milestone { + OneOfbody158MilestoneVariant0(String), + OneOfbody158MilestoneVariant1(i32), } -impl From for OneOfbody154Milestone { +impl From for OneOfbody158Milestone { fn from(value: String) -> Self { - OneOfbody154Milestone::OneOfbody154MilestoneVariant0(value) + OneOfbody158Milestone::OneOfbody158MilestoneVariant0(value) } } -impl From for OneOfbody154Milestone { +impl From for OneOfbody158Milestone { fn from(value: i32) -> Self { - OneOfbody154Milestone::OneOfbody154MilestoneVariant1(value) + OneOfbody158Milestone::OneOfbody158MilestoneVariant1(value) } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum OneOfbody154Title { - OneOfbody154TitleVariant0(String), - OneOfbody154TitleVariant1(i32), +pub enum OneOfbody158Title { + OneOfbody158TitleVariant0(String), + OneOfbody158TitleVariant1(i32), } -impl From for OneOfbody154Title { +impl From for OneOfbody158Title { fn from(value: String) -> Self { - OneOfbody154Title::OneOfbody154TitleVariant0(value) + OneOfbody158Title::OneOfbody158TitleVariant0(value) } } -impl From for OneOfbody154Title { +impl From for OneOfbody158Title { fn from(value: i32) -> Self { - OneOfbody154Title::OneOfbody154TitleVariant1(value) + OneOfbody158Title::OneOfbody158TitleVariant1(value) } } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(untagged)] -pub enum OneOfbody54DefaultValue { - OneOfbody54DefaultValueVariant0(String), - OneOfbody54DefaultValueVariant1(Vec), +pub enum OneOfbody58DefaultValue { + OneOfbody58DefaultValueVariant0(String), + OneOfbody58DefaultValueVariant1(Vec), } -impl From for OneOfbody54DefaultValue { +impl From for OneOfbody58DefaultValue { fn from(value: String) -> Self { - OneOfbody54DefaultValue::OneOfbody54DefaultValueVariant0(value) + OneOfbody58DefaultValue::OneOfbody58DefaultValueVariant0(value) } } -impl From> for OneOfbody54DefaultValue { +impl From> for OneOfbody58DefaultValue { fn from(value: Vec) -> Self { - OneOfbody54DefaultValue::OneOfbody54DefaultValueVariant1(value) + OneOfbody58DefaultValue::OneOfbody58DefaultValueVariant1(value) } } @@ -26569,6 +26651,8 @@ pub struct ReposownerrepoSecurityAndAnalysis { #[serde(skip_serializing_if="Option::is_none")] pub secret_scanning_push_protection: Option, #[serde(skip_serializing_if="Option::is_none")] + pub secret_scanning_ai_detection: Option, + #[serde(skip_serializing_if="Option::is_none")] pub secret_scanning_non_provider_patterns: Option, } @@ -26588,6 +26672,14 @@ pub struct ReposownerrepoSecurityAndAnalysisSecretScanning { pub status: Option, } +/// Use the `status` property to enable or disable secret scanning AI detection for this repository. For more information, see \"[Responsible detection of generic secrets with AI](https://docs.github.com/code-security/secret-scanning/using-advanced-secret-scanning-and-push-protection-features/generic-secret-detection/responsible-ai-generic-secrets).\" +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct ReposownerrepoSecurityAndAnalysisSecretScanningAiDetection { + /// Can be `enabled` or `disabled`. + #[serde(skip_serializing_if="Option::is_none")] + pub status: Option, +} + /// Use the `status` property to enable or disable secret scanning non-provider patterns for this repository. For more information, see \"[Supported secret scanning patterns](/code-security/secret-scanning/introduction/supported-secret-scanning-patterns#supported-secrets).\" #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct ReposownerrepoSecurityAndAnalysisSecretScanningNonProviderPatterns { @@ -27404,6 +27496,40 @@ pub struct RunnerApplication { pub sha256_checksum: Option, } +#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] +pub struct RunnerGroupsOrg { + #[serde(skip_serializing_if="Option::is_none")] + pub id: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub name: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub visibility: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub default: Option, + /// Link to the selected repositories resource for this runner group. Not present unless visibility was set to `selected` + #[serde(skip_serializing_if="Option::is_none")] + pub selected_repositories_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub runners_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub hosted_runners_url: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub inherited: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub inherited_allows_public_repositories: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub allows_public_repositories: Option, + /// If `true`, the `restricted_to_workflows` and `selected_workflows` fields cannot be modified. + #[serde(skip_serializing_if="Option::is_none")] + pub workflow_restrictions_read_only: Option, + /// If `true`, the runner group will be restricted to running only the workflows specified in the `selected_workflows` array. + #[serde(skip_serializing_if="Option::is_none")] + pub restricted_to_workflows: Option, + /// List of workflows the runner group should be allowed to run. This setting will be ignored unless `restricted_to_workflows` is set to `true`. + #[serde(skip_serializing_if="Option::is_none")] + pub selected_workflows: Option>, +} + /// A label for a self hosted runner #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] pub struct RunnerLabel { @@ -28050,6 +28176,8 @@ pub struct SecurityAndAnalysis { pub secret_scanning_push_protection: Option, #[serde(skip_serializing_if="Option::is_none")] pub secret_scanning_non_provider_patterns: Option, + #[serde(skip_serializing_if="Option::is_none")] + pub secret_scanning_ai_detection: Option, } #[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)] diff --git a/tests/simple.rs b/tests/simple.rs index c724773..d3225e4 100644 --- a/tests/simple.rs +++ b/tests/simple.rs @@ -2,7 +2,13 @@ use wasm_bindgen_test::*; use roctogen::api::{self, repos}; -use roctogen::{adapters::client, auth::Auth}; +use roctogen::{auth::Auth}; +#[cfg(any( + feature = "reqwest", + feature = "ureq", + target_arch = "wasm32" +))] +use roctogen::adapters::client; use roctogen::models; @@ -31,8 +37,8 @@ async fn get_wasm_fail() { .await; match &req { Ok(_) => {} - Err(repos::ReposListCommitsError::Status404(e)) => { - debug!("{}", e.message.as_ref().unwrap()); + Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + debug!("{}", description); } Err(_) => { assert!(false); @@ -54,8 +60,8 @@ fn get_sync_fail() { repos::new(&client).list_commits("this-user-does-not-exist", "bollard", Some(&per_page)); match &req { Ok(_) => {} - Err(repos::ReposListCommitsError::Status404(e)) => { - debug!("{}", e.message.as_ref().unwrap()); + Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + debug!("{}", description); } Err(x) => { debug!("{:?}", x); @@ -146,8 +152,8 @@ async fn get_async_fail() { .await; match &req { Ok(_) => {} - Err(repos::ReposListCommitsError::Status404(e)) => { - debug!("{}", e.message.as_ref().unwrap()); + Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + debug!("{}", description); } Err(x) => { debug!("{:?}", x); @@ -175,8 +181,8 @@ async fn post_wasm_fail() { .await; match &req { Ok(_) => {} - Err(repos::ReposAddUserAccessRestrictionsError::Generic { code }) => { - assert_eq!(404, *code); + Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + debug!("{}", description); } Err(_) => { assert!(false); @@ -200,8 +206,8 @@ fn post_sync_fail() { repos::new(&client).add_user_access_restrictions("fussybeaver", "bollard", "master", body); match &req { Ok(_) => {} - Err(repos::ReposAddUserAccessRestrictionsError::Generic { code }) => { - assert_eq!(404, *code); + Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + debug!("{}", description); } Err(_) => { assert!(false); @@ -214,6 +220,7 @@ fn post_sync_fail() { #[cfg(all(not(target_arch = "wasm32"), feature = "reqwest"))] #[tokio::test] async fn post_async_fail() { + env_logger::try_init(); let auth = Auth::None; let client = client(&auth).expect("Cannot create client"); @@ -226,8 +233,8 @@ async fn post_async_fail() { .await; match &req { Ok(_) => {} - Err(repos::ReposAddUserAccessRestrictionsError::Generic { code }) => { - assert_eq!(404, *code); + Err(e @ roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + debug!("{:?}", e); } Err(_) => { assert!(false); diff --git a/tests/sync.rs b/tests/sync.rs index a82dd8f..ebd2879 100644 --- a/tests/sync.rs +++ b/tests/sync.rs @@ -3,6 +3,11 @@ use roctogen::api::{ self, activity, gists, issues, licenses, meta, rate_limit, reactions, repos, search, users, }; +#[cfg(any( + feature = "reqwest", + feature = "ureq", + target_arch = "wasm32" +))] use roctogen::adapters::client; use roctogen::auth::Auth; use roctogen::models; @@ -105,6 +110,7 @@ fn issues_sync_ok() { #[cfg(all(not(target_arch = "wasm32"), not(feature = "reqwest")))] #[test] fn license_sync_ok() { + env_logger::try_init(); use roctogen::api::licenses::LicensesGetForRepoParams; let auth = Auth::None; @@ -112,6 +118,7 @@ fn license_sync_ok() { let license = licenses::new(&client); let req = license.get_for_repo("fussybeaver", "bollard", None::); + debug!("{:?}", req); assert!(req.is_ok()); let req = license.get_all_commonly_used(None::); @@ -194,8 +201,8 @@ fn post_sync_fail() { repos::new(&client).add_user_access_restrictions("fussybeaver", "bollard", "master", body); match &req { Ok(_) => {} - Err(repos::ReposAddUserAccessRestrictionsError::Generic { code }) => { - assert_eq!(404, *code); + Err(roctogen::adapters::AdapterError::Endpoint { description, status_code: 404, .. }) => { + debug!("{}", description); } Err(_) => { panic!();