/*
* Orthanc API
*
* This is the full documentation of the [REST API](https://orthanc.uclouvain.be/book/users/rest.html) of Orthanc.<p>This reference is automatically generated from the source code of Orthanc. A [shorter cheat sheet](https://orthanc.uclouvain.be/book/users/rest-cheatsheet.html) is part of the Orthanc Book.<p>An earlier, manually crafted version from August 2019, is [still available](2019-08-orthanc-openapi.html), but is not up-to-date anymore ([source](https://groups.google.com/g/orthanc-users/c/NUiJTEICSl8/m/xKeqMrbqAAAJ)).
*
* The version of the OpenAPI document: 1.12.8
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`instances_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_anonymize_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAnonymizePostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_compress_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameCompressPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_compressed_data_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameCompressedDataGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_compressed_md5_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameCompressedMd5GetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_compressed_size_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameCompressedSizeGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_data_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameDataGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameDeleteError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_info_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameInfoGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_is_compressed_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameIsCompressedGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_md5_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameMd5GetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_put`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNamePutError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_size_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameSizeGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_uncompress_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameUncompressPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_attachments_name_verify_md5_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdAttachmentsNameVerifyMd5PostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_content_path_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdContentPathGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdDeleteError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_export_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdExportPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_file_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdFileGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_frames_frame_image_int16_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdFramesFrameImageInt16GetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_frames_frame_image_uint16_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdFramesFrameImageUint16GetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_frames_frame_image_uint8_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdFramesFrameImageUint8GetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_frames_frame_matlab_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdFramesFrameMatlabGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_frames_frame_numpy_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdFramesFrameNumpyGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_frames_frame_preview_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdFramesFramePreviewGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_frames_frame_raw_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdFramesFrameRawGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_frames_frame_raw_gz_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdFramesFrameRawGzGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_frames_frame_rendered_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdFramesFrameRenderedGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_frames_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdFramesGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_header_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdHeaderGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_image_int16_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdImageInt16GetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_image_uint16_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdImageUint16GetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_image_uint8_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdImageUint8GetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_labels_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdLabelsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_labels_label_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdLabelsLabelDeleteError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_labels_label_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdLabelsLabelGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_labels_label_put`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdLabelsLabelPutError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_matlab_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdMatlabGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_metadata_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdMetadataGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_metadata_name_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdMetadataNameDeleteError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_metadata_name_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdMetadataNameGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_metadata_name_put`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdMetadataNamePutError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_modify_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdModifyPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_module_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdModuleGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_numpy_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdNumpyGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_patient_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdPatientGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_pdf_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdPdfGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_preview_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdPreviewGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_reconstruct_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdReconstructPostError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_rendered_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdRenderedGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_series_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdSeriesGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_simplified_tags_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdSimplifiedTagsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_statistics_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdStatisticsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_study_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdStudyGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_id_tags_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesIdTagsGetError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`instances_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum InstancesPostError {
UnknownValue(serde_json::Value),
}
/// List the Orthanc identifiers of all the available DICOM instances
pub async fn instances_get(configuration: &configuration::Configuration, expand: Option<&str>, full: Option<bool>, limit: Option<f64>, requested_tags: Option<&str>, response_content: Option<&str>, short: Option<bool>, since: Option<f64>) -> Result<serde_json::Value, Error<InstancesGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_expand = expand;
let p_full = full;
let p_limit = limit;
let p_requested_tags = requested_tags;
let p_response_content = response_content;
let p_short = short;
let p_since = since;
let uri_str = format!("{}/instances", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_expand {
req_builder = req_builder.query(&[("expand", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_requested_tags {
req_builder = req_builder.query(&[("requested-tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_response_content {
req_builder = req_builder.query(&[("response-content", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_since {
req_builder = req_builder.query(&[("since", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Download an anonymized version of the DICOM instance whose Orthanc identifier is provided in the URL: <https://orthanc.uclouvain.be/book/users/anonymization.html>#anonymization-of-a-single-instance
pub async fn instances_id_anonymize_post(configuration: &configuration::Configuration, id: &str, instances_id_anonymize_post_request: Option<models::InstancesIdAnonymizePostRequest>) -> Result<serde_json::Value, Error<InstancesIdAnonymizePostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_instances_id_anonymize_post_request = instances_id_anonymize_post_request;
let uri_str = format!("{}/instances/{id}/anonymize", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_instances_id_anonymize_post_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAnonymizePostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the list of attachments that are associated with the given instance
pub async fn instances_id_attachments_get(configuration: &configuration::Configuration, id: &str, full: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdAttachmentsGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_full = full;
let uri_str = format!("{}/instances/{id}/attachments", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Change the compression scheme that is used to store an attachment.
pub async fn instances_id_attachments_name_compress_post(configuration: &configuration::Configuration, id: &str, name: &str) -> Result<(), Error<InstancesIdAttachmentsNameCompressPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let uri_str = format!("{}/instances/{id}/attachments/{name}/compress", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameCompressPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the (binary) content of one attachment associated with the given instance. The attachment will not be decompressed if `StorageCompression` is `true`.
pub async fn instances_id_attachments_name_compressed_data_get(configuration: &configuration::Configuration, id: &str, name: &str, filename: Option<&str>, content_range: Option<&str>, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdAttachmentsNameCompressedDataGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_filename = filename;
let p_content_range = content_range;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/instances/{id}/attachments/{name}/compressed-data", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_filename {
req_builder = req_builder.query(&[("filename", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_content_range {
req_builder = req_builder.header("Content-Range", param_value.to_string());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameCompressedDataGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the MD5 hash of one attachment associated with the given instance, as stored on the disk. This is different from `.../md5` iff `EnableStorage` is `true`.
pub async fn instances_id_attachments_name_compressed_md5_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdAttachmentsNameCompressedMd5GetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/instances/{id}/attachments/{name}/compressed-md5", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameCompressedMd5GetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the size of one attachment associated with the given instance, as stored on the disk. This is different from `.../size` iff `EnableStorage` is `true`.
pub async fn instances_id_attachments_name_compressed_size_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdAttachmentsNameCompressedSizeGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/instances/{id}/attachments/{name}/compressed-size", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameCompressedSizeGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the (binary) content of one attachment associated with the given instance
pub async fn instances_id_attachments_name_data_get(configuration: &configuration::Configuration, id: &str, name: &str, filename: Option<&str>, content_range: Option<&str>, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdAttachmentsNameDataGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_filename = filename;
let p_content_range = content_range;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/instances/{id}/attachments/{name}/data", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_filename {
req_builder = req_builder.query(&[("filename", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_content_range {
req_builder = req_builder.header("Content-Range", param_value.to_string());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameDataGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Delete an attachment associated with the given DICOM instance. This call will fail if trying to delete a system attachment (i.e. whose index is < 1024).
pub async fn instances_id_attachments_name_delete(configuration: &configuration::Configuration, id: &str, name: &str, if_match: Option<&str>) -> Result<(), Error<InstancesIdAttachmentsNameDeleteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_match = if_match;
let uri_str = format!("{}/instances/{id}/attachments/{name}", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_match {
req_builder = req_builder.header("If-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get all the information about the attachment associated with the given instance
pub async fn instances_id_attachments_name_info_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdAttachmentsNameInfoGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/instances/{id}/attachments/{name}/info", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameInfoGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Test whether the attachment has been stored as a compressed file on the disk.
pub async fn instances_id_attachments_name_is_compressed_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdAttachmentsNameIsCompressedGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/instances/{id}/attachments/{name}/is-compressed", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameIsCompressedGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the MD5 hash of one attachment associated with the given instance
pub async fn instances_id_attachments_name_md5_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdAttachmentsNameMd5GetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/instances/{id}/attachments/{name}/md5", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameMd5GetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Attach a file to the given DICOM instance. This call will fail if trying to modify a system attachment (i.e. whose index is < 1024).
pub async fn instances_id_attachments_name_put(configuration: &configuration::Configuration, id: &str, name: &str, if_match: Option<&str>, body: Option<serde_json::Value>) -> Result<serde_json::Value, Error<InstancesIdAttachmentsNamePutError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_match = if_match;
let p_body = body;
let uri_str = format!("{}/instances/{id}/attachments/{name}", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_match {
req_builder = req_builder.header("If-Match", param_value.to_string());
}
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNamePutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the size of one attachment associated with the given instance
pub async fn instances_id_attachments_name_size_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdAttachmentsNameSizeGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/instances/{id}/attachments/{name}/size", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameSizeGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Change the compression scheme that is used to store an attachment.
pub async fn instances_id_attachments_name_uncompress_post(configuration: &configuration::Configuration, id: &str, name: &str) -> Result<(), Error<InstancesIdAttachmentsNameUncompressPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let uri_str = format!("{}/instances/{id}/attachments/{name}/uncompress", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameUncompressPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Verify that the attachment is not corrupted, by validating its MD5 hash
pub async fn instances_id_attachments_name_verify_md5_post(configuration: &configuration::Configuration, id: &str, name: &str) -> Result<serde_json::Value, Error<InstancesIdAttachmentsNameVerifyMd5PostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let uri_str = format!("{}/instances/{id}/attachments/{name}/verify-md5", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdAttachmentsNameVerifyMd5PostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the raw content of one DICOM tag in the hierarchy of DICOM dataset
pub async fn instances_id_content_path_get(configuration: &configuration::Configuration, id: &str, path: &str) -> Result<serde_json::Value, Error<InstancesIdContentPathGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_path = path;
let uri_str = format!("{}/instances/{id}/content/{path}", configuration.base_path, id=crate::apis::urlencode(p_id), path=crate::apis::urlencode(p_path));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdContentPathGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Delete the DICOM instance whose Orthanc identifier is provided in the URL
pub async fn instances_id_delete(configuration: &configuration::Configuration, id: &str) -> Result<(), Error<InstancesIdDeleteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let uri_str = format!("{}/instances/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Write the DICOM file onto the filesystem where Orthanc is running. This is insecure for Orthanc servers that are remotely accessible since one could overwrite any system file. Since Orthanc 1.12.0, this route is disabled by default, but can be enabled using the `RestApiWriteToFileSystemEnabled` configuration option.
pub async fn instances_id_export_post(configuration: &configuration::Configuration, id: &str, body: Option<serde_json::Value>) -> Result<(), Error<InstancesIdExportPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_body = body;
let uri_str = format!("{}/instances/{id}/export", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdExportPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Download one DICOM instance
pub async fn instances_id_file_get(configuration: &configuration::Configuration, id: &str, filename: Option<&str>, lossy_quality: Option<f64>, transcode: Option<&str>, accept: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdFileGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_filename = filename;
let p_lossy_quality = lossy_quality;
let p_transcode = transcode;
let p_accept = accept;
let uri_str = format!("{}/instances/{id}/file", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_filename {
req_builder = req_builder.query(&[("filename", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_lossy_quality {
req_builder = req_builder.query(&[("lossy-quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_transcode {
req_builder = req_builder.query(&[("transcode", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdFileGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode one frame of interest from the given DICOM instance. Pixels of grayscale images are truncated to the [-32768,32767] range. Negative values must be interpreted according to two's complement.
pub async fn instances_id_frames_frame_image_int16_get(configuration: &configuration::Configuration, frame: f64, id: &str, quality: Option<f64>, return_unsupported_image: Option<bool>, accept: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdFramesFrameImageInt16GetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_frame = frame;
let p_id = id;
let p_quality = quality;
let p_return_unsupported_image = return_unsupported_image;
let p_accept = accept;
let uri_str = format!("{}/instances/{id}/frames/{frame}/image-int16", configuration.base_path, frame=p_frame, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_quality {
req_builder = req_builder.query(&[("quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_return_unsupported_image {
req_builder = req_builder.query(&[("returnUnsupportedImage", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdFramesFrameImageInt16GetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode one frame of interest from the given DICOM instance. Pixels of grayscale images are truncated to the \[0,65535\] range.
pub async fn instances_id_frames_frame_image_uint16_get(configuration: &configuration::Configuration, frame: f64, id: &str, quality: Option<f64>, return_unsupported_image: Option<bool>, accept: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdFramesFrameImageUint16GetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_frame = frame;
let p_id = id;
let p_quality = quality;
let p_return_unsupported_image = return_unsupported_image;
let p_accept = accept;
let uri_str = format!("{}/instances/{id}/frames/{frame}/image-uint16", configuration.base_path, frame=p_frame, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_quality {
req_builder = req_builder.query(&[("quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_return_unsupported_image {
req_builder = req_builder.query(&[("returnUnsupportedImage", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdFramesFrameImageUint16GetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode one frame of interest from the given DICOM instance. Pixels of grayscale images are truncated to the \[0,255\] range.
pub async fn instances_id_frames_frame_image_uint8_get(configuration: &configuration::Configuration, frame: f64, id: &str, quality: Option<f64>, return_unsupported_image: Option<bool>, accept: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdFramesFrameImageUint8GetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_frame = frame;
let p_id = id;
let p_quality = quality;
let p_return_unsupported_image = return_unsupported_image;
let p_accept = accept;
let uri_str = format!("{}/instances/{id}/frames/{frame}/image-uint8", configuration.base_path, frame=p_frame, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_quality {
req_builder = req_builder.query(&[("quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_return_unsupported_image {
req_builder = req_builder.query(&[("returnUnsupportedImage", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdFramesFrameImageUint8GetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode one frame of interest from the given DICOM instance, and export this frame as a Octave/Matlab matrix to be imported with `eval()`: <https://orthanc.uclouvain.be/book/faq/matlab.html>
pub async fn instances_id_frames_frame_matlab_get(configuration: &configuration::Configuration, frame: f64, id: &str) -> Result<serde_json::Value, Error<InstancesIdFramesFrameMatlabGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_frame = frame;
let p_id = id;
let uri_str = format!("{}/instances/{id}/frames/{frame}/matlab", configuration.base_path, frame=p_frame, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdFramesFrameMatlabGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode one frame of interest from the given DICOM instance, for use with numpy in Python. The numpy array has 3 dimensions: (height, width, color channel).
pub async fn instances_id_frames_frame_numpy_get(configuration: &configuration::Configuration, frame: f64, id: &str, compress: Option<bool>, rescale: Option<bool>) -> Result<serde_json::Value, Error<InstancesIdFramesFrameNumpyGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_frame = frame;
let p_id = id;
let p_compress = compress;
let p_rescale = rescale;
let uri_str = format!("{}/instances/{id}/frames/{frame}/numpy", configuration.base_path, frame=p_frame, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_compress {
req_builder = req_builder.query(&[("compress", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_rescale {
req_builder = req_builder.query(&[("rescale", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdFramesFrameNumpyGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode one frame of interest from the given DICOM instance. The full dynamic range of grayscale images is rescaled to the \[0,255\] range.
pub async fn instances_id_frames_frame_preview_get(configuration: &configuration::Configuration, frame: f64, id: &str, quality: Option<f64>, return_unsupported_image: Option<bool>, accept: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdFramesFramePreviewGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_frame = frame;
let p_id = id;
let p_quality = quality;
let p_return_unsupported_image = return_unsupported_image;
let p_accept = accept;
let uri_str = format!("{}/instances/{id}/frames/{frame}/preview", configuration.base_path, frame=p_frame, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_quality {
req_builder = req_builder.query(&[("quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_return_unsupported_image {
req_builder = req_builder.query(&[("returnUnsupportedImage", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdFramesFramePreviewGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Access the raw content of one individual frame of the DICOM instance of interest, bypassing image decoding. This is notably useful to access the source files in compressed transfer syntaxes.
pub async fn instances_id_frames_frame_raw_get(configuration: &configuration::Configuration, frame: f64, id: &str) -> Result<serde_json::Value, Error<InstancesIdFramesFrameRawGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_frame = frame;
let p_id = id;
let uri_str = format!("{}/instances/{id}/frames/{frame}/raw", configuration.base_path, frame=p_frame, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdFramesFrameRawGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Access the raw content of one individual frame of the DICOM instance of interest, bypassing image decoding. This is notably useful to access the source files in compressed transfer syntaxes. The image is compressed using gzip
pub async fn instances_id_frames_frame_raw_gz_get(configuration: &configuration::Configuration, frame: f64, id: &str) -> Result<serde_json::Value, Error<InstancesIdFramesFrameRawGzGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_frame = frame;
let p_id = id;
let uri_str = format!("{}/instances/{id}/frames/{frame}/raw.gz", configuration.base_path, frame=p_frame, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdFramesFrameRawGzGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Render one frame of interest from the given DICOM instance. This function takes scaling into account (`RescaleSlope` and `RescaleIntercept` tags), as well as the default windowing stored in the DICOM file (`WindowCenter` and `WindowWidth`tags), and can be used to resize the resulting image. Color images are not affected by windowing.
pub async fn instances_id_frames_frame_rendered_get(configuration: &configuration::Configuration, frame: f64, id: &str, height: Option<f64>, quality: Option<f64>, return_unsupported_image: Option<bool>, smooth: Option<bool>, width: Option<f64>, window_center: Option<f64>, window_width: Option<f64>, accept: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdFramesFrameRenderedGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_frame = frame;
let p_id = id;
let p_height = height;
let p_quality = quality;
let p_return_unsupported_image = return_unsupported_image;
let p_smooth = smooth;
let p_width = width;
let p_window_center = window_center;
let p_window_width = window_width;
let p_accept = accept;
let uri_str = format!("{}/instances/{id}/frames/{frame}/rendered", configuration.base_path, frame=p_frame, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_height {
req_builder = req_builder.query(&[("height", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_quality {
req_builder = req_builder.query(&[("quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_return_unsupported_image {
req_builder = req_builder.query(&[("returnUnsupportedImage", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_smooth {
req_builder = req_builder.query(&[("smooth", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_width {
req_builder = req_builder.query(&[("width", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_window_center {
req_builder = req_builder.query(&[("window-center", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_window_width {
req_builder = req_builder.query(&[("window-width", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdFramesFrameRenderedGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// List the frames that are available in the DICOM instance of interest
pub async fn instances_id_frames_get(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<InstancesIdFramesGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let uri_str = format!("{}/instances/{id}/frames", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdFramesGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get detailed information about the DICOM instance whose Orthanc identifier is provided in the URL
pub async fn instances_id_get(configuration: &configuration::Configuration, id: &str, full: Option<bool>, requested_tags: Option<&str>, short: Option<bool>) -> Result<serde_json::Value, Error<InstancesIdGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_full = full;
let p_requested_tags = requested_tags;
let p_short = short;
let uri_str = format!("{}/instances/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_requested_tags {
req_builder = req_builder.query(&[("requested-tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the DICOM tags in the meta-header of the DICOM instance. By default, the `full` format is used, which combines hexadecimal tags with human-readable description.
pub async fn instances_id_header_get(configuration: &configuration::Configuration, id: &str, short: Option<bool>, simplify: Option<bool>) -> Result<serde_json::Value, Error<InstancesIdHeaderGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_short = short;
let p_simplify = simplify;
let uri_str = format!("{}/instances/{id}/header", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_simplify {
req_builder = req_builder.query(&[("simplify", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdHeaderGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode the first frame of the given DICOM instance. Pixels of grayscale images are truncated to the [-32768,32767] range. Negative values must be interpreted according to two's complement.
pub async fn instances_id_image_int16_get(configuration: &configuration::Configuration, id: &str, quality: Option<f64>, return_unsupported_image: Option<bool>, accept: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdImageInt16GetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_quality = quality;
let p_return_unsupported_image = return_unsupported_image;
let p_accept = accept;
let uri_str = format!("{}/instances/{id}/image-int16", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_quality {
req_builder = req_builder.query(&[("quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_return_unsupported_image {
req_builder = req_builder.query(&[("returnUnsupportedImage", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdImageInt16GetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode the first frame of the given DICOM instance. Pixels of grayscale images are truncated to the \[0,65535\] range.
pub async fn instances_id_image_uint16_get(configuration: &configuration::Configuration, id: &str, quality: Option<f64>, return_unsupported_image: Option<bool>, accept: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdImageUint16GetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_quality = quality;
let p_return_unsupported_image = return_unsupported_image;
let p_accept = accept;
let uri_str = format!("{}/instances/{id}/image-uint16", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_quality {
req_builder = req_builder.query(&[("quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_return_unsupported_image {
req_builder = req_builder.query(&[("returnUnsupportedImage", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdImageUint16GetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode the first frame of the given DICOM instance. Pixels of grayscale images are truncated to the \[0,255\] range.
pub async fn instances_id_image_uint8_get(configuration: &configuration::Configuration, id: &str, quality: Option<f64>, return_unsupported_image: Option<bool>, accept: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdImageUint8GetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_quality = quality;
let p_return_unsupported_image = return_unsupported_image;
let p_accept = accept;
let uri_str = format!("{}/instances/{id}/image-uint8", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_quality {
req_builder = req_builder.query(&[("quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_return_unsupported_image {
req_builder = req_builder.query(&[("returnUnsupportedImage", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdImageUint8GetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the labels that are associated with the given instance (new in Orthanc 1.12.0)
pub async fn instances_id_labels_get(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<InstancesIdLabelsGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let uri_str = format!("{}/instances/{id}/labels", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdLabelsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Remove a label associated with a instance
pub async fn instances_id_labels_label_delete(configuration: &configuration::Configuration, id: &str, label: &str) -> Result<(), Error<InstancesIdLabelsLabelDeleteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_label = label;
let uri_str = format!("{}/instances/{id}/labels/{label}", configuration.base_path, id=crate::apis::urlencode(p_id), label=crate::apis::urlencode(p_label));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdLabelsLabelDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Test whether the instance is associated with the given label
pub async fn instances_id_labels_label_get(configuration: &configuration::Configuration, id: &str, label: &str) -> Result<serde_json::Value, Error<InstancesIdLabelsLabelGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_label = label;
let uri_str = format!("{}/instances/{id}/labels/{label}", configuration.base_path, id=crate::apis::urlencode(p_id), label=crate::apis::urlencode(p_label));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdLabelsLabelGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Associate a label with a instance
pub async fn instances_id_labels_label_put(configuration: &configuration::Configuration, id: &str, label: &str) -> Result<(), Error<InstancesIdLabelsLabelPutError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_label = label;
let uri_str = format!("{}/instances/{id}/labels/{label}", configuration.base_path, id=crate::apis::urlencode(p_id), label=crate::apis::urlencode(p_label));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdLabelsLabelPutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode the first frame of the given DICOM instance., and export this frame as a Octave/Matlab matrix to be imported with `eval()`: <https://orthanc.uclouvain.be/book/faq/matlab.html>
pub async fn instances_id_matlab_get(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<InstancesIdMatlabGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let uri_str = format!("{}/instances/{id}/matlab", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdMatlabGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the list of metadata that are associated with the given instance
pub async fn instances_id_metadata_get(configuration: &configuration::Configuration, id: &str, expand: Option<&str>, numeric: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdMetadataGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_expand = expand;
let p_numeric = numeric;
let uri_str = format!("{}/instances/{id}/metadata", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_expand {
req_builder = req_builder.query(&[("expand", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_numeric {
req_builder = req_builder.query(&[("numeric", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdMetadataGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Delete some metadata associated with the given DICOM instance. This call will fail if trying to delete a system metadata (i.e. whose index is < 1024).
pub async fn instances_id_metadata_name_delete(configuration: &configuration::Configuration, id: &str, name: &str, if_match: Option<&str>) -> Result<(), Error<InstancesIdMetadataNameDeleteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_match = if_match;
let uri_str = format!("{}/instances/{id}/metadata/{name}", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_match {
req_builder = req_builder.header("If-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdMetadataNameDeleteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the value of a metadata that is associated with the given instance
pub async fn instances_id_metadata_name_get(configuration: &configuration::Configuration, id: &str, name: &str, if_none_match: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdMetadataNameGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_none_match = if_none_match;
let uri_str = format!("{}/instances/{id}/metadata/{name}", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdMetadataNameGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Set the value of some metadata in the given DICOM instance. This call will fail if trying to modify a system metadata (i.e. whose index is < 1024).
pub async fn instances_id_metadata_name_put(configuration: &configuration::Configuration, id: &str, name: &str, if_match: Option<&str>, body: Option<serde_json::Value>) -> Result<(), Error<InstancesIdMetadataNamePutError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_name = name;
let p_if_match = if_match;
let p_body = body;
let uri_str = format!("{}/instances/{id}/metadata/{name}", configuration.base_path, id=crate::apis::urlencode(p_id), name=crate::apis::urlencode(p_name));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_if_match {
req_builder = req_builder.header("If-Match", param_value.to_string());
}
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdMetadataNamePutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Download a modified version of the DICOM instance whose Orthanc identifier is provided in the URL: <https://orthanc.uclouvain.be/book/users/anonymization.html>#modification-of-a-single-instance
pub async fn instances_id_modify_post(configuration: &configuration::Configuration, id: &str, instances_id_modify_post_request: Option<models::InstancesIdModifyPostRequest>) -> Result<serde_json::Value, Error<InstancesIdModifyPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_instances_id_modify_post_request = instances_id_modify_post_request;
let uri_str = format!("{}/instances/{id}/modify", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_instances_id_modify_post_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdModifyPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the instance module of the DICOM instance whose Orthanc identifier is provided in the URL
pub async fn instances_id_module_get(configuration: &configuration::Configuration, id: &str, ignore_length: Option<Vec<String>>, short: Option<bool>, simplify: Option<bool>) -> Result<serde_json::Value, Error<InstancesIdModuleGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_ignore_length = ignore_length;
let p_short = short;
let p_simplify = simplify;
let uri_str = format!("{}/instances/{id}/module", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_ignore_length {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("ignore-length".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("ignore-length", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_simplify {
req_builder = req_builder.query(&[("simplify", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdModuleGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode the given DICOM instance, for use with numpy in Python. The numpy array has 4 dimensions: (frame, height, width, color channel).
pub async fn instances_id_numpy_get(configuration: &configuration::Configuration, id: &str, compress: Option<bool>, rescale: Option<bool>) -> Result<serde_json::Value, Error<InstancesIdNumpyGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_compress = compress;
let p_rescale = rescale;
let uri_str = format!("{}/instances/{id}/numpy", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_compress {
req_builder = req_builder.query(&[("compress", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_rescale {
req_builder = req_builder.query(&[("rescale", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdNumpyGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get detailed information about the parent patient of the DICOM instance whose Orthanc identifier is provided in the URL
pub async fn instances_id_patient_get(configuration: &configuration::Configuration, id: &str, full: Option<bool>, requested_tags: Option<&str>, short: Option<bool>) -> Result<serde_json::Value, Error<InstancesIdPatientGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_full = full;
let p_requested_tags = requested_tags;
let p_short = short;
let uri_str = format!("{}/instances/{id}/patient", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_requested_tags {
req_builder = req_builder.query(&[("requested-tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdPatientGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the PDF file that is embedded in one DICOM instance. If the DICOM instance doesn't contain the `EncapsulatedDocument` tag or if the `MIMETypeOfEncapsulatedDocument` tag doesn't correspond to the PDF type, a `404` HTTP error is raised.
pub async fn instances_id_pdf_get(configuration: &configuration::Configuration, id: &str) -> Result<serde_json::Value, Error<InstancesIdPdfGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let uri_str = format!("{}/instances/{id}/pdf", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdPdfGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Decode the first frame of the given DICOM instance. The full dynamic range of grayscale images is rescaled to the \[0,255\] range.
pub async fn instances_id_preview_get(configuration: &configuration::Configuration, id: &str, quality: Option<f64>, return_unsupported_image: Option<bool>, accept: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdPreviewGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_quality = quality;
let p_return_unsupported_image = return_unsupported_image;
let p_accept = accept;
let uri_str = format!("{}/instances/{id}/preview", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_quality {
req_builder = req_builder.query(&[("quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_return_unsupported_image {
req_builder = req_builder.query(&[("returnUnsupportedImage", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdPreviewGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Reconstruct the main DICOM tags in DB of the instance whose Orthanc identifier is provided in the URL. This is useful if child studies/series/instances have inconsistent values for higher-level tags, in order to force Orthanc to use the value from the resource of interest. Beware that this is a time-consuming operation, as all the children DICOM instances will be parsed again, and the Orthanc index will be updated accordingly.
pub async fn instances_id_reconstruct_post(configuration: &configuration::Configuration, id: &str, instances_id_reconstruct_post_request: Option<models::InstancesIdReconstructPostRequest>) -> Result<(), Error<InstancesIdReconstructPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_instances_id_reconstruct_post_request = instances_id_reconstruct_post_request;
let uri_str = format!("{}/instances/{id}/reconstruct", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_instances_id_reconstruct_post_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdReconstructPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Render the first frame of the given DICOM instance. This function takes scaling into account (`RescaleSlope` and `RescaleIntercept` tags), as well as the default windowing stored in the DICOM file (`WindowCenter` and `WindowWidth`tags), and can be used to resize the resulting image. Color images are not affected by windowing.
pub async fn instances_id_rendered_get(configuration: &configuration::Configuration, id: &str, height: Option<f64>, quality: Option<f64>, return_unsupported_image: Option<bool>, smooth: Option<bool>, width: Option<f64>, window_center: Option<f64>, window_width: Option<f64>, accept: Option<&str>) -> Result<serde_json::Value, Error<InstancesIdRenderedGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_height = height;
let p_quality = quality;
let p_return_unsupported_image = return_unsupported_image;
let p_smooth = smooth;
let p_width = width;
let p_window_center = window_center;
let p_window_width = window_width;
let p_accept = accept;
let uri_str = format!("{}/instances/{id}/rendered", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_height {
req_builder = req_builder.query(&[("height", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_quality {
req_builder = req_builder.query(&[("quality", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_return_unsupported_image {
req_builder = req_builder.query(&[("returnUnsupportedImage", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_smooth {
req_builder = req_builder.query(&[("smooth", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_width {
req_builder = req_builder.query(&[("width", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_window_center {
req_builder = req_builder.query(&[("window-center", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_window_width {
req_builder = req_builder.query(&[("window-width", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_accept {
req_builder = req_builder.header("Accept", param_value.to_string());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdRenderedGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get detailed information about the parent series of the DICOM instance whose Orthanc identifier is provided in the URL
pub async fn instances_id_series_get(configuration: &configuration::Configuration, id: &str, full: Option<bool>, requested_tags: Option<&str>, short: Option<bool>) -> Result<serde_json::Value, Error<InstancesIdSeriesGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_full = full;
let p_requested_tags = requested_tags;
let p_short = short;
let uri_str = format!("{}/instances/{id}/series", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_requested_tags {
req_builder = req_builder.query(&[("requested-tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdSeriesGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the DICOM tags in human-readable format (same as the `/instances/{id}/tags?simplify` route)
pub async fn instances_id_simplified_tags_get(configuration: &configuration::Configuration, id: &str, ignore_length: Option<Vec<String>>, whole: Option<bool>) -> Result<serde_json::Value, Error<InstancesIdSimplifiedTagsGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_ignore_length = ignore_length;
let p_whole = whole;
let uri_str = format!("{}/instances/{id}/simplified-tags", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_ignore_length {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("ignore-length".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("ignore-length", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = p_whole {
req_builder = req_builder.query(&[("whole", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdSimplifiedTagsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get statistics about the given instance
pub async fn instances_id_statistics_get(configuration: &configuration::Configuration, id: &str) -> Result<models::InstancesIdStatisticsGet200Response, Error<InstancesIdStatisticsGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let uri_str = format!("{}/instances/{id}/statistics", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InstancesIdStatisticsGet200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::InstancesIdStatisticsGet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdStatisticsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get detailed information about the parent study of the DICOM instance whose Orthanc identifier is provided in the URL
pub async fn instances_id_study_get(configuration: &configuration::Configuration, id: &str, full: Option<bool>, requested_tags: Option<&str>, short: Option<bool>) -> Result<serde_json::Value, Error<InstancesIdStudyGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_full = full;
let p_requested_tags = requested_tags;
let p_short = short;
let uri_str = format!("{}/instances/{id}/study", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_requested_tags {
req_builder = req_builder.query(&[("requested-tags", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdStudyGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the DICOM tags in the specified format. By default, the `full` format is used, which combines hexadecimal tags with human-readable description.
pub async fn instances_id_tags_get(configuration: &configuration::Configuration, id: &str, ignore_length: Option<Vec<String>>, short: Option<bool>, simplify: Option<bool>, whole: Option<bool>) -> Result<serde_json::Value, Error<InstancesIdTagsGetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_id = id;
let p_ignore_length = ignore_length;
let p_short = short;
let p_simplify = simplify;
let p_whole = whole;
let uri_str = format!("{}/instances/{id}/tags", configuration.base_path, id=crate::apis::urlencode(p_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_ignore_length {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("ignore-length".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("ignore-length", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
if let Some(ref param_value) = p_short {
req_builder = req_builder.query(&[("short", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_simplify {
req_builder = req_builder.query(&[("simplify", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_whole {
req_builder = req_builder.query(&[("whole", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesIdTagsGetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Upload DICOM instances
pub async fn instances_post(configuration: &configuration::Configuration, body: Option<serde_json::Value>) -> Result<models::InstancesPost200Response, Error<InstancesPostError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body = body;
let uri_str = format!("{}/instances", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::InstancesPost200Response`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::InstancesPost200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<InstancesPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}