use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct NamespaceWorkerList<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
}
impl<'a> NamespaceWorkerList<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self { client, account_id } = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_list",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerCreate<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
body: Result<types::builder::NamespaceWorkerCreateBody, String>,
}
impl<'a> NamespaceWorkerCreate<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::NamespaceWorkerCreateBody>,
<V as std::convert::TryInto<types::NamespaceWorkerCreateBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `NamespaceWorkerCreateBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::NamespaceWorkerCreateBody,
) -> types::builder::NamespaceWorkerCreateBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::NamespaceWorkerCreateBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_create",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerGetNamespace<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
}
impl<'a> NamespaceWorkerGetNamespace<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_get_namespace",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerPutNamespace<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
body: Result<types::builder::NamespaceWorkerPutNamespaceBody, String>,
}
impl<'a> NamespaceWorkerPutNamespace<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::NamespaceWorkerPutNamespaceBody>,
<V as std::convert::TryInto<types::NamespaceWorkerPutNamespaceBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `NamespaceWorkerPutNamespaceBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::NamespaceWorkerPutNamespaceBody,
) -> types::builder::NamespaceWorkerPutNamespaceBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::NamespaceWorkerPutNamespaceBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_put_namespace",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerDeleteNamespace<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
}
impl<'a> NamespaceWorkerDeleteNamespace<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_delete_namespace",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerPatchNamespace<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
body: Result<types::builder::NamespaceWorkerPatchNamespaceBody, String>,
}
impl<'a> NamespaceWorkerPatchNamespace<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::NamespaceWorkerPatchNamespaceBody>,
<V as std::convert::TryInto<types::NamespaceWorkerPatchNamespaceBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `NamespaceWorkerPatchNamespaceBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::NamespaceWorkerPatchNamespaceBody,
) -> types::builder::NamespaceWorkerPatchNamespaceBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::NamespaceWorkerPatchNamespaceBody::try_from(v).map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_patch_namespace",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerListScripts<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
tags: Result<::std::string::String, String>,
}
impl<'a> NamespaceWorkerListScripts<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
tags: Err("tags was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
tags,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_list_scripts",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerDeleteScripts<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
limit: Result<i64, String>,
tags: Result<::std::string::String, String>,
}
impl<'a> NamespaceWorkerDeleteScripts<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
limit: Err("limit was not initialized".to_string()),
tags: Err("tags was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn limit<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<i64>,
{
self.limit = value
.try_into()
.map_err(|_| "conversion to `i64` for limit failed".to_string());
self
}
pub fn tags<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.tags = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for tags failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
limit,
tags,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let limit = limit.map_err(Error::InvalidRequest)?;
let tags = tags.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new("limit", &limit))
.query(&progenitor_client::QueryParam::new("tags", &tags))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_delete_scripts",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerScriptWorkerDetails<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> NamespaceWorkerScriptWorkerDetails<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_script_worker_details",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerScriptUploadWorkerModule<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
bindings_inherit:
Result<types::NamespaceWorkerScriptUploadWorkerModuleBindingsInherit, String>,
body: Result<types::builder::WorkersMultipartScript, String>,
}
impl<'a> NamespaceWorkerScriptUploadWorkerModule<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
bindings_inherit: Err("bindings_inherit was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn bindings_inherit<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::NamespaceWorkerScriptUploadWorkerModuleBindingsInherit>,
{
self . bindings_inherit = value . try_into () . map_err (| _ | "conversion to `NamespaceWorkerScriptUploadWorkerModuleBindingsInherit` for bindings_inherit failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersMultipartScript>,
<V as std::convert::TryInto<types::WorkersMultipartScript>>::Error: std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `WorkersMultipartScript` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::WorkersMultipartScript,
) -> types::builder::WorkersMultipartScript,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
bindings_inherit,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let bindings_inherit = bindings_inherit.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| types::WorkersMultipartScript::try_from(v).map_err(|e| e.to_string()))
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.query(&progenitor_client::QueryParam::new(
"bindings_inherit",
&bindings_inherit,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_script_upload_worker_module",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerScriptDeleteWorker<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
force: Result<bool, String>,
body: Result<::serde_json::Map<::std::string::String, ::serde_json::Value>, String>,
}
impl<'a> NamespaceWorkerScriptDeleteWorker<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
force: Err("force was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn force<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<bool>,
{
self.force = value
.try_into()
.map_err(|_| "conversion to `bool` for force failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
{
self . body = value . try_into () . map_err (| _ | "conversion to `:: serde_json :: Map < :: std :: string :: String , :: serde_json :: Value >` for body failed" . to_string ()) ;
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
force,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let force = force.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.query(&progenitor_client::QueryParam::new("force", &force))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_script_delete_worker",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerGetScriptBindings<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> NamespaceWorkerGetScriptBindings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/bindings",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_get_script_bindings",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerGetScriptContent<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> NamespaceWorkerGetScriptContent<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/content",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client.client.get(url).headers(header_map).build()?;
let info = OperationInfo {
operation_id: "namespace_worker_get_script_content",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerPutScriptContent<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
cf_worker_body_part: Result<::std::string::String, String>,
cf_worker_main_module_part: Result<::std::string::String, String>,
body: Result<types::builder::NamespaceWorkerPutScriptContentBody, String>,
}
impl<'a> NamespaceWorkerPutScriptContent<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
cf_worker_body_part: Err("cf_worker_body_part was not initialized".to_string()),
cf_worker_main_module_part: Err(
"cf_worker_main_module_part was not initialized".to_string()
),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn cf_worker_body_part<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.cf_worker_body_part = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for cf_worker_body_part failed"
.to_string()
});
self
}
pub fn cf_worker_main_module_part<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self . cf_worker_main_module_part = value . try_into () . map_err (| _ | "conversion to `:: std :: string :: String` for cf_worker_main_module_part failed" . to_string ()) ;
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::NamespaceWorkerPutScriptContentBody>,
<V as std::convert::TryInto<types::NamespaceWorkerPutScriptContentBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `NamespaceWorkerPutScriptContentBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::NamespaceWorkerPutScriptContentBody,
) -> types::builder::NamespaceWorkerPutScriptContentBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
cf_worker_body_part,
cf_worker_main_module_part,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let cf_worker_body_part = cf_worker_body_part.map_err(Error::InvalidRequest)?;
let cf_worker_main_module_part =
cf_worker_main_module_part.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::NamespaceWorkerPutScriptContentBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/content",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(3usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
header_map.append(
"CF-WORKER-BODY-PART",
cf_worker_body_part.to_string().try_into()?,
);
header_map.append(
"CF-WORKER-MAIN-MODULE-PART",
cf_worker_main_module_part.to_string().try_into()?,
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_put_script_content",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerListScriptSecrets<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> NamespaceWorkerListScriptSecrets<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/secrets",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_list_script_secrets",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerPutScriptSecrets<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
body: Result<types::WorkersSecret, String>,
}
impl<'a> NamespaceWorkerPutScriptSecrets<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSecret>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `WorkersSecret` for body failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/secrets",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_put_script_secrets",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerGetScriptSecrets<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
secret_name: Result<types::WorkersSecretName, String>,
url_encoded: Result<types::WorkersSecretNameUrlEncoded, String>,
}
impl<'a> NamespaceWorkerGetScriptSecrets<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
secret_name: Err("secret_name was not initialized".to_string()),
url_encoded: Err("url_encoded was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn secret_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSecretName>,
{
self.secret_name = value.try_into().map_err(|_| {
"conversion to `WorkersSecretName` for secret_name failed".to_string()
});
self
}
pub fn url_encoded<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSecretNameUrlEncoded>,
{
self.url_encoded = value.try_into().map_err(|_| {
"conversion to `WorkersSecretNameUrlEncoded` for url_encoded failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
secret_name,
url_encoded,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let secret_name = secret_name.map_err(Error::InvalidRequest)?;
let url_encoded = url_encoded.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/secrets/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
encode_path(&secret_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new(
"url_encoded",
&url_encoded,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_get_script_secrets",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerDeleteScriptSecret<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
secret_name: Result<types::WorkersSecretName, String>,
url_encoded: Result<types::WorkersSecretNameUrlEncoded, String>,
}
impl<'a> NamespaceWorkerDeleteScriptSecret<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
secret_name: Err("secret_name was not initialized".to_string()),
url_encoded: Err("url_encoded was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn secret_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSecretName>,
{
self.secret_name = value.try_into().map_err(|_| {
"conversion to `WorkersSecretName` for secret_name failed".to_string()
});
self
}
pub fn url_encoded<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersSecretNameUrlEncoded>,
{
self.url_encoded = value.try_into().map_err(|_| {
"conversion to `WorkersSecretNameUrlEncoded` for url_encoded failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
secret_name,
url_encoded,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let secret_name = secret_name.map_err(Error::InvalidRequest)?;
let url_encoded = url_encoded.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/secrets/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
encode_path(&secret_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.query(&progenitor_client::QueryParam::new(
"url_encoded",
&url_encoded,
))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_delete_script_secret",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerGetScriptSettings<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> NamespaceWorkerGetScriptSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/settings",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_get_script_settings",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerPatchScriptSettings<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
body: Result<types::builder::NamespaceWorkerPatchScriptSettingsBody, String>,
}
impl<'a> NamespaceWorkerPatchScriptSettings<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
body: Ok(::std::default::Default::default()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::NamespaceWorkerPatchScriptSettingsBody>,
<V as std::convert::TryInto<types::NamespaceWorkerPatchScriptSettingsBody>>::Error:
std::fmt::Display,
{
self.body = value.try_into().map(From::from).map_err(|s| {
format!(
"conversion to `NamespaceWorkerPatchScriptSettingsBody` for body failed: {}",
s
)
});
self
}
pub fn body<F>(mut self, f: F) -> Self
where
F: std::ops::FnOnce(
types::builder::NamespaceWorkerPatchScriptSettingsBody,
)
-> types::builder::NamespaceWorkerPatchScriptSettingsBody,
{
self.body = self.body.map(f);
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let body = body
.and_then(|v| {
types::NamespaceWorkerPatchScriptSettingsBody::try_from(v)
.map_err(|e| e.to_string())
})
.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/settings",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.patch(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_patch_script_settings",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerGetScriptTags<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
}
impl<'a> NamespaceWorkerGetScriptTags<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/tags",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.get(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_get_script_tags",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerPutScriptTags<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
body: Result<types::WorkersTags, String>,
}
impl<'a> NamespaceWorkerPutScriptTags<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersTags>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `WorkersTags` for body failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/tags",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_put_script_tags",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerPutScriptTag<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
tag: Result<types::WorkersTag, String>,
}
impl<'a> NamespaceWorkerPutScriptTag<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
tag: Err("tag was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn tag<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersTag>,
{
self.tag = value
.try_into()
.map_err(|_| "conversion to `WorkersTag` for tag failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
tag,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let tag = tag.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/tags/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
encode_path(&tag.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.put(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_put_script_tag",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct NamespaceWorkerDeleteScriptTag<'a> {
client: &'a crate::Client,
account_id: Result<types::WorkersIdentifier, String>,
dispatch_namespace: Result<types::WorkersDispatchNamespaceName, String>,
script_name: Result<types::WorkersScriptName, String>,
tag: Result<types::WorkersTag, String>,
}
impl<'a> NamespaceWorkerDeleteScriptTag<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
dispatch_namespace: Err("dispatch_namespace was not initialized".to_string()),
script_name: Err("script_name was not initialized".to_string()),
tag: Err("tag was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersIdentifier>,
{
self.account_id = value
.try_into()
.map_err(|_| "conversion to `WorkersIdentifier` for account_id failed".to_string());
self
}
pub fn dispatch_namespace<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersDispatchNamespaceName>,
{
self.dispatch_namespace = value.try_into().map_err(|_| {
"conversion to `WorkersDispatchNamespaceName` for dispatch_namespace failed"
.to_string()
});
self
}
pub fn script_name<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersScriptName>,
{
self.script_name = value.try_into().map_err(|_| {
"conversion to `WorkersScriptName` for script_name failed".to_string()
});
self
}
pub fn tag<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::WorkersTag>,
{
self.tag = value
.try_into()
.map_err(|_| "conversion to `WorkersTag` for tag failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
dispatch_namespace,
script_name,
tag,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let dispatch_namespace = dispatch_namespace.map_err(Error::InvalidRequest)?;
let script_name = script_name.map_err(Error::InvalidRequest)?;
let tag = tag.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/workers/dispatch/namespaces/{}/scripts/{}/tags/{}",
client.baseurl,
encode_path(&account_id.to_string()),
encode_path(&dispatch_namespace.to_string()),
encode_path(&script_name.to_string()),
encode_path(&tag.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.delete(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "namespace_worker_delete_script_tag",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}