From 36a1fbe4ce13be3631e07a5ecfc84ffc87c74931 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 6 Sep 2018 15:02:11 -0700 Subject: codegen put/delete --- rust/fatcat-api/src/client.rs | 1241 +++++++++++++++++++++++++++++++---------- 1 file changed, 957 insertions(+), 284 deletions(-) (limited to 'rust/fatcat-api/src/client.rs') diff --git a/rust/fatcat-api/src/client.rs b/rust/fatcat-api/src/client.rs index 4140da76..9b2caa32 100644 --- a/rust/fatcat-api/src/client.rs +++ b/rust/fatcat-api/src/client.rs @@ -36,10 +36,11 @@ use swagger::{ApiError, Context, XSpanId}; use models; use { AcceptEditgroupResponse, Api, CreateContainerBatchResponse, CreateContainerResponse, CreateCreatorBatchResponse, CreateCreatorResponse, CreateEditgroupResponse, CreateFileBatchResponse, - CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerHistoryResponse, - GetContainerResponse, GetCreatorHistoryResponse, GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileHistoryResponse, - GetFileResponse, GetReleaseFilesResponse, GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse, GetWorkReleasesResponse, GetWorkResponse, - LookupContainerResponse, LookupCreatorResponse, LookupFileResponse, LookupReleaseResponse, + CreateFileResponse, CreateReleaseBatchResponse, CreateReleaseResponse, CreateWorkBatchResponse, CreateWorkResponse, DeleteContainerResponse, DeleteCreatorResponse, DeleteFileResponse, + DeleteReleaseResponse, DeleteWorkResponse, GetChangelogEntryResponse, GetChangelogResponse, GetContainerHistoryResponse, GetContainerResponse, GetCreatorHistoryResponse, + GetCreatorReleasesResponse, GetCreatorResponse, GetEditgroupResponse, GetEditorChangelogResponse, GetEditorResponse, GetFileHistoryResponse, GetFileResponse, GetReleaseFilesResponse, + GetReleaseHistoryResponse, GetReleaseResponse, GetStatsResponse, GetWorkHistoryResponse, GetWorkReleasesResponse, GetWorkResponse, LookupContainerResponse, LookupCreatorResponse, + LookupFileResponse, LookupReleaseResponse, UpdateContainerResponse, UpdateCreatorResponse, UpdateFileResponse, UpdateReleaseResponse, UpdateWorkResponse, }; /// Convert input into a base path, e.g. "http://example:123". Also checks the scheme as it goes. @@ -200,6 +201,13 @@ impl Api for Client { 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::(&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)))?; @@ -933,14 +941,19 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_changelog(&self, param_limit: Option, context: &Context) -> Box + Send> { + fn delete_container(&self, param_id: String, param_editgroup: Option, context: &Context) -> Box + Send> { // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); - let url = format!("{}/v0/changelog?{limit}", self.base_path, limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET)); + let url = format!( + "{}/v0/container/{id}?{editgroup}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + editgroup = utf8_percent_encode(&query_editgroup, QUERY_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::Delete, &url); let mut custom_headers = hyper::header::Headers::new(); context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); @@ -948,74 +961,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::>(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetChangelogResponse::Success(body)) + Ok(DeleteContainerResponse::DeletedEntity(body)) } - 500 => { + 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::(&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!("", &buf[..len].to_vec())), - }, - Err(e) => Cow::from(format!("", 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_id: i64, context: &Context) -> Box + Send> { - let url = format!("{}/v0/changelog/{id}", self.base_path, id = utf8_percent_encode(¶m_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 { - 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::(&buf)?; - - Ok(GetChangelogEntryResponse::FoundChangelogEntry(body)) + Ok(DeleteContainerResponse::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::(&buf)?; - Ok(GetChangelogEntryResponse::NotFound(body)) + Ok(DeleteContainerResponse::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::(&buf)?; - Ok(GetChangelogEntryResponse::GenericError(body)) + Ok(DeleteContainerResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1035,19 +1009,19 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_container(&self, param_id: String, param_expand: Option, context: &Context) -> Box + Send> { + fn delete_creator(&self, param_id: String, param_editgroup: Option, context: &Context) -> Box + Send> { // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); let url = format!( - "{}/v0/container/{id}?{expand}", + "{}/v0/creator/{id}?{editgroup}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET) + editgroup = utf8_percent_encode(&query_editgroup, QUERY_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::Delete, &url); let mut custom_headers = hyper::header::Headers::new(); context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); @@ -1055,35 +1029,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetContainerResponse::FoundEntity(body)) + Ok(DeleteCreatorResponse::DeletedEntity(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::(&buf)?; - Ok(GetContainerResponse::BadRequest(body)) + Ok(DeleteCreatorResponse::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::(&buf)?; - Ok(GetContainerResponse::NotFound(body)) + Ok(DeleteCreatorResponse::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::(&buf)?; - Ok(GetContainerResponse::GenericError(body)) + Ok(DeleteCreatorResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1103,19 +1077,19 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_container_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { + fn delete_file(&self, param_id: String, param_editgroup: Option, context: &Context) -> Box + Send> { // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); let url = format!( - "{}/v0/container/{id}/history?{limit}", + "{}/v0/file/{id}?{editgroup}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) + editgroup = utf8_percent_encode(&query_editgroup, QUERY_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::Delete, &url); let mut custom_headers = hyper::header::Headers::new(); context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); @@ -1123,35 +1097,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::>(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetContainerHistoryResponse::FoundEntityHistory(body)) + Ok(DeleteFileResponse::DeletedEntity(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::(&buf)?; - Ok(GetContainerHistoryResponse::BadRequest(body)) + Ok(DeleteFileResponse::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::(&buf)?; - Ok(GetContainerHistoryResponse::NotFound(body)) + Ok(DeleteFileResponse::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::(&buf)?; - Ok(GetContainerHistoryResponse::GenericError(body)) + Ok(DeleteFileResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1171,19 +1145,19 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_creator(&self, param_id: String, param_expand: Option, context: &Context) -> Box + Send> { + fn delete_release(&self, param_id: String, param_editgroup: Option, context: &Context) -> Box + Send> { // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); let url = format!( - "{}/v0/creator/{id}?{expand}", + "{}/v0/release/{id}?{editgroup}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET) + editgroup = utf8_percent_encode(&query_editgroup, QUERY_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::Delete, &url); let mut custom_headers = hyper::header::Headers::new(); context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); @@ -1191,35 +1165,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetCreatorResponse::FoundEntity(body)) + Ok(DeleteReleaseResponse::DeletedEntity(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::(&buf)?; - Ok(GetCreatorResponse::BadRequest(body)) + Ok(DeleteReleaseResponse::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::(&buf)?; - Ok(GetCreatorResponse::NotFound(body)) + Ok(DeleteReleaseResponse::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::(&buf)?; - Ok(GetCreatorResponse::GenericError(body)) + Ok(DeleteReleaseResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1239,19 +1213,19 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_creator_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { + fn delete_work(&self, param_id: String, param_editgroup: Option, context: &Context) -> Box + Send> { // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + let query_editgroup = param_editgroup.map_or_else(String::new, |query| format!("editgroup={editgroup}&", editgroup = query.to_string())); let url = format!( - "{}/v0/creator/{id}/history?{limit}", + "{}/v0/work/{id}?{editgroup}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) + editgroup = utf8_percent_encode(&query_editgroup, QUERY_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::Delete, &url); let mut custom_headers = hyper::header::Headers::new(); context.x_span_id.as_ref().map(|header| custom_headers.set(XSpanId(header.clone()))); @@ -1259,35 +1233,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::>(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetCreatorHistoryResponse::FoundEntityHistory(body)) + Ok(DeleteWorkResponse::DeletedEntity(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::(&buf)?; - Ok(GetCreatorHistoryResponse::BadRequest(body)) + Ok(DeleteWorkResponse::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::(&buf)?; - Ok(GetCreatorHistoryResponse::NotFound(body)) + Ok(DeleteWorkResponse::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::(&buf)?; - Ok(GetCreatorHistoryResponse::GenericError(body)) + Ok(DeleteWorkResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1307,8 +1281,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_creator_releases(&self, param_id: String, context: &Context) -> Box + Send> { - let url = format!("{}/v0/creator/{id}/releases", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + fn get_changelog(&self, param_limit: Option, context: &Context) -> Box + 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); @@ -1319,35 +1296,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::>(&buf)?; - - Ok(GetCreatorReleasesResponse::FoundEntity(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::(&buf)?; - - Ok(GetCreatorReleasesResponse::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::(&buf)?; + let body = serde_json::from_str::>(&buf)?; - Ok(GetCreatorReleasesResponse::NotFound(body)) + Ok(GetChangelogResponse::Success(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::(&buf)?; - Ok(GetCreatorReleasesResponse::GenericError(body)) + Ok(GetChangelogResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1367,8 +1330,8 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_editgroup(&self, param_id: String, context: &Context) -> Box + Send> { - let url = format!("{}/v0/editgroup/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + fn get_changelog_entry(&self, param_id: i64, context: &Context) -> Box + Send> { + let url = format!("{}/v0/changelog/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); @@ -1379,35 +1342,28 @@ 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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::(&buf)?; - - Ok(GetEditgroupResponse::FoundEntity(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::(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetEditgroupResponse::BadRequest(body)) + Ok(GetChangelogEntryResponse::FoundChangelogEntry(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::(&buf)?; - Ok(GetEditgroupResponse::NotFound(body)) + 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::(&buf)?; - Ok(GetEditgroupResponse::GenericError(body)) + Ok(GetChangelogEntryResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1427,8 +1383,16 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_editor(&self, param_id: String, context: &Context) -> Box + Send> { - let url = format!("{}/v0/editor/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + fn get_container(&self, param_id: String, param_expand: Option, context: &Context) -> Box + 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/container/{id}?{expand}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET) + ); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); @@ -1439,28 +1403,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetEditorResponse::FoundEditor(body)) + Ok(GetContainerResponse::FoundEntity(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::(&buf)?; + + Ok(GetContainerResponse::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::(&buf)?; - Ok(GetEditorResponse::NotFound(body)) + Ok(GetContainerResponse::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::(&buf)?; - Ok(GetEditorResponse::GenericError(body)) + Ok(GetContainerResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1480,8 +1451,16 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_editor_changelog(&self, param_id: String, context: &Context) -> Box + Send> { - let url = format!("{}/v0/editor/{id}/changelog", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + fn get_container_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + 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/container/{id}/history?{limit}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + 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); @@ -1492,28 +1471,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::>(&buf)?; + let body = serde_json::from_str::>(&buf)?; - Ok(GetEditorChangelogResponse::FoundMergedChanges(body)) + Ok(GetContainerHistoryResponse::FoundEntityHistory(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::(&buf)?; + + Ok(GetContainerHistoryResponse::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::(&buf)?; - Ok(GetEditorChangelogResponse::NotFound(body)) + Ok(GetContainerHistoryResponse::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::(&buf)?; - Ok(GetEditorChangelogResponse::GenericError(body)) + Ok(GetContainerHistoryResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1533,12 +1519,12 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_file(&self, param_id: String, param_expand: Option, context: &Context) -> Box + Send> { + fn get_creator(&self, param_id: String, param_expand: Option, context: &Context) -> Box + 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/file/{id}?{expand}", + "{}/v0/creator/{id}?{expand}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET) @@ -1553,35 +1539,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetFileResponse::FoundEntity(body)) + Ok(GetCreatorResponse::FoundEntity(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::(&buf)?; - Ok(GetFileResponse::BadRequest(body)) + Ok(GetCreatorResponse::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::(&buf)?; - Ok(GetFileResponse::NotFound(body)) + Ok(GetCreatorResponse::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::(&buf)?; - Ok(GetFileResponse::GenericError(body)) + Ok(GetCreatorResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1601,12 +1587,12 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_file_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { + fn get_creator_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + 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/file/{id}/history?{limit}", + "{}/v0/creator/{id}/history?{limit}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) @@ -1621,35 +1607,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::>(&buf)?; - Ok(GetFileHistoryResponse::FoundEntityHistory(body)) + Ok(GetCreatorHistoryResponse::FoundEntityHistory(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::(&buf)?; - Ok(GetFileHistoryResponse::BadRequest(body)) + Ok(GetCreatorHistoryResponse::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::(&buf)?; - Ok(GetFileHistoryResponse::NotFound(body)) + Ok(GetCreatorHistoryResponse::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::(&buf)?; - Ok(GetFileHistoryResponse::GenericError(body)) + Ok(GetCreatorHistoryResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1669,14 +1655,376 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_release(&self, param_id: String, param_expand: Option, context: &Context) -> Box + Send> { - // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); + fn get_creator_releases(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/creator/{id}/releases", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); - let url = format!( - "{}/v0/release/{id}?{expand}", - self.base_path, - id = utf8_percent_encode(¶m_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 { + 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::>(&buf)?; + + Ok(GetCreatorReleasesResponse::FoundEntity(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::(&buf)?; + + Ok(GetCreatorReleasesResponse::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::(&buf)?; + + Ok(GetCreatorReleasesResponse::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::(&buf)?; + + Ok(GetCreatorReleasesResponse::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!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", 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(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/editgroup/{id}", self.base_path, id = utf8_percent_encode(¶m_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 { + 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::(&buf)?; + + Ok(GetEditgroupResponse::FoundEntity(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::(&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::(&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::(&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!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", 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_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/editor/{id}", self.base_path, id = utf8_percent_encode(¶m_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 { + 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::(&buf)?; + + Ok(GetEditorResponse::FoundEditor(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::(&buf)?; + + 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::(&buf)?; + + Ok(GetEditorResponse::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!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", 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_changelog(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/editor/{id}/changelog", self.base_path, id = utf8_percent_encode(¶m_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 { + 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::>(&buf)?; + + Ok(GetEditorChangelogResponse::FoundMergedChanges(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::(&buf)?; + + Ok(GetEditorChangelogResponse::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::(&buf)?; + + Ok(GetEditorChangelogResponse::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!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", 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_file(&self, param_id: String, param_expand: Option, context: &Context) -> Box + 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/file/{id}?{expand}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + expand = utf8_percent_encode(&query_expand, 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 { + 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::(&buf)?; + + Ok(GetFileResponse::FoundEntity(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::(&buf)?; + + Ok(GetFileResponse::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::(&buf)?; + + Ok(GetFileResponse::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::(&buf)?; + + Ok(GetFileResponse::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!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", 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_file_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + 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/file/{id}/history?{limit}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + 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 { + 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::>(&buf)?; + + Ok(GetFileHistoryResponse::FoundEntityHistory(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::(&buf)?; + + Ok(GetFileHistoryResponse::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::(&buf)?; + + Ok(GetFileHistoryResponse::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::(&buf)?; + + Ok(GetFileHistoryResponse::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!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", 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_release(&self, param_id: String, param_expand: Option, context: &Context) -> Box + 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/release/{id}?{expand}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET) ); @@ -1689,35 +2037,348 @@ 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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { + 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::(&buf)?; + + Ok(GetReleaseResponse::FoundEntity(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::(&buf)?; + + Ok(GetReleaseResponse::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::(&buf)?; + + Ok(GetReleaseResponse::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::(&buf)?; + + Ok(GetReleaseResponse::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!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", 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_release_files(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/release/{id}/files", self.base_path, id = utf8_percent_encode(¶m_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 { + 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::>(&buf)?; + + Ok(GetReleaseFilesResponse::FoundEntity(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::(&buf)?; + + Ok(GetReleaseFilesResponse::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::(&buf)?; + + Ok(GetReleaseFilesResponse::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::(&buf)?; + + Ok(GetReleaseFilesResponse::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!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", 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_release_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + 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/release/{id}/history?{limit}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + 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 { + 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::>(&buf)?; + + Ok(GetReleaseHistoryResponse::FoundEntityHistory(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::(&buf)?; + + Ok(GetReleaseHistoryResponse::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::(&buf)?; + + Ok(GetReleaseHistoryResponse::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::(&buf)?; + + Ok(GetReleaseHistoryResponse::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!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", 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_stats(&self, param_more: Option, context: &Context) -> Box + Send> { + // Query parameters + let query_more = param_more.map_or_else(String::new, |query| format!("more={more}&", more = query.to_string())); + + let url = format!("{}/v0/stats?{more}", self.base_path, more = utf8_percent_encode(&query_more, 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 { + 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::(&buf)?; + + Ok(GetStatsResponse::Success(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::(&buf)?; + + Ok(GetStatsResponse::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!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", 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_work(&self, param_id: String, param_expand: Option, context: &Context) -> Box + 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/work/{id}?{expand}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + expand = utf8_percent_encode(&query_expand, 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 { + 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::(&buf)?; + + Ok(GetWorkResponse::FoundEntity(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::(&buf)?; + + Ok(GetWorkResponse::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::(&buf)?; + + Ok(GetWorkResponse::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::(&buf)?; + + Ok(GetWorkResponse::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!("", &buf[..len].to_vec())), + }, + Err(e) => Cow::from(format!("", 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_work_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + 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/work/{id}/history?{limit}", + self.base_path, + id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), + 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 { 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::(&buf)?; + let body = serde_json::from_str::>(&buf)?; - Ok(GetReleaseResponse::FoundEntity(body)) + Ok(GetWorkHistoryResponse::FoundEntityHistory(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::(&buf)?; - Ok(GetReleaseResponse::BadRequest(body)) + Ok(GetWorkHistoryResponse::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::(&buf)?; - Ok(GetReleaseResponse::NotFound(body)) + Ok(GetWorkHistoryResponse::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::(&buf)?; - Ok(GetReleaseResponse::GenericError(body)) + Ok(GetWorkHistoryResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1737,8 +2398,8 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_release_files(&self, param_id: String, context: &Context) -> Box + Send> { - let url = format!("{}/v0/release/{id}/files", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + fn get_work_releases(&self, param_id: String, context: &Context) -> Box + Send> { + let url = format!("{}/v0/work/{id}/releases", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); @@ -1749,35 +2410,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::>(&buf)?; + let body = serde_json::from_str::>(&buf)?; - Ok(GetReleaseFilesResponse::FoundEntity(body)) + Ok(GetWorkReleasesResponse::FoundEntity(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::(&buf)?; - Ok(GetReleaseFilesResponse::BadRequest(body)) + Ok(GetWorkReleasesResponse::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::(&buf)?; - Ok(GetReleaseFilesResponse::NotFound(body)) + Ok(GetWorkReleasesResponse::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::(&buf)?; - Ok(GetReleaseFilesResponse::GenericError(body)) + Ok(GetWorkReleasesResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1797,16 +2458,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_release_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { + fn lookup_container(&self, param_issnl: String, context: &Context) -> Box + Send> { // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + let query_issnl = format!("issnl={issnl}&", issnl = param_issnl.to_string()); - let url = format!( - "{}/v0/release/{id}/history?{limit}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) - ); + let url = format!("{}/v0/container/lookup?{issnl}", self.base_path, issnl = utf8_percent_encode(&query_issnl, QUERY_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); @@ -1817,35 +2473,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::>(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetReleaseHistoryResponse::FoundEntityHistory(body)) + Ok(LookupContainerResponse::FoundEntity(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::(&buf)?; - Ok(GetReleaseHistoryResponse::BadRequest(body)) + Ok(LookupContainerResponse::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::(&buf)?; - Ok(GetReleaseHistoryResponse::NotFound(body)) + Ok(LookupContainerResponse::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::(&buf)?; - Ok(GetReleaseHistoryResponse::GenericError(body)) + Ok(LookupContainerResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1865,11 +2521,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_stats(&self, param_more: Option, context: &Context) -> Box + Send> { + fn lookup_creator(&self, param_orcid: String, context: &Context) -> Box + Send> { // Query parameters - let query_more = param_more.map_or_else(String::new, |query| format!("more={more}&", more = query.to_string())); + let query_orcid = format!("orcid={orcid}&", orcid = param_orcid.to_string()); - let url = format!("{}/v0/stats?{more}", self.base_path, more = utf8_percent_encode(&query_more, QUERY_ENCODE_SET)); + let url = format!("{}/v0/creator/lookup?{orcid}", self.base_path, orcid = utf8_percent_encode(&query_orcid, QUERY_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); @@ -1880,21 +2536,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetStatsResponse::Success(body)) + Ok(LookupCreatorResponse::FoundEntity(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::(&buf)?; + + Ok(LookupCreatorResponse::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::(&buf)?; + + Ok(LookupCreatorResponse::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::(&buf)?; - Ok(GetStatsResponse::GenericError(body)) + Ok(LookupCreatorResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1914,16 +2584,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_work(&self, param_id: String, param_expand: Option, context: &Context) -> Box + Send> { + fn lookup_file(&self, param_sha1: String, context: &Context) -> Box + Send> { // Query parameters - let query_expand = param_expand.map_or_else(String::new, |query| format!("expand={expand}&", expand = query.to_string())); + let query_sha1 = format!("sha1={sha1}&", sha1 = param_sha1.to_string()); - let url = format!( - "{}/v0/work/{id}?{expand}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - expand = utf8_percent_encode(&query_expand, QUERY_ENCODE_SET) - ); + let url = format!("{}/v0/file/lookup?{sha1}", self.base_path, sha1 = utf8_percent_encode(&query_sha1, QUERY_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); @@ -1934,35 +2599,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetWorkResponse::FoundEntity(body)) + Ok(LookupFileResponse::FoundEntity(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::(&buf)?; - Ok(GetWorkResponse::BadRequest(body)) + Ok(LookupFileResponse::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::(&buf)?; - Ok(GetWorkResponse::NotFound(body)) + Ok(LookupFileResponse::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::(&buf)?; - Ok(GetWorkResponse::GenericError(body)) + Ok(LookupFileResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -1982,16 +2647,11 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_work_history(&self, param_id: String, param_limit: Option, context: &Context) -> Box + Send> { + fn lookup_release(&self, param_doi: String, context: &Context) -> Box + Send> { // Query parameters - let query_limit = param_limit.map_or_else(String::new, |query| format!("limit={limit}&", limit = query.to_string())); + let query_doi = format!("doi={doi}&", doi = param_doi.to_string()); - let url = format!( - "{}/v0/work/{id}/history?{limit}", - self.base_path, - id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET), - limit = utf8_percent_encode(&query_limit, QUERY_ENCODE_SET) - ); + let url = format!("{}/v0/release/lookup?{doi}", self.base_path, doi = utf8_percent_encode(&query_doi, QUERY_ENCODE_SET)); let hyper_client = (self.hyper_client)(); let request = hyper_client.request(hyper::method::Method::Get, &url); @@ -2002,35 +2662,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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::>(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetWorkHistoryResponse::FoundEntityHistory(body)) + Ok(LookupReleaseResponse::FoundEntity(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::(&buf)?; - Ok(GetWorkHistoryResponse::BadRequest(body)) + Ok(LookupReleaseResponse::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::(&buf)?; - Ok(GetWorkHistoryResponse::NotFound(body)) + Ok(LookupReleaseResponse::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::(&buf)?; - Ok(GetWorkHistoryResponse::GenericError(body)) + Ok(LookupReleaseResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -2050,47 +2710,52 @@ impl Api for Client { Box::new(futures::done(result)) } - fn get_work_releases(&self, param_id: String, context: &Context) -> Box + Send> { - let url = format!("{}/v0/work/{id}/releases", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + fn update_container(&self, param_id: String, param_entity: models::ContainerEntity, context: &Context) -> Box + Send> { + let url = format!("{}/v0/container/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); + + let body = serde_json::to_string(¶m_entity).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(); + let request = request.body(&body); + + custom_headers.set(ContentType(mimetypes::requests::UPDATE_CONTAINER.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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::>(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(GetWorkReleasesResponse::FoundEntity(body)) + Ok(UpdateContainerResponse::UpdatedEntity(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::(&buf)?; - Ok(GetWorkReleasesResponse::BadRequest(body)) + Ok(UpdateContainerResponse::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::(&buf)?; - Ok(GetWorkReleasesResponse::NotFound(body)) + Ok(UpdateContainerResponse::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::(&buf)?; - Ok(GetWorkReleasesResponse::GenericError(body)) + Ok(UpdateContainerResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -2110,50 +2775,52 @@ impl Api for Client { Box::new(futures::done(result)) } - fn lookup_container(&self, param_issnl: String, context: &Context) -> Box + Send> { - // Query parameters - let query_issnl = format!("issnl={issnl}&", issnl = param_issnl.to_string()); + fn update_creator(&self, param_id: String, param_entity: models::CreatorEntity, context: &Context) -> Box + Send> { + let url = format!("{}/v0/creator/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); - let url = format!("{}/v0/container/lookup?{issnl}", self.base_path, issnl = utf8_percent_encode(&query_issnl, QUERY_ENCODE_SET)); + let body = serde_json::to_string(¶m_entity).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(); + let request = request.body(&body); + + custom_headers.set(ContentType(mimetypes::requests::UPDATE_CREATOR.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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(LookupContainerResponse::FoundEntity(body)) + Ok(UpdateCreatorResponse::UpdatedEntity(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::(&buf)?; - Ok(LookupContainerResponse::BadRequest(body)) + Ok(UpdateCreatorResponse::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::(&buf)?; - Ok(LookupContainerResponse::NotFound(body)) + Ok(UpdateCreatorResponse::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::(&buf)?; - Ok(LookupContainerResponse::GenericError(body)) + Ok(UpdateCreatorResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -2173,50 +2840,52 @@ impl Api for Client { Box::new(futures::done(result)) } - fn lookup_creator(&self, param_orcid: String, context: &Context) -> Box + Send> { - // Query parameters - let query_orcid = format!("orcid={orcid}&", orcid = param_orcid.to_string()); + fn update_file(&self, param_id: String, param_entity: models::FileEntity, context: &Context) -> Box + Send> { + let url = format!("{}/v0/file/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); - let url = format!("{}/v0/creator/lookup?{orcid}", self.base_path, orcid = utf8_percent_encode(&query_orcid, QUERY_ENCODE_SET)); + let body = serde_json::to_string(¶m_entity).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(); + let request = request.body(&body); + + custom_headers.set(ContentType(mimetypes::requests::UPDATE_FILE.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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(LookupCreatorResponse::FoundEntity(body)) + Ok(UpdateFileResponse::UpdatedEntity(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::(&buf)?; - Ok(LookupCreatorResponse::BadRequest(body)) + Ok(UpdateFileResponse::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::(&buf)?; - Ok(LookupCreatorResponse::NotFound(body)) + Ok(UpdateFileResponse::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::(&buf)?; - Ok(LookupCreatorResponse::GenericError(body)) + Ok(UpdateFileResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -2236,50 +2905,52 @@ impl Api for Client { Box::new(futures::done(result)) } - fn lookup_file(&self, param_sha1: String, context: &Context) -> Box + Send> { - // Query parameters - let query_sha1 = format!("sha1={sha1}&", sha1 = param_sha1.to_string()); + fn update_release(&self, param_id: String, param_entity: models::ReleaseEntity, context: &Context) -> Box + Send> { + let url = format!("{}/v0/release/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); - let url = format!("{}/v0/file/lookup?{sha1}", self.base_path, sha1 = utf8_percent_encode(&query_sha1, QUERY_ENCODE_SET)); + let body = serde_json::to_string(¶m_entity).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(); + let request = request.body(&body); + + custom_headers.set(ContentType(mimetypes::requests::UPDATE_RELEASE.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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(LookupFileResponse::FoundEntity(body)) + Ok(UpdateReleaseResponse::UpdatedEntity(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::(&buf)?; - Ok(LookupFileResponse::BadRequest(body)) + Ok(UpdateReleaseResponse::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::(&buf)?; - Ok(LookupFileResponse::NotFound(body)) + Ok(UpdateReleaseResponse::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::(&buf)?; - Ok(LookupFileResponse::GenericError(body)) + Ok(UpdateReleaseResponse::GenericError(body)) } code => { let mut buf = [0; 100]; @@ -2299,50 +2970,52 @@ impl Api for Client { Box::new(futures::done(result)) } - fn lookup_release(&self, param_doi: String, context: &Context) -> Box + Send> { - // Query parameters - let query_doi = format!("doi={doi}&", doi = param_doi.to_string()); + fn update_work(&self, param_id: String, param_entity: models::WorkEntity, context: &Context) -> Box + Send> { + let url = format!("{}/v0/work/{id}", self.base_path, id = utf8_percent_encode(¶m_id.to_string(), PATH_SEGMENT_ENCODE_SET)); - let url = format!("{}/v0/release/lookup?{doi}", self.base_path, doi = utf8_percent_encode(&query_doi, QUERY_ENCODE_SET)); + let body = serde_json::to_string(¶m_entity).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(); + let request = request.body(&body); + + custom_headers.set(ContentType(mimetypes::requests::UPDATE_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 { + fn parse_response(mut response: hyper::client::response::Response) -> Result { 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::(&buf)?; + let body = serde_json::from_str::(&buf)?; - Ok(LookupReleaseResponse::FoundEntity(body)) + Ok(UpdateWorkResponse::UpdatedEntity(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::(&buf)?; - Ok(LookupReleaseResponse::BadRequest(body)) + Ok(UpdateWorkResponse::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::(&buf)?; - Ok(LookupReleaseResponse::NotFound(body)) + Ok(UpdateWorkResponse::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::(&buf)?; - Ok(LookupReleaseResponse::GenericError(body)) + Ok(UpdateWorkResponse::GenericError(body)) } code => { let mut buf = [0; 100]; -- cgit v1.2.3