/*
* JSON Ledger API HTTP endpoints
*
* This specification version fixes the API inconsistencies where certain fields marked as required in the spec are in fact optional. If you use code generation tool based on this file, you might need to adjust the existing application code to handle those fields as optional. If you do not want to change your client code, continue using the OpenAPI specification for the latest Canton 3.4 patch release. MINIMUM_CANTON_VERSION=3.6.0
*
* The version of the OpenAPI document: 3.6.0-SNAPSHOT
*
* 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};
use tokio::fs::File as TokioFile;
use tokio_util::codec::{BytesCodec, FramedRead};
/// struct for typed errors of method [`delete_v2_idps_idp_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteV2IdpsIdpIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_v2_users_user_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteV2UsersUserIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_livez`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetLivezError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_readyz`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetReadyzError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_authenticated_user`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2AuthenticatedUserError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_idps`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2IdpsError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_idps_idp_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2IdpsIdpIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_interactive_submission_preferred_package_version`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2InteractiveSubmissionPreferredPackageVersionError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_package_vetting`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2PackageVettingError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_packages`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2PackagesError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_packages_package_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2PackagesPackageIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_packages_package_id_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2PackagesPackageIdStatusError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_parties`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2PartiesError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_parties_participant_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2PartiesParticipantIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_parties_party`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2PartiesPartyError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_state_active_contracts_page`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2StateActiveContractsPageError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_state_connected_synchronizers`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2StateConnectedSynchronizersError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_state_latest_pruned_offsets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2StateLatestPrunedOffsetsError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_state_ledger_end`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2StateLedgerEndError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_updates_transaction_tree_by_id_update_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2UpdatesTransactionTreeByIdUpdateIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_updates_transaction_tree_by_offset_offset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2UpdatesTransactionTreeByOffsetOffsetError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_users`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2UsersError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_users_user_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2UsersUserIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_users_user_id_rights`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2UsersUserIdRightsError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_v2_version`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetV2VersionError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patch_v2_idps_idp_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchV2IdpsIdpIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patch_v2_parties_party`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchV2PartiesPartyError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patch_v2_users_user_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchV2UsersUserIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patch_v2_users_user_id_identity_provider_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchV2UsersUserIdIdentityProviderIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patch_v2_users_user_id_rights`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchV2UsersUserIdRightsError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_commands_async_submit`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2CommandsAsyncSubmitError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_commands_async_submit_reassignment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2CommandsAsyncSubmitReassignmentError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_commands_completions`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2CommandsCompletionsError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_commands_submit_and_wait`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2CommandsSubmitAndWaitError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_commands_submit_and_wait_for_reassignment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2CommandsSubmitAndWaitForReassignmentError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_commands_submit_and_wait_for_transaction`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2CommandsSubmitAndWaitForTransactionError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_commands_submit_and_wait_for_transaction_tree`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2CommandsSubmitAndWaitForTransactionTreeError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_contracts_contract_by_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2ContractsContractByIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_dars`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2DarsError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_dars_validate`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2DarsValidateError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_events_events_by_contract_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2EventsEventsByContractIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_idps`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2IdpsError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_interactive_submission_execute`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2InteractiveSubmissionExecuteError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_interactive_submission_executeandwait`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2InteractiveSubmissionExecuteandwaitError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_interactive_submission_executeandwaitfortransaction`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2InteractiveSubmissionExecuteandwaitfortransactionError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_interactive_submission_preferred_packages`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2InteractiveSubmissionPreferredPackagesError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_interactive_submission_prepare`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2InteractiveSubmissionPrepareError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_package_vetting`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2PackageVettingError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_package_vetting_list`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2PackageVettingListError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_package_vetting_update`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2PackageVettingUpdateError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_parties`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2PartiesError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_parties_external_allocate`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2PartiesExternalAllocateError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_parties_external_generate_topology`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2PartiesExternalGenerateTopologyError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_state_active_contracts`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2StateActiveContractsError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_updates`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2UpdatesError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_updates_flats`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2UpdatesFlatsError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_updates_get_updates_page`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2UpdatesGetUpdatesPageError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_updates_transaction_by_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2UpdatesTransactionByIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_updates_transaction_by_offset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2UpdatesTransactionByOffsetError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_updates_trees`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2UpdatesTreesError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_updates_update_by_id`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2UpdatesUpdateByIdError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_updates_update_by_offset`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2UpdatesUpdateByOffsetError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_users`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2UsersError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_v2_users_user_id_rights`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostV2UsersUserIdRightsError {
Status400(String),
DefaultResponse(models::JsCantonError),
UnknownValue(serde_json::Value),
}
/// Delete an existing identity provider configuration.
pub async fn delete_v2_idps_idp_id(configuration: &configuration::Configuration, idp_id: &str) -> Result<serde_json::Value, Error<DeleteV2IdpsIdpIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_idp_id = idp_id;
let uri_str = format!("{}/v2/idps/{idp_id}", configuration.base_path, idp_id=crate::apis::urlencode(p_path_idp_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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<DeleteV2IdpsIdpIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Delete an existing user and all its rights.
pub async fn delete_v2_users_user_id(configuration: &configuration::Configuration, user_id: &str) -> Result<serde_json::Value, Error<DeleteV2UsersUserIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_user_id = user_id;
let uri_str = format!("{}/v2/users/{user_id}", configuration.base_path, user_id=crate::apis::urlencode(p_path_user_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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<DeleteV2UsersUserIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Checks if the service is alive
pub async fn get_livez(configuration: &configuration::Configuration, ) -> Result<(), Error<GetLivezError>> {
let uri_str = format!("{}/livez", configuration.base_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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<GetLivezError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Checks if the service is ready to serve requests
pub async fn get_readyz(configuration: &configuration::Configuration, ) -> Result<String, Error<GetReadyzError>> {
let uri_str = format!("{}/readyz", configuration.base_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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 Ok(content),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetReadyzError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the user data of the current authenticated user.
pub async fn get_v2_authenticated_user(configuration: &configuration::Configuration, identity_provider_id: Option<&str>) -> Result<models::GetUserResponse, Error<GetV2AuthenticatedUserError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_identity_provider_id = identity_provider_id;
let uri_str = format!("{}/v2/authenticated-user", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_identity_provider_id {
req_builder = req_builder.query(&[("identity-provider-id", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::GetUserResponse`"))),
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::GetUserResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2AuthenticatedUserError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// List all existing identity provider configurations.
pub async fn get_v2_idps(configuration: &configuration::Configuration, ) -> Result<models::ListIdentityProviderConfigsResponse, Error<GetV2IdpsError>> {
let uri_str = format!("{}/v2/idps", configuration.base_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::ListIdentityProviderConfigsResponse`"))),
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::ListIdentityProviderConfigsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2IdpsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the identity provider configuration data by id.
pub async fn get_v2_idps_idp_id(configuration: &configuration::Configuration, idp_id: &str) -> Result<models::GetIdentityProviderConfigResponse, Error<GetV2IdpsIdpIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_idp_id = idp_id;
let uri_str = format!("{}/v2/idps/{idp_id}", configuration.base_path, idp_id=crate::apis::urlencode(p_path_idp_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::GetIdentityProviderConfigResponse`"))),
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::GetIdentityProviderConfigResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2IdpsIdpIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// A preferred package is the highest-versioned package for a provided package-name that is vetted by all the participants hosting the provided parties. Ledger API clients should use this endpoint for constructing command submissions that are compatible with the provided preferred package, by making informed decisions on: - which are the compatible packages that can be used to create contracts - which contract or exercise choice argument version can be used in the command - which choices can be executed on a template or interface of a contract Can be accessed by any Ledger API client with a valid token when Ledger API authorization is enabled. Provided for backwards compatibility, it will be removed in the Canton version 3.4.0
pub async fn get_v2_interactive_submission_preferred_package_version(configuration: &configuration::Configuration, package_name: &str, parties: Option<Vec<String>>, vetting_valid_at: Option<chrono::DateTime<chrono::FixedOffset>>, synchronizer_id: Option<&str>) -> Result<models::GetPreferredPackageVersionResponse, Error<GetV2InteractiveSubmissionPreferredPackageVersionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_package_name = package_name;
let p_query_parties = parties;
let p_query_vetting_valid_at = vetting_valid_at;
let p_query_synchronizer_id = synchronizer_id;
let uri_str = format!("{}/v2/interactive-submission/preferred-package-version", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_parties {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("parties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("parties", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
};
}
req_builder = req_builder.query(&[("package-name", &p_query_package_name.to_string())]);
if let Some(ref param_value) = p_query_vetting_valid_at {
req_builder = req_builder.query(&[("vetting_valid_at", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_synchronizer_id {
req_builder = req_builder.query(&[("synchronizer-id", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::GetPreferredPackageVersionResponse`"))),
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::GetPreferredPackageVersionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2InteractiveSubmissionPreferredPackageVersionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lists which participant node vetted what packages on which synchronizer. This endpoint (GET /package-vetting) is deprecated and will be removed in a future release. Please use POST /package-vetting/list instead.
#[deprecated]
pub async fn get_v2_package_vetting(configuration: &configuration::Configuration, list_vetted_packages_request: models::ListVettedPackagesRequest) -> Result<models::ListVettedPackagesResponse, Error<GetV2PackageVettingError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_list_vetted_packages_request = list_vetted_packages_request;
let uri_str = format!("{}/v2/package-vetting", configuration.base_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_list_vetted_packages_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 `models::ListVettedPackagesResponse`"))),
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::ListVettedPackagesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2PackageVettingError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns the identifiers of all supported packages.
pub async fn get_v2_packages(configuration: &configuration::Configuration, ) -> Result<models::ListPackagesResponse, Error<GetV2PackagesError>> {
let uri_str = format!("{}/v2/packages", configuration.base_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::ListPackagesResponse`"))),
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::ListPackagesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2PackagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns the contents of a single package.
pub async fn get_v2_packages_package_id(configuration: &configuration::Configuration, package_id: &str) -> Result<reqwest::Response, Error<GetV2PackagesPackageIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_package_id = package_id;
let uri_str = format!("{}/v2/packages/{package_id}", configuration.base_path, package_id=crate::apis::urlencode(p_path_package_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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(resp)
} else {
let content = resp.text().await?;
let entity: Option<GetV2PackagesPackageIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns the status of a single package.
pub async fn get_v2_packages_package_id_status(configuration: &configuration::Configuration, package_id: &str) -> Result<models::GetPackageStatusResponse, Error<GetV2PackagesPackageIdStatusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_package_id = package_id;
let uri_str = format!("{}/v2/packages/{package_id}/status", configuration.base_path, package_id=crate::apis::urlencode(p_path_package_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::GetPackageStatusResponse`"))),
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::GetPackageStatusResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2PackagesPackageIdStatusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// List the parties known by the participant. The list returned contains parties whose ledger access is facilitated by the participant and the ones maintained elsewhere.
pub async fn get_v2_parties(configuration: &configuration::Configuration, identity_provider_id: Option<&str>, filter_party: Option<&str>, page_size: Option<i32>, page_token: Option<&str>) -> Result<models::ListKnownPartiesResponse, Error<GetV2PartiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_identity_provider_id = identity_provider_id;
let p_query_filter_party = filter_party;
let p_query_page_size = page_size;
let p_query_page_token = page_token;
let uri_str = format!("{}/v2/parties", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_identity_provider_id {
req_builder = req_builder.query(&[("identity-provider-id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_filter_party {
req_builder = req_builder.query(&[("filter-party", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page_size {
req_builder = req_builder.query(&[("pageSize", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page_token {
req_builder = req_builder.query(&[("pageToken", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::ListKnownPartiesResponse`"))),
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::ListKnownPartiesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2PartiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Return the identifier of the participant. All horizontally scaled replicas should return the same id. daml-on-kv-ledger: returns an identifier supplied on command line at launch time canton: returns globally unique identifier of the participant
pub async fn get_v2_parties_participant_id(configuration: &configuration::Configuration, ) -> Result<models::GetParticipantIdResponse, Error<GetV2PartiesParticipantIdError>> {
let uri_str = format!("{}/v2/parties/participant-id", configuration.base_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::GetParticipantIdResponse`"))),
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::GetParticipantIdResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2PartiesParticipantIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the party details of the given parties. Only known parties will be returned in the list.
pub async fn get_v2_parties_party(configuration: &configuration::Configuration, party: &str, identity_provider_id: Option<&str>, parties: Option<Vec<String>>) -> Result<models::GetPartiesResponse, Error<GetV2PartiesPartyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_party = party;
let p_query_identity_provider_id = identity_provider_id;
let p_query_parties = parties;
let uri_str = format!("{}/v2/parties/{party}", configuration.base_path, party=crate::apis::urlencode(p_path_party));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_identity_provider_id {
req_builder = req_builder.query(&[("identity-provider-id", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_parties {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("parties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("parties", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::GetPartiesResponse`"))),
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::GetPartiesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2PartiesPartyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Returns a page of the snapshot of the active contracts and incomplete (un)assignments at a ledger offset. Once all pages are fetched by repeated calls to ``GetActiveContractsPage``, the client SHOULD begin retrieving updates from the update service, starting at the ``GetActiveContractsPageResponse``.``active_at_offset`` specified in this request. Clients SHOULD NOT assume that the set of active contracts they receive reflects the state at the ledger end.
pub async fn get_v2_state_active_contracts_page(configuration: &configuration::Configuration, get_active_contracts_page_request: models::GetActiveContractsPageRequest) -> Result<models::JsGetActiveContractsPageResponse, Error<GetV2StateActiveContractsPageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_active_contracts_page_request = get_active_contracts_page_request;
let uri_str = format!("{}/v2/state/active-contracts-page", configuration.base_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_active_contracts_page_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 `models::JsGetActiveContractsPageResponse`"))),
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::JsGetActiveContractsPageResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2StateActiveContractsPageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the list of connected synchronizers at the time of the query.
pub async fn get_v2_state_connected_synchronizers(configuration: &configuration::Configuration, party: Option<&str>, participant_id: Option<&str>, identity_provider_id: Option<&str>) -> Result<models::GetConnectedSynchronizersResponse, Error<GetV2StateConnectedSynchronizersError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_party = party;
let p_query_participant_id = participant_id;
let p_query_identity_provider_id = identity_provider_id;
let uri_str = format!("{}/v2/state/connected-synchronizers", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_party {
req_builder = req_builder.query(&[("party", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_participant_id {
req_builder = req_builder.query(&[("participantId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_identity_provider_id {
req_builder = req_builder.query(&[("identityProviderId", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::GetConnectedSynchronizersResponse`"))),
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::GetConnectedSynchronizersResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2StateConnectedSynchronizersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the latest successfully pruned ledger offsets
pub async fn get_v2_state_latest_pruned_offsets(configuration: &configuration::Configuration, ) -> Result<models::GetLatestPrunedOffsetsResponse, Error<GetV2StateLatestPrunedOffsetsError>> {
let uri_str = format!("{}/v2/state/latest-pruned-offsets", configuration.base_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::GetLatestPrunedOffsetsResponse`"))),
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::GetLatestPrunedOffsetsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2StateLatestPrunedOffsetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the current ledger end. Subscriptions started with the returned offset will serve events after this RPC was called.
pub async fn get_v2_state_ledger_end(configuration: &configuration::Configuration, ) -> Result<models::GetLedgerEndResponse, Error<GetV2StateLedgerEndError>> {
let uri_str = format!("{}/v2/state/ledger-end", configuration.base_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::GetLedgerEndResponse`"))),
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::GetLedgerEndResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2StateLedgerEndError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get transaction tree by id. Provided for backwards compatibility, it will be removed in the Canton version 3.5.0, use v2/updates/update-by-id instead.
#[deprecated]
pub async fn get_v2_updates_transaction_tree_by_id_update_id(configuration: &configuration::Configuration, update_id: &str, parties: Option<Vec<String>>) -> Result<models::JsGetTransactionTreeResponse, Error<GetV2UpdatesTransactionTreeByIdUpdateIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_update_id = update_id;
let p_query_parties = parties;
let uri_str = format!("{}/v2/updates/transaction-tree-by-id/{update_id}", configuration.base_path, update_id=crate::apis::urlencode(p_path_update_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_parties {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("parties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("parties", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::JsGetTransactionTreeResponse`"))),
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::JsGetTransactionTreeResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2UpdatesTransactionTreeByIdUpdateIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get transaction tree by offset. Provided for backwards compatibility, it will be removed in the Canton version 3.5.0, use v2/updates/update-by-offset instead.
#[deprecated]
pub async fn get_v2_updates_transaction_tree_by_offset_offset(configuration: &configuration::Configuration, offset: i64, parties: Option<Vec<String>>) -> Result<models::JsGetTransactionTreeResponse, Error<GetV2UpdatesTransactionTreeByOffsetOffsetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_offset = offset;
let p_query_parties = parties;
let uri_str = format!("{}/v2/updates/transaction-tree-by-offset/{offset}", configuration.base_path, offset=p_path_offset);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_parties {
req_builder = match "multi" {
"multi" => req_builder.query(¶m_value.into_iter().map(|p| ("parties".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
_ => req_builder.query(&[("parties", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::JsGetTransactionTreeResponse`"))),
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::JsGetTransactionTreeResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2UpdatesTransactionTreeByOffsetOffsetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// List all existing users.
pub async fn get_v2_users(configuration: &configuration::Configuration, page_size: Option<i32>, page_token: Option<&str>) -> Result<models::ListUsersResponse, Error<GetV2UsersError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_page_size = page_size;
let p_query_page_token = page_token;
let uri_str = format!("{}/v2/users", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page_size {
req_builder = req_builder.query(&[("pageSize", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_page_token {
req_builder = req_builder.query(&[("pageToken", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::ListUsersResponse`"))),
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::ListUsersResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2UsersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the user data of a specific user or the authenticated user.
pub async fn get_v2_users_user_id(configuration: &configuration::Configuration, user_id: &str, identity_provider_id: Option<&str>) -> Result<models::GetUserResponse, Error<GetV2UsersUserIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_user_id = user_id;
let p_query_identity_provider_id = identity_provider_id;
let uri_str = format!("{}/v2/users/{user_id}", configuration.base_path, user_id=crate::apis::urlencode(p_path_user_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_identity_provider_id {
req_builder = req_builder.query(&[("identity-provider-id", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::GetUserResponse`"))),
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::GetUserResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2UsersUserIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// List the set of all rights granted to a user.
pub async fn get_v2_users_user_id_rights(configuration: &configuration::Configuration, user_id: &str) -> Result<models::ListUserRightsResponse, Error<GetV2UsersUserIdRightsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_user_id = user_id;
let uri_str = format!("{}/v2/users/{user_id}/rights", configuration.base_path, user_id=crate::apis::urlencode(p_path_user_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::ListUserRightsResponse`"))),
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::ListUserRightsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2UsersUserIdRightsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Read the Ledger API version
pub async fn get_v2_version(configuration: &configuration::Configuration, ) -> Result<models::GetLedgerApiVersionResponse, Error<GetV2VersionError>> {
let uri_str = format!("{}/v2/version", configuration.base_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
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::GetLedgerApiVersionResponse`"))),
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::GetLedgerApiVersionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetV2VersionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Update selected modifiable attribute of an identity provider config resource described by the ``IdentityProviderConfig`` message.
pub async fn patch_v2_idps_idp_id(configuration: &configuration::Configuration, idp_id: &str, update_identity_provider_config_request: models::UpdateIdentityProviderConfigRequest) -> Result<models::UpdateIdentityProviderConfigResponse, Error<PatchV2IdpsIdpIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_idp_id = idp_id;
let p_body_update_identity_provider_config_request = update_identity_provider_config_request;
let uri_str = format!("{}/v2/idps/{idp_id}", configuration.base_path, idp_id=crate::apis::urlencode(p_path_idp_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_update_identity_provider_config_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 `models::UpdateIdentityProviderConfigResponse`"))),
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::UpdateIdentityProviderConfigResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatchV2IdpsIdpIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Update selected modifiable participant-local attributes of a party details resource. Can update the participant's local information for local parties.
pub async fn patch_v2_parties_party(configuration: &configuration::Configuration, party: &str, update_party_details_request: models::UpdatePartyDetailsRequest) -> Result<models::UpdatePartyDetailsResponse, Error<PatchV2PartiesPartyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_party = party;
let p_body_update_party_details_request = update_party_details_request;
let uri_str = format!("{}/v2/parties/{party}", configuration.base_path, party=crate::apis::urlencode(p_path_party));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_update_party_details_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 `models::UpdatePartyDetailsResponse`"))),
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::UpdatePartyDetailsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatchV2PartiesPartyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Update selected modifiable attribute of a user resource described by the ``User`` message.
pub async fn patch_v2_users_user_id(configuration: &configuration::Configuration, user_id: &str, update_user_request: models::UpdateUserRequest) -> Result<models::UpdateUserResponse, Error<PatchV2UsersUserIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_user_id = user_id;
let p_body_update_user_request = update_user_request;
let uri_str = format!("{}/v2/users/{user_id}", configuration.base_path, user_id=crate::apis::urlencode(p_path_user_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_update_user_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 `models::UpdateUserResponse`"))),
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::UpdateUserResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatchV2UsersUserIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Update the assignment of a user from one IDP to another.
pub async fn patch_v2_users_user_id_identity_provider_id(configuration: &configuration::Configuration, user_id: &str, update_user_identity_provider_id_request: models::UpdateUserIdentityProviderIdRequest) -> Result<serde_json::Value, Error<PatchV2UsersUserIdIdentityProviderIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_user_id = user_id;
let p_body_update_user_identity_provider_id_request = update_user_identity_provider_id_request;
let uri_str = format!("{}/v2/users/{user_id}/identity-provider-id", configuration.base_path, user_id=crate::apis::urlencode(p_path_user_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_update_user_identity_provider_id_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<PatchV2UsersUserIdIdentityProviderIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Revoke rights from a user. Revoking rights does not affect the resource version of the corresponding user.
pub async fn patch_v2_users_user_id_rights(configuration: &configuration::Configuration, user_id: &str, revoke_user_rights_request: models::RevokeUserRightsRequest) -> Result<models::RevokeUserRightsResponse, Error<PatchV2UsersUserIdRightsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_user_id = user_id;
let p_body_revoke_user_rights_request = revoke_user_rights_request;
let uri_str = format!("{}/v2/users/{user_id}/rights", configuration.base_path, user_id=crate::apis::urlencode(p_path_user_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_revoke_user_rights_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 `models::RevokeUserRightsResponse`"))),
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::RevokeUserRightsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatchV2UsersUserIdRightsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Submit a single composite command.
pub async fn post_v2_commands_async_submit(configuration: &configuration::Configuration, js_commands: models::JsCommands) -> Result<serde_json::Value, Error<PostV2CommandsAsyncSubmitError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_js_commands = js_commands;
let uri_str = format!("{}/v2/commands/async/submit", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_js_commands);
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<PostV2CommandsAsyncSubmitError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Submit a single reassignment.
pub async fn post_v2_commands_async_submit_reassignment(configuration: &configuration::Configuration, submit_reassignment_request: models::SubmitReassignmentRequest) -> Result<serde_json::Value, Error<PostV2CommandsAsyncSubmitReassignmentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_submit_reassignment_request = submit_reassignment_request;
let uri_str = format!("{}/v2/commands/async/submit-reassignment", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_submit_reassignment_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<PostV2CommandsAsyncSubmitReassignmentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Query completions list (blocking call) Subscribe to command completion events. Notice: This endpoint should be used for small results set. When number of results exceeded node configuration limit (`http-list-max-elements-limit`) there will be an error (`413 Content Too Large`) returned. Increasing this limit may lead to performance issues and high memory consumption. Consider using websockets (asyncapi) for better efficiency with larger results.
pub async fn post_v2_commands_completions(configuration: &configuration::Configuration, completion_stream_request: models::CompletionStreamRequest, limit: Option<i64>, stream_idle_timeout_ms: Option<i64>) -> Result<Vec<models::CompletionStreamResponse>, Error<PostV2CommandsCompletionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_completion_stream_request = completion_stream_request;
let p_query_limit = limit;
let p_query_stream_idle_timeout_ms = stream_idle_timeout_ms;
let uri_str = format!("{}/v2/commands/completions", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_stream_idle_timeout_ms {
req_builder = req_builder.query(&[("stream_idle_timeout_ms", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_completion_stream_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 `Vec<models::CompletionStreamResponse>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CompletionStreamResponse>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2CommandsCompletionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Submits a single composite command and waits for its result. Propagates the gRPC error of failed submissions including Daml interpretation errors.
pub async fn post_v2_commands_submit_and_wait(configuration: &configuration::Configuration, js_commands: models::JsCommands) -> Result<models::SubmitAndWaitResponse, Error<PostV2CommandsSubmitAndWaitError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_js_commands = js_commands;
let uri_str = format!("{}/v2/commands/submit-and-wait", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_js_commands);
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::SubmitAndWaitResponse`"))),
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::SubmitAndWaitResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2CommandsSubmitAndWaitError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Submits a single composite reassignment command, waits for its result, and returns the reassignment. Propagates the gRPC error of failed submission.
pub async fn post_v2_commands_submit_and_wait_for_reassignment(configuration: &configuration::Configuration, submit_and_wait_for_reassignment_request: models::SubmitAndWaitForReassignmentRequest) -> Result<models::JsSubmitAndWaitForReassignmentResponse, Error<PostV2CommandsSubmitAndWaitForReassignmentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_submit_and_wait_for_reassignment_request = submit_and_wait_for_reassignment_request;
let uri_str = format!("{}/v2/commands/submit-and-wait-for-reassignment", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_submit_and_wait_for_reassignment_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 `models::JsSubmitAndWaitForReassignmentResponse`"))),
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::JsSubmitAndWaitForReassignmentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2CommandsSubmitAndWaitForReassignmentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Submits a single composite command, waits for its result, and returns the transaction. Propagates the gRPC error of failed submissions including Daml interpretation errors.
pub async fn post_v2_commands_submit_and_wait_for_transaction(configuration: &configuration::Configuration, js_submit_and_wait_for_transaction_request: models::JsSubmitAndWaitForTransactionRequest) -> Result<models::JsSubmitAndWaitForTransactionResponse, Error<PostV2CommandsSubmitAndWaitForTransactionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_js_submit_and_wait_for_transaction_request = js_submit_and_wait_for_transaction_request;
let uri_str = format!("{}/v2/commands/submit-and-wait-for-transaction", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_js_submit_and_wait_for_transaction_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 `models::JsSubmitAndWaitForTransactionResponse`"))),
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::JsSubmitAndWaitForTransactionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2CommandsSubmitAndWaitForTransactionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Submit a batch of commands and wait for the transaction trees response. Provided for backwards compatibility, it will be removed in the Canton version 3.5.0, use submit-and-wait-for-transaction instead.
#[deprecated]
pub async fn post_v2_commands_submit_and_wait_for_transaction_tree(configuration: &configuration::Configuration, js_commands: models::JsCommands) -> Result<models::JsSubmitAndWaitForTransactionTreeResponse, Error<PostV2CommandsSubmitAndWaitForTransactionTreeError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_js_commands = js_commands;
let uri_str = format!("{}/v2/commands/submit-and-wait-for-transaction-tree", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_js_commands);
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::JsSubmitAndWaitForTransactionTreeResponse`"))),
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::JsSubmitAndWaitForTransactionTreeResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2CommandsSubmitAndWaitForTransactionTreeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Looking up contract data by contract ID. This endpoint is experimental / alpha, therefore no backwards compatibility is guaranteed. This endpoint must not be used to look up contracts which entered the participant via party replication or repair service.
pub async fn post_v2_contracts_contract_by_id(configuration: &configuration::Configuration, get_contract_request: models::GetContractRequest) -> Result<models::GetContractResponse, Error<PostV2ContractsContractByIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_contract_request = get_contract_request;
let uri_str = format!("{}/v2/contracts/contract-by-id", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_contract_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 `models::GetContractResponse`"))),
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::GetContractResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2ContractsContractByIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Upload a DAR to the participant node
pub async fn post_v2_dars(configuration: &configuration::Configuration, body: std::path::PathBuf, vet_all_packages: Option<bool>, synchronizer_id: Option<&str>) -> Result<serde_json::Value, Error<PostV2DarsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let p_query_vet_all_packages = vet_all_packages;
let p_query_synchronizer_id = synchronizer_id;
let uri_str = format!("{}/v2/dars", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_vet_all_packages {
req_builder = req_builder.query(&[("vetAllPackages", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_synchronizer_id {
req_builder = req_builder.query(&[("synchronizerId", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
let file = TokioFile::open(p_body_body).await?;
let stream = FramedRead::new(file, BytesCodec::new());
req_builder = req_builder.body(reqwest::Body::wrap_stream(stream));
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<PostV2DarsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Validates the DAR and checks the upgrade compatibility of the DAR's packages with the set of the already vetted packages on the target vetting synchronizer. See ValidateDarFileRequest for details regarding the target vetting synchronizer. The operation has no effect on the state of the participant or the Canton ledger: the DAR payload and its packages are not persisted neither are the packages vetted.
pub async fn post_v2_dars_validate(configuration: &configuration::Configuration, body: std::path::PathBuf, synchronizer_id: Option<&str>) -> Result<(), Error<PostV2DarsValidateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_body = body;
let p_query_synchronizer_id = synchronizer_id;
let uri_str = format!("{}/v2/dars/validate", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_synchronizer_id {
req_builder = req_builder.query(&[("synchronizerId", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
let file = TokioFile::open(p_body_body).await?;
let stream = FramedRead::new(file, BytesCodec::new());
req_builder = req_builder.body(reqwest::Body::wrap_stream(stream));
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<PostV2DarsValidateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get the create and the consuming exercise event for the contract with the provided ID. No events will be returned for contracts that have been pruned because they have already been archived before the latest pruning offset. If the contract cannot be found for the request, or all the contract-events are filtered, a CONTRACT_EVENTS_NOT_FOUND error will be raised.
pub async fn post_v2_events_events_by_contract_id(configuration: &configuration::Configuration, get_events_by_contract_id_request: models::GetEventsByContractIdRequest) -> Result<models::JsGetEventsByContractIdResponse, Error<PostV2EventsEventsByContractIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_events_by_contract_id_request = get_events_by_contract_id_request;
let uri_str = format!("{}/v2/events/events-by-contract-id", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_events_by_contract_id_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 `models::JsGetEventsByContractIdResponse`"))),
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::JsGetEventsByContractIdResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2EventsEventsByContractIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create a new identity provider configuration. The request will fail if the maximum allowed number of separate configurations is reached.
pub async fn post_v2_idps(configuration: &configuration::Configuration, create_identity_provider_config_request: models::CreateIdentityProviderConfigRequest) -> Result<models::CreateIdentityProviderConfigResponse, Error<PostV2IdpsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_identity_provider_config_request = create_identity_provider_config_request;
let uri_str = format!("{}/v2/idps", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_create_identity_provider_config_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 `models::CreateIdentityProviderConfigResponse`"))),
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::CreateIdentityProviderConfigResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2IdpsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Execute a prepared submission _asynchronously_ on the ledger. Requires a signature of the transaction from the submitting external party.
pub async fn post_v2_interactive_submission_execute(configuration: &configuration::Configuration, js_execute_submission_request: models::JsExecuteSubmissionRequest) -> Result<serde_json::Value, Error<PostV2InteractiveSubmissionExecuteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_js_execute_submission_request = js_execute_submission_request;
let uri_str = format!("{}/v2/interactive-submission/execute", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_js_execute_submission_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<PostV2InteractiveSubmissionExecuteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Similar to ExecuteSubmission but _synchronously_ wait for the completion of the transaction IMPORTANT: Relying on the response from this endpoint requires trusting the Participant Node to be honest. A malicious node could make a successfully committed request appeared failed and vice versa
pub async fn post_v2_interactive_submission_executeandwait(configuration: &configuration::Configuration, js_execute_submission_and_wait_request: models::JsExecuteSubmissionAndWaitRequest) -> Result<models::ExecuteSubmissionAndWaitResponse, Error<PostV2InteractiveSubmissionExecuteandwaitError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_js_execute_submission_and_wait_request = js_execute_submission_and_wait_request;
let uri_str = format!("{}/v2/interactive-submission/executeAndWait", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_js_execute_submission_and_wait_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 `models::ExecuteSubmissionAndWaitResponse`"))),
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::ExecuteSubmissionAndWaitResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2InteractiveSubmissionExecuteandwaitError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Similar to ExecuteSubmissionAndWait but additionally returns the transaction IMPORTANT: Relying on the response from this endpoint requires trusting the Participant Node to be honest. A malicious node could make a successfully committed request appear as failed and vice versa
pub async fn post_v2_interactive_submission_executeandwaitfortransaction(configuration: &configuration::Configuration, js_execute_submission_and_wait_for_transaction_request: models::JsExecuteSubmissionAndWaitForTransactionRequest) -> Result<models::JsExecuteSubmissionAndWaitForTransactionResponse, Error<PostV2InteractiveSubmissionExecuteandwaitfortransactionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_js_execute_submission_and_wait_for_transaction_request = js_execute_submission_and_wait_for_transaction_request;
let uri_str = format!("{}/v2/interactive-submission/executeAndWaitForTransaction", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_js_execute_submission_and_wait_for_transaction_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 `models::JsExecuteSubmissionAndWaitForTransactionResponse`"))),
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::JsExecuteSubmissionAndWaitForTransactionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2InteractiveSubmissionExecuteandwaitfortransactionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Compute the preferred packages for the vetting requirements in the request. A preferred package is the highest-versioned package for a provided package-name that is vetted by all the participants hosting the provided parties. Ledger API clients should use this endpoint for constructing command submissions that are compatible with the provided preferred packages, by making informed decisions on: - which are the compatible packages that can be used to create contracts - which contract or exercise choice argument version can be used in the command - which choices can be executed on a template or interface of a contract If the package preferences could not be computed due to no selection satisfying the requirements, a `FAILED_PRECONDITION` error will be returned. Can be accessed by any Ledger API client with a valid token when Ledger API authorization is enabled. Experimental API: this endpoint is not guaranteed to provide backwards compatibility in future releases
pub async fn post_v2_interactive_submission_preferred_packages(configuration: &configuration::Configuration, get_preferred_packages_request: models::GetPreferredPackagesRequest) -> Result<models::GetPreferredPackagesResponse, Error<PostV2InteractiveSubmissionPreferredPackagesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_preferred_packages_request = get_preferred_packages_request;
let uri_str = format!("{}/v2/interactive-submission/preferred-packages", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_preferred_packages_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 `models::GetPreferredPackagesResponse`"))),
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::GetPreferredPackagesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2InteractiveSubmissionPreferredPackagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Requires `readAs` scope for the submitting party when LAPI User authorization is enabled
pub async fn post_v2_interactive_submission_prepare(configuration: &configuration::Configuration, js_prepare_submission_request: models::JsPrepareSubmissionRequest) -> Result<models::JsPrepareSubmissionResponse, Error<PostV2InteractiveSubmissionPrepareError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_js_prepare_submission_request = js_prepare_submission_request;
let uri_str = format!("{}/v2/interactive-submission/prepare", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_js_prepare_submission_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 `models::JsPrepareSubmissionResponse`"))),
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::JsPrepareSubmissionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2InteractiveSubmissionPrepareError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Update the vetted packages of this participant This endpoint (POST /package-vetting) is deprecated and will be removed in a future release. Please use POST /package-vetting/update instead.
#[deprecated]
pub async fn post_v2_package_vetting(configuration: &configuration::Configuration, update_vetted_packages_request: models::UpdateVettedPackagesRequest) -> Result<models::UpdateVettedPackagesResponse, Error<PostV2PackageVettingError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_update_vetted_packages_request = update_vetted_packages_request;
let uri_str = format!("{}/v2/package-vetting", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_update_vetted_packages_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 `models::UpdateVettedPackagesResponse`"))),
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::UpdateVettedPackagesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2PackageVettingError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lists which participant node vetted what packages on which synchronizer. Can be called by any authenticated user.
pub async fn post_v2_package_vetting_list(configuration: &configuration::Configuration, list_vetted_packages_request: models::ListVettedPackagesRequest) -> Result<models::ListVettedPackagesResponse, Error<PostV2PackageVettingListError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_list_vetted_packages_request = list_vetted_packages_request;
let uri_str = format!("{}/v2/package-vetting/list", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_list_vetted_packages_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 `models::ListVettedPackagesResponse`"))),
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::ListVettedPackagesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2PackageVettingListError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Update the vetted packages of this participant
pub async fn post_v2_package_vetting_update(configuration: &configuration::Configuration, update_vetted_packages_request: models::UpdateVettedPackagesRequest) -> Result<models::UpdateVettedPackagesResponse, Error<PostV2PackageVettingUpdateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_update_vetted_packages_request = update_vetted_packages_request;
let uri_str = format!("{}/v2/package-vetting/update", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_update_vetted_packages_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 `models::UpdateVettedPackagesResponse`"))),
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::UpdateVettedPackagesResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2PackageVettingUpdateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Allocates a new party on a ledger and adds it to the set managed by the participant. Caller specifies a party identifier suggestion, the actual identifier allocated might be different and is implementation specific. Caller can specify party metadata that is stored locally on the participant. This call may: - Succeed, in which case the actual allocated identifier is visible in the response. - Respond with a gRPC error daml-on-kv-ledger: suggestion's uniqueness is checked by the validators in the consensus layer and call rejected if the identifier is already present. canton: completely different globally unique identifier is allocated. Behind the scenes calls to an internal protocol are made. As that protocol is richer than the surface protocol, the arguments take implicit values The party identifier suggestion must be a valid party name. Party names are required to be non-empty US-ASCII strings built from letters, digits, space, colon, minus and underscore limited to 255 chars
pub async fn post_v2_parties(configuration: &configuration::Configuration, allocate_party_request: models::AllocatePartyRequest) -> Result<models::AllocatePartyResponse, Error<PostV2PartiesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_allocate_party_request = allocate_party_request;
let uri_str = format!("{}/v2/parties", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_allocate_party_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 `models::AllocatePartyResponse`"))),
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::AllocatePartyResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2PartiesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Alpha 3.3: Endpoint to allocate a new external party on a synchronizer Expected to be stable in 3.5 The external party must be hosted (at least) on this node with either confirmation or observation permissions It can optionally be hosted on other nodes (then called a multi-hosted party). If hosted on additional nodes, explicit authorization of the hosting relationship must be performed on those nodes before the party can be used. Decentralized namespaces are supported but must be provided fully authorized by their owners. The individual owner namespace transactions can be submitted in the same call (fully authorized as well). In the simple case of a non-multi hosted, non-decentralized party, the RPC will return once the party is effectively allocated and ready to use, similarly to the AllocateParty behavior. For more complex scenarios applications may need to query the party status explicitly (only through the admin API as of now).
pub async fn post_v2_parties_external_allocate(configuration: &configuration::Configuration, allocate_external_party_request: models::AllocateExternalPartyRequest) -> Result<models::AllocateExternalPartyResponse, Error<PostV2PartiesExternalAllocateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_allocate_external_party_request = allocate_external_party_request;
let uri_str = format!("{}/v2/parties/external/allocate", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_allocate_external_party_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 `models::AllocateExternalPartyResponse`"))),
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::AllocateExternalPartyResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2PartiesExternalAllocateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Alpha 3.3: Convenience endpoint to generate topology transactions for external signing Expected to be stable in 3.5 You may use this endpoint to generate the common external topology transactions which can be signed externally and uploaded as part of the allocate party process Note that this request will create a normal namespace using the same key for the identity as for signing. More elaborate schemes such as multi-signature or decentralized parties require you to construct the topology transactions yourself.
pub async fn post_v2_parties_external_generate_topology(configuration: &configuration::Configuration, generate_external_party_topology_request: models::GenerateExternalPartyTopologyRequest) -> Result<models::GenerateExternalPartyTopologyResponse, Error<PostV2PartiesExternalGenerateTopologyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_generate_external_party_topology_request = generate_external_party_topology_request;
let uri_str = format!("{}/v2/parties/external/generate-topology", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_generate_external_party_topology_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 `models::GenerateExternalPartyTopologyResponse`"))),
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::GenerateExternalPartyTopologyResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2PartiesExternalGenerateTopologyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Query active contracts list (blocking call). Querying active contracts is an expensive operation and if possible should not be repeated often. Consider querying active contracts initially (for a given offset) and then repeatedly call one of `/v2/updates/...`endpoints to get subsequent modifications. You can also use websockets to get updates with better performance. Returns a stream of the snapshot of the active contracts and incomplete (un)assignments at a ledger offset. Once the stream of GetActiveContractsResponses completes, the client SHOULD begin streaming updates from the update service, starting at the GetActiveContractsRequest.active_at_offset specified in this request. Clients SHOULD NOT assume that the set of active contracts they receive reflects the state at the ledger end. Notice: This endpoint should be used for small results set. When number of results exceeded node configuration limit (`http-list-max-elements-limit`) there will be an error (`413 Content Too Large`) returned. Increasing this limit may lead to performance issues and high memory consumption. Consider using websockets (asyncapi) for better efficiency with larger results.
pub async fn post_v2_state_active_contracts(configuration: &configuration::Configuration, get_active_contracts_request: models::GetActiveContractsRequest, limit: Option<i64>, stream_idle_timeout_ms: Option<i64>) -> Result<Vec<models::JsGetActiveContractsResponse>, Error<PostV2StateActiveContractsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_active_contracts_request = get_active_contracts_request;
let p_query_limit = limit;
let p_query_stream_idle_timeout_ms = stream_idle_timeout_ms;
let uri_str = format!("{}/v2/state/active-contracts", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_stream_idle_timeout_ms {
req_builder = req_builder.query(&[("stream_idle_timeout_ms", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_active_contracts_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 `Vec<models::JsGetActiveContractsResponse>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::JsGetActiveContractsResponse>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2StateActiveContractsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Read the ledger's filtered update stream for the specified contents and filters. It returns the event types in accordance with the stream contents selected. Also the selection criteria for individual events depends on the transaction shape chosen. - ACS delta: a requesting party must be a stakeholder of an event for it to be included. - ledger effects: a requesting party must be a witness of an event for it to be included. Notice: This endpoint should be used for small results set. When number of results exceeded node configuration limit (`http-list-max-elements-limit`) there will be an error (`413 Content Too Large`) returned. Increasing this limit may lead to performance issues and high memory consumption. Consider using websockets (asyncapi) for better efficiency with larger results.
pub async fn post_v2_updates(configuration: &configuration::Configuration, get_updates_request: models::GetUpdatesRequest, limit: Option<i64>, stream_idle_timeout_ms: Option<i64>) -> Result<Vec<models::JsGetUpdatesResponse>, Error<PostV2UpdatesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_updates_request = get_updates_request;
let p_query_limit = limit;
let p_query_stream_idle_timeout_ms = stream_idle_timeout_ms;
let uri_str = format!("{}/v2/updates", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_stream_idle_timeout_ms {
req_builder = req_builder.query(&[("stream_idle_timeout_ms", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_updates_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 `Vec<models::JsGetUpdatesResponse>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::JsGetUpdatesResponse>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2UpdatesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Query flat transactions update list (blocking call). Provided for backwards compatibility, it will be removed in the Canton version 3.5.0, use v2/updates instead. Notice: This endpoint should be used for small results set. When number of results exceeded node configuration limit (`http-list-max-elements-limit`) there will be an error (`413 Content Too Large`) returned. Increasing this limit may lead to performance issues and high memory consumption. Consider using websockets (asyncapi) for better efficiency with larger results.
#[deprecated]
pub async fn post_v2_updates_flats(configuration: &configuration::Configuration, get_updates_request: models::GetUpdatesRequest, limit: Option<i64>, stream_idle_timeout_ms: Option<i64>) -> Result<Vec<models::JsGetUpdatesResponse>, Error<PostV2UpdatesFlatsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_updates_request = get_updates_request;
let p_query_limit = limit;
let p_query_stream_idle_timeout_ms = stream_idle_timeout_ms;
let uri_str = format!("{}/v2/updates/flats", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_stream_idle_timeout_ms {
req_builder = req_builder.query(&[("stream_idle_timeout_ms", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_updates_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 `Vec<models::JsGetUpdatesResponse>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::JsGetUpdatesResponse>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2UpdatesFlatsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Read a page of ledger's filtered updates. It returns the event types in accordance with the specified contents and filters. Additionally, the selection criteria for individual events depends on the transaction shape chosen. - ACS delta: an event is included only if the requesting party is a stakeholder. - ledger effects: an event is included if the requesting party is a witness.
pub async fn post_v2_updates_get_updates_page(configuration: &configuration::Configuration, get_updates_page_request: models::GetUpdatesPageRequest) -> Result<models::JsGetUpdatesPageResponse, Error<PostV2UpdatesGetUpdatesPageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_updates_page_request = get_updates_page_request;
let uri_str = format!("{}/v2/updates/get-updates-page", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_updates_page_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 `models::JsGetUpdatesPageResponse`"))),
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::JsGetUpdatesPageResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2UpdatesGetUpdatesPageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get transaction by id. Provided for backwards compatibility, it will be removed in the Canton version 3.5.0, use v2/updates/update-by-id instead.
#[deprecated]
pub async fn post_v2_updates_transaction_by_id(configuration: &configuration::Configuration, get_transaction_by_id_request: models::GetTransactionByIdRequest) -> Result<models::JsGetTransactionResponse, Error<PostV2UpdatesTransactionByIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_transaction_by_id_request = get_transaction_by_id_request;
let uri_str = format!("{}/v2/updates/transaction-by-id", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_transaction_by_id_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 `models::JsGetTransactionResponse`"))),
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::JsGetTransactionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2UpdatesTransactionByIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Get transaction by offset. Provided for backwards compatibility, it will be removed in the Canton version 3.5.0, use v2/updates/update-by-offset instead.
#[deprecated]
pub async fn post_v2_updates_transaction_by_offset(configuration: &configuration::Configuration, get_transaction_by_offset_request: models::GetTransactionByOffsetRequest) -> Result<models::JsGetTransactionResponse, Error<PostV2UpdatesTransactionByOffsetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_transaction_by_offset_request = get_transaction_by_offset_request;
let uri_str = format!("{}/v2/updates/transaction-by-offset", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_transaction_by_offset_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 `models::JsGetTransactionResponse`"))),
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::JsGetTransactionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2UpdatesTransactionByOffsetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Query update transactions tree list (blocking call). Provided for backwards compatibility, it will be removed in the Canton version 3.5.0, use v2/updates instead. Notice: This endpoint should be used for small results set. When number of results exceeded node configuration limit (`http-list-max-elements-limit`) there will be an error (`413 Content Too Large`) returned. Increasing this limit may lead to performance issues and high memory consumption. Consider using websockets (asyncapi) for better efficiency with larger results.
#[deprecated]
pub async fn post_v2_updates_trees(configuration: &configuration::Configuration, get_updates_request: models::GetUpdatesRequest, limit: Option<i64>, stream_idle_timeout_ms: Option<i64>) -> Result<Vec<models::JsGetUpdateTreesResponse>, Error<PostV2UpdatesTreesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_updates_request = get_updates_request;
let p_query_limit = limit;
let p_query_stream_idle_timeout_ms = stream_idle_timeout_ms;
let uri_str = format!("{}/v2/updates/trees", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_stream_idle_timeout_ms {
req_builder = req_builder.query(&[("stream_idle_timeout_ms", ¶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(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_updates_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 `Vec<models::JsGetUpdateTreesResponse>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::JsGetUpdateTreesResponse>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2UpdatesTreesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lookup an update by its ID. If there is no update with this ID, or all the events are filtered, an UPDATE_NOT_FOUND error will be raised.
pub async fn post_v2_updates_update_by_id(configuration: &configuration::Configuration, get_update_by_id_request: models::GetUpdateByIdRequest) -> Result<models::JsGetUpdateResponse, Error<PostV2UpdatesUpdateByIdError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_update_by_id_request = get_update_by_id_request;
let uri_str = format!("{}/v2/updates/update-by-id", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_update_by_id_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 `models::JsGetUpdateResponse`"))),
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::JsGetUpdateResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2UpdatesUpdateByIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lookup an update by its offset. If there is no update with this offset, or all the events are filtered, an UPDATE_NOT_FOUND error will be raised.
pub async fn post_v2_updates_update_by_offset(configuration: &configuration::Configuration, get_update_by_offset_request: models::GetUpdateByOffsetRequest) -> Result<models::JsGetUpdateResponse, Error<PostV2UpdatesUpdateByOffsetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_get_update_by_offset_request = get_update_by_offset_request;
let uri_str = format!("{}/v2/updates/update-by-offset", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_get_update_by_offset_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 `models::JsGetUpdateResponse`"))),
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::JsGetUpdateResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2UpdatesUpdateByOffsetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Create a new user.
pub async fn post_v2_users(configuration: &configuration::Configuration, create_user_request: models::CreateUserRequest) -> Result<models::CreateUserResponse, Error<PostV2UsersError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_user_request = create_user_request;
let uri_str = format!("{}/v2/users", 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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_create_user_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 `models::CreateUserResponse`"))),
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::CreateUserResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2UsersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Grant rights to a user. Granting rights does not affect the resource version of the corresponding user.
pub async fn post_v2_users_user_id_rights(configuration: &configuration::Configuration, user_id: &str, grant_user_rights_request: models::GrantUserRightsRequest) -> Result<models::GrantUserRightsResponse, Error<PostV2UsersUserIdRightsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_user_id = user_id;
let p_body_grant_user_rights_request = grant_user_rights_request;
let uri_str = format!("{}/v2/users/{user_id}/rights", configuration.base_path, user_id=crate::apis::urlencode(p_path_user_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());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Sec-WebSocket-Protocol", value);
};
req_builder = req_builder.json(&p_body_grant_user_rights_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 `models::GrantUserRightsResponse`"))),
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::GrantUserRightsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostV2UsersUserIdRightsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}