/*
* Antimatter Public API
*
* Interact with the Antimatter Cloud API
*
* The version of the OpenAPI document: 2.0.13
* Contact: support@antimatter.io
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};
/// struct for typed errors of method [`domain_add_new`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainAddNewError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_add_peer_domain`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainAddPeerDomainError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_delete_peer`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainDeletePeerError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_get_disaster_recovery_settings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainGetDisasterRecoverySettingsError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_get_peer`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainGetPeerError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_get_peer_config`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainGetPeerConfigError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_get_private_info`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainGetPrivateInfoError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_get_public_info`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainGetPublicInfoError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_get_settings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainGetSettingsError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_get_status`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainGetStatusError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_get_vendor_settings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainGetVendorSettingsError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_list_peers`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainListPeersError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_put_disaster_recovery_settings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainPutDisasterRecoverySettingsError {
Status404(models::ResourceNotFoundError),
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_put_settings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainPutSettingsError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_query_control_log`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainQueryControlLogError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`domain_update_peer`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DomainUpdatePeerError {
Status400(models::InvalidRequestError),
Status401(models::UnauthorizedError),
Status404(models::ResourceNotFoundError),
Status409(models::ConflictError),
Status412(models::PreconditionFailedError),
Status429(models::ResourceExhaustedError),
DefaultResponse(models::Error),
UnknownValue(serde_json::Value),
}
/// Add a new domain with no default peer relationships. You will need to confirm the email address before the domain is able to be interacted with.
pub async fn domain_add_new(configuration: &configuration::Configuration, new_domain: models::NewDomain) -> Result<models::NewDomainResponse, Error<DomainAddNewError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
local_var_req_builder = local_var_req_builder.json(&new_domain);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainAddNewError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Add a domain with a default \"subordinate\" peering relationship with the current domain. Namely, the current \"parent\" domain will be configured to allow the new \"child\" domain to use the parent's billing and admin contact settings, and the child domain will be configured to import those settings. Optionally, similar linking can be performed for identity providers, read/write contexts and facts by setting the appropriate linkX parameter to true. In most cases, what you want is to set `linkAll=true`. Note, that a \"subdomain\" is just shorthand for a domain with the above-described peering config. This peering can be changed at any time, and there is no permanent difference between a domain created in this way, and a domain created with POST /domains.
pub async fn domain_add_peer_domain(configuration: &configuration::Configuration, domain_id: &str, create_peer_domain: models::CreatePeerDomain) -> Result<models::NewDomainResponse, Error<DomainAddPeerDomainError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/peer-domain", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&create_peer_domain);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainAddPeerDomainError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Removes the peering relationship with the given domain
pub async fn domain_delete_peer(configuration: &configuration::Configuration, domain_id: &str, peer_domain_id: &str) -> Result<(), Error<DomainDeletePeerError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/control/peers/{peerDomainID}", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id), peerDomainID=crate::apis::urlencode(peer_domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DomainDeletePeerError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Return the current domain's disaster recovery settings.
pub async fn domain_get_disaster_recovery_settings(configuration: &configuration::Configuration, domain_id: &str) -> Result<models::DisasterRecoverySettings, Error<DomainGetDisasterRecoverySettingsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/control/keys/disaster-recovery", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainGetDisasterRecoverySettingsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Retrieve the details of a domain that is configured as a peer of this domain, by using its alias or one of its nicknames
pub async fn domain_get_peer(configuration: &configuration::Configuration, domain_id: &str, nickname: Option<&str>, alias: Option<&str>) -> Result<models::Domain, Error<DomainGetPeerError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/peer-domain", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = nickname {
local_var_req_builder = local_var_req_builder.query(&[("nickname", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = alias {
local_var_req_builder = local_var_req_builder.query(&[("alias", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainGetPeerError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Get the configuration for this peer.
pub async fn domain_get_peer_config(configuration: &configuration::Configuration, domain_id: &str, peer_domain_id: &str) -> Result<models::DomainPeerConfig, Error<DomainGetPeerConfigError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/control/peers/{peerDomainID}", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id), peerDomainID=crate::apis::urlencode(peer_domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainGetPeerConfigError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Returns a Domain's summary information. This may include more information than the `public-info` endpoint but requires authentication.
pub async fn domain_get_private_info(configuration: &configuration::Configuration, domain_id: &str) -> Result<models::DomainPrivateInfo, Error<DomainGetPrivateInfoError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/info", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainGetPrivateInfoError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Returns a Domain's summary information. This endpoint does not require authorization. This endpoint can be used to determine which identity providers the `/authenticate` endpoint supports.
pub async fn domain_get_public_info(configuration: &configuration::Configuration, domain_id: &str) -> Result<models::DomainPublicInfo, Error<DomainGetPublicInfoError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/public-info", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainGetPublicInfoError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Get the domain settings. This contains configuration for the contact email addresses as well as the display name for the domain.
pub async fn domain_get_settings(configuration: &configuration::Configuration, domain_id: &str) -> Result<models::DomainSettings, Error<DomainGetSettingsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/control/settings", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainGetSettingsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// The domain status object contains important notifications for administrators of the domain
pub async fn domain_get_status(configuration: &configuration::Configuration, domain_id: &str) -> Result<models::DomainStatus, Error<DomainGetStatusError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/control/status", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainGetStatusError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Return the current vendor settings for a given domain.
pub async fn domain_get_vendor_settings(configuration: &configuration::Configuration, domain_id: &str) -> Result<models::VendorSettings, Error<DomainGetVendorSettingsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/control/vendor/settings", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainGetVendorSettingsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Returns a list of this domains peers
pub async fn domain_list_peers(configuration: &configuration::Configuration, domain_id: &str) -> Result<models::DomainPeerList, Error<DomainListPeersError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/control/peers", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainListPeersError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Create or update the current domain's disaster recovery settings.
pub async fn domain_put_disaster_recovery_settings(configuration: &configuration::Configuration, domain_id: &str, disaster_recovery_settings: models::DisasterRecoverySettings) -> Result<(), Error<DomainPutDisasterRecoverySettingsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/control/keys/disaster-recovery", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&disaster_recovery_settings);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DomainPutDisasterRecoverySettingsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Replace the current settings with the new settings supplied.
pub async fn domain_put_settings(configuration: &configuration::Configuration, domain_id: &str, new_domain_settings: models::NewDomainSettings) -> Result<models::DomainSettings, Error<DomainPutSettingsError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/control/settings", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&new_domain_settings);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainPutSettingsError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Query the domain control-plane audit log. Results are returned in reverse chronological order
pub async fn domain_query_control_log(configuration: &configuration::Configuration, domain_id: &str, start_date: Option<String>, end_date: Option<String>, num_results: Option<i32>, start_from_id: Option<&str>, session: Option<&str>, url: Option<&str>, description: Option<&str>) -> Result<models::DomainControlLogResults, Error<DomainQueryControlLogError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/control/log", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = start_date {
local_var_req_builder = local_var_req_builder.query(&[("start_date", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = end_date {
local_var_req_builder = local_var_req_builder.query(&[("end_date", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = num_results {
local_var_req_builder = local_var_req_builder.query(&[("num_results", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = start_from_id {
local_var_req_builder = local_var_req_builder.query(&[("start_from_id", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = session {
local_var_req_builder = local_var_req_builder.query(&[("session", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = url {
local_var_req_builder = local_var_req_builder.query(&[("url", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = description {
local_var_req_builder = local_var_req_builder.query(&[("description", &local_var_str.to_string())]);
}
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<DomainQueryControlLogError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}
/// Create or update the configuration for this peer. Please note, if the configuration already exists, it is updated to reflect the values in the request. This will include setting the fields to their default value if not supplied.
pub async fn domain_update_peer(configuration: &configuration::Configuration, domain_id: &str, peer_domain_id: &str, domain_peer_config: models::DomainPeerConfig) -> Result<(), Error<DomainUpdatePeerError>> {
let local_var_configuration = configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}/domains/{domainID}/control/peers/{peerDomainID}", local_var_configuration.base_path, domainID=crate::apis::urlencode(domain_id), peerDomainID=crate::apis::urlencode(peer_domain_id));
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
};
local_var_req_builder = local_var_req_builder.json(&domain_peer_config);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
Ok(())
} else {
let local_var_entity: Option<DomainUpdatePeerError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}