/*
* CrowdStrike API Specification
*
* Use this API specification as a reference for the API endpoints you can use to interact with your Falcon environment. These endpoints support authentication via OAuth2 and interact with detections and network containment. For detailed usage guides and examples, see our [documentation inside the Falcon console](https://falcon.crowdstrike.com/support/documentation). To use the APIs described below, combine the base URL with the path shown for each API endpoint. For commercial cloud customers, your base URL is `https://api.crowdstrike.com`. Each API endpoint requires authorization via an OAuth2 token. Your first API request should retrieve an OAuth2 token using the `oauth2/token` endpoint, such as `https://api.crowdstrike.com/oauth2/token`. For subsequent requests, include the OAuth2 token in an HTTP authorization header. Tokens expire after 30 minutes, after which you should make a new token request to continue making API requests.
*
* The version of the OpenAPI document: rolling
*
* Generated by: https://openapi-generator.tech
*/
use super::{ContentType, Error, configuration};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::de::Error as _;
/// struct for typed errors of method [`delete_object`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteObjectError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_versioned_object`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteVersionedObjectError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`describe_collection`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DescribeCollectionError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`describe_collections`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DescribeCollectionsError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_object`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetObjectError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_object_metadata`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetObjectMetadataError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_schema`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSchemaError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_schema_metadata`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetSchemaMetadataError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_versioned_object`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetVersionedObjectError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_versioned_object_metadata`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetVersionedObjectMetadataError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_collections`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCollectionsError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_objects`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListObjectsError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_objects_by_version`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListObjectsByVersionError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_schemas`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListSchemasError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`put_object`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PutObjectError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`put_object_by_version`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PutObjectByVersionError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_objects`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchObjectsError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_objects_by_version`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchObjectsByVersionError {
Status403(models::MsaReplyMetaOnly),
Status429(models::MsaReplyMetaOnly),
Status500(models::MsaReplyMetaOnly),
UnknownValue(serde_json::Value),
}
pub async fn delete_object(
configuration: &configuration::Configuration,
collection_name: &str,
object_key: &str,
dry_run: Option<bool>,
) -> Result<models::CustomType3191042536, Error<DeleteObjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_object_key = object_key;
let p_query_dry_run = dry_run;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/objects/{object_key}",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
object_key = crate::apis::urlencode(p_path_object_key)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_dry_run {
req_builder = req_builder.query(&[("dry_run", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType3191042536`",
)));
}
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::CustomType3191042536`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteObjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_versioned_object(
configuration: &configuration::Configuration,
collection_name: &str,
collection_version: &str,
object_key: &str,
dry_run: Option<bool>,
) -> Result<models::CustomType3191042536, Error<DeleteVersionedObjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_collection_version = collection_version;
let p_path_object_key = object_key;
let p_query_dry_run = dry_run;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/{collection_version}/objects/{object_key}",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
collection_version = crate::apis::urlencode(p_path_collection_version),
object_key = crate::apis::urlencode(p_path_object_key)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_dry_run {
req_builder = req_builder.query(&[("dry_run", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType3191042536`",
)));
}
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::CustomType3191042536`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteVersionedObjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn describe_collection(
configuration: &configuration::Configuration,
collection_name: &str,
) -> Result<models::CustomType1942251022, Error<DescribeCollectionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType1942251022`",
)));
}
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::CustomType1942251022`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<DescribeCollectionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn describe_collections(
configuration: &configuration::Configuration,
names: Vec<String>,
) -> Result<models::CustomType1942251022, Error<DescribeCollectionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_names = names;
let uri_str = format!("{}/customobjects/v1/collections", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
req_builder = match "csv" {
"multi" => req_builder.query(
&p_query_names
.into_iter()
.map(|p| ("names".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"names",
&p_query_names
.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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType1942251022`",
)));
}
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::CustomType1942251022`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<DescribeCollectionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_object(
configuration: &configuration::Configuration,
collection_name: &str,
object_key: &str,
) -> Result<reqwest::Response, Error<GetObjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_object_key = object_key;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/objects/{object_key}",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
object_key = crate::apis::urlencode(p_path_object_key)
);
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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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<GetObjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_object_metadata(
configuration: &configuration::Configuration,
collection_name: &str,
object_key: &str,
) -> Result<models::CustomType3191042536, Error<GetObjectMetadataError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_object_key = object_key;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/objects/{object_key}/metadata",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
object_key = crate::apis::urlencode(p_path_object_key)
);
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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType3191042536`",
)));
}
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::CustomType3191042536`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetObjectMetadataError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_schema(
configuration: &configuration::Configuration,
collection_name: &str,
schema_version: &str,
) -> Result<reqwest::Response, Error<GetSchemaError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_schema_version = schema_version;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/schemas/{schema_version}",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
schema_version = crate::apis::urlencode(p_path_schema_version)
);
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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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<GetSchemaError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_schema_metadata(
configuration: &configuration::Configuration,
collection_name: &str,
schema_version: &str,
) -> Result<models::CustomType4161059146, Error<GetSchemaMetadataError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_schema_version = schema_version;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/schemas/{schema_version}/metadata",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
schema_version = crate::apis::urlencode(p_path_schema_version)
);
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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType4161059146`",
)));
}
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::CustomType4161059146`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetSchemaMetadataError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_versioned_object(
configuration: &configuration::Configuration,
collection_name: &str,
collection_version: &str,
object_key: &str,
) -> Result<reqwest::Response, Error<GetVersionedObjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_collection_version = collection_version;
let p_path_object_key = object_key;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/{collection_version}/objects/{object_key}",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
collection_version = crate::apis::urlencode(p_path_collection_version),
object_key = crate::apis::urlencode(p_path_object_key)
);
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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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<GetVersionedObjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_versioned_object_metadata(
configuration: &configuration::Configuration,
collection_name: &str,
collection_version: &str,
object_key: &str,
) -> Result<models::CustomType3191042536, Error<GetVersionedObjectMetadataError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_collection_version = collection_version;
let p_path_object_key = object_key;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/{collection_version}/objects/{object_key}/metadata",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
collection_version = crate::apis::urlencode(p_path_collection_version),
object_key = crate::apis::urlencode(p_path_object_key)
);
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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType3191042536`",
)));
}
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::CustomType3191042536`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<GetVersionedObjectMetadataError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_collections(
configuration: &configuration::Configuration,
end: Option<&str>,
limit: Option<i32>,
start: Option<&str>,
) -> Result<models::CustomType1255839303, Error<ListCollectionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_end = end;
let p_query_limit = limit;
let p_query_start = start;
let uri_str = format!("{}/customobjects/v1/collections", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_end {
req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
}
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_start {
req_builder = req_builder.query(&[("start", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType1255839303`",
)));
}
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::CustomType1255839303`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<ListCollectionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_objects(
configuration: &configuration::Configuration,
collection_name: &str,
end: Option<&str>,
limit: Option<i32>,
start: Option<&str>,
) -> Result<models::CustomType1255839303, Error<ListObjectsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_query_end = end;
let p_query_limit = limit;
let p_query_start = start;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/objects",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_end {
req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
}
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_start {
req_builder = req_builder.query(&[("start", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType1255839303`",
)));
}
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::CustomType1255839303`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<ListObjectsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_objects_by_version(
configuration: &configuration::Configuration,
collection_name: &str,
collection_version: &str,
end: Option<&str>,
limit: Option<i32>,
start: Option<&str>,
) -> Result<models::CustomType1255839303, Error<ListObjectsByVersionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_collection_version = collection_version;
let p_query_end = end;
let p_query_limit = limit;
let p_query_start = start;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/{collection_version}/objects",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
collection_version = crate::apis::urlencode(p_path_collection_version)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_end {
req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
}
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_start {
req_builder = req_builder.query(&[("start", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType1255839303`",
)));
}
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::CustomType1255839303`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<ListObjectsByVersionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_schemas(
configuration: &configuration::Configuration,
collection_name: &str,
end: Option<&str>,
limit: Option<i32>,
start: Option<&str>,
) -> Result<models::CustomType1255839303, Error<ListSchemasError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_query_end = end;
let p_query_limit = limit;
let p_query_start = start;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/schemas",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_end {
req_builder = req_builder.query(&[("end", ¶m_value.to_string())]);
}
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_start {
req_builder = req_builder.query(&[("start", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType1255839303`",
)));
}
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::CustomType1255839303`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<ListSchemasError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn put_object(
configuration: &configuration::Configuration,
collection_name: &str,
object_key: &str,
body: std::path::PathBuf,
dry_run: Option<bool>,
schema_version: Option<&str>,
) -> Result<models::CustomType3191042536, Error<PutObjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_object_key = object_key;
let p_body_body = body;
let p_query_dry_run = dry_run;
let p_query_schema_version = schema_version;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/objects/{object_key}",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
object_key = crate::apis::urlencode(p_path_object_key)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref param_value) = p_query_dry_run {
req_builder = req_builder.query(&[("dry_run", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_schema_version {
req_builder = req_builder.query(&[("schema_version", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::CustomType3191042536`",
)));
}
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::CustomType3191042536`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<PutObjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn put_object_by_version(
configuration: &configuration::Configuration,
collection_name: &str,
collection_version: &str,
object_key: &str,
body: std::path::PathBuf,
dry_run: Option<bool>,
) -> Result<models::CustomType3191042536, Error<PutObjectByVersionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_collection_version = collection_version;
let p_path_object_key = object_key;
let p_body_body = body;
let p_query_dry_run = dry_run;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/{collection_version}/objects/{object_key}",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
collection_version = crate::apis::urlencode(p_path_collection_version),
object_key = crate::apis::urlencode(p_path_object_key)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref param_value) = p_query_dry_run {
req_builder = req_builder.query(&[("dry_run", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => {
return Err(Error::from(serde_json::Error::custom(
"Received `text/plain` content type response that cannot be converted to `models::CustomType3191042536`",
)));
}
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::CustomType3191042536`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<PutObjectByVersionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn search_objects(
configuration: &configuration::Configuration,
collection_name: &str,
filter: &str,
limit: Option<i32>,
offset: Option<i32>,
sort: Option<&str>,
) -> Result<models::CustomType3191042536, Error<SearchObjectsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_query_filter = filter;
let p_query_limit = limit;
let p_query_offset = offset;
let p_query_sort = sort;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/objects",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("filter", &p_query_filter.to_string())]);
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_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort {
req_builder = req_builder.query(&[("sort", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType3191042536`",
)));
}
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::CustomType3191042536`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<SearchObjectsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn search_objects_by_version(
configuration: &configuration::Configuration,
collection_name: &str,
collection_version: &str,
filter: &str,
limit: Option<i32>,
offset: Option<i32>,
sort: Option<&str>,
) -> Result<models::CustomType3191042536, Error<SearchObjectsByVersionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_name = collection_name;
let p_path_collection_version = collection_version;
let p_query_filter = filter;
let p_query_limit = limit;
let p_query_offset = offset;
let p_query_sort = sort;
let uri_str = format!(
"{}/customobjects/v1/collections/{collection_name}/{collection_version}/objects",
configuration.base_path,
collection_name = crate::apis::urlencode(p_path_collection_name),
collection_version = crate::apis::urlencode(p_path_collection_version)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
req_builder = req_builder.query(&[("filter", &p_query_filter.to_string())]);
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_offset {
req_builder = req_builder.query(&[("offset", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort {
req_builder = req_builder.query(&[("sort", ¶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.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
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::CustomType3191042536`",
)));
}
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::CustomType3191042536`"
))));
}
}
} else {
let content = resp.text().await?;
let entity: Option<SearchObjectsByVersionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}