aboutsummaryrefslogtreecommitdiffstats
path: root/rust/fatcat-openapi/src
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-09-13 11:27:09 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-09-13 11:32:05 -0700
commiteb6993c6cc40e532cb1462e44408ed30db5244c0 (patch)
tree3dce637443f1fdf602f8967b65b140456445f004 /rust/fatcat-openapi/src
parent601f3f6ac91546dd5e047c3e932a61c402305826 (diff)
downloadfatcat-eb6993c6cc40e532cb1462e44408ed30db5244c0.tar.gz
fatcat-eb6993c6cc40e532cb1462e44408ed30db5244c0.zip
rust codegen
This re-ordered a lot of code, because several endpoints had their tags changed, but should be no actual change in behavior/spec.
Diffstat (limited to 'rust/fatcat-openapi/src')
-rw-r--r--rust/fatcat-openapi/src/client.rs1210
-rw-r--r--rust/fatcat-openapi/src/lib.rs432
-rw-r--r--rust/fatcat-openapi/src/mimetypes.rs420
-rw-r--r--rust/fatcat-openapi/src/models.rs173
-rw-r--r--rust/fatcat-openapi/src/server.rs1856
5 files changed, 2101 insertions, 1990 deletions
diff --git a/rust/fatcat-openapi/src/client.rs b/rust/fatcat-openapi/src/client.rs
index 378c546f..65bf67a5 100644
--- a/rust/fatcat-openapi/src/client.rs
+++ b/rust/fatcat-openapi/src/client.rs
@@ -173,6 +173,298 @@ impl Client {
}
impl Api for Client {
+ fn auth_check(&self, param_role: Option<String>, context: &Context) -> Box<Future<Item = AuthCheckResponse, Error = ApiError> + Send> {
+ // Query parameters
+ let query_role = param_role.map_or_else(String::new, |query| format!("role={role}&", role = query.to_string()));
+
+ let url = format!("{}/v0/auth/check?{role}", self.base_path, role = utf8_percent_encode(&query_role, QUERY_ENCODE_SET));
+
+ let hyper_client = (self.hyper_client)();
+ let request = hyper_client.request(hyper::method::Method::Get, &url);
+ let mut custom_headers = hyper::header::Headers::new();
+
+ context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
+
+ let request = request.headers(custom_headers);
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<AuthCheckResponse, ApiError> {
+ match response.status.to_u16() {
+ 200 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::Success>(&buf)?;
+
+ Ok(AuthCheckResponse::Success(body))
+ }
+ 400 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(AuthCheckResponse::BadRequest(body))
+ }
+ 401 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+ header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
+ let response_www_authenticate = response
+ .headers
+ .get::<ResponseWwwAuthenticate>()
+ .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
+
+ Ok(AuthCheckResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate.0.clone(),
+ })
+ }
+ 403 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(AuthCheckResponse::Forbidden(body))
+ }
+ 500 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(AuthCheckResponse::GenericError(body))
+ }
+ code => {
+ let mut buf = [0; 100];
+ let debug_body = match response.read(&mut buf) {
+ Ok(len) => match str::from_utf8(&buf[..len]) {
+ Ok(body) => Cow::from(body),
+ Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ };
+ Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
+ }
+ }
+ }
+
+ let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ Box::new(futures::done(result))
+ }
+
+ fn auth_oidc(&self, param_oidc_params: models::AuthOidc, context: &Context) -> Box<Future<Item = AuthOidcResponse, Error = ApiError> + Send> {
+ let url = format!("{}/v0/auth/oidc", self.base_path);
+
+ let body = serde_json::to_string(&param_oidc_params).expect("impossible to fail to serialize");
+
+ let hyper_client = (self.hyper_client)();
+ let request = hyper_client.request(hyper::method::Method::Post, &url);
+ let mut custom_headers = hyper::header::Headers::new();
+
+ let request = request.body(&body);
+
+ custom_headers.set(ContentType(mimetypes::requests::AUTH_OIDC.clone()));
+ context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
+
+ let request = request.headers(custom_headers);
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<AuthOidcResponse, ApiError> {
+ match response.status.to_u16() {
+ 200 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::AuthOidcResult>(&buf)?;
+
+ Ok(AuthOidcResponse::Found(body))
+ }
+ 201 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::AuthOidcResult>(&buf)?;
+
+ Ok(AuthOidcResponse::Created(body))
+ }
+ 400 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(AuthOidcResponse::BadRequest(body))
+ }
+ 401 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+ header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
+ let response_www_authenticate = response
+ .headers
+ .get::<ResponseWwwAuthenticate>()
+ .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
+
+ Ok(AuthOidcResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate.0.clone(),
+ })
+ }
+ 403 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(AuthOidcResponse::Forbidden(body))
+ }
+ 409 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(AuthOidcResponse::Conflict(body))
+ }
+ 500 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(AuthOidcResponse::GenericError(body))
+ }
+ code => {
+ let mut buf = [0; 100];
+ let debug_body = match response.read(&mut buf) {
+ Ok(len) => match str::from_utf8(&buf[..len]) {
+ Ok(body) => Cow::from(body),
+ Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ };
+ Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
+ }
+ }
+ }
+
+ let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ Box::new(futures::done(result))
+ }
+
+ fn get_changelog(&self, param_limit: Option<i64>, context: &Context) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send> {
+ // Query parameters
+ let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
+
+ let url = format!("{}/v0/changelog?{limit}", self.base_path, limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET));
+
+ let hyper_client = (self.hyper_client)();
+ let request = hyper_client.request(hyper::method::Method::Get, &url);
+ let mut custom_headers = hyper::header::Headers::new();
+
+ context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
+
+ let request = request.headers(custom_headers);
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<GetChangelogResponse, ApiError> {
+ match response.status.to_u16() {
+ 200 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<Vec<models::ChangelogEntry>>(&buf)?;
+
+ Ok(GetChangelogResponse::Success(body))
+ }
+ 400 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(GetChangelogResponse::BadRequest(body))
+ }
+ 500 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(GetChangelogResponse::GenericError(body))
+ }
+ code => {
+ let mut buf = [0; 100];
+ let debug_body = match response.read(&mut buf) {
+ Ok(len) => match str::from_utf8(&buf[..len]) {
+ Ok(body) => Cow::from(body),
+ Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ };
+ Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
+ }
+ }
+ }
+
+ let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ Box::new(futures::done(result))
+ }
+
+ fn get_changelog_entry(&self, param_index: i64, context: &Context) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> {
+ let url = format!(
+ "{}/v0/changelog/{index}",
+ self.base_path,
+ index = utf8_percent_encode(&param_index.to_string(), PATH_SEGMENT_ENCODE_SET)
+ );
+
+ let hyper_client = (self.hyper_client)();
+ let request = hyper_client.request(hyper::method::Method::Get, &url);
+ let mut custom_headers = hyper::header::Headers::new();
+
+ context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
+
+ let request = request.headers(custom_headers);
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<GetChangelogEntryResponse, ApiError> {
+ match response.status.to_u16() {
+ 200 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ChangelogEntry>(&buf)?;
+
+ Ok(GetChangelogEntryResponse::FoundChangelogEntry(body))
+ }
+ 400 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(GetChangelogEntryResponse::BadRequest(body))
+ }
+ 404 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(GetChangelogEntryResponse::NotFound(body))
+ }
+ 500 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(GetChangelogEntryResponse::GenericError(body))
+ }
+ code => {
+ let mut buf = [0; 100];
+ let debug_body = match response.read(&mut buf) {
+ Ok(len) => match str::from_utf8(&buf[..len]) {
+ Ok(body) => Cow::from(body),
+ Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ };
+ Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
+ }
+ }
+ }
+
+ let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ Box::new(futures::done(result))
+ }
+
fn create_container(&self, param_editgroup_id: String, param_entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/editgroup/{editgroup_id}/container",
@@ -1985,14 +2277,15 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn auth_check(&self, param_role: Option<String>, context: &Context) -> Box<Future<Item = AuthCheckResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_role = param_role.map_or_else(String::new, |query| format!("role={role}&", role = query.to_string()));
-
- let url = format!("{}/v0/auth/check?{role}", self.base_path, role = utf8_percent_encode(&query_role, QUERY_ENCODE_SET));
+ fn accept_editgroup(&self, param_editgroup_id: String, context: &Context) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
+ let url = format!(
+ "{}/v0/editgroup/{editgroup_id}/accept",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ );
let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Get, &url);
+ let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
@@ -2000,21 +2293,21 @@ impl Api for Client {
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<AuthCheckResponse, ApiError> {
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<AcceptEditgroupResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::Success>(&buf)?;
- Ok(AuthCheckResponse::Success(body))
+ Ok(AcceptEditgroupResponse::MergedSuccessfully(body))
}
400 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(AuthCheckResponse::BadRequest(body))
+ Ok(AcceptEditgroupResponse::BadRequest(body))
}
401 => {
let mut buf = String::new();
@@ -2026,7 +2319,7 @@ impl Api for Client {
.get::<ResponseWwwAuthenticate>()
.ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
- Ok(AuthCheckResponse::NotAuthorized {
+ Ok(AcceptEditgroupResponse::NotAuthorized {
body: body,
www_authenticate: response_www_authenticate.0.clone(),
})
@@ -2036,14 +2329,28 @@ impl Api for Client {
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(AuthCheckResponse::Forbidden(body))
+ Ok(AcceptEditgroupResponse::Forbidden(body))
+ }
+ 404 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(AcceptEditgroupResponse::NotFound(body))
+ }
+ 409 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(AcceptEditgroupResponse::EditConflict(body))
}
500 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(AuthCheckResponse::GenericError(body))
+ Ok(AcceptEditgroupResponse::GenericError(body))
}
code => {
let mut buf = [0; 100];
@@ -2063,10 +2370,10 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn auth_oidc(&self, param_oidc_params: models::AuthOidc, context: &Context) -> Box<Future<Item = AuthOidcResponse, Error = ApiError> + Send> {
- let url = format!("{}/v0/auth/oidc", self.base_path);
+ fn create_editgroup(&self, param_editgroup: models::Editgroup, context: &Context) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> {
+ let url = format!("{}/v0/editgroup", self.base_path);
- let body = serde_json::to_string(&param_oidc_params).expect("impossible to fail to serialize");
+ let body = serde_json::to_string(&param_editgroup).expect("impossible to fail to serialize");
let hyper_client = (self.hyper_client)();
let request = hyper_client.request(hyper::method::Method::Post, &url);
@@ -2074,34 +2381,27 @@ impl Api for Client {
let request = request.body(&body);
- custom_headers.set(ContentType(mimetypes::requests::AUTH_OIDC.clone()));
+ custom_headers.set(ContentType(mimetypes::requests::CREATE_EDITGROUP.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<AuthOidcResponse, ApiError> {
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<CreateEditgroupResponse, ApiError> {
match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::AuthOidcResult>(&buf)?;
-
- Ok(AuthOidcResponse::Found(body))
- }
201 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::AuthOidcResult>(&buf)?;
+ let body = serde_json::from_str::<models::Editgroup>(&buf)?;
- Ok(AuthOidcResponse::Created(body))
+ Ok(CreateEditgroupResponse::SuccessfullyCreated(body))
}
400 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(AuthOidcResponse::BadRequest(body))
+ Ok(CreateEditgroupResponse::BadRequest(body))
}
401 => {
let mut buf = String::new();
@@ -2113,7 +2413,7 @@ impl Api for Client {
.get::<ResponseWwwAuthenticate>()
.ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
- Ok(AuthOidcResponse::NotAuthorized {
+ Ok(CreateEditgroupResponse::NotAuthorized {
body: body,
www_authenticate: response_www_authenticate.0.clone(),
})
@@ -2123,21 +2423,21 @@ impl Api for Client {
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(AuthOidcResponse::Forbidden(body))
+ Ok(CreateEditgroupResponse::Forbidden(body))
}
- 409 => {
+ 404 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(AuthOidcResponse::Conflict(body))
+ Ok(CreateEditgroupResponse::NotFound(body))
}
500 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(AuthOidcResponse::GenericError(body))
+ Ok(CreateEditgroupResponse::GenericError(body))
}
code => {
let mut buf = [0; 100];
@@ -2157,131 +2457,83 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn get_editgroups_reviewable(
+ fn create_editgroup_annotation(
&self,
- param_expand: Option<String>,
- param_limit: Option<i64>,
- param_before: Option<chrono::DateTime<chrono::Utc>>,
- param_since: Option<chrono::DateTime<chrono::Utc>>,
+ param_editgroup_id: String,
+ param_annotation: models::EditgroupAnnotation,
context: &Context,
- ) -> Box<Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
- let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
- let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string()));
- let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string()));
-
+ ) -> Box<Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> {
let url = format!(
- "{}/v0/editgroup/reviewable?{expand}{limit}{before}{since}",
+ "{}/v0/editgroup/{editgroup_id}/annotation",
self.base_path,
- expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET),
- limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET),
- before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET),
- since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET)
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
);
+ let body = serde_json::to_string(&param_annotation).expect("impossible to fail to serialize");
+
let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Get, &url);
+ let request = hyper_client.request(hyper::method::Method::Post, &url);
let mut custom_headers = hyper::header::Headers::new();
+ let request = request.body(&body);
+
+ custom_headers.set(ContentType(mimetypes::requests::CREATE_EDITGROUP_ANNOTATION.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditgroupsReviewableResponse, ApiError> {
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<CreateEditgroupAnnotationResponse, ApiError> {
match response.status.to_u16() {
- 200 => {
+ 201 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::Editgroup>>(&buf)?;
+ let body = serde_json::from_str::<models::EditgroupAnnotation>(&buf)?;
- Ok(GetEditgroupsReviewableResponse::Found(body))
+ Ok(CreateEditgroupAnnotationResponse::Created(body))
}
400 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetEditgroupsReviewableResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditgroupsReviewableResponse::NotFound(body))
+ Ok(CreateEditgroupAnnotationResponse::BadRequest(body))
}
- 500 => {
+ 401 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+ header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
+ let response_www_authenticate = response
+ .headers
+ .get::<ResponseWwwAuthenticate>()
+ .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
- Ok(GetEditgroupsReviewableResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_editor(&self, param_editor_id: String, context: &Context) -> Box<Future<Item = GetEditorResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editor/{editor_id}",
- self.base_path,
- editor_id = utf8_percent_encode(&param_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Get, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditorResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editor>(&buf)?;
-
- Ok(GetEditorResponse::Found(body))
+ Ok(CreateEditgroupAnnotationResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate.0.clone(),
+ })
}
- 400 => {
+ 403 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetEditorResponse::BadRequest(body))
+ Ok(CreateEditgroupAnnotationResponse::Forbidden(body))
}
404 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetEditorResponse::NotFound(body))
+ Ok(CreateEditgroupAnnotationResponse::NotFound(body))
}
500 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetEditorResponse::GenericError(body))
+ Ok(CreateEditgroupAnnotationResponse::GenericError(body))
}
code => {
let mut buf = [0; 100];
@@ -2301,26 +2553,11 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn get_editor_editgroups(
- &self,
- param_editor_id: String,
- param_limit: Option<i64>,
- param_before: Option<chrono::DateTime<chrono::Utc>>,
- param_since: Option<chrono::DateTime<chrono::Utc>>,
- context: &Context,
- ) -> Box<Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
- let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string()));
- let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string()));
-
+ fn get_editgroup(&self, param_editgroup_id: String, context: &Context) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send> {
let url = format!(
- "{}/v0/editor/{editor_id}/editgroups?{limit}{before}{since}",
+ "{}/v0/editgroup/{editgroup_id}",
self.base_path,
- editor_id = utf8_percent_encode(&param_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET),
- before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET),
- since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET)
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
);
let hyper_client = (self.hyper_client)();
@@ -2332,35 +2569,35 @@ impl Api for Client {
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditorEditgroupsResponse, ApiError> {
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditgroupResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::Editgroup>>(&buf)?;
+ let body = serde_json::from_str::<models::Editgroup>(&buf)?;
- Ok(GetEditorEditgroupsResponse::Found(body))
+ Ok(GetEditgroupResponse::Found(body))
}
400 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetEditorEditgroupsResponse::BadRequest(body))
+ Ok(GetEditgroupResponse::BadRequest(body))
}
404 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetEditorEditgroupsResponse::NotFound(body))
+ Ok(GetEditgroupResponse::NotFound(body))
}
500 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetEditorEditgroupsResponse::GenericError(body))
+ Ok(GetEditgroupResponse::GenericError(body))
}
code => {
let mut buf = [0; 100];
@@ -2380,52 +2617,41 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn update_editgroup(
- &self,
- param_editgroup_id: String,
- param_editgroup: models::Editgroup,
- param_submit: Option<bool>,
- context: &Context,
- ) -> Box<Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send> {
+ fn get_editgroup_annotations(&self, param_editgroup_id: String, param_expand: Option<String>, context: &Context) -> Box<Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> {
// Query parameters
- let query_submit = param_submit.map_or_else(String::new, |query| format!("submit={submit}&", submit = query.to_string()));
+ let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
let url = format!(
- "{}/v0/editgroup/{editgroup_id}?{submit}",
+ "{}/v0/editgroup/{editgroup_id}/annotations?{expand}",
self.base_path,
editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- submit = utf8_percent_encode(&query_submit, QUERY_ENCODE_SET)
+ expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET)
);
- let body = serde_json::to_string(&param_editgroup).expect("impossible to fail to serialize");
-
let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Put, &url);
+ let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::UPDATE_EDITGROUP.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<UpdateEditgroupResponse, ApiError> {
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditgroupAnnotationsResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
+ let body = serde_json::from_str::<Vec<models::EditgroupAnnotation>>(&buf)?;
- Ok(UpdateEditgroupResponse::UpdatedEditgroup(body))
+ Ok(GetEditgroupAnnotationsResponse::Success(body))
}
400 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(UpdateEditgroupResponse::BadRequest(body))
+ Ok(GetEditgroupAnnotationsResponse::BadRequest(body))
}
401 => {
let mut buf = String::new();
@@ -2437,7 +2663,7 @@ impl Api for Client {
.get::<ResponseWwwAuthenticate>()
.ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
- Ok(UpdateEditgroupResponse::NotAuthorized {
+ Ok(GetEditgroupAnnotationsResponse::NotAuthorized {
body: body,
www_authenticate: response_www_authenticate.0.clone(),
})
@@ -2447,21 +2673,21 @@ impl Api for Client {
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(UpdateEditgroupResponse::Forbidden(body))
+ Ok(GetEditgroupAnnotationsResponse::Forbidden(body))
}
404 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(UpdateEditgroupResponse::NotFound(body))
+ Ok(GetEditgroupAnnotationsResponse::NotFound(body))
}
500 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(UpdateEditgroupResponse::GenericError(body))
+ Ok(GetEditgroupAnnotationsResponse::GenericError(body))
}
code => {
let mut buf = [0; 100];
@@ -2481,78 +2707,67 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn update_editor(&self, param_editor_id: String, param_editor: models::Editor, context: &Context) -> Box<Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
+ fn get_editgroups_reviewable(
+ &self,
+ param_expand: Option<String>,
+ param_limit: Option<i64>,
+ param_before: Option<chrono::DateTime<chrono::Utc>>,
+ param_since: Option<chrono::DateTime<chrono::Utc>>,
+ context: &Context,
+ ) -> Box<Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send> {
+ // Query parameters
+ let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
+ let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
+ let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string()));
+ let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string()));
+
let url = format!(
- "{}/v0/editor/{editor_id}",
+ "{}/v0/editgroup/reviewable?{expand}{limit}{before}{since}",
self.base_path,
- editor_id = utf8_percent_encode(&param_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET),
+ limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET),
+ before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET),
+ since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET)
);
- let body = serde_json::to_string(&param_editor).expect("impossible to fail to serialize");
-
let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Put, &url);
+ let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::UPDATE_EDITOR.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<UpdateEditorResponse, ApiError> {
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditgroupsReviewableResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editor>(&buf)?;
+ let body = serde_json::from_str::<Vec<models::Editgroup>>(&buf)?;
- Ok(UpdateEditorResponse::UpdatedEditor(body))
+ Ok(GetEditgroupsReviewableResponse::Found(body))
}
400 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(UpdateEditorResponse::BadRequest(body))
- }
- 401 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
-
- Ok(UpdateEditorResponse::NotAuthorized {
- body: body,
- www_authenticate: response_www_authenticate.0.clone(),
- })
- }
- 403 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(UpdateEditorResponse::Forbidden(body))
+ Ok(GetEditgroupsReviewableResponse::BadRequest(body))
}
404 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(UpdateEditorResponse::NotFound(body))
+ Ok(GetEditgroupsReviewableResponse::NotFound(body))
}
500 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(UpdateEditorResponse::GenericError(body))
+ Ok(GetEditgroupsReviewableResponse::GenericError(body))
}
code => {
let mut buf = [0; 100];
@@ -2572,37 +2787,52 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn accept_editgroup(&self, param_editgroup_id: String, context: &Context) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
+ fn update_editgroup(
+ &self,
+ param_editgroup_id: String,
+ param_editgroup: models::Editgroup,
+ param_submit: Option<bool>,
+ context: &Context,
+ ) -> Box<Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send> {
+ // Query parameters
+ let query_submit = param_submit.map_or_else(String::new, |query| format!("submit={submit}&", submit = query.to_string()));
+
let url = format!(
- "{}/v0/editgroup/{editgroup_id}/accept",
+ "{}/v0/editgroup/{editgroup_id}?{submit}",
self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
+ submit = utf8_percent_encode(&query_submit, QUERY_ENCODE_SET)
);
+ let body = serde_json::to_string(&param_editgroup).expect("impossible to fail to serialize");
+
let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Post, &url);
+ let request = hyper_client.request(hyper::method::Method::Put, &url);
let mut custom_headers = hyper::header::Headers::new();
+ let request = request.body(&body);
+
+ custom_headers.set(ContentType(mimetypes::requests::UPDATE_EDITGROUP.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<AcceptEditgroupResponse, ApiError> {
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<UpdateEditgroupResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Success>(&buf)?;
+ let body = serde_json::from_str::<models::Editgroup>(&buf)?;
- Ok(AcceptEditgroupResponse::MergedSuccessfully(body))
+ Ok(UpdateEditgroupResponse::UpdatedEditgroup(body))
}
400 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(AcceptEditgroupResponse::BadRequest(body))
+ Ok(UpdateEditgroupResponse::BadRequest(body))
}
401 => {
let mut buf = String::new();
@@ -2614,7 +2844,7 @@ impl Api for Client {
.get::<ResponseWwwAuthenticate>()
.ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
- Ok(AcceptEditgroupResponse::NotAuthorized {
+ Ok(UpdateEditgroupResponse::NotAuthorized {
body: body,
www_authenticate: response_www_authenticate.0.clone(),
})
@@ -2624,28 +2854,21 @@ impl Api for Client {
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(AcceptEditgroupResponse::Forbidden(body))
+ Ok(UpdateEditgroupResponse::Forbidden(body))
}
404 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(AcceptEditgroupResponse::NotFound(body))
- }
- 409 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(AcceptEditgroupResponse::EditConflict(body))
+ Ok(UpdateEditgroupResponse::NotFound(body))
}
500 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(AcceptEditgroupResponse::GenericError(body))
+ Ok(UpdateEditgroupResponse::GenericError(body))
}
code => {
let mut buf = [0; 100];
@@ -2665,74 +2888,51 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn create_editgroup(&self, param_editgroup: models::Editgroup, context: &Context) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> {
- let url = format!("{}/v0/editgroup", self.base_path);
-
- let body = serde_json::to_string(&param_editgroup).expect("impossible to fail to serialize");
+ fn get_editor(&self, param_editor_id: String, context: &Context) -> Box<Future<Item = GetEditorResponse, Error = ApiError> + Send> {
+ let url = format!(
+ "{}/v0/editor/{editor_id}",
+ self.base_path,
+ editor_id = utf8_percent_encode(&param_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ );
let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Post, &url);
+ let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::CREATE_EDITGROUP.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<CreateEditgroupResponse, ApiError> {
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditorResponse, ApiError> {
match response.status.to_u16() {
- 201 => {
+ 200 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
+ let body = serde_json::from_str::<models::Editor>(&buf)?;
- Ok(CreateEditgroupResponse::SuccessfullyCreated(body))
+ Ok(GetEditorResponse::Found(body))
}
400 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(CreateEditgroupResponse::BadRequest(body))
- }
- 401 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
-
- Ok(CreateEditgroupResponse::NotAuthorized {
- body: body,
- www_authenticate: response_www_authenticate.0.clone(),
- })
- }
- 403 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateEditgroupResponse::Forbidden(body))
+ Ok(GetEditorResponse::BadRequest(body))
}
404 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(CreateEditgroupResponse::NotFound(body))
+ Ok(GetEditorResponse::NotFound(body))
}
500 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(CreateEditgroupResponse::GenericError(body))
+ Ok(GetEditorResponse::GenericError(body))
}
code => {
let mut buf = [0; 100];
@@ -2752,47 +2952,52 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn create_editgroup_annotation(
+ fn get_editor_annotations(
&self,
- param_editgroup_id: String,
- param_annotation: models::EditgroupAnnotation,
+ param_editor_id: String,
+ param_limit: Option<i64>,
+ param_before: Option<chrono::DateTime<chrono::Utc>>,
+ param_since: Option<chrono::DateTime<chrono::Utc>>,
context: &Context,
- ) -> Box<Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> {
+ ) -> Box<Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send> {
+ // Query parameters
+ let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
+ let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string()));
+ let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string()));
+
let url = format!(
- "{}/v0/editgroup/{editgroup_id}/annotation",
+ "{}/v0/editor/{editor_id}/annotations?{limit}{before}{since}",
self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ editor_id = utf8_percent_encode(&param_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET),
+ limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET),
+ before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET),
+ since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET)
);
- let body = serde_json::to_string(&param_annotation).expect("impossible to fail to serialize");
-
let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Post, &url);
+ let request = hyper_client.request(hyper::method::Method::Get, &url);
let mut custom_headers = hyper::header::Headers::new();
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::CREATE_EDITGROUP_ANNOTATION.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<CreateEditgroupAnnotationResponse, ApiError> {
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditorAnnotationsResponse, ApiError> {
match response.status.to_u16() {
- 201 => {
+ 200 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EditgroupAnnotation>(&buf)?;
+ let body = serde_json::from_str::<Vec<models::EditgroupAnnotation>>(&buf)?;
- Ok(CreateEditgroupAnnotationResponse::Created(body))
+ Ok(GetEditorAnnotationsResponse::Success(body))
}
400 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(CreateEditgroupAnnotationResponse::BadRequest(body))
+ Ok(GetEditorAnnotationsResponse::BadRequest(body))
}
401 => {
let mut buf = String::new();
@@ -2804,7 +3009,7 @@ impl Api for Client {
.get::<ResponseWwwAuthenticate>()
.ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
- Ok(CreateEditgroupAnnotationResponse::NotAuthorized {
+ Ok(GetEditorAnnotationsResponse::NotAuthorized {
body: body,
www_authenticate: response_www_authenticate.0.clone(),
})
@@ -2814,21 +3019,21 @@ impl Api for Client {
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(CreateEditgroupAnnotationResponse::Forbidden(body))
+ Ok(GetEditorAnnotationsResponse::Forbidden(body))
}
404 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(CreateEditgroupAnnotationResponse::NotFound(body))
+ Ok(GetEditorAnnotationsResponse::NotFound(body))
}
500 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(CreateEditgroupAnnotationResponse::GenericError(body))
+ Ok(GetEditorAnnotationsResponse::GenericError(body))
}
code => {
let mut buf = [0; 100];
@@ -2848,67 +3053,26 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn get_changelog(&self, param_limit: Option<i64>, context: &Context) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send> {
+ fn get_editor_editgroups(
+ &self,
+ param_editor_id: String,
+ param_limit: Option<i64>,
+ param_before: Option<chrono::DateTime<chrono::Utc>>,
+ param_since: Option<chrono::DateTime<chrono::Utc>>,
+ context: &Context,
+ ) -> Box<Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send> {
// Query parameters
let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
+ let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string()));
+ let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string()));
- let url = format!("{}/v0/changelog?{limit}", self.base_path, limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET));
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Get, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<GetChangelogResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::ChangelogEntry>>(&buf)?;
-
- Ok(GetChangelogResponse::Success(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetChangelogResponse::BadRequest(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetChangelogResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_changelog_entry(&self, param_index: i64, context: &Context) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> {
let url = format!(
- "{}/v0/changelog/{index}",
+ "{}/v0/editor/{editor_id}/editgroups?{limit}{before}{since}",
self.base_path,
- index = utf8_percent_encode(&param_index.to_string(), PATH_SEGMENT_ENCODE_SET)
+ editor_id = utf8_percent_encode(&param_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET),
+ limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET),
+ before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET),
+ since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET)
);
let hyper_client = (self.hyper_client)();
@@ -2920,35 +3084,35 @@ impl Api for Client {
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<GetChangelogEntryResponse, ApiError> {
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditorEditgroupsResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ChangelogEntry>(&buf)?;
+ let body = serde_json::from_str::<Vec<models::Editgroup>>(&buf)?;
- Ok(GetChangelogEntryResponse::FoundChangelogEntry(body))
+ Ok(GetEditorEditgroupsResponse::Found(body))
}
400 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetChangelogEntryResponse::BadRequest(body))
+ Ok(GetEditorEditgroupsResponse::BadRequest(body))
}
404 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetChangelogEntryResponse::NotFound(body))
+ Ok(GetEditorEditgroupsResponse::NotFound(body))
}
500 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetChangelogEntryResponse::GenericError(body))
+ Ok(GetEditorEditgroupsResponse::GenericError(body))
}
code => {
let mut buf = [0; 100];
@@ -2968,206 +3132,42 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn get_editgroup(&self, param_editgroup_id: String, context: &Context) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send> {
+ fn update_editor(&self, param_editor_id: String, param_editor: models::Editor, context: &Context) -> Box<Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
let url = format!(
- "{}/v0/editgroup/{editgroup_id}",
+ "{}/v0/editor/{editor_id}",
self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ editor_id = utf8_percent_encode(&param_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET)
);
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Get, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditgroupResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::Editgroup>(&buf)?;
-
- Ok(GetEditgroupResponse::Found(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditgroupResponse::BadRequest(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditgroupResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditgroupResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_editgroup_annotations(&self, param_editgroup_id: String, param_expand: Option<String>, context: &Context) -> Box<Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string()));
-
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/annotations?{expand}",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET)
- );
+ let body = serde_json::to_string(&param_editor).expect("impossible to fail to serialize");
let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Get, &url);
+ let request = hyper_client.request(hyper::method::Method::Put, &url);
let mut custom_headers = hyper::header::Headers::new();
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditgroupAnnotationsResponse, ApiError> {
- match response.status.to_u16() {
- 200 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::EditgroupAnnotation>>(&buf)?;
-
- Ok(GetEditgroupAnnotationsResponse::Success(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditgroupAnnotationsResponse::BadRequest(body))
- }
- 401 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
-
- Ok(GetEditgroupAnnotationsResponse::NotAuthorized {
- body: body,
- www_authenticate: response_www_authenticate.0.clone(),
- })
- }
- 403 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditgroupAnnotationsResponse::Forbidden(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditgroupAnnotationsResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(GetEditgroupAnnotationsResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
- fn get_editor_annotations(
- &self,
- param_editor_id: String,
- param_limit: Option<i64>,
- param_before: Option<chrono::DateTime<chrono::Utc>>,
- param_since: Option<chrono::DateTime<chrono::Utc>>,
- context: &Context,
- ) -> Box<Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send> {
- // Query parameters
- let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string()));
- let query_before = param_before.map_or_else(String::new, |query| format!("before={before}&", before = query.to_string()));
- let query_since = param_since.map_or_else(String::new, |query| format!("since={since}&", since = query.to_string()));
-
- let url = format!(
- "{}/v0/editor/{editor_id}/annotations?{limit}{before}{since}",
- self.base_path,
- editor_id = utf8_percent_encode(&param_editor_id.to_string(), PATH_SEGMENT_ENCODE_SET),
- limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET),
- before = utf8_percent_encode(&query_before, QUERY_ENCODE_SET),
- since = utf8_percent_encode(&query_since, QUERY_ENCODE_SET)
- );
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Get, &url);
- let mut custom_headers = hyper::header::Headers::new();
+ let request = request.body(&body);
+ custom_headers.set(ContentType(mimetypes::requests::UPDATE_EDITOR.clone()));
context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
let request = request.headers(custom_headers);
// Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<GetEditorAnnotationsResponse, ApiError> {
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<UpdateEditorResponse, ApiError> {
match response.status.to_u16() {
200 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<Vec<models::EditgroupAnnotation>>(&buf)?;
+ let body = serde_json::from_str::<models::Editor>(&buf)?;
- Ok(GetEditorAnnotationsResponse::Success(body))
+ Ok(UpdateEditorResponse::UpdatedEditor(body))
}
400 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetEditorAnnotationsResponse::BadRequest(body))
+ Ok(UpdateEditorResponse::BadRequest(body))
}
401 => {
let mut buf = String::new();
@@ -3179,7 +3179,7 @@ impl Api for Client {
.get::<ResponseWwwAuthenticate>()
.ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
- Ok(GetEditorAnnotationsResponse::NotAuthorized {
+ Ok(UpdateEditorResponse::NotAuthorized {
body: body,
www_authenticate: response_www_authenticate.0.clone(),
})
@@ -3189,21 +3189,21 @@ impl Api for Client {
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetEditorAnnotationsResponse::Forbidden(body))
+ Ok(UpdateEditorResponse::Forbidden(body))
}
404 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetEditorAnnotationsResponse::NotFound(body))
+ Ok(UpdateEditorResponse::NotFound(body))
}
500 => {
let mut buf = String::new();
response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- Ok(GetEditorAnnotationsResponse::GenericError(body))
+ Ok(UpdateEditorResponse::GenericError(body))
}
code => {
let mut buf = [0; 100];
@@ -5062,97 +5062,6 @@ impl Api for Client {
Box::new(futures::done(result))
}
- fn create_work(&self, param_editgroup_id: String, param_entity: models::WorkEntity, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> {
- let url = format!(
- "{}/v0/editgroup/{editgroup_id}/work",
- self.base_path,
- editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
- );
-
- let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
-
- let hyper_client = (self.hyper_client)();
- let request = hyper_client.request(hyper::method::Method::Post, &url);
- let mut custom_headers = hyper::header::Headers::new();
-
- let request = request.body(&body);
-
- custom_headers.set(ContentType(mimetypes::requests::CREATE_WORK.clone()));
- context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
-
- let request = request.headers(custom_headers);
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn parse_response(mut response: hyper::client::response::Response) -> Result<CreateWorkResponse, ApiError> {
- match response.status.to_u16() {
- 201 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
-
- Ok(CreateWorkResponse::CreatedEntity(body))
- }
- 400 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateWorkResponse::BadRequest(body))
- }
- 401 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- let response_www_authenticate = response
- .headers
- .get::<ResponseWwwAuthenticate>()
- .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
-
- Ok(CreateWorkResponse::NotAuthorized {
- body: body,
- www_authenticate: response_www_authenticate.0.clone(),
- })
- }
- 403 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateWorkResponse::Forbidden(body))
- }
- 404 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateWorkResponse::NotFound(body))
- }
- 500 => {
- let mut buf = String::new();
- response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
- let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
-
- Ok(CreateWorkResponse::GenericError(body))
- }
- code => {
- let mut buf = [0; 100];
- let debug_body = match response.read(&mut buf) {
- Ok(len) => match str::from_utf8(&buf[..len]) {
- Ok(body) => Cow::from(body),
- Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
- },
- Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
- };
- Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
- }
- }
- }
-
- let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
- Box::new(futures::done(result))
- }
-
fn delete_release(&self, param_editgroup_id: String, param_ident: String, context: &Context) -> Box<Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> {
let url = format!(
"{}/v0/editgroup/{editgroup_id}/release/{ident}",
@@ -6867,6 +6776,97 @@ impl Api for Client {
Box::new(futures::done(result))
}
+ fn create_work(&self, param_editgroup_id: String, param_entity: models::WorkEntity, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> {
+ let url = format!(
+ "{}/v0/editgroup/{editgroup_id}/work",
+ self.base_path,
+ editgroup_id = utf8_percent_encode(&param_editgroup_id.to_string(), PATH_SEGMENT_ENCODE_SET)
+ );
+
+ let body = serde_json::to_string(&param_entity).expect("impossible to fail to serialize");
+
+ let hyper_client = (self.hyper_client)();
+ let request = hyper_client.request(hyper::method::Method::Post, &url);
+ let mut custom_headers = hyper::header::Headers::new();
+
+ let request = request.body(&body);
+
+ custom_headers.set(ContentType(mimetypes::requests::CREATE_WORK.clone()));
+ context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone())));
+
+ let request = request.headers(custom_headers);
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn parse_response(mut response: hyper::client::response::Response) -> Result<CreateWorkResponse, ApiError> {
+ match response.status.to_u16() {
+ 201 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::EntityEdit>(&buf)?;
+
+ Ok(CreateWorkResponse::CreatedEntity(body))
+ }
+ 400 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(CreateWorkResponse::BadRequest(body))
+ }
+ 401 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+ header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
+ let response_www_authenticate = response
+ .headers
+ .get::<ResponseWwwAuthenticate>()
+ .ok_or_else(|| "Required response header WWW_Authenticate for response 401 was not found.")?;
+
+ Ok(CreateWorkResponse::NotAuthorized {
+ body: body,
+ www_authenticate: response_www_authenticate.0.clone(),
+ })
+ }
+ 403 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(CreateWorkResponse::Forbidden(body))
+ }
+ 404 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(CreateWorkResponse::NotFound(body))
+ }
+ 500 => {
+ let mut buf = String::new();
+ response.read_to_string(&mut buf).map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e)))?;
+ let body = serde_json::from_str::<models::ErrorResponse>(&buf)?;
+
+ Ok(CreateWorkResponse::GenericError(body))
+ }
+ code => {
+ let mut buf = [0; 100];
+ let debug_body = match response.read(&mut buf) {
+ Ok(len) => match str::from_utf8(&buf[..len]) {
+ Ok(body) => Cow::from(body),
+ Err(_) => Cow::from(format!("<Body was not UTF8: {:?}>", &buf[..len].to_vec())),
+ },
+ Err(e) => Cow::from(format!("<Failed to read body: {}>", e)),
+ };
+ Err(ApiError(format!("Unexpected response code {}:\n{:?}\n\n{}", code, response.headers, debug_body)))
+ }
+ }
+ }
+
+ let result = request.send().map_err(|e| ApiError(format!("No response received: {}", e))).and_then(parse_response);
+ Box::new(futures::done(result))
+ }
+
fn create_work_auto_batch(&self, param_auto_batch: models::WorkAutoBatch, context: &Context) -> Box<Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send> {
let url = format!("{}/v0/editgroup/auto/work/batch", self.base_path);
diff --git a/rust/fatcat-openapi/src/lib.rs b/rust/fatcat-openapi/src/lib.rs
index b19b5793..da4f23af 100644
--- a/rust/fatcat-openapi/src/lib.rs
+++ b/rust/fatcat-openapi/src/lib.rs
@@ -33,6 +33,60 @@ mod mimetypes;
pub use swagger::{ApiError, Context, ContextWrapper};
#[derive(Debug, PartialEq)]
+pub enum AuthCheckResponse {
+ /// Success
+ Success(models::Success),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
+ /// Not Authorized
+ NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ /// Forbidden
+ Forbidden(models::ErrorResponse),
+ /// Generic Error
+ GenericError(models::ErrorResponse),
+}
+
+#[derive(Debug, PartialEq)]
+pub enum AuthOidcResponse {
+ /// Found
+ Found(models::AuthOidcResult),
+ /// Created
+ Created(models::AuthOidcResult),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
+ /// Not Authorized
+ NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ /// Forbidden
+ Forbidden(models::ErrorResponse),
+ /// Conflict
+ Conflict(models::ErrorResponse),
+ /// Generic Error
+ GenericError(models::ErrorResponse),
+}
+
+#[derive(Debug, PartialEq)]
+pub enum GetChangelogResponse {
+ /// Success
+ Success(Vec<models::ChangelogEntry>),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
+ /// Generic Error
+ GenericError(models::ErrorResponse),
+}
+
+#[derive(Debug, PartialEq)]
+pub enum GetChangelogEntryResponse {
+ /// Found Changelog Entry
+ FoundChangelogEntry(models::ChangelogEntry),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
+ /// Not Found
+ NotFound(models::ErrorResponse),
+ /// Generic Error
+ GenericError(models::ErrorResponse),
+}
+
+#[derive(Debug, PartialEq)]
pub enum CreateContainerResponse {
/// Created Entity
CreatedEntity(models::EntityEdit),
@@ -349,43 +403,33 @@ pub enum UpdateCreatorResponse {
}
#[derive(Debug, PartialEq)]
-pub enum AuthCheckResponse {
- /// Success
- Success(models::Success),
+pub enum AcceptEditgroupResponse {
+ /// Merged Successfully
+ MergedSuccessfully(models::Success),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
/// Forbidden
Forbidden(models::ErrorResponse),
+ /// Not Found
+ NotFound(models::ErrorResponse),
+ /// Edit Conflict
+ EditConflict(models::ErrorResponse),
/// Generic Error
GenericError(models::ErrorResponse),
}
#[derive(Debug, PartialEq)]
-pub enum AuthOidcResponse {
- /// Found
- Found(models::AuthOidcResult),
- /// Created
- Created(models::AuthOidcResult),
+pub enum CreateEditgroupResponse {
+ /// Successfully Created
+ SuccessfullyCreated(models::Editgroup),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
/// Forbidden
Forbidden(models::ErrorResponse),
- /// Conflict
- Conflict(models::ErrorResponse),
- /// Generic Error
- GenericError(models::ErrorResponse),
-}
-
-#[derive(Debug, PartialEq)]
-pub enum GetEditgroupsReviewableResponse {
- /// Found
- Found(Vec<models::Editgroup>),
- /// Bad Request
- BadRequest(models::ErrorResponse),
/// Not Found
NotFound(models::ErrorResponse),
/// Generic Error
@@ -393,11 +437,15 @@ pub enum GetEditgroupsReviewableResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetEditorResponse {
- /// Found
- Found(models::Editor),
+pub enum CreateEditgroupAnnotationResponse {
+ /// Created
+ Created(models::EditgroupAnnotation),
/// Bad Request
BadRequest(models::ErrorResponse),
+ /// Not Authorized
+ NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ /// Forbidden
+ Forbidden(models::ErrorResponse),
/// Not Found
NotFound(models::ErrorResponse),
/// Generic Error
@@ -405,9 +453,9 @@ pub enum GetEditorResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetEditorEditgroupsResponse {
+pub enum GetEditgroupResponse {
/// Found
- Found(Vec<models::Editgroup>),
+ Found(models::Editgroup),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -417,9 +465,9 @@ pub enum GetEditorEditgroupsResponse {
}
#[derive(Debug, PartialEq)]
-pub enum UpdateEditgroupResponse {
- /// Updated Editgroup
- UpdatedEditgroup(models::Editgroup),
+pub enum GetEditgroupAnnotationsResponse {
+ /// Success
+ Success(Vec<models::EditgroupAnnotation>),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
@@ -433,15 +481,11 @@ pub enum UpdateEditgroupResponse {
}
#[derive(Debug, PartialEq)]
-pub enum UpdateEditorResponse {
- /// Updated Editor
- UpdatedEditor(models::Editor),
+pub enum GetEditgroupsReviewableResponse {
+ /// Found
+ Found(Vec<models::Editgroup>),
/// Bad Request
BadRequest(models::ErrorResponse),
- /// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
- /// Forbidden
- Forbidden(models::ErrorResponse),
/// Not Found
NotFound(models::ErrorResponse),
/// Generic Error
@@ -449,9 +493,9 @@ pub enum UpdateEditorResponse {
}
#[derive(Debug, PartialEq)]
-pub enum AcceptEditgroupResponse {
- /// Merged Successfully
- MergedSuccessfully(models::Success),
+pub enum UpdateEditgroupResponse {
+ /// Updated Editgroup
+ UpdatedEditgroup(models::Editgroup),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
@@ -460,22 +504,16 @@ pub enum AcceptEditgroupResponse {
Forbidden(models::ErrorResponse),
/// Not Found
NotFound(models::ErrorResponse),
- /// Edit Conflict
- EditConflict(models::ErrorResponse),
/// Generic Error
GenericError(models::ErrorResponse),
}
#[derive(Debug, PartialEq)]
-pub enum CreateEditgroupResponse {
- /// Successfully Created
- SuccessfullyCreated(models::Editgroup),
+pub enum GetEditorResponse {
+ /// Found
+ Found(models::Editor),
/// Bad Request
BadRequest(models::ErrorResponse),
- /// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
- /// Forbidden
- Forbidden(models::ErrorResponse),
/// Not Found
NotFound(models::ErrorResponse),
/// Generic Error
@@ -483,9 +521,9 @@ pub enum CreateEditgroupResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateEditgroupAnnotationResponse {
- /// Created
- Created(models::EditgroupAnnotation),
+pub enum GetEditorAnnotationsResponse {
+ /// Success
+ Success(Vec<models::EditgroupAnnotation>),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
@@ -499,31 +537,9 @@ pub enum CreateEditgroupAnnotationResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetChangelogResponse {
- /// Success
- Success(Vec<models::ChangelogEntry>),
- /// Bad Request
- BadRequest(models::ErrorResponse),
- /// Generic Error
- GenericError(models::ErrorResponse),
-}
-
-#[derive(Debug, PartialEq)]
-pub enum GetChangelogEntryResponse {
- /// Found Changelog Entry
- FoundChangelogEntry(models::ChangelogEntry),
- /// Bad Request
- BadRequest(models::ErrorResponse),
- /// Not Found
- NotFound(models::ErrorResponse),
- /// Generic Error
- GenericError(models::ErrorResponse),
-}
-
-#[derive(Debug, PartialEq)]
-pub enum GetEditgroupResponse {
+pub enum GetEditorEditgroupsResponse {
/// Found
- Found(models::Editgroup),
+ Found(Vec<models::Editgroup>),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Found
@@ -533,25 +549,9 @@ pub enum GetEditgroupResponse {
}
#[derive(Debug, PartialEq)]
-pub enum GetEditgroupAnnotationsResponse {
- /// Success
- Success(Vec<models::EditgroupAnnotation>),
- /// Bad Request
- BadRequest(models::ErrorResponse),
- /// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
- /// Forbidden
- Forbidden(models::ErrorResponse),
- /// Not Found
- NotFound(models::ErrorResponse),
- /// Generic Error
- GenericError(models::ErrorResponse),
-}
-
-#[derive(Debug, PartialEq)]
-pub enum GetEditorAnnotationsResponse {
- /// Success
- Success(Vec<models::EditgroupAnnotation>),
+pub enum UpdateEditorResponse {
+ /// Updated Editor
+ UpdatedEditor(models::Editor),
/// Bad Request
BadRequest(models::ErrorResponse),
/// Not Authorized
@@ -889,22 +889,6 @@ pub enum CreateReleaseAutoBatchResponse {
}
#[derive(Debug, PartialEq)]
-pub enum CreateWorkResponse {
- /// Created Entity
- CreatedEntity(models::EntityEdit),
- /// Bad Request
- BadRequest(models::ErrorResponse),
- /// Not Authorized
- NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
- /// Forbidden
- Forbidden(models::ErrorResponse),
- /// Not Found
- NotFound(models::ErrorResponse),
- /// Generic Error
- GenericError(models::ErrorResponse),
-}
-
-#[derive(Debug, PartialEq)]
pub enum DeleteReleaseResponse {
/// Deleted Entity
DeletedEntity(models::EntityEdit),
@@ -1201,6 +1185,22 @@ pub enum UpdateWebcaptureResponse {
}
#[derive(Debug, PartialEq)]
+pub enum CreateWorkResponse {
+ /// Created Entity
+ CreatedEntity(models::EntityEdit),
+ /// Bad Request
+ BadRequest(models::ErrorResponse),
+ /// Not Authorized
+ NotAuthorized { body: models::ErrorResponse, www_authenticate: String },
+ /// Forbidden
+ Forbidden(models::ErrorResponse),
+ /// Not Found
+ NotFound(models::ErrorResponse),
+ /// Generic Error
+ GenericError(models::ErrorResponse),
+}
+
+#[derive(Debug, PartialEq)]
pub enum CreateWorkAutoBatchResponse {
/// Created Editgroup
CreatedEditgroup(models::Editgroup),
@@ -1338,6 +1338,14 @@ pub enum UpdateWorkResponse {
/// API
pub trait Api {
+ fn auth_check(&self, role: Option<String>, context: &Context) -> Box<Future<Item = AuthCheckResponse, Error = ApiError> + Send>;
+
+ fn auth_oidc(&self, oidc_params: models::AuthOidc, context: &Context) -> Box<Future<Item = AuthOidcResponse, Error = ApiError> + Send>;
+
+ fn get_changelog(&self, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send>;
+
+ fn get_changelog_entry(&self, index: i64, context: &Context) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send>;
+
fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity, context: &Context) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send>;
fn create_container_auto_batch(&self, auto_batch: models::ContainerAutoBatch, context: &Context) -> Box<Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send>;
@@ -1398,9 +1406,20 @@ pub trait Api {
fn update_creator(&self, editgroup_id: String, ident: String, entity: models::CreatorEntity, context: &Context) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>;
- fn auth_check(&self, role: Option<String>, context: &Context) -> Box<Future<Item = AuthCheckResponse, Error = ApiError> + Send>;
+ fn accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>;
- fn auth_oidc(&self, oidc_params: models::AuthOidc, context: &Context) -> Box<Future<Item = AuthOidcResponse, Error = ApiError> + Send>;
+ fn create_editgroup(&self, editgroup: models::Editgroup, context: &Context) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>;
+
+ fn create_editgroup_annotation(
+ &self,
+ editgroup_id: String,
+ annotation: models::EditgroupAnnotation,
+ context: &Context,
+ ) -> Box<Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send>;
+
+ fn get_editgroup(&self, editgroup_id: String, context: &Context) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send>;
+
+ fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send>;
fn get_editgroups_reviewable(
&self,
@@ -1411,48 +1430,29 @@ pub trait Api {
context: &Context,
) -> Box<Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send>;
+ fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option<bool>, context: &Context) -> Box<Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send>;
+
fn get_editor(&self, editor_id: String, context: &Context) -> Box<Future<Item = GetEditorResponse, Error = ApiError> + Send>;
- fn get_editor_editgroups(
+ fn get_editor_annotations(
&self,
editor_id: String,
limit: Option<i64>,
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
context: &Context,
- ) -> Box<Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send>;
-
- fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option<bool>, context: &Context) -> Box<Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send>;
-
- fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box<Future<Item = UpdateEditorResponse, Error = ApiError> + Send>;
-
- fn accept_editgroup(&self, editgroup_id: String, context: &Context) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>;
-
- fn create_editgroup(&self, editgroup: models::Editgroup, context: &Context) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>;
-
- fn create_editgroup_annotation(
- &self,
- editgroup_id: String,
- annotation: models::EditgroupAnnotation,
- context: &Context,
- ) -> Box<Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send>;
-
- fn get_changelog(&self, limit: Option<i64>, context: &Context) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send>;
-
- fn get_changelog_entry(&self, index: i64, context: &Context) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send>;
-
- fn get_editgroup(&self, editgroup_id: String, context: &Context) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send>;
-
- fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option<String>, context: &Context) -> Box<Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send>;
+ ) -> Box<Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send>;
- fn get_editor_annotations(
+ fn get_editor_editgroups(
&self,
editor_id: String,
limit: Option<i64>,
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
context: &Context,
- ) -> Box<Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send>;
+ ) -> Box<Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send>;
+
+ fn update_editor(&self, editor_id: String, editor: models::Editor, context: &Context) -> Box<Future<Item = UpdateEditorResponse, Error = ApiError> + Send>;
fn create_file(&self, editgroup_id: String, entity: models::FileEntity, context: &Context) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send>;
@@ -1508,8 +1508,6 @@ pub trait Api {
fn create_release_auto_batch(&self, auto_batch: models::ReleaseAutoBatch, context: &Context) -> Box<Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send>;
- fn create_work(&self, editgroup_id: String, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send>;
-
fn delete_release(&self, editgroup_id: String, ident: String, context: &Context) -> Box<Future<Item = DeleteReleaseResponse, Error = ApiError> + Send>;
fn delete_release_edit(&self, editgroup_id: String, edit_id: String, context: &Context) -> Box<Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send>;
@@ -1569,6 +1567,8 @@ pub trait Api {
fn update_webcapture(&self, editgroup_id: String, ident: String, entity: models::WebcaptureEntity, context: &Context) -> Box<Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send>;
+ fn create_work(&self, editgroup_id: String, entity: models::WorkEntity, context: &Context) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send>;
+
fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch, context: &Context) -> Box<Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send>;
fn delete_work(&self, editgroup_id: String, ident: String, context: &Context) -> Box<Future<Item = DeleteWorkResponse, Error = ApiError> + Send>;
@@ -1592,6 +1592,14 @@ pub trait Api {
/// API without a `Context`
pub trait ApiNoContext {
+ fn auth_check(&self, role: Option<String>) -> Box<Future<Item = AuthCheckResponse, Error = ApiError> + Send>;
+
+ fn auth_oidc(&self, oidc_params: models::AuthOidc) -> Box<Future<Item = AuthOidcResponse, Error = ApiError> + Send>;
+
+ fn get_changelog(&self, limit: Option<i64>) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send>;
+
+ fn get_changelog_entry(&self, index: i64) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send>;
+
fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send>;
fn create_container_auto_batch(&self, auto_batch: models::ContainerAutoBatch) -> Box<Future<Item = CreateContainerAutoBatchResponse, Error = ApiError> + Send>;
@@ -1644,9 +1652,15 @@ pub trait ApiNoContext {
fn update_creator(&self, editgroup_id: String, ident: String, entity: models::CreatorEntity) -> Box<Future<Item = UpdateCreatorResponse, Error = ApiError> + Send>;
- fn auth_check(&self, role: Option<String>) -> Box<Future<Item = AuthCheckResponse, Error = ApiError> + Send>;
+ fn accept_editgroup(&self, editgroup_id: String) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>;
- fn auth_oidc(&self, oidc_params: models::AuthOidc) -> Box<Future<Item = AuthOidcResponse, Error = ApiError> + Send>;
+ fn create_editgroup(&self, editgroup: models::Editgroup) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>;
+
+ fn create_editgroup_annotation(&self, editgroup_id: String, annotation: models::EditgroupAnnotation) -> Box<Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send>;
+
+ fn get_editgroup(&self, editgroup_id: String) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send>;
+
+ fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option<String>) -> Box<Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send>;
fn get_editgroups_reviewable(
&self,
@@ -1656,41 +1670,27 @@ pub trait ApiNoContext {
since: Option<chrono::DateTime<chrono::Utc>>,
) -> Box<Future<Item = GetEditgroupsReviewableResponse, Error = ApiError> + Send>;
+ fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option<bool>) -> Box<Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send>;
+
fn get_editor(&self, editor_id: String) -> Box<Future<Item = GetEditorResponse, Error = ApiError> + Send>;
- fn get_editor_editgroups(
+ fn get_editor_annotations(
&self,
editor_id: String,
limit: Option<i64>,
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
- ) -> Box<Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send>;
-
- fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option<bool>) -> Box<Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send>;
-
- fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box<Future<Item = UpdateEditorResponse, Error = ApiError> + Send>;
-
- fn accept_editgroup(&self, editgroup_id: String) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send>;
-
- fn create_editgroup(&self, editgroup: models::Editgroup) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send>;
-
- fn create_editgroup_annotation(&self, editgroup_id: String, annotation: models::EditgroupAnnotation) -> Box<Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send>;
-
- fn get_changelog(&self, limit: Option<i64>) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send>;
-
- fn get_changelog_entry(&self, index: i64) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send>;
-
- fn get_editgroup(&self, editgroup_id: String) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send>;
-
- fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option<String>) -> Box<Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send>;
+ ) -> Box<Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send>;
- fn get_editor_annotations(
+ fn get_editor_editgroups(
&self,
editor_id: String,
limit: Option<i64>,
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
- ) -> Box<Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send>;
+ ) -> Box<Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send>;
+
+ fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box<Future<Item = UpdateEditorResponse, Error = ApiError> + Send>;
fn create_file(&self, editgroup_id: String, entity: models::FileEntity) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send>;
@@ -1745,8 +1745,6 @@ pub trait ApiNoContext {
fn create_release_auto_batch(&self, auto_batch: models::ReleaseAutoBatch) -> Box<Future<Item = CreateReleaseAutoBatchResponse, Error = ApiError> + Send>;
- fn create_work(&self, editgroup_id: String, entity: models::WorkEntity) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send>;
-
fn delete_release(&self, editgroup_id: String, ident: String) -> Box<Future<Item = DeleteReleaseResponse, Error = ApiError> + Send>;
fn delete_release_edit(&self, editgroup_id: String, edit_id: String) -> Box<Future<Item = DeleteReleaseEditResponse, Error = ApiError> + Send>;
@@ -1805,6 +1803,8 @@ pub trait ApiNoContext {
fn update_webcapture(&self, editgroup_id: String, ident: String, entity: models::WebcaptureEntity) -> Box<Future<Item = UpdateWebcaptureResponse, Error = ApiError> + Send>;
+ fn create_work(&self, editgroup_id: String, entity: models::WorkEntity) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send>;
+
fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch) -> Box<Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send>;
fn delete_work(&self, editgroup_id: String, ident: String) -> Box<Future<Item = DeleteWorkResponse, Error = ApiError> + Send>;
@@ -1842,6 +1842,22 @@ impl<'a, T: Api + Sized> ContextWrapperExt<'a> for T {
}
impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
+ fn auth_check(&self, role: Option<String>) -> Box<Future<Item = AuthCheckResponse, Error = ApiError> + Send> {
+ self.api().auth_check(role, &self.context())
+ }
+
+ fn auth_oidc(&self, oidc_params: models::AuthOidc) -> Box<Future<Item = AuthOidcResponse, Error = ApiError> + Send> {
+ self.api().auth_oidc(oidc_params, &self.context())
+ }
+
+ fn get_changelog(&self, limit: Option<i64>) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send> {
+ self.api().get_changelog(limit, &self.context())
+ }
+
+ fn get_changelog_entry(&self, index: i64) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> {
+ self.api().get_changelog_entry(index, &self.context())
+ }
+
fn create_container(&self, editgroup_id: String, entity: models::ContainerEntity) -> Box<Future<Item = CreateContainerResponse, Error = ApiError> + Send> {
self.api().create_container(editgroup_id, entity, &self.context())
}
@@ -1940,12 +1956,24 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
self.api().update_creator(editgroup_id, ident, entity, &self.context())
}
- fn auth_check(&self, role: Option<String>) -> Box<Future<Item = AuthCheckResponse, Error = ApiError> + Send> {
- self.api().auth_check(role, &self.context())
+ fn accept_editgroup(&self, editgroup_id: String) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
+ self.api().accept_editgroup(editgroup_id, &self.context())
}
- fn auth_oidc(&self, oidc_params: models::AuthOidc) -> Box<Future<Item = AuthOidcResponse, Error = ApiError> + Send> {
- self.api().auth_oidc(oidc_params, &self.context())
+ fn create_editgroup(&self, editgroup: models::Editgroup) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> {
+ self.api().create_editgroup(editgroup, &self.context())
+ }
+
+ fn create_editgroup_annotation(&self, editgroup_id: String, annotation: models::EditgroupAnnotation) -> Box<Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> {
+ self.api().create_editgroup_annotation(editgroup_id, annotation, &self.context())
+ }
+
+ fn get_editgroup(&self, editgroup_id: String) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send> {
+ self.api().get_editgroup(editgroup_id, &self.context())
+ }
+
+ fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option<String>) -> Box<Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> {
+ self.api().get_editgroup_annotations(editgroup_id, expand, &self.context())
}
fn get_editgroups_reviewable(
@@ -1958,64 +1986,36 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
self.api().get_editgroups_reviewable(expand, limit, before, since, &self.context())
}
+ fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option<bool>) -> Box<Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send> {
+ self.api().update_editgroup(editgroup_id, editgroup, submit, &self.context())
+ }
+
fn get_editor(&self, editor_id: String) -> Box<Future<Item = GetEditorResponse, Error = ApiError> + Send> {
self.api().get_editor(editor_id, &self.context())
}
- fn get_editor_editgroups(
+ fn get_editor_annotations(
&self,
editor_id: String,
limit: Option<i64>,
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
- ) -> Box<Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send> {
- self.api().get_editor_editgroups(editor_id, limit, before, since, &self.context())
- }
-
- fn update_editgroup(&self, editgroup_id: String, editgroup: models::Editgroup, submit: Option<bool>) -> Box<Future<Item = UpdateEditgroupResponse, Error = ApiError> + Send> {
- self.api().update_editgroup(editgroup_id, editgroup, submit, &self.context())
- }
-
- fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box<Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
- self.api().update_editor(editor_id, editor, &self.context())
- }
-
- fn accept_editgroup(&self, editgroup_id: String) -> Box<Future<Item = AcceptEditgroupResponse, Error = ApiError> + Send> {
- self.api().accept_editgroup(editgroup_id, &self.context())
- }
-
- fn create_editgroup(&self, editgroup: models::Editgroup) -> Box<Future<Item = CreateEditgroupResponse, Error = ApiError> + Send> {
- self.api().create_editgroup(editgroup, &self.context())
- }
-
- fn create_editgroup_annotation(&self, editgroup_id: String, annotation: models::EditgroupAnnotation) -> Box<Future<Item = CreateEditgroupAnnotationResponse, Error = ApiError> + Send> {
- self.api().create_editgroup_annotation(editgroup_id, annotation, &self.context())
- }
-
- fn get_changelog(&self, limit: Option<i64>) -> Box<Future<Item = GetChangelogResponse, Error = ApiError> + Send> {
- self.api().get_changelog(limit, &self.context())
- }
-
- fn get_changelog_entry(&self, index: i64) -> Box<Future<Item = GetChangelogEntryResponse, Error = ApiError> + Send> {
- self.api().get_changelog_entry(index, &self.context())
- }
-
- fn get_editgroup(&self, editgroup_id: String) -> Box<Future<Item = GetEditgroupResponse, Error = ApiError> + Send> {
- self.api().get_editgroup(editgroup_id, &self.context())
- }
-
- fn get_editgroup_annotations(&self, editgroup_id: String, expand: Option<String>) -> Box<Future<Item = GetEditgroupAnnotationsResponse, Error = ApiError> + Send> {
- self.api().get_editgroup_annotations(editgroup_id, expand, &self.context())
+ ) -> Box<Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send> {
+ self.api().get_editor_annotations(editor_id, limit, before, since, &self.context())
}
- fn get_editor_annotations(
+ fn get_editor_editgroups(
&self,
editor_id: String,
limit: Option<i64>,
before: Option<chrono::DateTime<chrono::Utc>>,
since: Option<chrono::DateTime<chrono::Utc>>,
- ) -> Box<Future<Item = GetEditorAnnotationsResponse, Error = ApiError> + Send> {
- self.api().get_editor_annotations(editor_id, limit, before, since, &self.context())
+ ) -> Box<Future<Item = GetEditorEditgroupsResponse, Error = ApiError> + Send> {
+ self.api().get_editor_editgroups(editor_id, limit, before, since, &self.context())
+ }
+
+ fn update_editor(&self, editor_id: String, editor: models::Editor) -> Box<Future<Item = UpdateEditorResponse, Error = ApiError> + Send> {
+ self.api().update_editor(editor_id, editor, &self.context())
}
fn create_file(&self, editgroup_id: String, entity: models::FileEntity) -> Box<Future<Item = CreateFileResponse, Error = ApiError> + Send> {
@@ -2117,10 +2117,6 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
self.api().create_release_auto_batch(auto_batch, &self.context())
}
- fn create_work(&self, editgroup_id: String, entity: models::WorkEntity) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> {
- self.api().create_work(editgroup_id, entity, &self.context())
- }
-
fn delete_release(&self, editgroup_id: String, ident: String) -> Box<Future<Item = DeleteReleaseResponse, Error = ApiError> + Send> {
self.api().delete_release(editgroup_id, ident, &self.context())
}
@@ -2224,6 +2220,10 @@ impl<'a, T: Api> ApiNoContext for ContextWrapper<'a, T> {
self.api().update_webcapture(editgroup_id, ident, entity, &self.context())
}
+ fn create_work(&self, editgroup_id: String, entity: models::WorkEntity) -> Box<Future<Item = CreateWorkResponse, Error = ApiError> + Send> {
+ self.api().create_work(editgroup_id, entity, &self.context())
+ }
+
fn create_work_auto_batch(&self, auto_batch: models::WorkAutoBatch) -> Box<Future<Item = CreateWorkAutoBatchResponse, Error = ApiError> + Send> {
self.api().create_work_auto_batch(auto_batch, &self.context())
}
diff --git a/rust/fatcat-openapi/src/mimetypes.rs b/rust/fatcat-openapi/src/mimetypes.rs
index 0676f63b..ef297f69 100644
--- a/rust/fatcat-openapi/src/mimetypes.rs
+++ b/rust/fatcat-openapi/src/mimetypes.rs
@@ -4,6 +4,82 @@ pub mod responses {
use hyper::mime::*;
// The macro is called per-operation to beat the recursion limit
+ /// Create Mime objects for the response content types for AuthCheck
+ lazy_static! {
+ pub static ref AUTH_CHECK_SUCCESS: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for AuthCheck
+ lazy_static! {
+ pub static ref AUTH_CHECK_BAD_REQUEST: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for AuthCheck
+ lazy_static! {
+ pub static ref AUTH_CHECK_NOT_AUTHORIZED: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for AuthCheck
+ lazy_static! {
+ pub static ref AUTH_CHECK_FORBIDDEN: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for AuthCheck
+ lazy_static! {
+ pub static ref AUTH_CHECK_GENERIC_ERROR: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for AuthOidc
+ lazy_static! {
+ pub static ref AUTH_OIDC_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for AuthOidc
+ lazy_static! {
+ pub static ref AUTH_OIDC_CREATED: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for AuthOidc
+ lazy_static! {
+ pub static ref AUTH_OIDC_BAD_REQUEST: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for AuthOidc
+ lazy_static! {
+ pub static ref AUTH_OIDC_NOT_AUTHORIZED: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for AuthOidc
+ lazy_static! {
+ pub static ref AUTH_OIDC_FORBIDDEN: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for AuthOidc
+ lazy_static! {
+ pub static ref AUTH_OIDC_CONFLICT: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for AuthOidc
+ lazy_static! {
+ pub static ref AUTH_OIDC_GENERIC_ERROR: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetChangelog
+ lazy_static! {
+ pub static ref GET_CHANGELOG_SUCCESS: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetChangelog
+ lazy_static! {
+ pub static ref GET_CHANGELOG_BAD_REQUEST: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetChangelog
+ lazy_static! {
+ pub static ref GET_CHANGELOG_GENERIC_ERROR: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetChangelogEntry
+ lazy_static! {
+ pub static ref GET_CHANGELOG_ENTRY_FOUND_CHANGELOG_ENTRY: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetChangelogEntry
+ lazy_static! {
+ pub static ref GET_CHANGELOG_ENTRY_BAD_REQUEST: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetChangelogEntry
+ lazy_static! {
+ pub static ref GET_CHANGELOG_ENTRY_NOT_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetChangelogEntry
+ lazy_static! {
+ pub static ref GET_CHANGELOG_ENTRY_GENERIC_ERROR: Mime = mime!(Application / Json);
+ }
/// Create Mime objects for the response content types for CreateContainer
lazy_static! {
pub static ref CREATE_CONTAINER_CREATED_ENTITY: Mime = mime!(Application / Json);
@@ -452,150 +528,6 @@ pub mod responses {
lazy_static! {
pub static ref UPDATE_CREATOR_GENERIC_ERROR: Mime = mime!(Application / Json);
}
- /// Create Mime objects for the response content types for AuthCheck
- lazy_static! {
- pub static ref AUTH_CHECK_SUCCESS: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for AuthCheck
- lazy_static! {
- pub static ref AUTH_CHECK_BAD_REQUEST: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for AuthCheck
- lazy_static! {
- pub static ref AUTH_CHECK_NOT_AUTHORIZED: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for AuthCheck
- lazy_static! {
- pub static ref AUTH_CHECK_FORBIDDEN: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for AuthCheck
- lazy_static! {
- pub static ref AUTH_CHECK_GENERIC_ERROR: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for AuthOidc
- lazy_static! {
- pub static ref AUTH_OIDC_FOUND: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for AuthOidc
- lazy_static! {
- pub static ref AUTH_OIDC_CREATED: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for AuthOidc
- lazy_static! {
- pub static ref AUTH_OIDC_BAD_REQUEST: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for AuthOidc
- lazy_static! {
- pub static ref AUTH_OIDC_NOT_AUTHORIZED: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for AuthOidc
- lazy_static! {
- pub static ref AUTH_OIDC_FORBIDDEN: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for AuthOidc
- lazy_static! {
- pub static ref AUTH_OIDC_CONFLICT: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for AuthOidc
- lazy_static! {
- pub static ref AUTH_OIDC_GENERIC_ERROR: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditgroupsReviewable
- lazy_static! {
- pub static ref GET_EDITGROUPS_REVIEWABLE_FOUND: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditgroupsReviewable
- lazy_static! {
- pub static ref GET_EDITGROUPS_REVIEWABLE_BAD_REQUEST: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditgroupsReviewable
- lazy_static! {
- pub static ref GET_EDITGROUPS_REVIEWABLE_NOT_FOUND: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditgroupsReviewable
- lazy_static! {
- pub static ref GET_EDITGROUPS_REVIEWABLE_GENERIC_ERROR: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditor
- lazy_static! {
- pub static ref GET_EDITOR_FOUND: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditor
- lazy_static! {
- pub static ref GET_EDITOR_BAD_REQUEST: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditor
- lazy_static! {
- pub static ref GET_EDITOR_NOT_FOUND: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditor
- lazy_static! {
- pub static ref GET_EDITOR_GENERIC_ERROR: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditorEditgroups
- lazy_static! {
- pub static ref GET_EDITOR_EDITGROUPS_FOUND: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditorEditgroups
- lazy_static! {
- pub static ref GET_EDITOR_EDITGROUPS_BAD_REQUEST: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditorEditgroups
- lazy_static! {
- pub static ref GET_EDITOR_EDITGROUPS_NOT_FOUND: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetEditorEditgroups
- lazy_static! {
- pub static ref GET_EDITOR_EDITGROUPS_GENERIC_ERROR: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditgroup
- lazy_static! {
- pub static ref UPDATE_EDITGROUP_UPDATED_EDITGROUP: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditgroup
- lazy_static! {
- pub static ref UPDATE_EDITGROUP_BAD_REQUEST: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditgroup
- lazy_static! {
- pub static ref UPDATE_EDITGROUP_NOT_AUTHORIZED: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditgroup
- lazy_static! {
- pub static ref UPDATE_EDITGROUP_FORBIDDEN: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditgroup
- lazy_static! {
- pub static ref UPDATE_EDITGROUP_NOT_FOUND: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditgroup
- lazy_static! {
- pub static ref UPDATE_EDITGROUP_GENERIC_ERROR: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditor
- lazy_static! {
- pub static ref UPDATE_EDITOR_UPDATED_EDITOR: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditor
- lazy_static! {
- pub static ref UPDATE_EDITOR_BAD_REQUEST: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditor
- lazy_static! {
- pub static ref UPDATE_EDITOR_NOT_AUTHORIZED: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditor
- lazy_static! {
- pub static ref UPDATE_EDITOR_FORBIDDEN: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditor
- lazy_static! {
- pub static ref UPDATE_EDITOR_NOT_FOUND: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for UpdateEditor
- lazy_static! {
- pub static ref UPDATE_EDITOR_GENERIC_ERROR: Mime = mime!(Application / Json);
- }
/// Create Mime objects for the response content types for AcceptEditgroup
lazy_static! {
pub static ref ACCEPT_EDITGROUP_MERGED_SUCCESSFULLY: Mime = mime!(Application / Json);
@@ -672,34 +604,6 @@ pub mod responses {
lazy_static! {
pub static ref CREATE_EDITGROUP_ANNOTATION_GENERIC_ERROR: Mime = mime!(Application / Json);
}
- /// Create Mime objects for the response content types for GetChangelog
- lazy_static! {
- pub static ref GET_CHANGELOG_SUCCESS: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetChangelog
- lazy_static! {
- pub static ref GET_CHANGELOG_BAD_REQUEST: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetChangelog
- lazy_static! {
- pub static ref GET_CHANGELOG_GENERIC_ERROR: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetChangelogEntry
- lazy_static! {
- pub static ref GET_CHANGELOG_ENTRY_FOUND_CHANGELOG_ENTRY: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetChangelogEntry
- lazy_static! {
- pub static ref GET_CHANGELOG_ENTRY_BAD_REQUEST: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetChangelogEntry
- lazy_static! {
- pub static ref GET_CHANGELOG_ENTRY_NOT_FOUND: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for GetChangelogEntry
- lazy_static! {
- pub static ref GET_CHANGELOG_ENTRY_GENERIC_ERROR: Mime = mime!(Application / Json);
- }
/// Create Mime objects for the response content types for GetEditgroup
lazy_static! {
pub static ref GET_EDITGROUP_FOUND: Mime = mime!(Application / Json);
@@ -740,6 +644,62 @@ pub mod responses {
lazy_static! {
pub static ref GET_EDITGROUP_ANNOTATIONS_GENERIC_ERROR: Mime = mime!(Application / Json);
}
+ /// Create Mime objects for the response content types for GetEditgroupsReviewable
+ lazy_static! {
+ pub static ref GET_EDITGROUPS_REVIEWABLE_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditgroupsReviewable
+ lazy_static! {
+ pub static ref GET_EDITGROUPS_REVIEWABLE_BAD_REQUEST: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditgroupsReviewable
+ lazy_static! {
+ pub static ref GET_EDITGROUPS_REVIEWABLE_NOT_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditgroupsReviewable
+ lazy_static! {
+ pub static ref GET_EDITGROUPS_REVIEWABLE_GENERIC_ERROR: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditgroup
+ lazy_static! {
+ pub static ref UPDATE_EDITGROUP_UPDATED_EDITGROUP: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditgroup
+ lazy_static! {
+ pub static ref UPDATE_EDITGROUP_BAD_REQUEST: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditgroup
+ lazy_static! {
+ pub static ref UPDATE_EDITGROUP_NOT_AUTHORIZED: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditgroup
+ lazy_static! {
+ pub static ref UPDATE_EDITGROUP_FORBIDDEN: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditgroup
+ lazy_static! {
+ pub static ref UPDATE_EDITGROUP_NOT_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditgroup
+ lazy_static! {
+ pub static ref UPDATE_EDITGROUP_GENERIC_ERROR: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditor
+ lazy_static! {
+ pub static ref GET_EDITOR_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditor
+ lazy_static! {
+ pub static ref GET_EDITOR_BAD_REQUEST: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditor
+ lazy_static! {
+ pub static ref GET_EDITOR_NOT_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditor
+ lazy_static! {
+ pub static ref GET_EDITOR_GENERIC_ERROR: Mime = mime!(Application / Json);
+ }
/// Create Mime objects for the response content types for GetEditorAnnotations
lazy_static! {
pub static ref GET_EDITOR_ANNOTATIONS_SUCCESS: Mime = mime!(Application / Json);
@@ -764,6 +724,46 @@ pub mod responses {
lazy_static! {
pub static ref GET_EDITOR_ANNOTATIONS_GENERIC_ERROR: Mime = mime!(Application / Json);
}
+ /// Create Mime objects for the response content types for GetEditorEditgroups
+ lazy_static! {
+ pub static ref GET_EDITOR_EDITGROUPS_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditorEditgroups
+ lazy_static! {
+ pub static ref GET_EDITOR_EDITGROUPS_BAD_REQUEST: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditorEditgroups
+ lazy_static! {
+ pub static ref GET_EDITOR_EDITGROUPS_NOT_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for GetEditorEditgroups
+ lazy_static! {
+ pub static ref GET_EDITOR_EDITGROUPS_GENERIC_ERROR: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditor
+ lazy_static! {
+ pub static ref UPDATE_EDITOR_UPDATED_EDITOR: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditor
+ lazy_static! {
+ pub static ref UPDATE_EDITOR_BAD_REQUEST: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditor
+ lazy_static! {
+ pub static ref UPDATE_EDITOR_NOT_AUTHORIZED: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditor
+ lazy_static! {
+ pub static ref UPDATE_EDITOR_FORBIDDEN: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditor
+ lazy_static! {
+ pub static ref UPDATE_EDITOR_NOT_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for UpdateEditor
+ lazy_static! {
+ pub static ref UPDATE_EDITOR_GENERIC_ERROR: Mime = mime!(Application / Json);
+ }
/// Create Mime objects for the response content types for CreateFile
lazy_static! {
pub static ref CREATE_FILE_CREATED_ENTITY: Mime = mime!(Application / Json);
@@ -1228,30 +1228,6 @@ pub mod responses {
lazy_static! {
pub static ref CREATE_RELEASE_AUTO_BATCH_GENERIC_ERROR: Mime = mime!(Application / Json);
}
- /// Create Mime objects for the response content types for CreateWork
- lazy_static! {
- pub static ref CREATE_WORK_CREATED_ENTITY: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for CreateWork
- lazy_static! {
- pub static ref CREATE_WORK_BAD_REQUEST: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for CreateWork
- lazy_static! {
- pub static ref CREATE_WORK_NOT_AUTHORIZED: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for CreateWork
- lazy_static! {
- pub static ref CREATE_WORK_FORBIDDEN: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for CreateWork
- lazy_static! {
- pub static ref CREATE_WORK_NOT_FOUND: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the response content types for CreateWork
- lazy_static! {
- pub static ref CREATE_WORK_GENERIC_ERROR: Mime = mime!(Application / Json);
- }
/// Create Mime objects for the response content types for DeleteRelease
lazy_static! {
pub static ref DELETE_RELEASE_DELETED_ENTITY: Mime = mime!(Application / Json);
@@ -1668,6 +1644,30 @@ pub mod responses {
lazy_static! {
pub static ref UPDATE_WEBCAPTURE_GENERIC_ERROR: Mime = mime!(Application / Json);
}
+ /// Create Mime objects for the response content types for CreateWork
+ lazy_static! {
+ pub static ref CREATE_WORK_CREATED_ENTITY: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for CreateWork
+ lazy_static! {
+ pub static ref CREATE_WORK_BAD_REQUEST: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for CreateWork
+ lazy_static! {
+ pub static ref CREATE_WORK_NOT_AUTHORIZED: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for CreateWork
+ lazy_static! {
+ pub static ref CREATE_WORK_FORBIDDEN: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for CreateWork
+ lazy_static! {
+ pub static ref CREATE_WORK_NOT_FOUND: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the response content types for CreateWork
+ lazy_static! {
+ pub static ref CREATE_WORK_GENERIC_ERROR: Mime = mime!(Application / Json);
+ }
/// Create Mime objects for the response content types for CreateWorkAutoBatch
lazy_static! {
pub static ref CREATE_WORK_AUTO_BATCH_CREATED_EDITGROUP: Mime = mime!(Application / Json);
@@ -1865,6 +1865,10 @@ pub mod responses {
pub mod requests {
use hyper::mime::*;
+ /// Create Mime objects for the request content types for AuthOidc
+ lazy_static! {
+ pub static ref AUTH_OIDC: Mime = mime!(Application / Json);
+ }
/// Create Mime objects for the request content types for CreateContainer
lazy_static! {
pub static ref CREATE_CONTAINER: Mime = mime!(Application / Json);
@@ -1889,9 +1893,13 @@ pub mod requests {
lazy_static! {
pub static ref UPDATE_CREATOR: Mime = mime!(Application / Json);
}
- /// Create Mime objects for the request content types for AuthOidc
+ /// Create Mime objects for the request content types for CreateEditgroup
lazy_static! {
- pub static ref AUTH_OIDC: Mime = mime!(Application / Json);
+ pub static ref CREATE_EDITGROUP: Mime = mime!(Application / Json);
+ }
+ /// Create Mime objects for the request content types for CreateEditgroupAnnotation
+ lazy_static! {
+ pub static ref CREATE_EDITGROUP_ANNOTATION: Mime = mime!(Application / Json);
}
/// Create Mime objects for the request content types for UpdateEditgroup
lazy_static! {
@@ -1901,14 +1909,6 @@ pub mod requests {
lazy_static! {
pub static ref UPDATE_EDITOR: Mime = mime!(Application / Json);
}
- /// Create Mime objects for the request content types for CreateEditgroup
- lazy_static! {
- pub static ref CREATE_EDITGROUP: Mime = mime!(Application / Json);
- }
- /// Create Mime objects for the request content types for CreateEditgroupAnnotation
- lazy_static! {
- pub static ref CREATE_EDITGROUP_ANNOTATION: Mime = mime!(Application / Json);
- }
/// Create Mime objects for the request content types for CreateFile
lazy_static! {
pub static ref CREATE_FILE: Mime = mime!(Application / Json);
@@ -1941,10 +1941,6 @@ pub mod requests {
lazy_static! {
pub static ref CREATE_RELEASE_AUTO_BATCH: Mime = mime!(Application / Json);
}
- /// Create Mime objects for the request content types for CreateWork
- lazy_static! {
- pub static ref CREATE_WORK: Mime = mime!(Application / Json);
- }
/// Create Mime objects for the request content types for UpdateRelease
lazy_static! {
pub static ref UPDATE_RELEASE: Mime = mime!(Application / Json);
@@ -1961,6 +1957,10 @@ pub mod requests {
lazy_static! {
pub static ref UPDATE_WEBCAPTURE: Mime = mime!(Application / Json);
}
+ /// Create Mime objects for the request content types for CreateWork
+ lazy_static! {
+ pub static ref CREATE_WORK: Mime = mime!(Application / Json);
+ }
/// Create Mime objects for the request content types for CreateWorkAutoBatch
lazy_static! {
pub static ref CREATE_WORK_AUTO_BATCH: Mime = mime!(Application / Json);
diff --git a/rust/fatcat-openapi/src/models.rs b/rust/fatcat-openapi/src/models.rs
index c8b68328..e9e527f5 100644
--- a/rust/fatcat-openapi/src/models.rs
+++ b/rust/fatcat-openapi/src/models.rs
@@ -11,15 +11,19 @@ use swagger;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct AuthOidc {
+ /// Fatcat-specific short name (slug) for remote service being used for authentication.
#[serde(rename = "provider")]
pub provider: String,
+ /// `SUB` from OIDC protocol. Usually a URL.
#[serde(rename = "sub")]
pub sub: String,
+ /// `ISS` from OIDC protocol. Usually a stable account username, number, or identifier.
#[serde(rename = "iss")]
pub iss: String,
+ /// What it sounds like; returned by OIDC, and used as a hint when creating new editor accounts. Fatcat usernames are usually this string with the `provider` slug as a suffix, though some munging may occur.
#[serde(rename = "preferred_username")]
pub preferred_username: String,
}
@@ -52,12 +56,15 @@ impl AuthOidcResult {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ChangelogEntry {
+ /// Monotonically increasing sequence number of this changelog entry.
#[serde(rename = "index")]
pub index: i64,
+ /// Identifier of editgroup accepted/merged in this changelog entry.
#[serde(rename = "editgroup_id")]
pub editgroup_id: String,
+ /// Date and time when the editgroup was accpeted.
#[serde(rename = "timestamp")]
pub timestamp: chrono::DateTime<chrono::Utc>,
@@ -101,28 +108,32 @@ pub struct ContainerEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub wikidata_qid: Option<String>,
+ /// Linking ISSN number (ISSN-L). Should be valid and registered with issn.org
#[serde(rename = "issnl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub issnl: Option<String>,
+ /// Name of the organization or entity responsible for publication. Not the complete imprint/brand.
#[serde(rename = "publisher")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publisher: Option<String>,
- /// Eg, 'journal'
+ /// Type of container, eg 'journal' or 'proceedings'. See Guide for list of valid types.
#[serde(rename = "container_type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub container_type: Option<String>,
- /// Required for valid entities
+ /// Name of the container (eg, Journal title). Required for entity creation.
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
+ /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
#[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edit_extra: Option<serde_json::Value>,
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
@@ -186,23 +197,27 @@ impl CreatorAutoBatch {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CreatorEntity {
+ /// Wikidata entity QID
#[serde(rename = "wikidata_qid")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wikidata_qid: Option<String>,
+ /// ORCiD (https://orcid.org) identifier
#[serde(rename = "orcid")]
#[serde(skip_serializing_if = "Option::is_none")]
pub orcid: Option<String>,
+ /// In English commonly the last, or family name, but ordering is context and culture specific.
#[serde(rename = "surname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub surname: Option<String>,
+ /// In English commonly the first name, but ordering is context and culture specific.
#[serde(rename = "given_name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub given_name: Option<String>,
- /// Required for valid entities
+ /// Name as should be displayed in web interface or in author lists (not index/sorted). Required for valid entities.
#[serde(rename = "display_name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
@@ -227,10 +242,12 @@ pub struct CreatorEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub redirect: Option<String>,
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
+ /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
#[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edit_extra: Option<serde_json::Value>,
@@ -256,40 +273,47 @@ impl CreatorEntity {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Editgroup {
- /// base32-encoded unique identifier
+ /// Fatcat identifier for this editgroup. Assigned on creation.
#[serde(rename = "editgroup_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub editgroup_id: Option<String>,
- /// base32-encoded unique identifier
+ /// Fatcat identifer of editor that created this editgroup.
#[serde(rename = "editor_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub editor_id: Option<String>,
+ /// Complete editor object identified by `container_id` field. Only included in GET responses.
#[serde(rename = "editor")]
#[serde(skip_serializing_if = "Option::is_none")]
pub editor: Option<models::Editor>,
+ /// For accepted/merged editgroups, the changelog index that the accept occured at. WARNING: not populated in all contexts that an editgroup could be included in a response.
#[serde(rename = "changelog_index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub changelog_index: Option<i64>,
+ /// Timestamp when this editgroup was first created.
#[serde(rename = "created")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created: Option<chrono::DateTime<chrono::Utc>>,
+ /// Timestamp when this editgroup was most recently submitted for review. If withdrawn, or never submitted, will be `null`.
#[serde(rename = "submitted")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submitted: Option<chrono::DateTime<chrono::Utc>>,
+ /// Comment describing the changes in this editgroup. Can be updated with PUT request.
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
+ /// Free-form JSON metadata attached to this editgroup. Eg, metadata provenance, or script user-agent details. See guide for (unenforced) schema norms.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
+ /// Only included in GET responses, and not in all contexts. Do not include this field in PUT or POST requests.
#[serde(rename = "annotations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub annotations: Option<Vec<models::EditgroupAnnotation>>,
@@ -323,20 +347,22 @@ pub struct EditgroupAnnotation {
#[serde(skip_serializing_if = "Option::is_none")]
pub annotation_id: Option<String>,
- /// base32-encoded unique identifier
+ /// Editgroup that this annotation applies to. Set automatically in creations based on URL parameter.
#[serde(rename = "editgroup_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub editgroup_id: Option<String>,
- /// base32-encoded unique identifier
+ /// Defaults to editor created the annotation via POST request.
#[serde(rename = "editor_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub editor_id: Option<String>,
+ /// Only included in GET responses; ignored in PUT or POST requests.
#[serde(rename = "editor")]
#[serde(skip_serializing_if = "Option::is_none")]
pub editor: Option<models::Editor>,
+ /// Timestamp when annotation was first created.
#[serde(rename = "created")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created: Option<chrono::DateTime<chrono::Utc>>,
@@ -345,6 +371,7 @@ pub struct EditgroupAnnotation {
#[serde(skip_serializing_if = "Option::is_none")]
pub comment_markdown: Option<String>,
+ /// Additional free-form JSON metadata that can be included as part of the annotation (or even as the primary annotation itself). See guide for details.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
@@ -364,6 +391,7 @@ impl EditgroupAnnotation {
}
}
+/// Only included in GET responses, and not in all contexts. Do not include this field in PUT or POST requests.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EditgroupEdits {
#[serde(rename = "containers")]
@@ -411,22 +439,26 @@ impl EditgroupEdits {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Editor {
- /// base32-encoded unique identifier
+ /// Fatcat identifier for the editor. Can not be changed.
#[serde(rename = "editor_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub editor_id: Option<String>,
+ /// Username/handle (short slug-like string) to identify this editor. May be changed at any time by the editor; use the `editor_id` as a persistend identifer.
#[serde(rename = "username")]
pub username: String,
+ /// Whether this editor has the `admin` role.
#[serde(rename = "is_admin")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_admin: Option<bool>,
+ /// Whether this editor is a bot (as opposed to a human making manual edits)
#[serde(rename = "is_bot")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_bot: Option<bool>,
+ /// Whether this editor's account is enabled (if not API tokens and web logins will not work).
#[serde(rename = "is_active")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_active: Option<bool>,
@@ -446,30 +478,30 @@ impl Editor {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct EntityEdit {
- /// UUID (lower-case, dash-separated, hex-encoded 128-bit)
+ /// Unique UUID for this specific edit object.
#[serde(rename = "edit_id")]
pub edit_id: String,
- /// base32-encoded unique identifier
+ /// Fatcat identifier of the entity this edit is mutating.
#[serde(rename = "ident")]
pub ident: String,
- /// UUID (lower-case, dash-separated, hex-encoded 128-bit)
+ /// Entity revision that this edit will set the entity to. May be `null` in the case of deletions.
#[serde(rename = "revision")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revision: Option<String>,
- /// UUID (lower-case, dash-separated, hex-encoded 128-bit)
+ /// Revision of entity just before this edit. May be used in the future to prevent edit race conditions.
#[serde(rename = "prev_revision")]
#[serde(skip_serializing_if = "Option::is_none")]
pub prev_revision: Option<String>,
- /// base32-encoded unique identifier
+ /// When an edit is to merge entities (redirect one to another), this is the entity fatcat identifier for the target entity.
#[serde(rename = "redirect_ident")]
#[serde(skip_serializing_if = "Option::is_none")]
pub redirect_ident: Option<String>,
- /// base32-encoded unique identifier
+ /// Editgroup identifier that this edit is part of.
#[serde(rename = "editgroup_id")]
pub editgroup_id: String,
@@ -556,11 +588,12 @@ impl FileAutoBatch {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct FileEntity {
- /// Optional; GET-only
+ /// Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests.
#[serde(rename = "releases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub releases: Option<Vec<models::ReleaseEntity>>,
+ /// Set of identifier of release entities this file represents a full manifestation of. Usually a single release, but some files contain content of multiple full releases (eg, an issue of a journal).
#[serde(rename = "release_ids")]
#[serde(skip_serializing_if = "Option::is_none")]
pub release_ids: Option<Vec<String>>,
@@ -573,26 +606,32 @@ pub struct FileEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub urls: Option<Vec<models::FileUrl>>,
+ /// SHA-256 hash of data, in hex encoding
#[serde(rename = "sha256")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sha256: Option<String>,
+ /// SHA-1 hash of data, in hex encoding
#[serde(rename = "sha1")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sha1: Option<String>,
+ /// MD5 hash of data, in hex encoding
#[serde(rename = "md5")]
#[serde(skip_serializing_if = "Option::is_none")]
pub md5: Option<String>,
+ /// Size of file in bytes. Non-zero.
#[serde(rename = "size")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
+ /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
#[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edit_extra: Option<serde_json::Value>,
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
@@ -641,9 +680,11 @@ impl FileEntity {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct FileUrl {
+ /// URL/URI pointing directly to a machine retrievable copy of this exact file.
#[serde(rename = "url")]
pub url: String,
+ /// Indicates type of host this URL points to. Eg, \"publisher\", \"repository\", \"webarchive\". See guide for list of acceptable values.
#[serde(rename = "rel")]
pub rel: String,
}
@@ -674,11 +715,12 @@ impl FilesetAutoBatch {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct FilesetEntity {
- /// Optional; GET-only
+ /// Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests.
#[serde(rename = "releases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub releases: Option<Vec<models::ReleaseEntity>>,
+ /// Set of identifier of release entities this fileset represents a full manifestation of. Usually a single release.
#[serde(rename = "release_ids")]
#[serde(skip_serializing_if = "Option::is_none")]
pub release_ids: Option<Vec<String>>,
@@ -711,10 +753,12 @@ pub struct FilesetEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub redirect: Option<String>,
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
+ /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
#[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edit_extra: Option<serde_json::Value>,
@@ -739,24 +783,30 @@ impl FilesetEntity {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct FilesetFile {
+ /// Path name of file within this fileset (eg, directory)
#[serde(rename = "path")]
pub path: String,
+ /// File size in bytes
#[serde(rename = "size")]
pub size: i64,
+ /// MD5 hash of data, in hex encoding
#[serde(rename = "md5")]
#[serde(skip_serializing_if = "Option::is_none")]
pub md5: Option<String>,
+ /// SHA-1 hash of data, in hex encoding
#[serde(rename = "sha1")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sha1: Option<String>,
+ /// SHA-256 hash of data, in hex encoding
#[serde(rename = "sha256")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sha256: Option<String>,
+ /// Free-form additional metadata about this specific file in the set. Eg, `mimetype`. See guide for nomative (but unenforced) schema fields.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
@@ -780,6 +830,7 @@ pub struct FilesetUrl {
#[serde(rename = "url")]
pub url: String,
+ /// Indicates type of host this URL points to. See guide for list of acceptable values.
#[serde(rename = "rel")]
pub rel: String,
}
@@ -792,18 +843,22 @@ impl FilesetUrl {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReleaseAbstract {
+ /// SHA-1 hash of data, in hex encoding
#[serde(rename = "sha1")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sha1: Option<String>,
+ /// Abstract content. May be encoded, as per `mimetype` field, but only string/text content may be included.
#[serde(rename = "content")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<String>,
+ /// Mimetype of abstract contents. `text/plain` is the default if content isn't encoded.
#[serde(rename = "mimetype")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mimetype: Option<String>,
+ /// ISO language code of the abstract. Same semantics as release `language` field.
#[serde(rename = "lang")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lang: Option<String>,
@@ -840,32 +895,37 @@ impl ReleaseAutoBatch {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReleaseContrib {
+ /// Internally assigned zero-indexed sequence number of contribution. Authors should come first; this encodes the order of attriubtion.
#[serde(rename = "index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i64>,
- /// base32-encoded unique identifier
+ /// If known, indicates the creator entity this contribution was made by.
#[serde(rename = "creator_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub creator_id: Option<String>,
- /// Optional; GET-only
+ /// Complete creator entity. Only returned in GET responses, and only if `contribs` included in the `expand` query parameter.
#[serde(rename = "creator")]
#[serde(skip_serializing_if = "Option::is_none")]
pub creator: Option<models::CreatorEntity>,
+ /// Full name of the contributor as typeset in the release.
#[serde(rename = "raw_name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub raw_name: Option<String>,
+ /// In English commonly the first name, but ordering is context and culture specific.
#[serde(rename = "given_name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub given_name: Option<String>,
+ /// In English commonly the last, or family name, but ordering is context and culture specific.
#[serde(rename = "surname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub surname: Option<String>,
+ /// Short string (slug) indicating type of contribution (eg, \"author\", \"translator\"). See guide for list of accpeted values.
#[serde(rename = "role")]
#[serde(skip_serializing_if = "Option::is_none")]
pub role: Option<String>,
@@ -875,6 +935,7 @@ pub struct ReleaseContrib {
#[serde(skip_serializing_if = "Option::is_none")]
pub raw_affiliation: Option<String>,
+ /// Additional free-form JSON metadata about this contributor/contribution. See guide for normative schema.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
@@ -910,110 +971,126 @@ pub struct ReleaseEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub contribs: Option<Vec<models::ReleaseContrib>>,
- /// Short version of license name. Eg, 'CC-BY'
+ /// Short string (slug) name of license under which release is openly published (if applicable).
#[serde(rename = "license_slug")]
#[serde(skip_serializing_if = "Option::is_none")]
pub license_slug: Option<String>,
- /// Two-letter RFC1766/ISO639-1 language code, with extensions
+ /// Primary language of the content of the full release. Two-letter RFC1766/ISO639-1 language code, with some custom extensions/additions. See guide.
#[serde(rename = "language")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
+ /// Name, usually English, of the entity or institution responsible for publication of this release. Not necessarily the imprint/brand. See guide.
#[serde(rename = "publisher")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publisher: Option<String>,
+ /// For, eg, updated technical reports or software packages, where the version string may be the only field disambiguating between releases.
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
+ /// For, eg, technical reports, which are published in series or assigned some other institutional or container-specific identifier.
#[serde(rename = "number")]
#[serde(skip_serializing_if = "Option::is_none")]
pub number: Option<String>,
+ /// Either a single page number (\"first page\") or a range of pages separated by a dash (\"-\"). See guide for details.
#[serde(rename = "pages")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pages: Option<String>,
+ /// Issue number of volume/container that this release was published in. Sometimes coresponds to a month number in the year, but can be any string. See guide.
#[serde(rename = "issue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub issue: Option<String>,
+ /// Volume number of container that this release was published in. Often corresponds to the \"Nth\" year of publication, but can be any string. See guide.
#[serde(rename = "volume")]
#[serde(skip_serializing_if = "Option::is_none")]
pub volume: Option<String>,
+ /// Set of external identifiers for this release.
#[serde(rename = "ext_ids")]
pub ext_ids: models::ReleaseExtIds,
+ /// Year corresponding with `withdrawn_date` like `release_year`/`release_date`.
#[serde(rename = "withdrawn_year")]
#[serde(skip_serializing_if = "Option::is_none")]
pub withdrawn_year: Option<i64>,
+ /// Full date when this release was formally withdrawn (if applicable). ISO format, like `release_date`.
#[serde(rename = "withdrawn_date")]
#[serde(skip_serializing_if = "Option::is_none")]
pub withdrawn_date: Option<chrono::NaiveDate>,
+ /// Type of withdrawl or retraction of this release, if applicable. If release has not been withdrawn, should be `null` (aka, not set, not the string \"null\" or an empty string).
#[serde(rename = "withdrawn_status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub withdrawn_status: Option<String>,
+ /// Year when this release was formally published. Must match `release_date` if that field is set; this field exists because sometimes only the year is known.
#[serde(rename = "release_year")]
#[serde(skip_serializing_if = "Option::is_none")]
pub release_year: Option<i64>,
+ /// Full date when this release was formally published. ISO format, like `2019-03-05`. See guide for semantics.
#[serde(rename = "release_date")]
#[serde(skip_serializing_if = "Option::is_none")]
pub release_date: Option<chrono::NaiveDate>,
+ /// The stage of publication of this specific release. See guide for valid values and semantics.
#[serde(rename = "release_stage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub release_stage: Option<String>,
+ /// \"Type\" or \"medium\" that this release is published as. See guide for valid values.
#[serde(rename = "release_type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub release_type: Option<String>,
+ /// Used to link this release to a container entity that the release was published as part of.
#[serde(rename = "container_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub container_id: Option<String>,
- /// Optional; GET-only
+ /// Complete webcapture entities identified by `webcapture_ids` field. Only included in GET responses when `webcaptures` included in `expand` parameter; ignored in PUT or POST requests.
#[serde(rename = "webcaptures")]
#[serde(skip_serializing_if = "Option::is_none")]
pub webcaptures: Option<Vec<models::WebcaptureEntity>>,
- /// Optional; GET-only
+ /// Complete file entities identified by `filesets_ids` field. Only included in GET responses when `filesets` included in `expand` parameter; ignored in PUT or POST requests.
#[serde(rename = "filesets")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filesets: Option<Vec<models::FilesetEntity>>,
- /// Optional; GET-only
+ /// Complete file entities identified by `file_ids` field. Only included in GET responses when `files` included in `expand` parameter; ignored in PUT or POST requests.
#[serde(rename = "files")]
#[serde(skip_serializing_if = "Option::is_none")]
pub files: Option<Vec<models::FileEntity>>,
- /// Optional; GET-only
+ /// Complete container entity identified by `container_id` field. Only included in GET reponses when `container` included in `expand` parameter; ignored in PUT or POST requests.
#[serde(rename = "container")]
#[serde(skip_serializing_if = "Option::is_none")]
pub container: Option<models::ContainerEntity>,
+ /// Identifier of work this release is part of. In creation (POST) requests, a work entity will be created automatically if this field is not set.
#[serde(rename = "work_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_id: Option<String>,
- /// Title in original language (or, the language of the full text of this release)
+ /// Title in original language if `title` field has been translated. See guide for details.
#[serde(rename = "original_title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub original_title: Option<String>,
- /// Avoid this field if possible, and merge with title; usually English
+ /// Subtitle of release. In many cases, better to merge with title than include as separate field (unless combined title would be very long). See guide for details.
#[serde(rename = "subtitle")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subtitle: Option<String>,
- /// Required for valid entities. The title used in citations and for display; usually English
+ /// Required for valid entities. The title used in citations and for display. Sometimes the English translation of title e even if release content is not English.
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
@@ -1038,10 +1115,12 @@ pub struct ReleaseEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub redirect: Option<String>,
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
+ /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
#[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edit_extra: Option<serde_json::Value>,
@@ -1090,42 +1169,52 @@ impl ReleaseEntity {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReleaseExtIds {
+ /// Digital serde_json::Value Identifier (DOI), mostly for published papers and datasets. Should be registered and resolvable via https://doi.org/
#[serde(rename = "doi")]
#[serde(skip_serializing_if = "Option::is_none")]
pub doi: Option<String>,
+ /// Wikidata entity QID
#[serde(rename = "wikidata_qid")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wikidata_qid: Option<String>,
+ /// ISBN-13, for books. Usually not set for chapters. ISBN-10 should be converted to ISBN-13.
#[serde(rename = "isbn13")]
#[serde(skip_serializing_if = "Option::is_none")]
pub isbn13: Option<String>,
+ /// PubMed Identifier
#[serde(rename = "pmid")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pmid: Option<String>,
+ /// PubMed Central Identifier
#[serde(rename = "pmcid")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pmcid: Option<String>,
+ /// CORE (https://core.ac.uk) identifier
#[serde(rename = "core")]
#[serde(skip_serializing_if = "Option::is_none")]
pub core: Option<String>,
+ /// arXiv (https://arxiv.org) identifier; must include version
#[serde(rename = "arxiv")]
#[serde(skip_serializing_if = "Option::is_none")]
pub arxiv: Option<String>,
+ /// JSTOR work identifier
#[serde(rename = "jstor")]
#[serde(skip_serializing_if = "Option::is_none")]
pub jstor: Option<String>,
+ /// ARK identifier
#[serde(rename = "ark")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ark: Option<String>,
+ /// Microsoft Academic Graph identifier
#[serde(rename = "mag")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mag: Option<String>,
@@ -1150,35 +1239,42 @@ impl ReleaseExtIds {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReleaseRef {
+ /// Zero-indexed sequence number of this reference in the list of references. Assigned automatically and used internally; don't confuse with `key`.
#[serde(rename = "index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i64>,
- /// base32-encoded unique identifier
+ /// Optional, fatcat identifier of release entity that this reference is citing.
#[serde(rename = "target_release_id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target_release_id: Option<String>,
+ /// Additional free-form JSON metadata about this citation. Generally follows Citation Style Language (CSL) JSON schema. See guide for details.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
+ /// Short string used to indicate this reference from within the release text; or numbering of references as typeset in the release itself. Optional; don't confuse with `index` field.
#[serde(rename = "key")]
#[serde(skip_serializing_if = "Option::is_none")]
pub key: Option<String>,
+ /// Year that the cited work was published in.
#[serde(rename = "year")]
#[serde(skip_serializing_if = "Option::is_none")]
pub year: Option<i64>,
+ /// Name of the container (eg, journal) that the citation work was published as part of. May be an acronym or full name.
#[serde(rename = "container_name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub container_name: Option<String>,
+ /// Name of the work being cited.
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
+ /// Page number or other indicator of the specific subset of a work being cited. Not to be confused with the first page (or page range) of an entire paper or chapter being cited.
#[serde(rename = "locator")]
#[serde(skip_serializing_if = "Option::is_none")]
pub locator: Option<String>,
@@ -1234,31 +1330,38 @@ impl WebcaptureAutoBatch {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WebcaptureCdxLine {
+ /// \"Sortable URL\" format. See guide for details.
#[serde(rename = "surt")]
pub surt: String,
- /// UTC, 'Z'-terminated, second (or better) precision
+ /// Date and time of capture, in ISO format. UTC, 'Z'-terminated, second (or better) precision.
#[serde(rename = "timestamp")]
pub timestamp: chrono::DateTime<chrono::Utc>,
+ /// Full URL/URI of resource captured.
#[serde(rename = "url")]
pub url: String,
+ /// Mimetype of the resource at this URL. May be the Content-Type header, or the actually sniffed file type.
#[serde(rename = "mimetype")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mimetype: Option<String>,
+ /// HTTP status code. Should generally be 200, especially for the primary resource, but may be 3xx (redirect) or even error codes if embedded resources can not be fetched successfully.
#[serde(rename = "status_code")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status_code: Option<i64>,
+ /// Resource (file) size in bytes
#[serde(rename = "size")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
+ /// SHA-1 hash of data, in hex encoding
#[serde(rename = "sha1")]
pub sha1: String,
+ /// SHA-256 hash of data, in hex encoding
#[serde(rename = "sha256")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sha256: Option<String>,
@@ -1281,20 +1384,22 @@ impl WebcaptureCdxLine {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WebcaptureEntity {
- /// Optional; GET-only
+ /// Full release entities, included in GET responses when `releases` included in `expand` parameter. Ignored if included in PUT or POST requests.
#[serde(rename = "releases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub releases: Option<Vec<models::ReleaseEntity>>,
+ /// Set of identifier of release entities this fileset represents a full manifestation of. Usually a single release.
#[serde(rename = "release_ids")]
#[serde(skip_serializing_if = "Option::is_none")]
pub release_ids: Option<Vec<String>>,
- /// same format as CDX line timestamp (UTC, etc). Corresponds to the overall capture timestamp. Can be the earliest or average of CDX timestamps if that makes sense.
+ /// Same format as CDX line timestamp (UTC, etc). Corresponds to the overall capture timestamp. Should generally be the timestamp of capture of the primary resource URL.
#[serde(rename = "timestamp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<chrono::DateTime<chrono::Utc>>,
+ /// Base URL of the primary resource this is a capture of
#[serde(rename = "original_url")]
#[serde(skip_serializing_if = "Option::is_none")]
pub original_url: Option<String>,
@@ -1307,10 +1412,12 @@ pub struct WebcaptureEntity {
#[serde(skip_serializing_if = "Option::is_none")]
pub cdx: Option<Vec<models::WebcaptureCdxLine>>,
+ /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
#[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edit_extra: Option<serde_json::Value>,
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
@@ -1357,9 +1464,11 @@ impl WebcaptureEntity {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WebcaptureUrl {
+ /// URL/URI pointing to archive of this web resource.
#[serde(rename = "url")]
pub url: String,
+ /// Type of archive endpoint. Usually `wayback` (WBM replay of primary resource), or `warc` (direct URL to a WARC file containing all resources of the capture). See guide for full list.
#[serde(rename = "rel")]
pub rel: String,
}
@@ -1390,10 +1499,12 @@ impl WorkAutoBatch {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WorkEntity {
+ /// Free-form JSON metadata that will be stored with specific entity edits (eg, creation/update/delete).
#[serde(rename = "edit_extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edit_extra: Option<serde_json::Value>,
+ /// Free-form JSON metadata that will be stored with the other entity metadata. See guide for (unenforced) schema conventions.
#[serde(rename = "extra")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extra: Option<serde_json::Value>,
diff --git a/rust/fatcat-openapi/src/server.rs b/rust/fatcat-openapi/src/server.rs
index 102b6e41..406b6789 100644
--- a/rust/fatcat-openapi/src/server.rs
+++ b/rust/fatcat-openapi/src/server.rs
@@ -98,6 +98,409 @@ where
T: Api + Send + Sync + Clone + 'static,
{
let api_clone = api.clone();
+ router.get(
+ "/v0/auth/check",
+ move |req: &mut Request| {
+ let mut context = Context::default();
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ context.auth_data = req.extensions.remove::<AuthData>();
+ context.authorization = req.extensions.remove::<Authorization>();
+
+ let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?;
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
+ let param_role = query_params.get("role").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
+
+ match api.auth_check(param_role, context).wait() {
+ Ok(rsp) => match rsp {
+ AuthCheckResponse::Success(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_SUCCESS.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ AuthCheckResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_BAD_REQUEST.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ AuthCheckResponse::NotAuthorized { body, www_authenticate } => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(401), body_string));
+ header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
+ response.headers.set(ResponseWwwAuthenticate(www_authenticate));
+
+ response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_NOT_AUTHORIZED.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ AuthCheckResponse::Forbidden(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(403), body_string));
+ response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_FORBIDDEN.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ AuthCheckResponse::GenericError(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(500), body_string));
+ response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_GENERIC_ERROR.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ }
+ }
+ }
+
+ handle_request(req, &api_clone, &mut context).or_else(|mut response| {
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ Ok(response)
+ })
+ },
+ "AuthCheck",
+ );
+
+ let api_clone = api.clone();
+ router.post(
+ "/v0/auth/oidc",
+ move |req: &mut Request| {
+ let mut context = Context::default();
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ context.auth_data = req.extensions.remove::<AuthData>();
+ context.authorization = req.extensions.remove::<Authorization>();
+
+ let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?;
+
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+
+ let param_oidc_params = req
+ .get::<bodyparser::Raw>()
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter oidc_params - not valid UTF-8: {}", e))))?;
+
+ let mut unused_elements = Vec::new();
+
+ let param_oidc_params = if let Some(param_oidc_params_raw) = param_oidc_params {
+ let deserializer = &mut serde_json::Deserializer::from_str(&param_oidc_params_raw);
+
+ let param_oidc_params: Option<models::AuthOidc> = serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ })
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter oidc_params - doesn't match schema: {}", e))))?;
+
+ param_oidc_params
+ } else {
+ None
+ };
+ let param_oidc_params = param_oidc_params.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter oidc_params".to_string())))?;
+
+ match api.auth_oidc(param_oidc_params, context).wait() {
+ Ok(rsp) => match rsp {
+ AuthOidcResponse::Found(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_FOUND.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ AuthOidcResponse::Created(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(201), body_string));
+ response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_CREATED.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ AuthOidcResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_BAD_REQUEST.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ AuthOidcResponse::NotAuthorized { body, www_authenticate } => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(401), body_string));
+ header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
+ response.headers.set(ResponseWwwAuthenticate(www_authenticate));
+
+ response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_NOT_AUTHORIZED.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ AuthOidcResponse::Forbidden(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(403), body_string));
+ response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_FORBIDDEN.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ AuthOidcResponse::Conflict(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(409), body_string));
+ response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_CONFLICT.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ AuthOidcResponse::GenericError(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(500), body_string));
+ response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_GENERIC_ERROR.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ }
+ }
+ }
+
+ handle_request(req, &api_clone, &mut context).or_else(|mut response| {
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ Ok(response)
+ })
+ },
+ "AuthOidc",
+ );
+
+ let api_clone = api.clone();
+ router.get(
+ "/v0/changelog",
+ move |req: &mut Request| {
+ let mut context = Context::default();
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ context.auth_data = req.extensions.remove::<AuthData>();
+ context.authorization = req.extensions.remove::<Authorization>();
+
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
+ let param_limit = query_params
+ .get("limit")
+ .and_then(|list| list.first())
+ .and_then(|x| Some(x.parse::<i64>()))
+ .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
+ .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?;
+
+ match api.get_changelog(param_limit, context).wait() {
+ Ok(rsp) => match rsp {
+ GetChangelogResponse::Success(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_SUCCESS.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ GetChangelogResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_BAD_REQUEST.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ GetChangelogResponse::GenericError(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(500), body_string));
+ response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_GENERIC_ERROR.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ }
+ }
+ }
+
+ handle_request(req, &api_clone, &mut context).or_else(|mut response| {
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ Ok(response)
+ })
+ },
+ "GetChangelog",
+ );
+
+ let api_clone = api.clone();
+ router.get(
+ "/v0/changelog/:index",
+ move |req: &mut Request| {
+ let mut context = Context::default();
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ context.auth_data = req.extensions.remove::<AuthData>();
+ context.authorization = req.extensions.remove::<Authorization>();
+
+ // Path parameters
+ let param_index = {
+ let param = req
+ .extensions
+ .get::<Router>()
+ .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
+ .find("index")
+ .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter index".to_string())))?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
+ .parse()
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter index: {}", e))))?
+ };
+
+ match api.get_changelog_entry(param_index, context).wait() {
+ Ok(rsp) => match rsp {
+ GetChangelogEntryResponse::FoundChangelogEntry(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_FOUND_CHANGELOG_ENTRY.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ GetChangelogEntryResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_BAD_REQUEST.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ GetChangelogEntryResponse::NotFound(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_NOT_FOUND.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ GetChangelogEntryResponse::GenericError(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(500), body_string));
+ response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_GENERIC_ERROR.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ }
+ }
+ }
+
+ handle_request(req, &api_clone, &mut context).or_else(|mut response| {
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ Ok(response)
+ })
+ },
+ "GetChangelogEntry",
+ );
+
+ let api_clone = api.clone();
router.post(
"/v0/editgroup/:editgroup_id/container",
move |req: &mut Request| {
@@ -2691,8 +3094,8 @@ where
);
let api_clone = api.clone();
- router.get(
- "/v0/auth/check",
+ router.post(
+ "/v0/editgroup/:editgroup_id/accept",
move |req: &mut Request| {
let mut context = Context::default();
@@ -2707,60 +3110,91 @@ where
let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?;
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_role = query_params.get("role").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
+ // Path parameters
+ let param_editgroup_id = {
+ let param = req
+ .extensions
+ .get::<Router>()
+ .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
+ .find("editgroup_id")
+ .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_id".to_string())))?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
+ .parse()
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))?
+ };
- match api.auth_check(param_role, context).wait() {
+ match api.accept_editgroup(param_editgroup_id, context).wait() {
Ok(rsp) => match rsp {
- AuthCheckResponse::Success(body) => {
+ AcceptEditgroupResponse::MergedSuccessfully(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_SUCCESS.clone()));
+ response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_MERGED_SUCCESSFULLY.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- AuthCheckResponse::BadRequest(body) => {
+ AcceptEditgroupResponse::BadRequest(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_BAD_REQUEST.clone()));
+ response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- AuthCheckResponse::NotAuthorized { body, www_authenticate } => {
+ AcceptEditgroupResponse::NotAuthorized { body, www_authenticate } => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(401), body_string));
header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
response.headers.set(ResponseWwwAuthenticate(www_authenticate));
- response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_NOT_AUTHORIZED.clone()));
+ response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_NOT_AUTHORIZED.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- AuthCheckResponse::Forbidden(body) => {
+ AcceptEditgroupResponse::Forbidden(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(403), body_string));
- response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_FORBIDDEN.clone()));
+ response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_FORBIDDEN.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- AuthCheckResponse::GenericError(body) => {
+ AcceptEditgroupResponse::NotFound(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_NOT_FOUND.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ AcceptEditgroupResponse::EditConflict(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(409), body_string));
+ response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_EDIT_CONFLICT.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ AcceptEditgroupResponse::GenericError(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::AUTH_CHECK_GENERIC_ERROR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_GENERIC_ERROR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
@@ -2780,12 +3214,12 @@ where
Ok(response)
})
},
- "AuthCheck",
+ "AcceptEditgroup",
);
let api_clone = api.clone();
router.post(
- "/v0/auth/oidc",
+ "/v0/editgroup",
move |req: &mut Request| {
let mut context = Context::default();
@@ -2804,46 +3238,34 @@ where
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
- let param_oidc_params = req
+ let param_editgroup = req
.get::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter oidc_params - not valid UTF-8: {}", e))))?;
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - not valid UTF-8: {}", e))))?;
let mut unused_elements = Vec::new();
- let param_oidc_params = if let Some(param_oidc_params_raw) = param_oidc_params {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_oidc_params_raw);
+ let param_editgroup = if let Some(param_editgroup_raw) = param_editgroup {
+ let deserializer = &mut serde_json::Deserializer::from_str(&param_editgroup_raw);
- let param_oidc_params: Option<models::AuthOidc> = serde_ignored::deserialize(deserializer, |path| {
+ let param_editgroup: Option<models::Editgroup> = serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
})
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter oidc_params - doesn't match schema: {}", e))))?;
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e))))?;
- param_oidc_params
+ param_editgroup
} else {
None
};
- let param_oidc_params = param_oidc_params.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter oidc_params".to_string())))?;
+ let param_editgroup = param_editgroup.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editgroup".to_string())))?;
- match api.auth_oidc(param_oidc_params, context).wait() {
+ match api.create_editgroup(param_editgroup, context).wait() {
Ok(rsp) => match rsp {
- AuthOidcResponse::Found(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_FOUND.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
- Ok(response)
- }
- AuthOidcResponse::Created(body) => {
+ CreateEditgroupResponse::SuccessfullyCreated(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(201), body_string));
- response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_CREATED.clone()));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_SUCCESSFULLY_CREATED.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -2851,11 +3273,11 @@ where
}
Ok(response)
}
- AuthOidcResponse::BadRequest(body) => {
+ CreateEditgroupResponse::BadRequest(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_BAD_REQUEST.clone()));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -2863,14 +3285,14 @@ where
}
Ok(response)
}
- AuthOidcResponse::NotAuthorized { body, www_authenticate } => {
+ CreateEditgroupResponse::NotAuthorized { body, www_authenticate } => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(401), body_string));
header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
response.headers.set(ResponseWwwAuthenticate(www_authenticate));
- response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_NOT_AUTHORIZED.clone()));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_NOT_AUTHORIZED.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -2878,11 +3300,11 @@ where
}
Ok(response)
}
- AuthOidcResponse::Forbidden(body) => {
+ CreateEditgroupResponse::Forbidden(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(403), body_string));
- response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_FORBIDDEN.clone()));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_FORBIDDEN.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -2890,11 +3312,11 @@ where
}
Ok(response)
}
- AuthOidcResponse::Conflict(body) => {
+ CreateEditgroupResponse::NotFound(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(409), body_string));
- response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_CONFLICT.clone()));
+ let mut response = Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_NOT_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -2902,11 +3324,11 @@ where
}
Ok(response)
}
- AuthOidcResponse::GenericError(body) => {
+ CreateEditgroupResponse::GenericError(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::AUTH_OIDC_GENERIC_ERROR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_GENERIC_ERROR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -2928,307 +3350,12 @@ where
Ok(response)
})
},
- "AuthOidc",
- );
-
- let api_clone = api.clone();
- router.get(
- "/v0/editgroup/reviewable",
- move |req: &mut Request| {
- let mut context = Context::default();
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
- .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?;
- let param_before = query_params
- .get("before")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
- .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
- .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
- let param_since = query_params
- .get("since")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
- .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
- .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
-
- match api.get_editgroups_reviewable(param_expand, param_limit, param_before, param_since, context).wait() {
- Ok(rsp) => match rsp {
- GetEditgroupsReviewableResponse::Found(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_FOUND.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetEditgroupsReviewableResponse::BadRequest(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetEditgroupsReviewableResponse::NotFound(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_NOT_FOUND.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetEditgroupsReviewableResponse::GenericError(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_GENERIC_ERROR.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
- }
- }
- }
-
- handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- Ok(response)
- })
- },
- "GetEditgroupsReviewable",
- );
-
- let api_clone = api.clone();
- router.get(
- "/v0/editor/:editor_id",
- move |req: &mut Request| {
- let mut context = Context::default();
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_editor_id = {
- let param = req
- .extensions
- .get::<Router>()
- .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("editor_id")
- .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editor_id".to_string())))?;
- percent_decode(param.as_bytes())
- .decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editor_id: {}", e))))?
- };
-
- match api.get_editor(param_editor_id, context).wait() {
- Ok(rsp) => match rsp {
- GetEditorResponse::Found(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_FOUND.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetEditorResponse::BadRequest(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetEditorResponse::NotFound(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_NOT_FOUND.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetEditorResponse::GenericError(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_GENERIC_ERROR.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
- }
- }
- }
-
- handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- Ok(response)
- })
- },
- "GetEditor",
- );
-
- let api_clone = api.clone();
- router.get(
- "/v0/editor/:editor_id/editgroups",
- move |req: &mut Request| {
- let mut context = Context::default();
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Path parameters
- let param_editor_id = {
- let param = req
- .extensions
- .get::<Router>()
- .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("editor_id")
- .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editor_id".to_string())))?;
- percent_decode(param.as_bytes())
- .decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editor_id: {}", e))))?
- };
-
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
- .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?;
- let param_before = query_params
- .get("before")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
- .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
- .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
- let param_since = query_params
- .get("since")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
- .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
- .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
-
- match api.get_editor_editgroups(param_editor_id, param_limit, param_before, param_since, context).wait() {
- Ok(rsp) => match rsp {
- GetEditorEditgroupsResponse::Found(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_FOUND.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetEditorEditgroupsResponse::BadRequest(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetEditorEditgroupsResponse::NotFound(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_NOT_FOUND.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetEditorEditgroupsResponse::GenericError(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_GENERIC_ERROR.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
- }
- }
- }
-
- handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- Ok(response)
- })
- },
- "GetEditorEditgroups",
+ "CreateEditgroup",
);
let api_clone = api.clone();
- router.put(
- "/v0/editgroup/:editgroup_id",
+ router.post(
+ "/v0/editgroup/:editgroup_id/annotation",
move |req: &mut Request| {
let mut context = Context::default();
@@ -3258,47 +3385,38 @@ where
.map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))?
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_submit = query_params
- .get("submit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.to_lowercase().parse::<bool>()))
- .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
- .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected boolean)".to_string())))?;
-
// Body parameters (note that non-required body parameters will ignore garbage
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
- let param_editgroup = req
+ let param_annotation = req
.get::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - not valid UTF-8: {}", e))))?;
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter annotation - not valid UTF-8: {}", e))))?;
let mut unused_elements = Vec::new();
- let param_editgroup = if let Some(param_editgroup_raw) = param_editgroup {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_editgroup_raw);
+ let param_annotation = if let Some(param_annotation_raw) = param_annotation {
+ let deserializer = &mut serde_json::Deserializer::from_str(&param_annotation_raw);
- let param_editgroup: Option<models::Editgroup> = serde_ignored::deserialize(deserializer, |path| {
+ let param_annotation: Option<models::EditgroupAnnotation> = serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
})
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e))))?;
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter annotation - doesn't match schema: {}", e))))?;
- param_editgroup
+ param_annotation
} else {
None
};
- let param_editgroup = param_editgroup.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editgroup".to_string())))?;
+ let param_annotation = param_annotation.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter annotation".to_string())))?;
- match api.update_editgroup(param_editgroup_id, param_editgroup, param_submit, context).wait() {
+ match api.create_editgroup_annotation(param_editgroup_id, param_annotation, context).wait() {
Ok(rsp) => match rsp {
- UpdateEditgroupResponse::UpdatedEditgroup(body) => {
+ CreateEditgroupAnnotationResponse::Created(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_UPDATED_EDITGROUP.clone()));
+ let mut response = Response::with((status::Status::from_u16(201), body_string));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_CREATED.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3306,11 +3424,11 @@ where
}
Ok(response)
}
- UpdateEditgroupResponse::BadRequest(body) => {
+ CreateEditgroupAnnotationResponse::BadRequest(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_BAD_REQUEST.clone()));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3318,14 +3436,14 @@ where
}
Ok(response)
}
- UpdateEditgroupResponse::NotAuthorized { body, www_authenticate } => {
+ CreateEditgroupAnnotationResponse::NotAuthorized { body, www_authenticate } => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(401), body_string));
header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
response.headers.set(ResponseWwwAuthenticate(www_authenticate));
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_NOT_AUTHORIZED.clone()));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_NOT_AUTHORIZED.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3333,11 +3451,11 @@ where
}
Ok(response)
}
- UpdateEditgroupResponse::Forbidden(body) => {
+ CreateEditgroupAnnotationResponse::Forbidden(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(403), body_string));
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_FORBIDDEN.clone()));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_FORBIDDEN.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3345,11 +3463,11 @@ where
}
Ok(response)
}
- UpdateEditgroupResponse::NotFound(body) => {
+ CreateEditgroupAnnotationResponse::NotFound(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_NOT_FOUND.clone()));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_NOT_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3357,11 +3475,11 @@ where
}
Ok(response)
}
- UpdateEditgroupResponse::GenericError(body) => {
+ CreateEditgroupAnnotationResponse::GenericError(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_GENERIC_ERROR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_GENERIC_ERROR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3383,12 +3501,12 @@ where
Ok(response)
})
},
- "UpdateEditgroup",
+ "CreateEditgroupAnnotation",
);
let api_clone = api.clone();
- router.put(
- "/v0/editor/:editor_id",
+ router.get(
+ "/v0/editgroup/:editgroup_id",
move |req: &mut Request| {
let mut context = Context::default();
@@ -3401,123 +3519,61 @@ where
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
- let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?;
-
// Path parameters
- let param_editor_id = {
+ let param_editgroup_id = {
let param = req
.extensions
.get::<Router>()
.ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("editor_id")
- .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editor_id".to_string())))?;
+ .find("editgroup_id")
+ .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_id".to_string())))?;
percent_decode(param.as_bytes())
.decode_utf8()
.map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
.parse()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editor_id: {}", e))))?
- };
-
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
-
- let param_editor = req
- .get::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editor - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_editor = if let Some(param_editor_raw) = param_editor {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_editor_raw);
-
- let param_editor: Option<models::Editor> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editor - doesn't match schema: {}", e))))?;
-
- param_editor
- } else {
- None
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))?
};
- let param_editor = param_editor.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editor".to_string())))?;
- match api.update_editor(param_editor_id, param_editor, context).wait() {
+ match api.get_editgroup(param_editgroup_id, context).wait() {
Ok(rsp) => match rsp {
- UpdateEditorResponse::UpdatedEditor(body) => {
+ GetEditgroupResponse::Found(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_UPDATED_EDITOR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
- Ok(response)
- }
- UpdateEditorResponse::BadRequest(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
Ok(response)
}
- UpdateEditorResponse::NotAuthorized { body, www_authenticate } => {
+ GetEditgroupResponse::BadRequest(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(401), body_string));
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- response.headers.set(ResponseWwwAuthenticate(www_authenticate));
-
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_NOT_AUTHORIZED.clone()));
+ let mut response = Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
- Ok(response)
- }
- UpdateEditorResponse::Forbidden(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(403), body_string));
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_FORBIDDEN.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
Ok(response)
}
- UpdateEditorResponse::NotFound(body) => {
+ GetEditgroupResponse::NotFound(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_NOT_FOUND.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_NOT_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
+
Ok(response)
}
- UpdateEditorResponse::GenericError(body) => {
+ GetEditgroupResponse::GenericError(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_GENERIC_ERROR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_GENERIC_ERROR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
+
Ok(response)
}
},
@@ -3534,12 +3590,12 @@ where
Ok(response)
})
},
- "UpdateEditor",
+ "GetEditgroup",
);
let api_clone = api.clone();
- router.post(
- "/v0/editgroup/:editgroup_id/accept",
+ router.get(
+ "/v0/editgroup/:editgroup_id/annotations",
move |req: &mut Request| {
let mut context = Context::default();
@@ -3552,8 +3608,6 @@ where
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
- let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?;
-
// Path parameters
let param_editgroup_id = {
let param = req
@@ -3569,76 +3623,70 @@ where
.map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))?
};
- match api.accept_editgroup(param_editgroup_id, context).wait() {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
+ let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
+
+ match api.get_editgroup_annotations(param_editgroup_id, param_expand, context).wait() {
Ok(rsp) => match rsp {
- AcceptEditgroupResponse::MergedSuccessfully(body) => {
+ GetEditgroupAnnotationsResponse::Success(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_MERGED_SUCCESSFULLY.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_SUCCESS.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- AcceptEditgroupResponse::BadRequest(body) => {
+ GetEditgroupAnnotationsResponse::BadRequest(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_BAD_REQUEST.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- AcceptEditgroupResponse::NotAuthorized { body, www_authenticate } => {
+ GetEditgroupAnnotationsResponse::NotAuthorized { body, www_authenticate } => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(401), body_string));
header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
response.headers.set(ResponseWwwAuthenticate(www_authenticate));
- response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_NOT_AUTHORIZED.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_NOT_AUTHORIZED.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- AcceptEditgroupResponse::Forbidden(body) => {
+ GetEditgroupAnnotationsResponse::Forbidden(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(403), body_string));
- response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_FORBIDDEN.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_FORBIDDEN.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- AcceptEditgroupResponse::NotFound(body) => {
+ GetEditgroupAnnotationsResponse::NotFound(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_NOT_FOUND.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- AcceptEditgroupResponse::EditConflict(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(409), body_string));
- response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_EDIT_CONFLICT.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_NOT_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- AcceptEditgroupResponse::GenericError(body) => {
+ GetEditgroupAnnotationsResponse::GenericError(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::ACCEPT_EDITGROUP_GENERIC_ERROR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_GENERIC_ERROR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
@@ -3658,12 +3706,12 @@ where
Ok(response)
})
},
- "AcceptEditgroup",
+ "GetEditgroupAnnotations",
);
let api_clone = api.clone();
- router.post(
- "/v0/editgroup",
+ router.get(
+ "/v0/editgroup/reviewable",
move |req: &mut Request| {
let mut context = Context::default();
@@ -3676,108 +3724,68 @@ where
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
- let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?;
-
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
-
- let param_editgroup = req
- .get::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_editgroup = if let Some(param_editgroup_raw) = param_editgroup {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_editgroup_raw);
-
- let param_editgroup: Option<models::Editgroup> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e))))?;
-
- param_editgroup
- } else {
- None
- };
- let param_editgroup = param_editgroup.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editgroup".to_string())))?;
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
+ let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
+ let param_limit = query_params
+ .get("limit")
+ .and_then(|list| list.first())
+ .and_then(|x| Some(x.parse::<i64>()))
+ .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
+ .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?;
+ let param_before = query_params
+ .get("before")
+ .and_then(|list| list.first())
+ .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
+ .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
+ .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
+ let param_since = query_params
+ .get("since")
+ .and_then(|list| list.first())
+ .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
+ .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
+ .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
- match api.create_editgroup(param_editgroup, context).wait() {
+ match api.get_editgroups_reviewable(param_expand, param_limit, param_before, param_since, context).wait() {
Ok(rsp) => match rsp {
- CreateEditgroupResponse::SuccessfullyCreated(body) => {
+ GetEditgroupsReviewableResponse::Found(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(201), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_SUCCESSFULLY_CREATED.clone()));
+ let mut response = Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
- Ok(response)
- }
- CreateEditgroupResponse::BadRequest(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_BAD_REQUEST.clone()));
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
Ok(response)
}
- CreateEditgroupResponse::NotAuthorized { body, www_authenticate } => {
+ GetEditgroupsReviewableResponse::BadRequest(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(401), body_string));
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- response.headers.set(ResponseWwwAuthenticate(www_authenticate));
-
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_NOT_AUTHORIZED.clone()));
+ let mut response = Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
- Ok(response)
- }
- CreateEditgroupResponse::Forbidden(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(403), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_FORBIDDEN.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
Ok(response)
}
- CreateEditgroupResponse::NotFound(body) => {
+ GetEditgroupsReviewableResponse::NotFound(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_NOT_FOUND.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_NOT_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
+
Ok(response)
}
- CreateEditgroupResponse::GenericError(body) => {
+ GetEditgroupsReviewableResponse::GenericError(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_GENERIC_ERROR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUPS_REVIEWABLE_GENERIC_ERROR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
+
Ok(response)
}
},
@@ -3794,12 +3802,12 @@ where
Ok(response)
})
},
- "CreateEditgroup",
+ "GetEditgroupsReviewable",
);
let api_clone = api.clone();
- router.post(
- "/v0/editgroup/:editgroup_id/annotation",
+ router.put(
+ "/v0/editgroup/:editgroup_id",
move |req: &mut Request| {
let mut context = Context::default();
@@ -3829,38 +3837,47 @@ where
.map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))?
};
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
+ let param_submit = query_params
+ .get("submit")
+ .and_then(|list| list.first())
+ .and_then(|x| Some(x.to_lowercase().parse::<bool>()))
+ .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
+ .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected boolean)".to_string())))?;
+
// Body parameters (note that non-required body parameters will ignore garbage
// values, rather than causing a 400 response). Produce warning header and logs for
// any unused fields.
- let param_annotation = req
+ let param_editgroup = req
.get::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter annotation - not valid UTF-8: {}", e))))?;
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - not valid UTF-8: {}", e))))?;
let mut unused_elements = Vec::new();
- let param_annotation = if let Some(param_annotation_raw) = param_annotation {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_annotation_raw);
+ let param_editgroup = if let Some(param_editgroup_raw) = param_editgroup {
+ let deserializer = &mut serde_json::Deserializer::from_str(&param_editgroup_raw);
- let param_annotation: Option<models::EditgroupAnnotation> = serde_ignored::deserialize(deserializer, |path| {
+ let param_editgroup: Option<models::Editgroup> = serde_ignored::deserialize(deserializer, |path| {
warn!("Ignoring unknown field in body: {}", path);
unused_elements.push(path.to_string());
})
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter annotation - doesn't match schema: {}", e))))?;
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editgroup - doesn't match schema: {}", e))))?;
- param_annotation
+ param_editgroup
} else {
None
};
- let param_annotation = param_annotation.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter annotation".to_string())))?;
+ let param_editgroup = param_editgroup.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editgroup".to_string())))?;
- match api.create_editgroup_annotation(param_editgroup_id, param_annotation, context).wait() {
+ match api.update_editgroup(param_editgroup_id, param_editgroup, param_submit, context).wait() {
Ok(rsp) => match rsp {
- CreateEditgroupAnnotationResponse::Created(body) => {
+ UpdateEditgroupResponse::UpdatedEditgroup(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
- let mut response = Response::with((status::Status::from_u16(201), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_CREATED.clone()));
+ let mut response = Response::with((status::Status::from_u16(200), body_string));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_UPDATED_EDITGROUP.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3868,11 +3885,11 @@ where
}
Ok(response)
}
- CreateEditgroupAnnotationResponse::BadRequest(body) => {
+ UpdateEditgroupResponse::BadRequest(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_BAD_REQUEST.clone()));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3880,14 +3897,14 @@ where
}
Ok(response)
}
- CreateEditgroupAnnotationResponse::NotAuthorized { body, www_authenticate } => {
+ UpdateEditgroupResponse::NotAuthorized { body, www_authenticate } => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(401), body_string));
header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
response.headers.set(ResponseWwwAuthenticate(www_authenticate));
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_NOT_AUTHORIZED.clone()));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_NOT_AUTHORIZED.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3895,11 +3912,11 @@ where
}
Ok(response)
}
- CreateEditgroupAnnotationResponse::Forbidden(body) => {
+ UpdateEditgroupResponse::Forbidden(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(403), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_FORBIDDEN.clone()));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_FORBIDDEN.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3907,11 +3924,11 @@ where
}
Ok(response)
}
- CreateEditgroupAnnotationResponse::NotFound(body) => {
+ UpdateEditgroupResponse::NotFound(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_NOT_FOUND.clone()));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_NOT_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3919,11 +3936,11 @@ where
}
Ok(response)
}
- CreateEditgroupAnnotationResponse::GenericError(body) => {
+ UpdateEditgroupResponse::GenericError(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_EDITGROUP_ANNOTATION_GENERIC_ERROR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITGROUP_GENERIC_ERROR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
if !unused_elements.is_empty() {
@@ -3945,85 +3962,12 @@ where
Ok(response)
})
},
- "CreateEditgroupAnnotation",
- );
-
- let api_clone = api.clone();
- router.get(
- "/v0/changelog",
- move |req: &mut Request| {
- let mut context = Context::default();
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
- .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?;
-
- match api.get_changelog(param_limit, context).wait() {
- Ok(rsp) => match rsp {
- GetChangelogResponse::Success(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_SUCCESS.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetChangelogResponse::BadRequest(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetChangelogResponse::GenericError(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_GENERIC_ERROR.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
- }
- }
- }
-
- handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- Ok(response)
- })
- },
- "GetChangelog",
+ "UpdateEditgroup",
);
let api_clone = api.clone();
router.get(
- "/v0/changelog/:index",
+ "/v0/editor/:editor_id",
move |req: &mut Request| {
let mut context = Context::default();
@@ -4037,57 +3981,57 @@ where
context.authorization = req.extensions.remove::<Authorization>();
// Path parameters
- let param_index = {
+ let param_editor_id = {
let param = req
.extensions
.get::<Router>()
.ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("index")
- .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter index".to_string())))?;
+ .find("editor_id")
+ .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editor_id".to_string())))?;
percent_decode(param.as_bytes())
.decode_utf8()
.map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
.parse()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter index: {}", e))))?
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editor_id: {}", e))))?
};
- match api.get_changelog_entry(param_index, context).wait() {
+ match api.get_editor(param_editor_id, context).wait() {
Ok(rsp) => match rsp {
- GetChangelogEntryResponse::FoundChangelogEntry(body) => {
+ GetEditorResponse::Found(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_FOUND_CHANGELOG_ENTRY.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- GetChangelogEntryResponse::BadRequest(body) => {
+ GetEditorResponse::BadRequest(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_BAD_REQUEST.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- GetChangelogEntryResponse::NotFound(body) => {
+ GetEditorResponse::NotFound(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_NOT_FOUND.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_NOT_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- GetChangelogEntryResponse::GenericError(body) => {
+ GetEditorResponse::GenericError(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_CHANGELOG_ENTRY_GENERIC_ERROR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_GENERIC_ERROR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
@@ -4107,12 +4051,12 @@ where
Ok(response)
})
},
- "GetChangelogEntry",
+ "GetEditor",
);
let api_clone = api.clone();
router.get(
- "/v0/editgroup/:editgroup_id",
+ "/v0/editor/:editor_id/annotations",
move |req: &mut Request| {
let mut context = Context::default();
@@ -4126,57 +4070,101 @@ where
context.authorization = req.extensions.remove::<Authorization>();
// Path parameters
- let param_editgroup_id = {
+ let param_editor_id = {
let param = req
.extensions
.get::<Router>()
.ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("editgroup_id")
- .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_id".to_string())))?;
+ .find("editor_id")
+ .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editor_id".to_string())))?;
percent_decode(param.as_bytes())
.decode_utf8()
.map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
.parse()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))?
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editor_id: {}", e))))?
};
- match api.get_editgroup(param_editgroup_id, context).wait() {
+ // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
+ let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
+ let param_limit = query_params
+ .get("limit")
+ .and_then(|list| list.first())
+ .and_then(|x| Some(x.parse::<i64>()))
+ .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
+ .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?;
+ let param_before = query_params
+ .get("before")
+ .and_then(|list| list.first())
+ .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
+ .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
+ .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
+ let param_since = query_params
+ .get("since")
+ .and_then(|list| list.first())
+ .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
+ .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
+ .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
+
+ match api.get_editor_annotations(param_editor_id, param_limit, param_before, param_since, context).wait() {
Ok(rsp) => match rsp {
- GetEditgroupResponse::Found(body) => {
+ GetEditorAnnotationsResponse::Success(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_FOUND.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_SUCCESS.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- GetEditgroupResponse::BadRequest(body) => {
+ GetEditorAnnotationsResponse::BadRequest(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_BAD_REQUEST.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- GetEditgroupResponse::NotFound(body) => {
+ GetEditorAnnotationsResponse::NotAuthorized { body, www_authenticate } => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(401), body_string));
+ header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
+ response.headers.set(ResponseWwwAuthenticate(www_authenticate));
+
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_NOT_AUTHORIZED.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ GetEditorAnnotationsResponse::Forbidden(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(403), body_string));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_FORBIDDEN.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+
+ Ok(response)
+ }
+ GetEditorAnnotationsResponse::NotFound(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_NOT_FOUND.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_NOT_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- GetEditgroupResponse::GenericError(body) => {
+ GetEditorAnnotationsResponse::GenericError(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_GENERIC_ERROR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_GENERIC_ERROR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
@@ -4196,12 +4184,12 @@ where
Ok(response)
})
},
- "GetEditgroup",
+ "GetEditorAnnotations",
);
let api_clone = api.clone();
router.get(
- "/v0/editgroup/:editgroup_id/annotations",
+ "/v0/editor/:editor_id/editgroups",
move |req: &mut Request| {
let mut context = Context::default();
@@ -4215,84 +4203,78 @@ where
context.authorization = req.extensions.remove::<Authorization>();
// Path parameters
- let param_editgroup_id = {
+ let param_editor_id = {
let param = req
.extensions
.get::<Router>()
.ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("editgroup_id")
- .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_id".to_string())))?;
+ .find("editor_id")
+ .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editor_id".to_string())))?;
percent_decode(param.as_bytes())
.decode_utf8()
.map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
.parse()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))?
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editor_id: {}", e))))?
};
// Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_expand = query_params.get("expand").and_then(|list| list.first()).and_then(|x| x.parse::<String>().ok());
+ let param_limit = query_params
+ .get("limit")
+ .and_then(|list| list.first())
+ .and_then(|x| Some(x.parse::<i64>()))
+ .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
+ .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?;
+ let param_before = query_params
+ .get("before")
+ .and_then(|list| list.first())
+ .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
+ .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
+ .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
+ let param_since = query_params
+ .get("since")
+ .and_then(|list| list.first())
+ .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
+ .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
+ .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
- match api.get_editgroup_annotations(param_editgroup_id, param_expand, context).wait() {
+ match api.get_editor_editgroups(param_editor_id, param_limit, param_before, param_since, context).wait() {
Ok(rsp) => match rsp {
- GetEditgroupAnnotationsResponse::Success(body) => {
+ GetEditorEditgroupsResponse::Found(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_SUCCESS.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- GetEditgroupAnnotationsResponse::BadRequest(body) => {
+ GetEditorEditgroupsResponse::BadRequest(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetEditgroupAnnotationsResponse::NotAuthorized { body, www_authenticate } => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(401), body_string));
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- response.headers.set(ResponseWwwAuthenticate(www_authenticate));
-
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_NOT_AUTHORIZED.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
- Ok(response)
- }
- GetEditgroupAnnotationsResponse::Forbidden(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(403), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_FORBIDDEN.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- GetEditgroupAnnotationsResponse::NotFound(body) => {
+ GetEditorEditgroupsResponse::NotFound(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_NOT_FOUND.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_NOT_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
Ok(response)
}
- GetEditgroupAnnotationsResponse::GenericError(body) => {
+ GetEditorEditgroupsResponse::GenericError(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITGROUP_ANNOTATIONS_GENERIC_ERROR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_EDITGROUPS_GENERIC_ERROR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
@@ -4312,12 +4294,12 @@ where
Ok(response)
})
},
- "GetEditgroupAnnotations",
+ "GetEditorEditgroups",
);
let api_clone = api.clone();
- router.get(
- "/v0/editor/:editor_id/annotations",
+ router.put(
+ "/v0/editor/:editor_id",
move |req: &mut Request| {
let mut context = Context::default();
@@ -4330,6 +4312,8 @@ where
context.auth_data = req.extensions.remove::<AuthData>();
context.authorization = req.extensions.remove::<Authorization>();
+ let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?;
+
// Path parameters
let param_editor_id = {
let param = req
@@ -4345,90 +4329,106 @@ where
.map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editor_id: {}", e))))?
};
- // Query parameters (note that non-required or collection query parameters will ignore garbage values, rather than causing a 400 response)
- let query_params = req.get::<UrlEncodedQuery>().unwrap_or_default();
- let param_limit = query_params
- .get("limit")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<i64>()))
- .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
- .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected integer)".to_string())))?;
- let param_before = query_params
- .get("before")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
- .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
- .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
- let param_since = query_params
- .get("since")
- .and_then(|list| list.first())
- .and_then(|x| Some(x.parse::<chrono::DateTime<chrono::Utc>>()))
- .map_or_else(|| Ok(None), |x| x.map(|v| Some(v)))
- .map_err(|x| Response::with((status::BadRequest, "unparsable query parameter (expected UTC datetime in ISO/RFC format)".to_string())))?;
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
- match api.get_editor_annotations(param_editor_id, param_limit, param_before, param_since, context).wait() {
+ let param_editor = req
+ .get::<bodyparser::Raw>()
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editor - not valid UTF-8: {}", e))))?;
+
+ let mut unused_elements = Vec::new();
+
+ let param_editor = if let Some(param_editor_raw) = param_editor {
+ let deserializer = &mut serde_json::Deserializer::from_str(&param_editor_raw);
+
+ let param_editor: Option<models::Editor> = serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ })
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter editor - doesn't match schema: {}", e))))?;
+
+ param_editor
+ } else {
+ None
+ };
+ let param_editor = param_editor.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter editor".to_string())))?;
+
+ match api.update_editor(param_editor_id, param_editor, context).wait() {
Ok(rsp) => match rsp {
- GetEditorAnnotationsResponse::Success(body) => {
+ UpdateEditorResponse::UpdatedEditor(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(200), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_SUCCESS.clone()));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_UPDATED_EDITOR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
Ok(response)
}
- GetEditorAnnotationsResponse::BadRequest(body) => {
+ UpdateEditorResponse::BadRequest(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_BAD_REQUEST.clone()));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_BAD_REQUEST.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
Ok(response)
}
- GetEditorAnnotationsResponse::NotAuthorized { body, www_authenticate } => {
+ UpdateEditorResponse::NotAuthorized { body, www_authenticate } => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(401), body_string));
header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
response.headers.set(ResponseWwwAuthenticate(www_authenticate));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_NOT_AUTHORIZED.clone()));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_NOT_AUTHORIZED.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
Ok(response)
}
- GetEditorAnnotationsResponse::Forbidden(body) => {
+ UpdateEditorResponse::Forbidden(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(403), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_FORBIDDEN.clone()));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_FORBIDDEN.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
Ok(response)
}
- GetEditorAnnotationsResponse::NotFound(body) => {
+ UpdateEditorResponse::NotFound(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_NOT_FOUND.clone()));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_NOT_FOUND.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
Ok(response)
}
- GetEditorAnnotationsResponse::GenericError(body) => {
+ UpdateEditorResponse::GenericError(body) => {
let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::GET_EDITOR_ANNOTATIONS_GENERIC_ERROR.clone()));
+ response.headers.set(ContentType(mimetypes::responses::UPDATE_EDITOR_GENERIC_ERROR.clone()));
context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
-
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
Ok(response)
}
},
@@ -4445,7 +4445,7 @@ where
Ok(response)
})
},
- "GetEditorAnnotations",
+ "UpdateEditor",
);
let api_clone = api.clone();
@@ -7156,157 +7156,6 @@ where
);
let api_clone = api.clone();
- router.post(
- "/v0/editgroup/:editgroup_id/work",
- move |req: &mut Request| {
- let mut context = Context::default();
-
- // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
- fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
- where
- T: Api,
- {
- context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
- context.auth_data = req.extensions.remove::<AuthData>();
- context.authorization = req.extensions.remove::<Authorization>();
-
- let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?;
-
- // Path parameters
- let param_editgroup_id = {
- let param = req
- .extensions
- .get::<Router>()
- .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
- .find("editgroup_id")
- .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_id".to_string())))?;
- percent_decode(param.as_bytes())
- .decode_utf8()
- .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
- .parse()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))?
- };
-
- // Body parameters (note that non-required body parameters will ignore garbage
- // values, rather than causing a 400 response). Produce warning header and logs for
- // any unused fields.
-
- let param_entity = req
- .get::<bodyparser::Raw>()
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
-
- let mut unused_elements = Vec::new();
-
- let param_entity = if let Some(param_entity_raw) = param_entity {
- let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
-
- let param_entity: Option<models::WorkEntity> = serde_ignored::deserialize(deserializer, |path| {
- warn!("Ignoring unknown field in body: {}", path);
- unused_elements.push(path.to_string());
- })
- .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
-
- param_entity
- } else {
- None
- };
- let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
-
- match api.create_work(param_editgroup_id, param_entity, context).wait() {
- Ok(rsp) => match rsp {
- CreateWorkResponse::CreatedEntity(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(201), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_CREATED_ENTITY.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
- Ok(response)
- }
- CreateWorkResponse::BadRequest(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(400), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BAD_REQUEST.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
- Ok(response)
- }
- CreateWorkResponse::NotAuthorized { body, www_authenticate } => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(401), body_string));
- header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
- response.headers.set(ResponseWwwAuthenticate(www_authenticate));
-
- response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_NOT_AUTHORIZED.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
- Ok(response)
- }
- CreateWorkResponse::Forbidden(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(403), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_FORBIDDEN.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
- Ok(response)
- }
- CreateWorkResponse::NotFound(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(404), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_NOT_FOUND.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
- Ok(response)
- }
- CreateWorkResponse::GenericError(body) => {
- let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
-
- let mut response = Response::with((status::Status::from_u16(500), body_string));
- response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_GENERIC_ERROR.clone()));
-
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- if !unused_elements.is_empty() {
- response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
- }
- Ok(response)
- }
- },
- Err(_) => {
- // Application code returned an error. This should not happen, as the implementation should
- // return a valid response.
- Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
- }
- }
- }
-
- handle_request(req, &api_clone, &mut context).or_else(|mut response| {
- context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
- Ok(response)
- })
- },
- "CreateWork",
- );
-
- let api_clone = api.clone();
router.delete(
"/v0/editgroup/:editgroup_id/release/:ident",
move |req: &mut Request| {
@@ -9744,6 +9593,157 @@ where
let api_clone = api.clone();
router.post(
+ "/v0/editgroup/:editgroup_id/work",
+ move |req: &mut Request| {
+ let mut context = Context::default();
+
+ // Helper function to provide a code block to use `?` in (to be replaced by the `catch` block when it exists).
+ fn handle_request<T>(req: &mut Request, api: &T, context: &mut Context) -> Result<Response, Response>
+ where
+ T: Api,
+ {
+ context.x_span_id = Some(req.headers.get::<XSpanId>().map(XSpanId::to_string).unwrap_or_else(|| self::uuid::Uuid::new_v4().to_string()));
+ context.auth_data = req.extensions.remove::<AuthData>();
+ context.authorization = req.extensions.remove::<Authorization>();
+
+ let authorization = context.authorization.as_ref().ok_or_else(|| Response::with((status::Forbidden, "Unauthenticated".to_string())))?;
+
+ // Path parameters
+ let param_editgroup_id = {
+ let param = req
+ .extensions
+ .get::<Router>()
+ .ok_or_else(|| Response::with((status::InternalServerError, "An internal error occurred".to_string())))?
+ .find("editgroup_id")
+ .ok_or_else(|| Response::with((status::BadRequest, "Missing path parameter editgroup_id".to_string())))?;
+ percent_decode(param.as_bytes())
+ .decode_utf8()
+ .map_err(|_| Response::with((status::BadRequest, format!("Couldn't percent-decode path parameter as UTF-8: {}", param))))?
+ .parse()
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse path parameter editgroup_id: {}", e))))?
+ };
+
+ // Body parameters (note that non-required body parameters will ignore garbage
+ // values, rather than causing a 400 response). Produce warning header and logs for
+ // any unused fields.
+
+ let param_entity = req
+ .get::<bodyparser::Raw>()
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - not valid UTF-8: {}", e))))?;
+
+ let mut unused_elements = Vec::new();
+
+ let param_entity = if let Some(param_entity_raw) = param_entity {
+ let deserializer = &mut serde_json::Deserializer::from_str(&param_entity_raw);
+
+ let param_entity: Option<models::WorkEntity> = serde_ignored::deserialize(deserializer, |path| {
+ warn!("Ignoring unknown field in body: {}", path);
+ unused_elements.push(path.to_string());
+ })
+ .map_err(|e| Response::with((status::BadRequest, format!("Couldn't parse body parameter entity - doesn't match schema: {}", e))))?;
+
+ param_entity
+ } else {
+ None
+ };
+ let param_entity = param_entity.ok_or_else(|| Response::with((status::BadRequest, "Missing required body parameter entity".to_string())))?;
+
+ match api.create_work(param_editgroup_id, param_entity, context).wait() {
+ Ok(rsp) => match rsp {
+ CreateWorkResponse::CreatedEntity(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(201), body_string));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_CREATED_ENTITY.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ CreateWorkResponse::BadRequest(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(400), body_string));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_BAD_REQUEST.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ CreateWorkResponse::NotAuthorized { body, www_authenticate } => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(401), body_string));
+ header! { (ResponseWwwAuthenticate, "WWW_Authenticate") => [String] }
+ response.headers.set(ResponseWwwAuthenticate(www_authenticate));
+
+ response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_NOT_AUTHORIZED.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ CreateWorkResponse::Forbidden(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(403), body_string));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_FORBIDDEN.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ CreateWorkResponse::NotFound(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(404), body_string));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_NOT_FOUND.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ CreateWorkResponse::GenericError(body) => {
+ let body_string = serde_json::to_string(&body).expect("impossible to fail to serialize");
+
+ let mut response = Response::with((status::Status::from_u16(500), body_string));
+ response.headers.set(ContentType(mimetypes::responses::CREATE_WORK_GENERIC_ERROR.clone()));
+
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ if !unused_elements.is_empty() {
+ response.headers.set(Warning(format!("Ignoring unknown fields in body: {:?}", unused_elements)));
+ }
+ Ok(response)
+ }
+ },
+ Err(_) => {
+ // Application code returned an error. This should not happen, as the implementation should
+ // return a valid response.
+ Err(Response::with((status::InternalServerError, "An internal error occurred".to_string())))
+ }
+ }
+ }
+
+ handle_request(req, &api_clone, &mut context).or_else(|mut response| {
+ context.x_span_id.as_ref().map(|header| response.headers.set(XSpanId(header.clone())));
+ Ok(response)
+ })
+ },
+ "CreateWork",
+ );
+
+ let api_clone = api.clone();
+ router.post(
"/v0/editgroup/auto/work/batch",
move |req: &mut Request| {
let mut context = Context::default();