/*
* Hanzo Cloud API
*
* The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
*
* The version of the OpenAPI document: v1
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`delete_cloudflare_d1_databases_by_database`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCloudflareD1DatabasesByDatabaseError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cloudflare_kv_namespaces_by_namespace`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCloudflareKvNamespacesByNamespaceError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cloudflare_kv_namespaces_by_namespace_values_by_key`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCloudflareKvNamespacesByNamespaceValuesByKeyError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cloudflare_pages_projects_by_project`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCloudflarePagesProjectsByProjectError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cloudflare_pages_projects_by_project_domains_by_domain`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCloudflarePagesProjectsByProjectDomainsByDomainError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cloudflare_r2_buckets_by_bucket`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCloudflareR2BucketsByBucketError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cloudflare_workers_scripts_by_script`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCloudflareWorkersScriptsByScriptError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_cloudflare_workers_zones_by_zone_routes_by_route`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCloudflareWorkersZonesByZoneRoutesByRouteError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_d1_databases`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflareD1DatabasesError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_kv_namespaces`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflareKvNamespacesError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_kv_namespaces_by_namespace_values_by_key`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflareKvNamespacesByNamespaceValuesByKeyError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_pages_projects`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflarePagesProjectsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_pages_projects_by_project`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflarePagesProjectsByProjectError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_r2_buckets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflareR2BucketsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_workers_scripts`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflareWorkersScriptsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_workers_subdomain`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflareWorkersSubdomainError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_workers_zones_by_zone_routes`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflareWorkersZonesByZoneRoutesError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_zones`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflareZonesError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_zones_by_zone`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflareZonesByZoneError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_cloudflare_zones_by_zone_analytics`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCloudflareZonesByZoneAnalyticsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_cloudflare_d1_databases`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostCloudflareD1DatabasesError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_cloudflare_d1_databases_by_database_query`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostCloudflareD1DatabasesByDatabaseQueryError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_cloudflare_kv_namespaces`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostCloudflareKvNamespacesError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_cloudflare_pages_projects`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostCloudflarePagesProjectsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_cloudflare_pages_projects_by_project_deployments`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostCloudflarePagesProjectsByProjectDeploymentsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_cloudflare_pages_projects_by_project_domains`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostCloudflarePagesProjectsByProjectDomainsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_cloudflare_r2_buckets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostCloudflareR2BucketsError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_cloudflare_workers_scripts_by_script_subdomain`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostCloudflareWorkersScriptsByScriptSubdomainError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_cloudflare_workers_zones_by_zone_routes`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostCloudflareWorkersZonesByZoneRoutesError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`post_cloudflare_zones_by_zone_purge`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PostCloudflareZonesByZonePurgeError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`put_cloudflare_kv_namespaces_by_namespace_values_by_key`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PutCloudflareKvNamespacesByNamespaceValuesByKeyError {
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`put_cloudflare_workers_scripts_by_script`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PutCloudflareWorkersScriptsByScriptError {
UnknownValue(serde_json::Value),
}
/// Deletes a D1 database and everything stored in it. Requires org admin.
pub async fn delete_cloudflare_d1_databases_by_database(configuration: &configuration::Configuration, database: &str) -> Result<serde_json::Value, Error<DeleteCloudflareD1DatabasesByDatabaseError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_database = database;
let uri_str = format!("{}/v1/cloudflare/d1/databases/{database}", configuration.base_path, database=crate::apis::urlencode(p_database));
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());
};
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<DeleteCloudflareD1DatabasesByDatabaseError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// KVNamespaceDelete deletes a Workers KV namespace and every key in it. Requires org admin.
pub async fn delete_cloudflare_kv_namespaces_by_namespace(configuration: &configuration::Configuration, namespace: &str) -> Result<serde_json::Value, Error<DeleteCloudflareKvNamespacesByNamespaceError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_namespace = namespace;
let uri_str = format!("{}/v1/cloudflare/kv/namespaces/{namespace}", configuration.base_path, namespace=crate::apis::urlencode(p_namespace));
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());
};
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<DeleteCloudflareKvNamespacesByNamespaceError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// KVValueDelete removes one key from a Workers KV namespace. Requires org admin.
pub async fn delete_cloudflare_kv_namespaces_by_namespace_values_by_key(configuration: &configuration::Configuration, namespace: &str, key: &str) -> Result<serde_json::Value, Error<DeleteCloudflareKvNamespacesByNamespaceValuesByKeyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_namespace = namespace;
let p_key = key;
let uri_str = format!("{}/v1/cloudflare/kv/namespaces/{namespace}/values/{key}", configuration.base_path, namespace=crate::apis::urlencode(p_namespace), key=crate::apis::urlencode(p_key));
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());
};
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<DeleteCloudflareKvNamespacesByNamespaceValuesByKeyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Deletes a Cloudflare Pages project, and with it every deployment it has ever made. Requires org admin.
pub async fn delete_cloudflare_pages_projects_by_project(configuration: &configuration::Configuration, project: &str) -> Result<serde_json::Value, Error<DeleteCloudflarePagesProjectsByProjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_project = project;
let uri_str = format!("{}/v1/cloudflare/pages/projects/{project}", configuration.base_path, project=crate::apis::urlencode(p_project));
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());
};
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<DeleteCloudflarePagesProjectsByProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Detaches a custom domain from a Cloudflare Pages project. Requires org admin.
pub async fn delete_cloudflare_pages_projects_by_project_domains_by_domain(configuration: &configuration::Configuration, project: &str, domain: &str) -> Result<serde_json::Value, Error<DeleteCloudflarePagesProjectsByProjectDomainsByDomainError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_project = project;
let p_domain = domain;
let uri_str = format!("{}/v1/cloudflare/pages/projects/{project}/domains/{domain}", configuration.base_path, project=crate::apis::urlencode(p_project), domain=crate::apis::urlencode(p_domain));
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());
};
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<DeleteCloudflarePagesProjectsByProjectDomainsByDomainError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Deletes an R2 bucket. Requires org admin. Cloudflare refuses a bucket that still holds objects, and that refusal is relayed.
pub async fn delete_cloudflare_r2_buckets_by_bucket(configuration: &configuration::Configuration, bucket: &str) -> Result<serde_json::Value, Error<DeleteCloudflareR2BucketsByBucketError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_bucket = bucket;
let uri_str = format!("{}/v1/cloudflare/r2/buckets/{bucket}", configuration.base_path, bucket=crate::apis::urlencode(p_bucket));
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());
};
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<DeleteCloudflareR2BucketsByBucketError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Removes a Worker script from the org's Cloudflare account. Requires org admin. Routes bound to the script stop serving it.
pub async fn delete_cloudflare_workers_scripts_by_script(configuration: &configuration::Configuration, script: &str) -> Result<serde_json::Value, Error<DeleteCloudflareWorkersScriptsByScriptError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_script = script;
let uri_str = format!("{}/v1/cloudflare/workers/scripts/{script}", configuration.base_path, script=crate::apis::urlencode(p_script));
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());
};
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<DeleteCloudflareWorkersScriptsByScriptError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Unbinds a Worker route, so its pattern stops dispatching to a script. Requires org admin.
pub async fn delete_cloudflare_workers_zones_by_zone_routes_by_route(configuration: &configuration::Configuration, zone: &str, route: &str) -> Result<serde_json::Value, Error<DeleteCloudflareWorkersZonesByZoneRoutesByRouteError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_zone = zone;
let p_route = route;
let uri_str = format!("{}/v1/cloudflare/workers/zones/{zone}/routes/{route}", configuration.base_path, zone=crate::apis::urlencode(p_zone), route=crate::apis::urlencode(p_route));
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());
};
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<DeleteCloudflareWorkersZonesByZoneRoutesByRouteError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lists the D1 databases on the org's Cloudflare account. Any org member may read.
pub async fn get_cloudflare_d1_databases(configuration: &configuration::Configuration, page: Option<&str>, per_page: Option<&str>, name: Option<&str>) -> Result<serde_json::Value, Error<GetCloudflareD1DatabasesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_page = page;
let p_per_page = per_page;
let p_name = name;
let uri_str = format!("{}/v1/cloudflare/d1/databases", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_per_page {
req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_name {
req_builder = req_builder.query(&[("name", ¶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());
};
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<GetCloudflareD1DatabasesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// KVNamespaceList lists the Workers KV namespaces on the org's Cloudflare account. Any org member may read.
pub async fn get_cloudflare_kv_namespaces(configuration: &configuration::Configuration, page: Option<&str>, per_page: Option<&str>, order: Option<&str>, direction: Option<&str>) -> Result<serde_json::Value, Error<GetCloudflareKvNamespacesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_page = page;
let p_per_page = per_page;
let p_order = order;
let p_direction = direction;
let uri_str = format!("{}/v1/cloudflare/kv/namespaces", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_per_page {
req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_order {
req_builder = req_builder.query(&[("order", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_direction {
req_builder = req_builder.query(&[("direction", ¶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());
};
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<GetCloudflareKvNamespacesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Answers one KV key's value from the org's OWN Cloudflare account as RAW BYTES under the content type it was written with — not wrapped in a JSON envelope, which is why this is not a typed op. Any org member may read. A key that does not exist is Cloudflare's own 404; an invalid namespace, or a key that is empty, over 512 bytes, not valid UTF-8, or carries a control character, is 400; 503 if the org has never connected a Cloudflare token.
pub async fn get_cloudflare_kv_namespaces_by_namespace_values_by_key(configuration: &configuration::Configuration, namespace: &str, key: &str) -> Result<(), Error<GetCloudflareKvNamespacesByNamespaceValuesByKeyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_namespace = namespace;
let p_key = key;
let uri_str = format!("{}/v1/cloudflare/kv/namespaces/{namespace}/values/{key}", configuration.base_path, namespace=crate::apis::urlencode(p_namespace), key=crate::apis::urlencode(p_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.bearer_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(())
} else {
let content = resp.text().await?;
let entity: Option<GetCloudflareKvNamespacesByNamespaceValuesByKeyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lists the org's Cloudflare Pages projects. Any org member may read.
pub async fn get_cloudflare_pages_projects(configuration: &configuration::Configuration, ) -> Result<serde_json::Value, Error<GetCloudflarePagesProjectsError>> {
let uri_str = format!("{}/v1/cloudflare/pages/projects", 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());
};
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<GetCloudflarePagesProjectsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Reads one Cloudflare Pages project — its build config, deployment configs and latest deployment. Any org member may read.
pub async fn get_cloudflare_pages_projects_by_project(configuration: &configuration::Configuration, project: &str) -> Result<serde_json::Value, Error<GetCloudflarePagesProjectsByProjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_project = project;
let uri_str = format!("{}/v1/cloudflare/pages/projects/{project}", configuration.base_path, project=crate::apis::urlencode(p_project));
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());
};
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<GetCloudflarePagesProjectsByProjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lists the R2 buckets on the org's Cloudflare account. Any org member may read.
pub async fn get_cloudflare_r2_buckets(configuration: &configuration::Configuration, per_page: Option<&str>, cursor: Option<&str>, name_contains: Option<&str>, order: Option<&str>, direction: Option<&str>) -> Result<serde_json::Value, Error<GetCloudflareR2BucketsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_per_page = per_page;
let p_cursor = cursor;
let p_name_contains = name_contains;
let p_order = order;
let p_direction = direction;
let uri_str = format!("{}/v1/cloudflare/r2/buckets", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_per_page {
req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_cursor {
req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_name_contains {
req_builder = req_builder.query(&[("name_contains", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_order {
req_builder = req_builder.query(&[("order", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_direction {
req_builder = req_builder.query(&[("direction", ¶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());
};
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<GetCloudflareR2BucketsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lists the Worker scripts on the org's Cloudflare account. Any org member may read.
pub async fn get_cloudflare_workers_scripts(configuration: &configuration::Configuration, ) -> Result<serde_json::Value, Error<GetCloudflareWorkersScriptsError>> {
let uri_str = format!("{}/v1/cloudflare/workers/scripts", 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());
};
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<GetCloudflareWorkersScriptsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Reads the org account's workers.dev subdomain — the name under which every subdomain-enabled script is served. Any org member may read.
pub async fn get_cloudflare_workers_subdomain(configuration: &configuration::Configuration, ) -> Result<serde_json::Value, Error<GetCloudflareWorkersSubdomainError>> {
let uri_str = format!("{}/v1/cloudflare/workers/subdomain", 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());
};
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<GetCloudflareWorkersSubdomainError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lists the Worker routes bound within one zone — the URL patterns that dispatch to a script. Any org member may read. Routes are zone-scoped, so no account is resolved.
pub async fn get_cloudflare_workers_zones_by_zone_routes(configuration: &configuration::Configuration, zone: &str) -> Result<serde_json::Value, Error<GetCloudflareWorkersZonesByZoneRoutesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_zone = zone;
let uri_str = format!("{}/v1/cloudflare/workers/zones/{zone}/routes", configuration.base_path, zone=crate::apis::urlencode(p_zone));
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());
};
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<GetCloudflareWorkersZonesByZoneRoutesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lists the Cloudflare zones the org's connected API token can see, paged and filtered by the query parameters Cloudflare itself accepts. Zones are token-scoped by Cloudflare, so no account is resolved. Any org member may read. Zone and DNS-record MANAGEMENT is not here: it stays on the Hanzo DNS plane (/v1/dns). This only surfaces the Cloudflare zone objects the asset plane needs — a zone id is what addresses a Worker route or an analytics read.
pub async fn get_cloudflare_zones(configuration: &configuration::Configuration, page: Option<&str>, per_page: Option<&str>, name: Option<&str>, status: Option<&str>, order: Option<&str>, direction: Option<&str>) -> Result<serde_json::Value, Error<GetCloudflareZonesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_page = page;
let p_per_page = per_page;
let p_name = name;
let p_status = status;
let p_order = order;
let p_direction = direction;
let uri_str = format!("{}/v1/cloudflare/zones", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_per_page {
req_builder = req_builder.query(&[("per_page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_name {
req_builder = req_builder.query(&[("name", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_order {
req_builder = req_builder.query(&[("order", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_direction {
req_builder = req_builder.query(&[("direction", ¶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());
};
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<GetCloudflareZonesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Reads one Cloudflare zone the org's token can see. Any org member may read. A zone id the token cannot see is Cloudflare's own not-found, relayed.
pub async fn get_cloudflare_zones_by_zone(configuration: &configuration::Configuration, zone: &str) -> Result<serde_json::Value, Error<GetCloudflareZonesByZoneError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_zone = zone;
let uri_str = format!("{}/v1/cloudflare/zones/{zone}", configuration.base_path, zone=crate::apis::urlencode(p_zone));
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());
};
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<GetCloudflareZonesByZoneError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Reads a zone's Cloudflare traffic dashboard — requests, bandwidth, threats and pageviews over the since/until window. Any org member may read. A zone whose Cloudflare plan does not serve this endpoint yields Cloudflare's OWN error, never a fabricated success.
pub async fn get_cloudflare_zones_by_zone_analytics(configuration: &configuration::Configuration, zone: &str, since: Option<&str>, until: Option<&str>, continuous: Option<&str>) -> Result<serde_json::Value, Error<GetCloudflareZonesByZoneAnalyticsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_zone = zone;
let p_since = since;
let p_until = until;
let p_continuous = continuous;
let uri_str = format!("{}/v1/cloudflare/zones/{zone}/analytics", configuration.base_path, zone=crate::apis::urlencode(p_zone));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_since {
req_builder = req_builder.query(&[("since", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_until {
req_builder = req_builder.query(&[("until", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_continuous {
req_builder = req_builder.query(&[("continuous", ¶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());
};
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<GetCloudflareZonesByZoneAnalyticsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Creates a D1 database on the org's Cloudflare account. Requires org admin.
pub async fn post_cloudflare_d1_databases(configuration: &configuration::Configuration, database_create_in: models::DatabaseCreateIn) -> Result<serde_json::Value, Error<PostCloudflareD1DatabasesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_database_create_in = database_create_in;
let uri_str = format!("{}/v1/cloudflare/d1/databases", 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());
};
req_builder = req_builder.json(&p_database_create_in);
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<PostCloudflareD1DatabasesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Runs one SQL statement against a D1 database. It executes on the org's OWN Cloudflare account and relays D1's result set. The body is checked for a non-empty `sql` and then forwarded VERBATIM, so every field D1 accepts reaches D1 even though only two are named here. Requires ORG ADMIN — a statement may INSERT, UPDATE or DROP, so a query takes the write gate rather than the read one — and a caller who is only an org member is refused 403. A missing `sql` is 400; 503 if the org has never connected a Cloudflare token.
pub async fn post_cloudflare_d1_databases_by_database_query(configuration: &configuration::Configuration, database: &str, d1_query: models::D1Query) -> Result<serde_json::Value, Error<PostCloudflareD1DatabasesByDatabaseQueryError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_database = database;
let p_d1_query = d1_query;
let uri_str = format!("{}/v1/cloudflare/d1/databases/{database}/query", configuration.base_path, database=crate::apis::urlencode(p_database));
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());
};
req_builder = req_builder.json(&p_d1_query);
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<PostCloudflareD1DatabasesByDatabaseQueryError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// KVNamespaceCreate creates a Workers KV namespace on the org's Cloudflare account. Requires org admin. Cloudflare mints the namespace id the value routes address.
pub async fn post_cloudflare_kv_namespaces(configuration: &configuration::Configuration, namespace_create_in: models::NamespaceCreateIn) -> Result<serde_json::Value, Error<PostCloudflareKvNamespacesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_namespace_create_in = namespace_create_in;
let uri_str = format!("{}/v1/cloudflare/kv/namespaces", 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());
};
req_builder = req_builder.json(&p_namespace_create_in);
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<PostCloudflareKvNamespacesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Creates a Cloudflare Pages project on the org's account. Requires org admin. Only the modeled fields reach Cloudflare, so an unmodeled key in the request is dropped rather than forwarded.
pub async fn post_cloudflare_pages_projects(configuration: &configuration::Configuration, pages_project_create: models::PagesProjectCreate) -> Result<serde_json::Value, Error<PostCloudflarePagesProjectsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_pages_project_create = pages_project_create;
let uri_str = format!("{}/v1/cloudflare/pages/projects", 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());
};
req_builder = req_builder.json(&p_pages_project_create);
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<PostCloudflarePagesProjectsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Starts a build and deployment of one Cloudflare Pages project on the org's OWN Cloudflare account, and relays Cloudflare's deployment record back. `branch` picks what to build; OMITTING it builds the project's production branch. A body it cannot parse is IGNORED rather than refused — the deployment falls back to the production branch — which is the one rule to get right here and the reason this is not a typed op: a typed request would answer 400 where this deploys. Requires ORG ADMIN (403 otherwise), and 503 if the org has never connected a Cloudflare token.
pub async fn post_cloudflare_pages_projects_by_project_deployments(configuration: &configuration::Configuration, project: &str, pages_deploy: Option<models::PagesDeploy>) -> Result<serde_json::Value, Error<PostCloudflarePagesProjectsByProjectDeploymentsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_project = project;
let p_pages_deploy = pages_deploy;
let uri_str = format!("{}/v1/cloudflare/pages/projects/{project}/deployments", configuration.base_path, project=crate::apis::urlencode(p_project));
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());
};
req_builder = req_builder.json(&p_pages_deploy);
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<PostCloudflarePagesProjectsByProjectDeploymentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Attaches a custom domain to a Cloudflare Pages project. Requires org admin. Cloudflare owns validation and certificate issuance from here on.
pub async fn post_cloudflare_pages_projects_by_project_domains(configuration: &configuration::Configuration, project: &str, domain_add_in: models::DomainAddIn) -> Result<serde_json::Value, Error<PostCloudflarePagesProjectsByProjectDomainsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_project = project;
let p_domain_add_in = domain_add_in;
let uri_str = format!("{}/v1/cloudflare/pages/projects/{project}/domains", configuration.base_path, project=crate::apis::urlencode(p_project));
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());
};
req_builder = req_builder.json(&p_domain_add_in);
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<PostCloudflarePagesProjectsByProjectDomainsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Creates an R2 bucket on the org's Cloudflare account. Requires org admin.
pub async fn post_cloudflare_r2_buckets(configuration: &configuration::Configuration, bucket_create_in: models::BucketCreateIn) -> Result<serde_json::Value, Error<PostCloudflareR2BucketsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_bucket_create_in = bucket_create_in;
let uri_str = format!("{}/v1/cloudflare/r2/buckets", 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());
};
req_builder = req_builder.json(&p_bucket_create_in);
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<PostCloudflareR2BucketsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Publishes or withdraws one Worker script on the account's workers.dev subdomain. Requires org admin.
pub async fn post_cloudflare_workers_scripts_by_script_subdomain(configuration: &configuration::Configuration, script: &str, subdomain_set_in: models::SubdomainSetIn) -> Result<serde_json::Value, Error<PostCloudflareWorkersScriptsByScriptSubdomainError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_script = script;
let p_subdomain_set_in = subdomain_set_in;
let uri_str = format!("{}/v1/cloudflare/workers/scripts/{script}/subdomain", configuration.base_path, script=crate::apis::urlencode(p_script));
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());
};
req_builder = req_builder.json(&p_subdomain_set_in);
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<PostCloudflareWorkersScriptsByScriptSubdomainError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Binds a URL pattern in a zone to a Worker script. Requires org admin — a route is what puts a script in front of live traffic.
pub async fn post_cloudflare_workers_zones_by_zone_routes(configuration: &configuration::Configuration, zone: &str, route_create_in: models::RouteCreateIn) -> Result<serde_json::Value, Error<PostCloudflareWorkersZonesByZoneRoutesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_zone = zone;
let p_route_create_in = route_create_in;
let uri_str = format!("{}/v1/cloudflare/workers/zones/{zone}/routes", configuration.base_path, zone=crate::apis::urlencode(p_zone));
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());
};
req_builder = req_builder.json(&p_route_create_in);
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<PostCloudflareWorkersZonesByZoneRoutesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Drops a zone's Cloudflare edge cache — either the whole zone (purge_everything) or exactly the listed file URLs. Requires org admin. Purging is the one zone-scoped WRITE this plane owns. It is not DNS — no record changes — so it does not belong on /v1/dns, and it is not a connection, so it does not belong on the integrations plane. It is a cache operation on a zone, which is what this asset plane is for. It takes the admin gate because dropping a zone's cache sends every subsequent request to the origin: on a site fronting a small origin that is a self-inflicted load spike, so it is a change, not a look. Exactly one selector is required. Cloudflare treats a body with neither as a no-op and answers 200, which reads as \"purged\" to a caller that never purged anything — the failure we refuse to pass through.
pub async fn post_cloudflare_zones_by_zone_purge(configuration: &configuration::Configuration, zone: &str, purge_in: models::PurgeIn) -> Result<serde_json::Value, Error<PostCloudflareZonesByZonePurgeError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_zone = zone;
let p_purge_in = purge_in;
let uri_str = format!("{}/v1/cloudflare/zones/{zone}/purge", configuration.base_path, zone=crate::apis::urlencode(p_zone));
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());
};
req_builder = req_builder.json(&p_purge_in);
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<PostCloudflareZonesByZonePurgeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Stores one KV key on the org's OWN Cloudflare account. The REQUEST BODY IS THE VALUE, forwarded verbatim under the caller's own Content-Type (`text/plain` when none is sent), so a value is never re-encoded on the way in — which is why this is not a typed op. `expiration` and `expiration_ttl` may ride the query string and are passed through to Cloudflare. Requires ORG ADMIN (403 otherwise); the same namespace and key validation as the read answers 400; 503 if the org has never connected a Cloudflare token.
pub async fn put_cloudflare_kv_namespaces_by_namespace_values_by_key(configuration: &configuration::Configuration, namespace: &str, key: &str) -> Result<(), Error<PutCloudflareKvNamespacesByNamespaceValuesByKeyError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_namespace = namespace;
let p_key = key;
let uri_str = format!("{}/v1/cloudflare/kv/namespaces/{namespace}/values/{key}", configuration.base_path, namespace=crate::apis::urlencode(p_namespace), key=crate::apis::urlencode(p_key));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_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(())
} else {
let content = resp.text().await?;
let entity: Option<PutCloudflareKvNamespacesByNamespaceValuesByKeyError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Uploads or replaces a module Worker script. It publishes to the org's OWN Cloudflare account under the name in the path, replacing whatever was there, and relays Cloudflare's result. The compatibility date, compatibility flags and bindings are packed into the multipart upload Cloudflare expects, beside the module source. Requires ORG ADMIN — a Worker is arbitrary code on the org's own account and domains — so a caller who is only an org member is refused 403. An empty source is 400, as is a `mainModule` that is not a plain file name; 503 if the org has never connected a Cloudflare token.
pub async fn put_cloudflare_workers_scripts_by_script(configuration: &configuration::Configuration, script: &str, worker_script_put: models::WorkerScriptPut) -> Result<serde_json::Value, Error<PutCloudflareWorkersScriptsByScriptError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_script = script;
let p_worker_script_put = worker_script_put;
let uri_str = format!("{}/v1/cloudflare/workers/scripts/{script}", configuration.base_path, script=crate::apis::urlencode(p_script));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_worker_script_put);
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<PutCloudflareWorkersScriptsByScriptError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}