#![allow(clippy::all, unused_imports, dead_code)]
//! Auto-generated API actors for Vercel
//!
//! Service: Vercel (vercel)
//! Frontend deployment and hosting platform
//!
//! Required env var: VERCEL_API_KEY (Bearer token)
//!
//! Generated by api-schema-gen codegen — do not edit manually.
use crate::{Actor, ActorBehavior, Message, Port};
use anyhow::{Error, Result};
use reflow_actor::{message::EncodableValue, ActorContext};
use reflow_actor_macro::actor;
use serde_json::{json, Value};
use std::collections::HashMap;
use std::time::Duration;
const BASE_URL: &str = "https://api.vercel.com";
const ENV_KEY: &str = "VERCEL_API_KEY";
/// Apply authentication to the request builder.
fn apply_auth(
config: &reflow_actor::ActorConfig,
mut builder: reqwest::RequestBuilder,
) -> Result<reqwest::RequestBuilder> {
let credential = config
.get_config_or_env(ENV_KEY)
.ok_or_else(|| anyhow::anyhow!("Missing env var: {}", ENV_KEY))?;
builder = builder.header("Authorization", format!("Bearer {}", credential));
Ok(builder)
}
/// Create a new deployment
///
/// Method: POST /v13/deployments
#[actor(
VercelCreateDeploymentActor,
inports::<100>(name, files, forceNew, skipAutoDetectionConfirmation, teamId, slug, projectSettings, target, deploymentId, withLatestCommit, gitMetadata, customEnvironmentSlugOrId, monorepoManager, project, gitSource, meta),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_deployment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v13/deployments".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("forceNew") {
query_pairs.push(("forceNew", super::message_to_str(val)));
}
if let Some(val) = inputs.get("skipAutoDetectionConfirmation") {
query_pairs.push(("skipAutoDetectionConfirmation", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("files") {
body.insert("files".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projectSettings") {
body.insert("projectSettings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("target") {
body.insert("target".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("deploymentId") {
body.insert("deploymentId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("withLatestCommit") {
body.insert("withLatestCommit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("gitMetadata") {
body.insert("gitMetadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customEnvironmentSlugOrId") {
body.insert("customEnvironmentSlugOrId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("monorepoManager") {
body.insert("monorepoManager".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("project") {
body.insert("project".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("gitSource") {
body.insert("gitSource".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("meta") {
body.insert("meta".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v13/deployments failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List deployments
///
/// Method: GET /v6/deployments
#[actor(
VercelListDeploymentsActor,
inports::<100>(app, from, limit, projectId, projectIds, target, to, users, since, until, state, rollbackCandidate, branch, sha, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_deployments(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v6/deployments".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("app") {
query_pairs.push(("app", super::message_to_str(val)));
}
if let Some(val) = inputs.get("from") {
query_pairs.push(("from", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("projectIds") {
query_pairs.push(("projectIds", super::message_to_str(val)));
}
if let Some(val) = inputs.get("target") {
query_pairs.push(("target", super::message_to_str(val)));
}
if let Some(val) = inputs.get("to") {
query_pairs.push(("to", super::message_to_str(val)));
}
if let Some(val) = inputs.get("users") {
query_pairs.push(("users", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("state") {
query_pairs.push(("state", super::message_to_str(val)));
}
if let Some(val) = inputs.get("rollbackCandidate") {
query_pairs.push(("rollbackCandidate", super::message_to_str(val)));
}
if let Some(val) = inputs.get("branch") {
query_pairs.push(("branch", super::message_to_str(val)));
}
if let Some(val) = inputs.get("sha") {
query_pairs.push(("sha", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v6/deployments failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update the protection bypass for a URL
///
/// Method: PATCH /aliases/{id}/protection-bypass
#[actor(
VercelUpdateUrlProtectionBypassActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_url_protection_bypass(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/aliases/{id}/protection-bypass".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("PATCH /aliases/{{id}}/protection-bypass failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Accept project transfer request
///
/// Method: PUT /projects/transfer-request/{code}
#[actor(
VercelUpdateProjectsActor,
inports::<100>(code, teamId, slug, acceptedPolicies, newProjectName, paidFeatures),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_projects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/projects/transfer-request/{code}".to_string();
if let Some(val) = inputs.get("code") {
endpoint = endpoint.replace("{{code}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.put(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("acceptedPolicies") {
body.insert("acceptedPolicies".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("newProjectName") {
body.insert("newProjectName".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("paidFeatures") {
body.insert("paidFeatures".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("PUT /projects/transfer-request/{{code}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create project transfer request
///
/// Method: POST /projects/{idOrName}/transfer-request
#[actor(
VercelCreateProjectTransferRequestActor,
inports::<100>(idOrName, teamId, slug, callbackUrl, callbackSecret),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_project_transfer_request(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/projects/{idOrName}/transfer-request".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("callbackUrl") {
body.insert("callbackUrl".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("callbackSecret") {
body.insert("callbackSecret".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /projects/{{idOrName}}/transfer-request failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List access groups for a team, project or member
///
/// Method: GET /v1/access-groups
#[actor(
VercelListAccessGroupsActor,
inports::<100>(projectId, search, membersLimit, projectsLimit, limit, next, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_access_groups(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/access-groups".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("search") {
query_pairs.push(("search", super::message_to_str(val)));
}
if let Some(val) = inputs.get("membersLimit") {
query_pairs.push(("membersLimit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("projectsLimit") {
query_pairs.push(("projectsLimit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("next") {
query_pairs.push(("next", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/access-groups failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Creates an access group
///
/// Method: POST /v1/access-groups
#[actor(
VercelCreateAccessGroupActor,
inports::<100>(teamId, slug, membersToAdd, projects, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_access_group(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/access-groups".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("membersToAdd") {
body.insert("membersToAdd".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projects") {
body.insert("projects".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/access-groups failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create an access group project
///
/// Method: POST /v1/access-groups/{accessGroupIdOrName}/projects
#[actor(
VercelCreateAccessGroupProjectActor,
inports::<100>(accessGroupIdOrName, teamId, slug, projectId, role),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_access_group_project(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/access-groups/{accessGroupIdOrName}/projects".to_string();
if let Some(val) = inputs.get("accessGroupIdOrName") {
endpoint = endpoint.replace("{{accessGroupIdOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("projectId") {
body.insert("projectId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("role") {
body.insert("role".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/access-groups/{{accessGroupIdOrName}}/projects failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Delete an access group project
///
/// Method: DELETE /v1/access-groups/{accessGroupIdOrName}/projects/{projectId}
#[actor(
VercelDeleteAccessGroupProjectActor,
inports::<100>(accessGroupIdOrName, projectId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_access_group_project(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/access-groups/{accessGroupIdOrName}/projects/{projectId}".to_string();
if let Some(val) = inputs.get("accessGroupIdOrName") {
endpoint = endpoint.replace("{{accessGroupIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("DELETE /v1/access-groups/{{accessGroupIdOrName}}/projects/{{projectId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Reads an access group project
///
/// Method: GET /v1/access-groups/{accessGroupIdOrName}/projects/{projectId}
#[actor(
VercelReadAccessGroupsActor,
inports::<100>(accessGroupIdOrName, projectId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_access_groups(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/access-groups/{accessGroupIdOrName}/projects/{projectId}".to_string();
if let Some(val) = inputs.get("accessGroupIdOrName") {
endpoint = endpoint.replace("{{accessGroupIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/access-groups/{{accessGroupIdOrName}}/projects/{{projectId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Update an access group project
///
/// Method: PATCH /v1/access-groups/{accessGroupIdOrName}/projects/{projectId}
#[actor(
VercelUpdateAccessGroupProjectActor,
inports::<100>(accessGroupIdOrName, projectId, teamId, slug, role),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_access_group_project(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/access-groups/{accessGroupIdOrName}/projects/{projectId}".to_string();
if let Some(val) = inputs.get("accessGroupIdOrName") {
endpoint = endpoint.replace("{{accessGroupIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("role") {
body.insert("role".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("PATCH /v1/access-groups/{{accessGroupIdOrName}}/projects/{{projectId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Deletes an access group
///
/// Method: DELETE /v1/access-groups/{idOrName}
#[actor(
VercelDeleteAccessGroupActor,
inports::<100>(idOrName, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_access_group(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/access-groups/{idOrName}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/access-groups/{{idOrName}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update an access group
///
/// Method: POST /v1/access-groups/{idOrName}
#[actor(
VercelUpdateAccessGroupActor,
inports::<100>(idOrName, teamId, slug, membersToRemove, projects, name, membersToAdd),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_access_group(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/access-groups/{idOrName}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("membersToRemove") {
body.insert("membersToRemove".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projects") {
body.insert("projects".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("membersToAdd") {
body.insert("membersToAdd".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/access-groups/{{idOrName}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List members of an access group
///
/// Method: GET /v1/access-groups/{idOrName}/members
#[actor(
VercelListAccessGroupMembersActor,
inports::<100>(idOrName, limit, next, search, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_access_group_members(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/access-groups/{idOrName}/members".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("next") {
query_pairs.push(("next", super::message_to_str(val)));
}
if let Some(val) = inputs.get("search") {
query_pairs.push(("search", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/access-groups/{{idOrName}}/members failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List projects of an access group
///
/// Method: GET /v1/access-groups/{idOrName}/projects
#[actor(
VercelListAccessGroupProjectsActor,
inports::<100>(idOrName, limit, next, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_access_group_projects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/access-groups/{idOrName}/projects".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("next") {
query_pairs.push(("next", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/access-groups/{{idOrName}}/projects failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List FOCUS billing charges
///
/// Method: GET /v1/billing/charges
#[actor(
VercelListBillingChargesActor,
inports::<100>(from, to, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_billing_charges(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/charges".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("from") {
query_pairs.push(("from", super::message_to_str(val)));
}
if let Some(val) = inputs.get("to") {
query_pairs.push(("to", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/billing/charges failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List FOCUS contract commitments
///
/// Method: GET /v1/billing/contract-commitments
#[actor(
VercelListContractCommitmentsActor,
inports::<100>(teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_contract_commitments(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/contract-commitments".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/billing/contract-commitments failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete project-level redirects.
///
/// Method: DELETE /v1/bulk-redirects
#[actor(
VercelDeleteRedirectsActor,
inports::<100>(projectId, teamId, slug, name, redirects),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_redirects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/bulk-redirects".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/bulk-redirects failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Edit a project-level redirect.
///
/// Method: PATCH /v1/bulk-redirects
#[actor(
VercelUpdateBulkRedirectsActor,
inports::<100>(projectId, teamId, slug, name, redirect, restore),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_bulk_redirects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/bulk-redirects".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("redirect") {
body.insert("redirect".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("restore") {
body.insert("restore".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("PATCH /v1/bulk-redirects failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Gets project-level redirects.
///
/// Method: GET /v1/bulk-redirects
#[actor(
VercelReadRedirectsActor,
inports::<100>(projectId, versionId, q, diff, page, per_page, sort_by, sort_order, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_redirects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/bulk-redirects".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("versionId") {
query_pairs.push(("versionId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("q") {
query_pairs.push(("q", super::message_to_str(val)));
}
if let Some(val) = inputs.get("diff") {
query_pairs.push(("diff", super::message_to_str(val)));
}
if let Some(val) = inputs.get("page") {
query_pairs.push(("page", super::message_to_str(val)));
}
if let Some(val) = inputs.get("per_page") {
query_pairs.push(("per_page", super::message_to_str(val)));
}
if let Some(val) = inputs.get("sort_by") {
query_pairs.push(("sort_by", super::message_to_str(val)));
}
if let Some(val) = inputs.get("sort_order") {
query_pairs.push(("sort_order", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/bulk-redirects failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Restore staged project-level redirects to their production version.
///
/// Method: POST /v1/bulk-redirects/restore
#[actor(
VercelRestoreBulkRedirectsActor,
inports::<100>(projectId, teamId, slug, name, redirects),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_restore_bulk_redirects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/bulk-redirects/restore".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("redirects") {
body.insert("redirects".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/bulk-redirects/restore failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get the version history for a project's redirects.
///
/// Method: GET /v1/bulk-redirects/versions
#[actor(
VercelReadVersionsActor,
inports::<100>(projectId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_versions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/bulk-redirects/versions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/bulk-redirects/versions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Promote a staging version to production or restore a previous production version.
///
/// Method: POST /v1/bulk-redirects/versions
#[actor(
VercelUpdateVersionActor,
inports::<100>(projectId, teamId, slug, action, id, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_version(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/bulk-redirects/versions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("action") {
body.insert("action".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id") {
body.insert("id".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/bulk-redirects/versions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List Secure Compute networks
///
/// Method: GET /v1/connect/networks
#[actor(
VercelListNetworksActor,
inports::<100>(includeHostedZones, includePeeringConnections, includeProjects, search, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_networks(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/connect/networks".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("includeHostedZones") {
query_pairs.push(("includeHostedZones", super::message_to_str(val)));
}
if let Some(val) = inputs.get("includePeeringConnections") {
query_pairs.push(("includePeeringConnections", super::message_to_str(val)));
}
if let Some(val) = inputs.get("includeProjects") {
query_pairs.push(("includeProjects", super::message_to_str(val)));
}
if let Some(val) = inputs.get("search") {
query_pairs.push(("search", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/connect/networks failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a Secure Compute network
///
/// Method: POST /v1/connect/networks
#[actor(
VercelCreateNetworkActor,
inports::<100>(teamId, slug, awsAvailabilityZoneIds, name, region, cidr),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_network(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/connect/networks".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("awsAvailabilityZoneIds") {
body.insert("awsAvailabilityZoneIds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("region") {
body.insert("region".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cidr") {
body.insert("cidr".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/connect/networks failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a Secure Compute network
///
/// Method: DELETE /v1/connect/networks/{networkId}
#[actor(
VercelDeleteNetworkActor,
inports::<100>(networkId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_network(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/connect/networks/{networkId}".to_string();
if let Some(val) = inputs.get("networkId") {
endpoint = endpoint.replace("{{networkId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/connect/networks/{{networkId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update a Secure Compute network
///
/// Method: PATCH /v1/connect/networks/{networkId}
#[actor(
VercelUpdateNetworkActor,
inports::<100>(networkId, teamId, slug, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_network(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/connect/networks/{networkId}".to_string();
if let Some(val) = inputs.get("networkId") {
endpoint = endpoint.replace("{{networkId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("PATCH /v1/connect/networks/{{networkId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Read a Secure Compute network
///
/// Method: GET /v1/connect/networks/{networkId}
#[actor(
VercelReadConnectActor,
inports::<100>(networkId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_connect(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/connect/networks/{networkId}".to_string();
if let Some(val) = inputs.get("networkId") {
endpoint = endpoint.replace("{{networkId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/connect/networks/{{networkId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve the feature flags of a deployment
///
/// Method: GET /v1/deployments/{deploymentId}/feature-flags
#[actor(
VercelReadDeploymentFeatureFlagsActor,
inports::<100>(deploymentId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_deployment_feature_flags(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/deployments/{deploymentId}/feature-flags".to_string();
if let Some(val) = inputs.get("deploymentId") {
endpoint = endpoint.replace("{{deploymentId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/deployments/{{deploymentId}}/feature-flags failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update deployment integration action
///
/// Method: PATCH /v1/deployments/{deploymentId}/integrations/{integrationConfigurationId}/resources/{resourceId}/actions/{action}
#[actor(
VercelUpdateIntegrationDeploymentActionActor,
inports::<100>(deploymentId, integrationConfigurationId, resourceId, action, outcomes, status, statusText, statusUrl),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_integration_deployment_action(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/deployments/{deploymentId}/integrations/{integrationConfigurationId}/resources/{resourceId}/actions/{action}".to_string();
if let Some(val) = inputs.get("deploymentId") {
endpoint = endpoint.replace("{{deploymentId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("action") {
endpoint = endpoint.replace("{{action}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("outcomes") {
body.insert("outcomes".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("status") {
body.insert("status".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statusText") {
body.insert("statusText".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statusUrl") {
body.insert("statusUrl".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("PATCH /v1/deployments/{{deploymentId}}/integrations/{{integrationConfigurationId}}/resources/{{resourceId}}/actions/{{action}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Update an existing DNS record
///
/// Method: PATCH /v1/domains/records/{recordId}
#[actor(
VercelUpdateRecordActor,
inports::<100>(recordId, teamId, slug, type_, srv, https, value, ttl, mxPriority, name, comment),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_record(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/domains/records/{recordId}".to_string();
if let Some(val) = inputs.get("recordId") {
endpoint = endpoint.replace("{{recordId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("srv") {
body.insert("srv".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("https") {
body.insert("https".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("value") {
body.insert("value".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ttl") {
body.insert("ttl".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mxPriority") {
body.insert("mxPriority".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("comment") {
body.insert("comment".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("PATCH /v1/domains/records/{{recordId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a list of all Drains
///
/// Method: GET /v1/drains
#[actor(
VercelReadDrainsActor,
inports::<100>(projectId, includeMetadata, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_drains(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/drains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("includeMetadata") {
query_pairs.push(("includeMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/drains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a new Drain
///
/// Method: POST /v1/drains
#[actor(
VercelCreateDrainActor,
inports::<100>(teamId, slug, filter, source, name, projects, sampling, delivery, schemas, projectIds, transforms),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_drain(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/drains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("filter") {
body.insert("filter".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projects") {
body.insert("projects".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sampling") {
body.insert("sampling".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("delivery") {
body.insert("delivery".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("schemas") {
body.insert("schemas".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projectIds") {
body.insert("projectIds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transforms") {
body.insert("transforms".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/drains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Validate Drain delivery configuration
///
/// Method: POST /v1/drains/test
#[actor(
VercelCreateDrainsActor,
inports::<100>(teamId, slug, delivery, schemas),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_drains(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/drains/test".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("delivery") {
body.insert("delivery".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("schemas") {
body.insert("schemas".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/drains/test failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a drain
///
/// Method: DELETE /v1/drains/{id}
#[actor(
VercelDeleteDrainActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_drain(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/drains/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/drains/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update an existing Drain
///
/// Method: PATCH /v1/drains/{id}
#[actor(
VercelUpdateDrainActor,
inports::<100>(id, teamId, slug, name, projects, status, transforms, delivery, projectIds, source, sampling, filter, schemas),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_drain(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/drains/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projects") {
body.insert("projects".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("status") {
body.insert("status".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transforms") {
body.insert("transforms".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("delivery") {
body.insert("delivery".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projectIds") {
body.insert("projectIds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sampling") {
body.insert("sampling".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("filter") {
body.insert("filter".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("schemas") {
body.insert("schemas".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("PATCH /v1/drains/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Find a Drain by id
///
/// Method: GET /v1/drains/{id}
#[actor(
VercelReadDrainActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_drain(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/drains/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/drains/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Dangerously delete by source image
///
/// Method: POST /v1/edge-cache/dangerously-delete-by-src-images
#[actor(
VercelCreateEdgeCacheActor,
inports::<100>(projectIdOrName, teamId, slug, srcImages, revalidationDeadlineSeconds),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_edge_cache(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/edge-cache/dangerously-delete-by-src-images".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectIdOrName") {
query_pairs.push(("projectIdOrName", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("srcImages") {
body.insert("srcImages".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("revalidationDeadlineSeconds") {
body.insert(
"revalidationDeadlineSeconds".to_string(),
val.clone().into(),
);
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/edge-cache/dangerously-delete-by-src-images failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create an Edge Config
///
/// Method: POST /v1/edge-config
#[actor(
VercelCreateEdgeConfigActor,
inports::<100>(teamId, slug, items),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_edge_config(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/edge-config".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("slug") {
body.insert("slug".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("items") {
body.insert("items".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/edge-config failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get Edge Configs
///
/// Method: GET /v1/edge-config
#[actor(
VercelReadEdgeConfigsActor,
inports::<100>(teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_edge_configs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/edge-config".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/edge-config failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get an Edge Config
///
/// Method: GET /v1/edge-config/{edgeConfigId}
#[actor(
VercelReadEdgeConfigActor,
inports::<100>(edgeConfigId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_edge_config(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/edge-config/{{edgeConfigId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update an Edge Config
///
/// Method: PUT /v1/edge-config/{edgeConfigId}
#[actor(
VercelUpdateEdgeConfigActor,
inports::<100>(edgeConfigId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_edge_config(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.put(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("slug") {
body.insert("slug".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("PUT /v1/edge-config/{{edgeConfigId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete an Edge Config
///
/// Method: DELETE /v1/edge-config/{edgeConfigId}
#[actor(
VercelDeleteEdgeConfigActor,
inports::<100>(edgeConfigId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_edge_config(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/edge-config/{{edgeConfigId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Get Edge Config backups
///
/// Method: GET /v1/edge-config/{edgeConfigId}/backups
#[actor(
VercelReadEdgeConfigBackupsActor,
inports::<100>(edgeConfigId, next, limit, metadata, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_edge_config_backups(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}/backups".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("next") {
query_pairs.push(("next", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("metadata") {
query_pairs.push(("metadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/edge-config/{{edgeConfigId}}/backups failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Get Edge Config backup
///
/// Method: GET /v1/edge-config/{edgeConfigId}/backups/{edgeConfigBackupVersionId}
#[actor(
VercelReadEdgeConfigBackupActor,
inports::<100>(edgeConfigId, edgeConfigBackupVersionId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_edge_config_backup(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/edge-config/{edgeConfigId}/backups/{edgeConfigBackupVersionId}".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("edgeConfigBackupVersionId") {
endpoint = endpoint.replace("{{edgeConfigBackupVersionId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/edge-config/{{edgeConfigId}}/backups/{{edgeConfigBackupVersionId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Get an Edge Config item
///
/// Method: GET /v1/edge-config/{edgeConfigId}/item/{edgeConfigItemKey}
#[actor(
VercelReadEdgeConfigItemActor,
inports::<100>(edgeConfigId, edgeConfigItemKey, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_edge_config_item(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}/item/{edgeConfigItemKey}".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("edgeConfigItemKey") {
endpoint = endpoint.replace("{{edgeConfigItemKey}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/edge-config/{{edgeConfigId}}/item/{{edgeConfigItemKey}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Get Edge Config items
///
/// Method: GET /v1/edge-config/{edgeConfigId}/items
#[actor(
VercelReadEdgeConfigItemsActor,
inports::<100>(edgeConfigId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_edge_config_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}/items".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/edge-config/{{edgeConfigId}}/items failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update Edge Config items in batch
///
/// Method: PATCH /v1/edge-config/{edgeConfigId}/items
#[actor(
VercelUpdateEdgeConfigItemsActor,
inports::<100>(edgeConfigId, teamId, slug, items),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_edge_config_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}/items".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("items") {
body.insert("items".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("PATCH /v1/edge-config/{{edgeConfigId}}/items failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete an Edge Config's schema
///
/// Method: DELETE /v1/edge-config/{edgeConfigId}/schema
#[actor(
VercelDeleteEdgeConfigSchemaActor,
inports::<100>(edgeConfigId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_edge_config_schema(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}/schema".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/edge-config/{{edgeConfigId}}/schema failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get Edge Config schema
///
/// Method: GET /v1/edge-config/{edgeConfigId}/schema
#[actor(
VercelReadEdgeConfigSchemaActor,
inports::<100>(edgeConfigId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_edge_config_schema(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}/schema".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/edge-config/{{edgeConfigId}}/schema failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update Edge Config schema
///
/// Method: POST /v1/edge-config/{edgeConfigId}/schema
#[actor(
VercelUpdateEdgeConfigSchemaActor,
inports::<100>(edgeConfigId, dryRun, teamId, slug, definition),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_edge_config_schema(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}/schema".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("dryRun") {
query_pairs.push(("dryRun", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("definition") {
body.insert("definition".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/edge-config/{{edgeConfigId}}/schema failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create an Edge Config token
///
/// Method: POST /v1/edge-config/{edgeConfigId}/token
#[actor(
VercelCreateEdgeConfigTokenActor,
inports::<100>(edgeConfigId, teamId, slug, label),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_edge_config_token(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}/token".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("label") {
body.insert("label".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/edge-config/{{edgeConfigId}}/token failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Get Edge Config token meta data
///
/// Method: GET /v1/edge-config/{edgeConfigId}/token/{token}
#[actor(
VercelReadEdgeConfigTokenActor,
inports::<100>(edgeConfigId, token, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_edge_config_token(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}/token/{token}".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("token") {
endpoint = endpoint.replace("{{token}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/edge-config/{{edgeConfigId}}/token/{{token}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get all tokens of an Edge Config
///
/// Method: GET /v1/edge-config/{edgeConfigId}/tokens
#[actor(
VercelReadEdgeConfigTokensActor,
inports::<100>(edgeConfigId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_edge_config_tokens(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}/tokens".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/edge-config/{{edgeConfigId}}/tokens failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete one or more Edge Config tokens
///
/// Method: DELETE /v1/edge-config/{edgeConfigId}/tokens
#[actor(
VercelDeleteEdgeConfigTokensActor,
inports::<100>(edgeConfigId, teamId, slug, tokens),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_edge_config_tokens(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/edge-config/{edgeConfigId}/tokens".to_string();
if let Some(val) = inputs.get("edgeConfigId") {
endpoint = endpoint.replace("{{edgeConfigId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/edge-config/{{edgeConfigId}}/tokens failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Lists all Shared Environment Variables for a team
///
/// Method: GET /v1/env
#[actor(
VercelListSharedEnvVariableActor,
inports::<100>(search, projectId, ids, exclude_ids, exclude_projectId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_shared_env_variable(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/env".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("search") {
query_pairs.push(("search", super::message_to_str(val)));
}
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ids") {
query_pairs.push(("ids", super::message_to_str(val)));
}
if let Some(val) = inputs.get("exclude_ids") {
query_pairs.push(("exclude_ids", super::message_to_str(val)));
}
if let Some(val) = inputs.get("exclude_ids") {
query_pairs.push(("exclude-ids", super::message_to_str(val)));
}
if let Some(val) = inputs.get("exclude_projectId") {
query_pairs.push(("exclude_projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("exclude_projectId") {
query_pairs.push(("exclude-projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/env failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete one or more Env Var
///
/// Method: DELETE /v1/env
#[actor(
VercelDeleteSharedEnvVariableActor,
inports::<100>(teamId, slug, ids),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_shared_env_variable(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/env".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/env failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create one or more shared environment variables
///
/// Method: POST /v1/env
#[actor(
VercelCreateSharedEnvVariableActor,
inports::<100>(teamId, slug, evs, target, projectId, type_),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_shared_env_variable(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/env".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("evs") {
body.insert("evs".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("target") {
body.insert("target".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projectId") {
body.insert("projectId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/env failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Updates one or more shared environment variables
///
/// Method: PATCH /v1/env
#[actor(
VercelUpdateSharedEnvVariableActor,
inports::<100>(teamId, slug, updates),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_shared_env_variable(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/env".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("updates") {
body.insert("updates".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("PATCH /v1/env failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve the decrypted value of a Shared Environment Variable by id.
///
/// Method: GET /v1/env/{id}
#[actor(
VercelReadSharedEnvVarActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_shared_env_var(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/env/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/env/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Disconnects a shared environment variable for a given project
///
/// Method: PATCH /v1/env/{id}/unlink/{projectId}
#[actor(
VercelUpdateEnvironmentActor,
inports::<100>(id, projectId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_environment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/env/{id}/unlink/{projectId}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("PATCH /v1/env/{{id}}/unlink/{{projectId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List Event Types
///
/// Method: GET /v1/events/types
#[actor(
VercelListEventTypesActor,
inports::<100>(teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_event_types(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/events/types".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/events/types failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update Installation
///
/// Method: PATCH /v1/installations/{integrationConfigurationId}
#[actor(
VercelUpdateInstallationActor,
inports::<100>(integrationConfigurationId, status, externalId, notification, billingPlan),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_installation(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/installations/{integrationConfigurationId}".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("status") {
body.insert("status".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("externalId") {
body.insert("externalId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("notification") {
body.insert("notification".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billingPlan") {
body.insert("billingPlan".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PATCH /v1/installations/{{integrationConfigurationId}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get Account Information
///
/// Method: GET /v1/installations/{integrationConfigurationId}/account
#[actor(
VercelReadAccountInfoActor,
inports::<100>(integrationConfigurationId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_account_info(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/installations/{integrationConfigurationId}/account".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/installations/{{integrationConfigurationId}}/account failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Submit Billing Data
///
/// Method: POST /v1/installations/{integrationConfigurationId}/billing
#[actor(
VercelCreateMarketplaceActor,
inports::<100>(integrationConfigurationId, timestamp, billing, usage, period, eod),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_marketplace(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/installations/{integrationConfigurationId}/billing".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("timestamp") {
body.insert("timestamp".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing") {
body.insert("billing".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("usage") {
body.insert("usage".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("period") {
body.insert("period".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("eod") {
body.insert("eod".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/installations/{{integrationConfigurationId}}/billing failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get Invoice
///
/// Method: GET /v1/installations/{integrationConfigurationId}/billing/invoices/{invoiceId}
#[actor(
VercelReadInvoiceActor,
inports::<100>(integrationConfigurationId, invoiceId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_invoice(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/installations/{integrationConfigurationId}/billing/invoices/{invoiceId}".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("invoiceId") {
endpoint = endpoint.replace("{{invoiceId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/installations/{{integrationConfigurationId}}/billing/invoices/{{invoiceId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Invoice Actions
///
/// Method: POST /v1/installations/{integrationConfigurationId}/billing/invoices/{invoiceId}/actions
#[actor(
VercelUpdateInvoiceActor,
inports::<100>(integrationConfigurationId, invoiceId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_invoice(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/installations/{integrationConfigurationId}/billing/invoices/{invoiceId}/actions"
.to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("invoiceId") {
endpoint = endpoint.replace("{{invoiceId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/installations/{{integrationConfigurationId}}/billing/invoices/{{invoiceId}}/actions failed: {}", e).into()));
}
}
Ok(output)
}
/// Create Event
///
/// Method: POST /v1/installations/{integrationConfigurationId}/events
#[actor(
VercelCreateEventActor,
inports::<100>(integrationConfigurationId, event),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_event(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/installations/{integrationConfigurationId}/events".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("event") {
body.insert("event".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/installations/{{integrationConfigurationId}}/events failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get Member Information
///
/// Method: GET /v1/installations/{integrationConfigurationId}/member/{memberId}
#[actor(
VercelReadMemberActor,
inports::<100>(integrationConfigurationId, memberId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_member(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/installations/{integrationConfigurationId}/member/{memberId}".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("memberId") {
endpoint = endpoint.replace("{{memberId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/installations/{{integrationConfigurationId}}/member/{{memberId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Get Integration Resources
///
/// Method: GET /v1/installations/{integrationConfigurationId}/resources
#[actor(
VercelReadIntegrationResourcesActor,
inports::<100>(integrationConfigurationId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_integration_resources(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/installations/{integrationConfigurationId}/resources".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/installations/{{integrationConfigurationId}}/resources failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get Integration Resource
///
/// Method: GET /v1/installations/{integrationConfigurationId}/resources/{resourceId}
#[actor(
VercelReadIntegrationResourceActor,
inports::<100>(integrationConfigurationId, resourceId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_integration_resource(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/installations/{integrationConfigurationId}/resources/{resourceId}".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/installations/{{integrationConfigurationId}}/resources/{{resourceId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Import Resource
///
/// Method: PUT /v1/installations/{integrationConfigurationId}/resources/{resourceId}
#[actor(
VercelUpdateMarketplaceActor,
inports::<100>(integrationConfigurationId, resourceId, billingPlan, name, productId, extras, secrets, status, notification, metadata, ownership),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_marketplace(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/installations/{integrationConfigurationId}/resources/{resourceId}".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.put(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("billingPlan") {
body.insert("billingPlan".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("productId") {
body.insert("productId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("extras") {
body.insert("extras".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("secrets") {
body.insert("secrets".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("status") {
body.insert("status".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("notification") {
body.insert("notification".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ownership") {
body.insert("ownership".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("PUT /v1/installations/{{integrationConfigurationId}}/resources/{{resourceId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Update Resource
///
/// Method: PATCH /v1/installations/{integrationConfigurationId}/resources/{resourceId}
#[actor(
VercelUpdateResourceActor,
inports::<100>(integrationConfigurationId, resourceId, name, metadata, billingPlan, status, extras, secrets, ownership, notification),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_resource(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/installations/{integrationConfigurationId}/resources/{resourceId}".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billingPlan") {
body.insert("billingPlan".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("status") {
body.insert("status".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("extras") {
body.insert("extras".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("secrets") {
body.insert("secrets".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ownership") {
body.insert("ownership".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("notification") {
body.insert("notification".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("PATCH /v1/installations/{{integrationConfigurationId}}/resources/{{resourceId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Delete Integration Resource
///
/// Method: DELETE /v1/installations/{integrationConfigurationId}/resources/{resourceId}
#[actor(
VercelDeleteIntegrationResourceActor,
inports::<100>(integrationConfigurationId, resourceId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_integration_resource(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/installations/{integrationConfigurationId}/resources/{resourceId}".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("DELETE /v1/installations/{{integrationConfigurationId}}/resources/{{resourceId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Get the data of a user-provided Edge Config
///
/// Method: HEAD /v1/installations/{integrationConfigurationId}/resources/{resourceId}/experimentation/edge-config
#[actor(
VercelReadMarketplaceActor,
inports::<100>(integrationConfigurationId, resourceId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_marketplace(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/installations/{integrationConfigurationId}/resources/{resourceId}/experimentation/edge-config".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.head(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("HEAD /v1/installations/{{integrationConfigurationId}}/resources/{{resourceId}}/experimentation/edge-config failed: {}", e).into()));
}
}
Ok(output)
}
/// Get the data of a user-provided Edge Config
///
/// Method: GET /v1/installations/{integrationConfigurationId}/resources/{resourceId}/experimentation/edge-config
#[actor(
VercelReadInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationEdgeConfigActor,
inports::<100>(integrationConfigurationId, resourceId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_installations_by_integration_configuration_id_resources_by_resource_id_experimentation_edge_config(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/installations/{integrationConfigurationId}/resources/{resourceId}/experimentation/edge-config".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/installations/{{integrationConfigurationId}}/resources/{{resourceId}}/experimentation/edge-config failed: {}", e).into()));
}
}
Ok(output)
}
/// Create one or multiple experimentation items
///
/// Method: POST /v1/installations/{integrationConfigurationId}/resources/{resourceId}/experimentation/items
#[actor(
VercelCreateInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationItemsActor,
inports::<100>(integrationConfigurationId, resourceId, items),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_installations_by_integration_configuration_id_resources_by_resource_id_experimentation_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/installations/{integrationConfigurationId}/resources/{resourceId}/experimentation/items".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("items") {
body.insert("items".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/installations/{{integrationConfigurationId}}/resources/{{resourceId}}/experimentation/items failed: {}", e).into()));
}
}
Ok(output)
}
/// Patch an existing experimentation item
///
/// Method: PATCH /v1/installations/{integrationConfigurationId}/resources/{resourceId}/experimentation/items/{itemId}
#[actor(
VercelUpdateInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationItemsByItemIdActor,
inports::<100>(integrationConfigurationId, resourceId, itemId, slug, description, name, category, origin, updatedAt, createdAt, isArchived),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_installations_by_integration_configuration_id_resources_by_resource_id_experimentation_items_by_item_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/installations/{integrationConfigurationId}/resources/{resourceId}/experimentation/items/{itemId}".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("itemId") {
endpoint = endpoint.replace("{{itemId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("slug") {
body.insert("slug".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("category") {
body.insert("category".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("origin") {
body.insert("origin".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("updatedAt") {
body.insert("updatedAt".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("createdAt") {
body.insert("createdAt".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("isArchived") {
body.insert("isArchived".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("PATCH /v1/installations/{{integrationConfigurationId}}/resources/{{resourceId}}/experimentation/items/{{itemId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Delete an existing experimentation item
///
/// Method: DELETE /v1/installations/{integrationConfigurationId}/resources/{resourceId}/experimentation/items/{itemId}
#[actor(
VercelDeleteInstallationsByIntegrationConfigurationIdResourcesByResourceIdExperimentationItemsByItemIdActor,
inports::<100>(integrationConfigurationId, resourceId, itemId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_installations_by_integration_configuration_id_resources_by_resource_id_experimentation_items_by_item_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/installations/{integrationConfigurationId}/resources/{resourceId}/experimentation/items/{itemId}".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("itemId") {
endpoint = endpoint.replace("{{itemId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("DELETE /v1/installations/{{integrationConfigurationId}}/resources/{{resourceId}}/experimentation/items/{{itemId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Update Resource Secrets
///
/// Method: PUT /v1/installations/{integrationConfigurationId}/resources/{resourceId}/secrets
#[actor(
VercelUpdateResourceSecretsByIdActor,
inports::<100>(integrationConfigurationId, resourceId, partial, secrets),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_resource_secrets_by_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/installations/{integrationConfigurationId}/resources/{resourceId}/secrets".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.put(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("partial") {
body.insert("partial".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("secrets") {
body.insert("secrets".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("PUT /v1/installations/{{integrationConfigurationId}}/resources/{{resourceId}}/secrets failed: {}", e).into()));
}
}
Ok(output)
}
/// Retrieve an integration configuration
///
/// Method: GET /v1/integrations/configuration/{id}
#[actor(
VercelReadConfigurationActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_configuration(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/integrations/configuration/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/integrations/configuration/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete an integration configuration
///
/// Method: DELETE /v1/integrations/configuration/{id}
#[actor(
VercelDeleteConfigurationActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_configuration(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/integrations/configuration/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/integrations/configuration/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List products for integration configuration
///
/// Method: GET /v1/integrations/configuration/{id}/products
#[actor(
VercelReadConfigurationProductsActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_configuration_products(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/integrations/configuration/{id}/products".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/integrations/configuration/{{id}}/products failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get configurations for the authenticated user or team
///
/// Method: GET /v1/integrations/configurations
#[actor(
VercelReadConfigurationsActor,
inports::<100>(view, installationType, integrationIdOrSlug, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_configurations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/integrations/configurations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("view") {
query_pairs.push(("view", super::message_to_str(val)));
}
if let Some(val) = inputs.get("installationType") {
query_pairs.push(("installationType", super::message_to_str(val)));
}
if let Some(val) = inputs.get("integrationIdOrSlug") {
query_pairs.push(("integrationIdOrSlug", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/integrations/configurations failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List git namespaces by provider
///
/// Method: GET /v1/integrations/git-namespaces
#[actor(
VercelListIntegrationsActor,
inports::<100>(host, provider),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_integrations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/integrations/git-namespaces".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("host") {
query_pairs.push(("host", super::message_to_str(val)));
}
if let Some(val) = inputs.get("provider") {
query_pairs.push(("provider", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/integrations/git-namespaces failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Connect integration resource to project
///
/// Method: POST /v1/integrations/installations/{integrationConfigurationId}/resources/{resourceId}/connections
#[actor(
VercelCreateIntegrationsActor,
inports::<100>(integrationConfigurationId, resourceId, teamId, slug, projectId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_integrations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/integrations/installations/{integrationConfigurationId}/resources/{resourceId}/connections".to_string();
if let Some(val) = inputs.get("integrationConfigurationId") {
endpoint = endpoint.replace(
"{{integrationConfigurationId}}",
&super::message_to_str(val),
);
}
if let Some(val) = inputs.get("resourceId") {
endpoint = endpoint.replace("{{resourceId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("projectId") {
body.insert("projectId".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/integrations/installations/{{integrationConfigurationId}}/resources/{{resourceId}}/connections failed: {}", e).into()));
}
}
Ok(output)
}
/// List integration billing plans
///
/// Method: GET /v1/integrations/integration/{integrationIdOrSlug}/products/{productIdOrSlug}/plans
#[actor(
VercelReadBillingPlansActor,
inports::<100>(integrationIdOrSlug, integrationConfigurationId, productIdOrSlug, metadata, source, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_billing_plans(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/integrations/integration/{integrationIdOrSlug}/products/{productIdOrSlug}/plans"
.to_string();
if let Some(val) = inputs.get("integrationIdOrSlug") {
endpoint = endpoint.replace("{{integrationIdOrSlug}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("productIdOrSlug") {
endpoint = endpoint.replace("{{productIdOrSlug}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("integrationConfigurationId") {
query_pairs.push(("integrationConfigurationId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("metadata") {
query_pairs.push(("metadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("source") {
query_pairs.push(("source", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/integrations/integration/{{integrationIdOrSlug}}/products/{{productIdOrSlug}}/plans failed: {}", e).into()));
}
}
Ok(output)
}
/// Deletes the Integration log drain with the provided `id` (deprecated)
///
/// Method: DELETE /v1/integrations/log-drains/{id}
#[actor(
VercelDeleteIntegrationLogDrainActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_integration_log_drain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/integrations/log-drains/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/integrations/log-drains/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List git repositories linked to namespace by provider
///
/// Method: GET /v1/integrations/search-repo
#[actor(
VercelSearchRepoActor,
inports::<100>(query, namespaceId, provider, installationId, host, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_search_repo(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/integrations/search-repo".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("query") {
query_pairs.push(("query", super::message_to_str(val)));
}
if let Some(val) = inputs.get("namespaceId") {
query_pairs.push(("namespaceId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("provider") {
query_pairs.push(("provider", super::message_to_str(val)));
}
if let Some(val) = inputs.get("installationId") {
query_pairs.push(("installationId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("host") {
query_pairs.push(("host", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/integrations/search-repo failed: {}", e).into()),
);
}
}
Ok(output)
}
/// SSO Token Exchange
///
/// Method: POST /v1/integrations/sso/token
#[actor(
VercelCreateAuthenticationActor,
inports::<100>(trigger),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_authentication(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/integrations/sso/token".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/integrations/sso/token failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Creates a Configurable Log Drain (deprecated)
///
/// Method: POST /v1/log-drains
#[actor(
VercelCreateConfigurableLogDrainActor,
inports::<100>(teamId, slug, sources, headers, secret, url, samplingRate, deliveryFormat, environments, projectIds, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_configurable_log_drain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/log-drains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("sources") {
body.insert("sources".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("headers") {
body.insert("headers".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("secret") {
body.insert("secret".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("url") {
body.insert("url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("samplingRate") {
body.insert("samplingRate".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("deliveryFormat") {
body.insert("deliveryFormat".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("environments") {
body.insert("environments".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projectIds") {
body.insert("projectIds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/log-drains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieves a list of all the Log Drains (deprecated)
///
/// Method: GET /v1/log-drains
#[actor(
VercelReadAllLogDrainsActor,
inports::<100>(projectId, projectIdOrName, includeMetadata, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_all_log_drains(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/log-drains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("projectIdOrName") {
query_pairs.push(("projectIdOrName", super::message_to_str(val)));
}
if let Some(val) = inputs.get("includeMetadata") {
query_pairs.push(("includeMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/log-drains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Deletes a Configurable Log Drain (deprecated)
///
/// Method: DELETE /v1/log-drains/{id}
#[actor(
VercelDeleteConfigurableLogDrainActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_configurable_log_drain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/log-drains/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/log-drains/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieves a Configurable Log Drain (deprecated)
///
/// Method: GET /v1/log-drains/{id}
#[actor(
VercelReadConfigurableLogDrainActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_configurable_log_drain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/log-drains/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/log-drains/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Move a project domain
///
/// Method: POST /v1/projects/{idOrName}/domains/{domain}/move
#[actor(
VercelMoveProjectsActor,
inports::<100>(idOrName, domain, teamId, slug, redirectStatusCode, projectId, redirect, gitBranch),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_move_projects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/domains/{domain}/move".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("redirectStatusCode") {
body.insert("redirectStatusCode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projectId") {
body.insert("projectId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("redirect") {
body.insert("redirect".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("gitBranch") {
body.insert("gitBranch".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/projects/{{idOrName}}/domains/{{domain}}/move failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Batch remove environment variables
///
/// Method: DELETE /v1/projects/{idOrName}/env
#[actor(
VercelDeleteProjectsActor,
inports::<100>(idOrName, teamId, slug, ids),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_projects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/env".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/projects/{{idOrName}}/env failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve the decrypted value of an environment variable of a project by id
///
/// Method: GET /v1/projects/{idOrName}/env/{id}
#[actor(
VercelReadProjectEnvActor,
inports::<100>(idOrName, id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_project_env(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/env/{id}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/projects/{{idOrName}}/env/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List project members
///
/// Method: GET /v1/projects/{idOrName}/members
#[actor(
VercelReadProjectMembersActor,
inports::<100>(idOrName, limit, since, until, search, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_project_members(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/members".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("search") {
query_pairs.push(("search", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/projects/{{idOrName}}/members failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Adds a new member to a project.
///
/// Method: POST /v1/projects/{idOrName}/members
#[actor(
VercelCreateProjectMembersActor,
inports::<100>(idOrName, teamId, slug, email, role, uid, username),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_project_members(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/members".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("role") {
body.insert("role".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("uid") {
body.insert("uid".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("username") {
body.insert("username".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/projects/{{idOrName}}/members failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Remove a Project Member
///
/// Method: DELETE /v1/projects/{idOrName}/members/{uid}
#[actor(
VercelDeleteProjectMemberActor,
inports::<100>(idOrName, uid, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_project_member(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/members/{uid}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("uid") {
endpoint = endpoint.replace("{{uid}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/projects/{{idOrName}}/members/{{uid}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update Protection Bypass for Automation
///
/// Method: PATCH /v1/projects/{idOrName}/protection-bypass
#[actor(
VercelUpdateProjectProtectionBypassActor,
inports::<100>(idOrName, teamId, slug, update, generate, revoke),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_project_protection_bypass(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/protection-bypass".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("update") {
body.insert("update".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("generate") {
body.insert("generate".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("revoke") {
body.insert("revoke".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PATCH /v1/projects/{{idOrName}}/protection-bypass failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get the active rolling release information for a project
///
/// Method: GET /v1/projects/{idOrName}/rolling-release
#[actor(
VercelReadRollingReleaseActor,
inports::<100>(idOrName, state, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_rolling_release(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/rolling-release".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("state") {
query_pairs.push(("state", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/projects/{{idOrName}}/rolling-release failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update the active rolling release to the next stage for a project
///
/// Method: POST /v1/projects/{idOrName}/rolling-release/approve-stage
#[actor(
VercelCreateRollingReleaseActor,
inports::<100>(idOrName, teamId, slug, nextStageIndex, canaryDeploymentId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_rolling_release(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/rolling-release/approve-stage".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("nextStageIndex") {
body.insert("nextStageIndex".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("canaryDeploymentId") {
body.insert("canaryDeploymentId".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/projects/{{idOrName}}/rolling-release/approve-stage failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get rolling release billing status
///
/// Method: GET /v1/projects/{idOrName}/rolling-release/billing
#[actor(
VercelReadRollingReleaseBillingStatusActor,
inports::<100>(idOrName, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_rolling_release_billing_status(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/rolling-release/billing".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/projects/{{idOrName}}/rolling-release/billing failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get rolling release configuration
///
/// Method: GET /v1/projects/{idOrName}/rolling-release/config
#[actor(
VercelReadRollingReleaseConfigActor,
inports::<100>(idOrName, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_rolling_release_config(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/rolling-release/config".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/projects/{{idOrName}}/rolling-release/config failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Delete rolling release configuration
///
/// Method: DELETE /v1/projects/{idOrName}/rolling-release/config
#[actor(
VercelDeleteRollingReleaseConfigActor,
inports::<100>(idOrName, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_rolling_release_config(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/rolling-release/config".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/projects/{{idOrName}}/rolling-release/config failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update the rolling release settings for the project
///
/// Method: PATCH /v1/projects/{idOrName}/rolling-release/config
#[actor(
VercelUpdateRollingReleaseConfigActor,
inports::<100>(idOrName, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_rolling_release_config(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/rolling-release/config".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PATCH /v1/projects/{{idOrName}}/rolling-release/config failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Configures Static IPs for a project
///
/// Method: PATCH /v1/projects/{idOrName}/shared-connect-links
#[actor(
VercelUpdateStaticIpsActor,
inports::<100>(idOrName, teamId, slug, builds, regions),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_static_ips(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{idOrName}/shared-connect-links".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("builds") {
body.insert("builds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("regions") {
body.insert("regions".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PATCH /v1/projects/{{idOrName}}/shared-connect-links failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a flag
///
/// Method: PUT /v1/projects/{projectIdOrName}/feature-flags/flags
#[actor(
VercelCreateFlagActor,
inports::<100>(projectIdOrName, teamId, slug, variants, kind, description, environments, seed, state),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_flag(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectIdOrName}/feature-flags/flags".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.put(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("variants") {
body.insert("variants".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("kind") {
body.insert("kind".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("environments") {
body.insert("environments".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("seed") {
body.insert("seed".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("slug") {
body.insert("slug".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("state") {
body.insert("state".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PUT /v1/projects/{{projectIdOrName}}/feature-flags/flags failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List flags
///
/// Method: GET /v1/projects/{projectIdOrName}/feature-flags/flags
#[actor(
VercelListFlagsActor,
inports::<100>(projectIdOrName, state, withMetadata, limit, cursor, search, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_flags(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectIdOrName}/feature-flags/flags".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("state") {
query_pairs.push(("state", super::message_to_str(val)));
}
if let Some(val) = inputs.get("withMetadata") {
query_pairs.push(("withMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("cursor") {
query_pairs.push(("cursor", super::message_to_str(val)));
}
if let Some(val) = inputs.get("search") {
query_pairs.push(("search", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/projects/{{projectIdOrName}}/feature-flags/flags failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a flag
///
/// Method: PATCH /v1/projects/{projectIdOrName}/feature-flags/flags/{flagIdOrSlug}
#[actor(
VercelUpdateFlagActor,
inports::<100>(projectIdOrName, flagIdOrSlug, ifMatch, withMetadata, teamId, slug, description, variants, message, environments, seed, createdBy, state),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_flag(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/projects/{projectIdOrName}/feature-flags/flags/{flagIdOrSlug}".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("flagIdOrSlug") {
endpoint = endpoint.replace("{{flagIdOrSlug}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ifMatch") {
query_pairs.push(("ifMatch", super::message_to_str(val)));
}
if let Some(val) = inputs.get("withMetadata") {
query_pairs.push(("withMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("variants") {
body.insert("variants".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("message") {
body.insert("message".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("environments") {
body.insert("environments".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("seed") {
body.insert("seed".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("createdBy") {
body.insert("createdBy".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("state") {
body.insert("state".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("PATCH /v1/projects/{{projectIdOrName}}/feature-flags/flags/{{flagIdOrSlug}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Get a flag
///
/// Method: GET /v1/projects/{projectIdOrName}/feature-flags/flags/{flagIdOrSlug}
#[actor(
VercelReadFlagActor,
inports::<100>(projectIdOrName, flagIdOrSlug, ifMatch, withMetadata, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_flag(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/projects/{projectIdOrName}/feature-flags/flags/{flagIdOrSlug}".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("flagIdOrSlug") {
endpoint = endpoint.replace("{{flagIdOrSlug}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ifMatch") {
query_pairs.push(("ifMatch", super::message_to_str(val)));
}
if let Some(val) = inputs.get("withMetadata") {
query_pairs.push(("withMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/projects/{{projectIdOrName}}/feature-flags/flags/{{flagIdOrSlug}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Delete a flag
///
/// Method: DELETE /v1/projects/{projectIdOrName}/feature-flags/flags/{flagIdOrSlug}
#[actor(
VercelDeleteFlagActor,
inports::<100>(projectIdOrName, flagIdOrSlug, ifMatch, withMetadata, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_flag(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/projects/{projectIdOrName}/feature-flags/flags/{flagIdOrSlug}".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("flagIdOrSlug") {
endpoint = endpoint.replace("{{flagIdOrSlug}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ifMatch") {
query_pairs.push(("ifMatch", super::message_to_str(val)));
}
if let Some(val) = inputs.get("withMetadata") {
query_pairs.push(("withMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("DELETE /v1/projects/{{projectIdOrName}}/feature-flags/flags/{{flagIdOrSlug}} failed: {}", e).into()));
}
}
Ok(output)
}
/// List flag versions
///
/// Method: GET /v1/projects/{projectIdOrName}/feature-flags/flags/{flagIdOrSlug}/versions
#[actor(
VercelListFlagVersionsActor,
inports::<100>(projectIdOrName, flagIdOrSlug, limit, cursor, environment, withMetadata, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_flag_versions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/projects/{projectIdOrName}/feature-flags/flags/{flagIdOrSlug}/versions".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("flagIdOrSlug") {
endpoint = endpoint.replace("{{flagIdOrSlug}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("cursor") {
query_pairs.push(("cursor", super::message_to_str(val)));
}
if let Some(val) = inputs.get("environment") {
query_pairs.push(("environment", super::message_to_str(val)));
}
if let Some(val) = inputs.get("withMetadata") {
query_pairs.push(("withMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/projects/{{projectIdOrName}}/feature-flags/flags/{{flagIdOrSlug}}/versions failed: {}", e).into()));
}
}
Ok(output)
}
/// Create an SDK key
///
/// Method: PUT /v1/projects/{projectIdOrName}/feature-flags/sdk-keys
#[actor(
VercelCreateSdkKeyActor,
inports::<100>(projectIdOrName, teamId, slug, label, environment, sdkKeyType),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_sdk_key(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectIdOrName}/feature-flags/sdk-keys".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.put(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("label") {
body.insert("label".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("environment") {
body.insert("environment".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sdkKeyType") {
body.insert("sdkKeyType".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PUT /v1/projects/{{projectIdOrName}}/feature-flags/sdk-keys failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get all SDK keys
///
/// Method: GET /v1/projects/{projectIdOrName}/feature-flags/sdk-keys
#[actor(
VercelReadSdkKeysActor,
inports::<100>(projectIdOrName, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_sdk_keys(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectIdOrName}/feature-flags/sdk-keys".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/projects/{{projectIdOrName}}/feature-flags/sdk-keys failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Delete an SDK key
///
/// Method: DELETE /v1/projects/{projectIdOrName}/feature-flags/sdk-keys/{hashKey}
#[actor(
VercelDeleteSdkKeyActor,
inports::<100>(projectIdOrName, hashKey, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_sdk_key(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/projects/{projectIdOrName}/feature-flags/sdk-keys/{hashKey}".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("hashKey") {
endpoint = endpoint.replace("{{hashKey}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("DELETE /v1/projects/{{projectIdOrName}}/feature-flags/sdk-keys/{{hashKey}} failed: {}", e).into()));
}
}
Ok(output)
}
/// List segments
///
/// Method: GET /v1/projects/{projectIdOrName}/feature-flags/segments
#[actor(
VercelListFlagSegmentsActor,
inports::<100>(projectIdOrName, withMetadata, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_flag_segments(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectIdOrName}/feature-flags/segments".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("withMetadata") {
query_pairs.push(("withMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/projects/{{projectIdOrName}}/feature-flags/segments failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a segment
///
/// Method: PUT /v1/projects/{projectIdOrName}/feature-flags/segments
#[actor(
VercelCreateFlagSegmentActor,
inports::<100>(projectIdOrName, teamId, slug, description, createdBy, label, hint, data),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_flag_segment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectIdOrName}/feature-flags/segments".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.put(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("createdBy") {
body.insert("createdBy".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("slug") {
body.insert("slug".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("label") {
body.insert("label".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("hint") {
body.insert("hint".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("data") {
body.insert("data".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PUT /v1/projects/{{projectIdOrName}}/feature-flags/segments failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a segment
///
/// Method: PATCH /v1/projects/{projectIdOrName}/feature-flags/segments/{segmentIdOrSlug}
#[actor(
VercelUpdateFlagSegmentActor,
inports::<100>(projectIdOrName, segmentIdOrSlug, withMetadata, teamId, slug, label, data, operations, description, hint),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_flag_segment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/projects/{projectIdOrName}/feature-flags/segments/{segmentIdOrSlug}".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("segmentIdOrSlug") {
endpoint = endpoint.replace("{{segmentIdOrSlug}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("withMetadata") {
query_pairs.push(("withMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("label") {
body.insert("label".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("data") {
body.insert("data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("operations") {
body.insert("operations".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("hint") {
body.insert("hint".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("PATCH /v1/projects/{{projectIdOrName}}/feature-flags/segments/{{segmentIdOrSlug}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Delete a segment
///
/// Method: DELETE /v1/projects/{projectIdOrName}/feature-flags/segments/{segmentIdOrSlug}
#[actor(
VercelDeleteFlagSegmentActor,
inports::<100>(projectIdOrName, segmentIdOrSlug, withMetadata, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_flag_segment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/projects/{projectIdOrName}/feature-flags/segments/{segmentIdOrSlug}".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("segmentIdOrSlug") {
endpoint = endpoint.replace("{{segmentIdOrSlug}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("withMetadata") {
query_pairs.push(("withMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("DELETE /v1/projects/{{projectIdOrName}}/feature-flags/segments/{{segmentIdOrSlug}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Get a segment
///
/// Method: GET /v1/projects/{projectIdOrName}/feature-flags/segments/{segmentIdOrSlug}
#[actor(
VercelReadFlagSegmentActor,
inports::<100>(projectIdOrName, segmentIdOrSlug, withMetadata, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_flag_segment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/projects/{projectIdOrName}/feature-flags/segments/{segmentIdOrSlug}".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("segmentIdOrSlug") {
endpoint = endpoint.replace("{{segmentIdOrSlug}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("withMetadata") {
query_pairs.push(("withMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/projects/{{projectIdOrName}}/feature-flags/segments/{{segmentIdOrSlug}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Update project flag settings
///
/// Method: PATCH /v1/projects/{projectIdOrName}/feature-flags/settings
#[actor(
VercelUpdateFlagSettingsActor,
inports::<100>(projectIdOrName, teamId, slug, enabled, environments, entities),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_flag_settings(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectIdOrName}/feature-flags/settings".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("enabled") {
body.insert("enabled".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("environments") {
body.insert("environments".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("entities") {
body.insert("entities".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PATCH /v1/projects/{{projectIdOrName}}/feature-flags/settings failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get project flag settings
///
/// Method: GET /v1/projects/{projectIdOrName}/feature-flags/settings
#[actor(
VercelReadFlagSettingsActor,
inports::<100>(projectIdOrName, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_flag_settings(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectIdOrName}/feature-flags/settings".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/projects/{{projectIdOrName}}/feature-flags/settings failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get logs for a deployment
///
/// Method: GET /v1/projects/{projectId}/deployments/{deploymentId}/runtime-logs
#[actor(
VercelReadRuntimeLogsActor,
inports::<100>(projectId, deploymentId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_runtime_logs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/projects/{projectId}/deployments/{deploymentId}/runtime-logs".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("deploymentId") {
endpoint = endpoint.replace("{{deploymentId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/projects/{{projectId}}/deployments/{{deploymentId}}/runtime-logs failed: {}", e).into()));
}
}
Ok(output)
}
/// Pause a project
///
/// Method: POST /v1/projects/{projectId}/pause
#[actor(
VercelPauseProjectsActor,
inports::<100>(projectId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_pause_projects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectId}/pause".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/projects/{{projectId}}/pause failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Gets a list of aliases with status for the current promote
///
/// Method: GET /v1/projects/{projectId}/promote/aliases
#[actor(
VercelListPromoteAliasesActor,
inports::<100>(projectId, limit, since, until, failedOnly, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_promote_aliases(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectId}/promote/aliases".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("failedOnly") {
query_pairs.push(("failedOnly", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/projects/{{projectId}}/promote/aliases failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Points all production domains for a project to the given deploy
///
/// Method: POST /v1/projects/{projectId}/rollback/{deploymentId}
#[actor(
VercelCreateProjectsActor,
inports::<100>(projectId, deploymentId, description, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_projects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectId}/rollback/{deploymentId}".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("deploymentId") {
endpoint = endpoint.replace("{{deploymentId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("description") {
query_pairs.push(("description", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/projects/{{projectId}}/rollback/{{deploymentId}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Updates the description for a rollback
///
/// Method: PATCH /v1/projects/{projectId}/rollback/{deploymentId}/update-description
#[actor(
VercelUpdateProjectsByProjectIdRollbackByDeploymentIdUpdateDescriptionActor,
inports::<100>(projectId, deploymentId, description),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_projects_by_project_id_rollback_by_deployment_id_update_description(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/projects/{projectId}/rollback/{deploymentId}/update-description".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("deploymentId") {
endpoint = endpoint.replace("{{deploymentId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("PATCH /v1/projects/{{projectId}}/rollback/{{deploymentId}}/update-description failed: {}", e).into()));
}
}
Ok(output)
}
/// Stage routing rules
///
/// Method: PUT /v1/projects/{projectId}/routes
#[actor(
VercelUpdateProjectRoutesActor,
inports::<100>(projectId, teamId, slug, overwrite, routes),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_project_routes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectId}/routes".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.put(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("overwrite") {
body.insert("overwrite".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("routes") {
body.insert("routes".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("PUT /v1/projects/{{projectId}}/routes failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Add a routing rule
///
/// Method: POST /v1/projects/{projectId}/routes
#[actor(
VercelCreateProjectRoutesActor,
inports::<100>(projectId, teamId, slug, position, route),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_project_routes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectId}/routes".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("position") {
body.insert("position".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("route") {
body.insert("route".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/projects/{{projectId}}/routes failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete routing rules
///
/// Method: DELETE /v1/projects/{projectId}/routes
#[actor(
VercelDeleteRoutesActor,
inports::<100>(projectId, teamId, slug, routeIds),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_routes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectId}/routes".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/projects/{{projectId}}/routes failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Get project routing rules
///
/// Method: GET /v1/projects/{projectId}/routes
#[actor(
VercelReadRoutesActor,
inports::<100>(projectId, versionId, q, filter, diff, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_routes(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectId}/routes".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("versionId") {
query_pairs.push(("versionId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("q") {
query_pairs.push(("q", super::message_to_str(val)));
}
if let Some(val) = inputs.get("filter") {
query_pairs.push(("filter", super::message_to_str(val)));
}
if let Some(val) = inputs.get("diff") {
query_pairs.push(("diff", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/projects/{{projectId}}/routes failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Generate a routing rule from natural language
///
/// Method: POST /v1/projects/{projectId}/routes/generate
#[actor(
VercelGenerateRouteActor,
inports::<100>(projectId, teamId, slug, currentRoute, prompt),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_generate_route(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectId}/routes/generate".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("currentRoute") {
body.insert("currentRoute".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("prompt") {
body.insert("prompt".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/projects/{{projectId}}/routes/generate failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Promote, restore, or discard a routing rule version
///
/// Method: POST /v1/projects/{projectId}/routes/versions
#[actor(
VercelUpdateRouteVersionsActor,
inports::<100>(projectId, teamId, slug, action, id),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_route_versions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectId}/routes/versions".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("action") {
body.insert("action".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id") {
body.insert("id".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/projects/{{projectId}}/routes/versions failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get routing rule version history
///
/// Method: GET /v1/projects/{projectId}/routes/versions
#[actor(
VercelReadRouteVersionsActor,
inports::<100>(projectId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_route_versions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/projects/{projectId}/routes/versions".to_string();
if let Some(val) = inputs.get("projectId") {
endpoint = endpoint.replace("{{projectId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/projects/{{projectId}}/routes/versions failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get availability for multiple domains
///
/// Method: POST /v1/registrar/domains/availability
#[actor(
VercelReadBulkAvailabilityActor,
inports::<100>(teamId, domains),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_bulk_availability(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/registrar/domains/availability".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("domains") {
body.insert("domains".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/registrar/domains/availability failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Buy multiple domains
///
/// Method: POST /v1/registrar/domains/buy
#[actor(
VercelCreateDomainsRegistrarActor,
inports::<100>(teamId, contactInformation, domains),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_domains_registrar(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/registrar/domains/buy".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("contactInformation") {
body.insert("contactInformation".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("domains") {
body.insert("domains".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/registrar/domains/buy failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get the auth code for a domain
///
/// Method: GET /v1/registrar/domains/{domain}/auth-code
#[actor(
VercelReadDomainAuthCodeActor,
inports::<100>(domain, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_domain_auth_code(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/registrar/domains/{domain}/auth-code".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/registrar/domains/{{domain}}/auth-code failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update auto-renew for a domain
///
/// Method: PATCH /v1/registrar/domains/{domain}/auto-renew
#[actor(
VercelUpdateDomainAutoRenewActor,
inports::<100>(domain, teamId, autoRenew),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_domain_auto_renew(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/registrar/domains/{domain}/auto-renew".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("autoRenew") {
body.insert("autoRenew".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PATCH /v1/registrar/domains/{{domain}}/auto-renew failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get availability for a domain
///
/// Method: GET /v1/registrar/domains/{domain}/availability
#[actor(
VercelReadDomainAvailabilityActor,
inports::<100>(domain, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_domain_availability(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/registrar/domains/{domain}/availability".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/registrar/domains/{{domain}}/availability failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get contact info schema
///
/// Method: GET /v1/registrar/domains/{domain}/contact-info/schema
#[actor(
VercelReadContactInfoSchemaActor,
inports::<100>(domain, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_contact_info_schema(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/registrar/domains/{domain}/contact-info/schema".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/registrar/domains/{{domain}}/contact-info/schema failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update nameservers for a domain
///
/// Method: PATCH /v1/registrar/domains/{domain}/nameservers
#[actor(
VercelUpdateDomainNameserversActor,
inports::<100>(domain, teamId, nameservers),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_domain_nameservers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/registrar/domains/{domain}/nameservers".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("nameservers") {
body.insert("nameservers".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PATCH /v1/registrar/domains/{{domain}}/nameservers failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get price data for a domain
///
/// Method: GET /v1/registrar/domains/{domain}/price
#[actor(
VercelReadDomainPriceActor,
inports::<100>(domain, years, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_domain_price(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/registrar/domains/{domain}/price".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("years") {
query_pairs.push(("years", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/registrar/domains/{{domain}}/price failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Get a domain's transfer status
///
/// Method: GET /v1/registrar/domains/{domain}/transfer
#[actor(
VercelReadDomainTransferInActor,
inports::<100>(domain, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_domain_transfer_in(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/registrar/domains/{domain}/transfer".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/registrar/domains/{{domain}}/transfer failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get a domain order
///
/// Method: GET /v1/registrar/orders/{orderId}
#[actor(
VercelReadOrderActor,
inports::<100>(orderId, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_order(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/registrar/orders/{orderId}".to_string();
if let Some(val) = inputs.get("orderId") {
endpoint = endpoint.replace("{{orderId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/registrar/orders/{{orderId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Get supported TLDs
///
/// Method: GET /v1/registrar/tlds/supported
#[actor(
VercelReadSupportedTldsActor,
inports::<100>(teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_supported_tlds(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/registrar/tlds/supported".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/registrar/tlds/supported failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get TLD
///
/// Method: GET /v1/registrar/tlds/{tld}
#[actor(
VercelReadTldActor,
inports::<100>(tld, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_tld(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/registrar/tlds/{tld}".to_string();
if let Some(val) = inputs.get("tld") {
endpoint = endpoint.replace("{{tld}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/registrar/tlds/{{tld}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get TLD price data
///
/// Method: GET /v1/registrar/tlds/{tld}/price
#[actor(
VercelReadTldPriceActor,
inports::<100>(tld, years, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_tld_price(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/registrar/tlds/{tld}/price".to_string();
if let Some(val) = inputs.get("tld") {
endpoint = endpoint.replace("{{tld}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("years") {
query_pairs.push(("years", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/registrar/tlds/{{tld}}/price failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List sandboxes
///
/// Method: GET /v1/sandboxes
#[actor(
VercelListSandboxesActor,
inports::<100>(project, limit, since, until, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_sandboxes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/sandboxes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("project") {
query_pairs.push(("project", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/sandboxes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a sandbox
///
/// Method: POST /v1/sandboxes
#[actor(
VercelCreateSandboxActor,
inports::<100>(teamId, slug, resources, timeout, env, networkPolicy, source, ports, projectId, runtime),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_sandbox(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/sandboxes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("resources") {
body.insert("resources".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("timeout") {
body.insert("timeout".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("env") {
body.insert("env".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("networkPolicy") {
body.insert("networkPolicy".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ports") {
body.insert("ports".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projectId") {
body.insert("projectId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("runtime") {
body.insert("runtime".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/sandboxes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List snapshots
///
/// Method: GET /v1/sandboxes/snapshots
#[actor(
VercelListSnapshotsActor,
inports::<100>(project, limit, since, until, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_snapshots(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/sandboxes/snapshots".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("project") {
query_pairs.push(("project", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/sandboxes/snapshots failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a snapshot
///
/// Method: DELETE /v1/sandboxes/snapshots/{snapshotId}
#[actor(
VercelDeleteSnapshotActor,
inports::<100>(snapshotId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_snapshot(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sandboxes/snapshots/{snapshotId}".to_string();
if let Some(val) = inputs.get("snapshotId") {
endpoint = endpoint.replace("{{snapshotId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/sandboxes/snapshots/{{snapshotId}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get a snapshot
///
/// Method: GET /v1/sandboxes/snapshots/{snapshotId}
#[actor(
VercelReadSnapshotActor,
inports::<100>(snapshotId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_snapshot(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sandboxes/snapshots/{snapshotId}".to_string();
if let Some(val) = inputs.get("snapshotId") {
endpoint = endpoint.replace("{{snapshotId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/sandboxes/snapshots/{{snapshotId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Get a sandbox
///
/// Method: GET /v1/sandboxes/{sandboxId}
#[actor(
VercelReadSandboxActor,
inports::<100>(sandboxId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_sandbox(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sandboxes/{sandboxId}".to_string();
if let Some(val) = inputs.get("sandboxId") {
endpoint = endpoint.replace("{{sandboxId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/sandboxes/{{sandboxId}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Execute a command
///
/// Method: POST /v1/sandboxes/{sandboxId}/cmd
#[actor(
VercelCreateSandboxesActor,
inports::<100>(sandboxId, teamId, slug, args, command, sudo, env, wait, cwd),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_sandboxes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sandboxes/{sandboxId}/cmd".to_string();
if let Some(val) = inputs.get("sandboxId") {
endpoint = endpoint.replace("{{sandboxId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("args") {
body.insert("args".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("command") {
body.insert("command".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sudo") {
body.insert("sudo".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("env") {
body.insert("env".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("wait") {
body.insert("wait".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cwd") {
body.insert("cwd".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/sandboxes/{{sandboxId}}/cmd failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List commands
///
/// Method: GET /v1/sandboxes/{sandboxId}/cmd
#[actor(
VercelListCommandsActor,
inports::<100>(sandboxId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_commands(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sandboxes/{sandboxId}/cmd".to_string();
if let Some(val) = inputs.get("sandboxId") {
endpoint = endpoint.replace("{{sandboxId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/sandboxes/{{sandboxId}}/cmd failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get a command
///
/// Method: GET /v1/sandboxes/{sandboxId}/cmd/{cmdId}
#[actor(
VercelReadCommandActor,
inports::<100>(sandboxId, cmdId, wait, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_command(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sandboxes/{sandboxId}/cmd/{cmdId}".to_string();
if let Some(val) = inputs.get("sandboxId") {
endpoint = endpoint.replace("{{sandboxId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("cmdId") {
endpoint = endpoint.replace("{{cmdId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("wait") {
query_pairs.push(("wait", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/sandboxes/{{sandboxId}}/cmd/{{cmdId}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Stream command logs
///
/// Method: GET /v1/sandboxes/{sandboxId}/cmd/{cmdId}/logs
#[actor(
VercelReadCommandLogsActor,
inports::<100>(sandboxId, cmdId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_command_logs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sandboxes/{sandboxId}/cmd/{cmdId}/logs".to_string();
if let Some(val) = inputs.get("sandboxId") {
endpoint = endpoint.replace("{{sandboxId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("cmdId") {
endpoint = endpoint.replace("{{cmdId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/sandboxes/{{sandboxId}}/cmd/{{cmdId}}/logs failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a directory
///
/// Method: POST /v1/sandboxes/{sandboxId}/fs/mkdir
#[actor(
VercelCreateDirectoryActor,
inports::<100>(sandboxId, teamId, slug, cwd, path, recursive),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_directory(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sandboxes/{sandboxId}/fs/mkdir".to_string();
if let Some(val) = inputs.get("sandboxId") {
endpoint = endpoint.replace("{{sandboxId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("cwd") {
body.insert("cwd".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("path") {
body.insert("path".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("recursive") {
body.insert("recursive".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/sandboxes/{{sandboxId}}/fs/mkdir failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update network policy
///
/// Method: POST /v1/sandboxes/{sandboxId}/network-policy
#[actor(
VercelUpdateNetworkPolicyActor,
inports::<100>(sandboxId, teamId, slug, deniedCIDRs, allowedDomains, mode, allowedCIDRs),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_network_policy(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sandboxes/{sandboxId}/network-policy".to_string();
if let Some(val) = inputs.get("sandboxId") {
endpoint = endpoint.replace("{{sandboxId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("deniedCIDRs") {
body.insert("deniedCIDRs".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("allowedDomains") {
body.insert("allowedDomains".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mode") {
body.insert("mode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("allowedCIDRs") {
body.insert("allowedCIDRs".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/sandboxes/{{sandboxId}}/network-policy failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a snapshot
///
/// Method: POST /v1/sandboxes/{sandboxId}/snapshot
#[actor(
VercelCreateSnapshotActor,
inports::<100>(sandboxId, teamId, slug, expiration),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_snapshot(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sandboxes/{sandboxId}/snapshot".to_string();
if let Some(val) = inputs.get("sandboxId") {
endpoint = endpoint.replace("{{sandboxId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expiration") {
body.insert("expiration".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/sandboxes/{{sandboxId}}/snapshot failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Stop a sandbox
///
/// Method: POST /v1/sandboxes/{sandboxId}/stop
#[actor(
VercelStopSandboxActor,
inports::<100>(sandboxId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_stop_sandbox(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sandboxes/{sandboxId}/stop".to_string();
if let Some(val) = inputs.get("sandboxId") {
endpoint = endpoint.replace("{{sandboxId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/sandboxes/{{sandboxId}}/stop failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update Attack Challenge mode
///
/// Method: POST /v1/security/attack-mode
#[actor(
VercelUpdateAttackChallengeModeActor,
inports::<100>(teamId, slug, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_attack_challenge_mode(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/security/attack-mode".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("body") {
body.insert("body".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/security/attack-mode failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Read active attack data
///
/// Method: GET /v1/security/firewall/attack-status
#[actor(
VercelReadActiveAttackStatusActor,
inports::<100>(projectId, since, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_active_attack_status(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/security/firewall/attack-status".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/security/firewall/attack-status failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create System Bypass Rule
///
/// Method: POST /v1/security/firewall/bypass
#[actor(
VercelCreateSecurityActor,
inports::<100>(projectId, teamId, slug, sourceIp, note, projectScope, domain, allSources, ttl),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_security(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/security/firewall/bypass".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("sourceIp") {
body.insert("sourceIp".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("note") {
body.insert("note".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projectScope") {
body.insert("projectScope".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("domain") {
body.insert("domain".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("allSources") {
body.insert("allSources".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ttl") {
body.insert("ttl".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/security/firewall/bypass failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Remove System Bypass Rule
///
/// Method: DELETE /v1/security/firewall/bypass
#[actor(
VercelDeleteBypassIpActor,
inports::<100>(projectId, teamId, slug, note, allSources, sourceIp, projectScope, domain),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_bypass_ip(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/security/firewall/bypass".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/security/firewall/bypass failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Read System Bypass
///
/// Method: GET /v1/security/firewall/bypass
#[actor(
VercelReadBypassIpActor,
inports::<100>(projectId, limit, sourceIp, domain, projectScope, offset, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_bypass_ip(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/security/firewall/bypass".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("sourceIp") {
query_pairs.push(("sourceIp", super::message_to_str(val)));
}
if let Some(val) = inputs.get("domain") {
query_pairs.push(("domain", super::message_to_str(val)));
}
if let Some(val) = inputs.get("projectScope") {
query_pairs.push(("projectScope", super::message_to_str(val)));
}
if let Some(val) = inputs.get("offset") {
query_pairs.push(("offset", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/security/firewall/bypass failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update Firewall Configuration
///
/// Method: PATCH /v1/security/firewall/config
#[actor(
VercelUpdateFirewallConfigActor,
inports::<100>(projectId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_firewall_config(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/security/firewall/config".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("PATCH /v1/security/firewall/config failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Read Firewall Configuration
///
/// Method: GET /v1/security/firewall/config/{configVersion}
#[actor(
VercelReadFirewallConfigActor,
inports::<100>(projectId, teamId, slug, configVersion),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_firewall_config(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/security/firewall/config/{configVersion}".to_string();
if let Some(val) = inputs.get("configVersion") {
endpoint = endpoint.replace("{{configVersion}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/security/firewall/config/{{configVersion}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Read Firewall Actions by Project
///
/// Method: GET /v1/security/firewall/events
#[actor(
VercelReadSecurityFirewallEventsActor,
inports::<100>(projectId, startTimestamp, endTimestamp, hosts),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_security_firewall_events(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/security/firewall/events".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("startTimestamp") {
query_pairs.push(("startTimestamp", super::message_to_str(val)));
}
if let Some(val) = inputs.get("endTimestamp") {
query_pairs.push(("endTimestamp", super::message_to_str(val)));
}
if let Some(val) = inputs.get("hosts") {
query_pairs.push(("hosts", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/security/firewall/events failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create integration store (free and paid plans)
///
/// Method: POST /v1/storage/stores/integration/direct
#[actor(
VercelCreateIntegrationStoreDirectActor,
inports::<100>(teamId, slug, name, prepaymentAmountCents, protocolSettings, source, billingPlanId, integrationConfigurationId, paymentMethodId, externalId, metadata, integrationProductIdOrSlug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_integration_store_direct(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/storage/stores/integration/direct".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("prepaymentAmountCents") {
body.insert("prepaymentAmountCents".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("protocolSettings") {
body.insert("protocolSettings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billingPlanId") {
body.insert("billingPlanId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("integrationConfigurationId") {
body.insert("integrationConfigurationId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("paymentMethodId") {
body.insert("paymentMethodId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("externalId") {
body.insert("externalId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("integrationProductIdOrSlug") {
body.insert("integrationProductIdOrSlug".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/storage/stores/integration/direct failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a Team
///
/// Method: POST /v1/teams
#[actor(
VercelCreateTeamActor,
inports::<100>(slug, name, attribution),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_team(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/teams".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("slug") {
body.insert("slug".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("attribution") {
body.insert("attribution".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/teams failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a Team
///
/// Method: DELETE /v1/teams/{teamId}
#[actor(
VercelDeleteTeamActor,
inports::<100>(newDefaultTeamId, teamId, slug, reasons),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_team(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/teams/{teamId}".to_string();
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("newDefaultTeamId") {
query_pairs.push(("newDefaultTeamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/teams/{{teamId}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update Team Directory Sync Role Mappings
///
/// Method: POST /v1/teams/{teamId}/dsync-roles
#[actor(
VercelCreateTeamDsyncRolesActor,
inports::<100>(teamId, slug, roles),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_team_dsync_roles(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/teams/{teamId}/dsync-roles".to_string();
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("roles") {
body.insert("roles".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/teams/{{teamId}}/dsync-roles failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all flags for a team
///
/// Method: GET /v1/teams/{teamId}/feature-flags/flags
#[actor(
VercelListTeamFlagsActor,
inports::<100>(state, withMetadata, limit, cursor, search, kind, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_team_flags(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/teams/{teamId}/feature-flags/flags".to_string();
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("state") {
query_pairs.push(("state", super::message_to_str(val)));
}
if let Some(val) = inputs.get("withMetadata") {
query_pairs.push(("withMetadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("cursor") {
query_pairs.push(("cursor", super::message_to_str(val)));
}
if let Some(val) = inputs.get("search") {
query_pairs.push(("search", super::message_to_str(val)));
}
if let Some(val) = inputs.get("kind") {
query_pairs.push(("kind", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/teams/{{teamId}}/feature-flags/flags failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List team project flag settings
///
/// Method: GET /v1/teams/{teamId}/feature-flags/settings
#[actor(
VercelListTeamFlagSettingsActor,
inports::<100>(limit, cursor, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_team_flag_settings(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/teams/{teamId}/feature-flags/settings".to_string();
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("cursor") {
query_pairs.push(("cursor", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/teams/{{teamId}}/feature-flags/settings failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Delete a Team invite code
///
/// Method: DELETE /v1/teams/{teamId}/invites/{inviteId}
#[actor(
VercelDeleteTeamInviteCodeActor,
inports::<100>(inviteId, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_team_invite_code(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/teams/{teamId}/invites/{inviteId}".to_string();
if let Some(val) = inputs.get("inviteId") {
endpoint = endpoint.replace("{{inviteId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/teams/{{teamId}}/invites/{{inviteId}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Join a team
///
/// Method: POST /v1/teams/{teamId}/members/teams/join
#[actor(
VercelCreateTeamsActor,
inports::<100>(teamId, inviteCode),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_teams(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/teams/{teamId}/members/teams/join".to_string();
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("inviteCode") {
body.insert("inviteCode".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/teams/{{teamId}}/members/teams/join failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Remove a Team Member
///
/// Method: DELETE /v1/teams/{teamId}/members/{uid}
#[actor(
VercelDeleteTeamMemberActor,
inports::<100>(uid, newDefaultTeamId, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_team_member(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/teams/{teamId}/members/{uid}".to_string();
if let Some(val) = inputs.get("uid") {
endpoint = endpoint.replace("{{uid}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("newDefaultTeamId") {
query_pairs.push(("newDefaultTeamId", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/teams/{{teamId}}/members/{{uid}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update a Team Member
///
/// Method: PATCH /v1/teams/{teamId}/members/{uid}
#[actor(
VercelUpdateTeamMemberActor,
inports::<100>(uid, teamId, projects, confirmed, joinedFrom, role),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_team_member(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/teams/{teamId}/members/{uid}".to_string();
if let Some(val) = inputs.get("uid") {
endpoint = endpoint.replace("{{uid}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("projects") {
body.insert("projects".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("confirmed") {
body.insert("confirmed".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("joinedFrom") {
body.insert("joinedFrom".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("role") {
body.insert("role".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("PATCH /v1/teams/{{teamId}}/members/{{uid}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Get access request status
///
/// Method: GET /v1/teams/{teamId}/request/{userId}
#[actor(
VercelReadTeamAccessRequestActor,
inports::<100>(userId, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_team_access_request(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/teams/{teamId}/request/{userId}".to_string();
if let Some(val) = inputs.get("userId") {
endpoint = endpoint.replace("{{userId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/teams/{{teamId}}/request/{{userId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete User Account
///
/// Method: DELETE /v1/user
#[actor(
VercelDeleteUserActor,
inports::<100>(reasons),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_user(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/user".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/user failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get a list of webhooks
///
/// Method: GET /v1/webhooks
#[actor(
VercelReadWebhooksActor,
inports::<100>(projectId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_webhooks(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/webhooks".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/webhooks failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Creates a webhook
///
/// Method: POST /v1/webhooks
#[actor(
VercelCreateWebhookActor,
inports::<100>(teamId, slug, projectIds, url, events),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_webhook(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/webhooks".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("projectIds") {
body.insert("projectIds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("url") {
body.insert("url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("events") {
body.insert("events".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/webhooks failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Deletes a webhook
///
/// Method: DELETE /v1/webhooks/{id}
#[actor(
VercelDeleteWebhookActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_webhook(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/webhooks/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/webhooks/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get a webhook
///
/// Method: GET /v1/webhooks/{id}
#[actor(
VercelReadWebhookActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_webhook(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/webhooks/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/webhooks/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a list of projects
///
/// Method: GET /v10/projects
#[actor(
VercelReadProjectsActor,
inports::<100>(from, gitForkProtection, limit, search, repo, repoId, repoUrl, excludeRepos, edgeConfigId, edgeConfigTokenId, deprecated, elasticConcurrencyEnabled, staticIpsEnabled, buildMachineTypes, buildQueueConfiguration, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_projects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v10/projects".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("from") {
query_pairs.push(("from", super::message_to_str(val)));
}
if let Some(val) = inputs.get("gitForkProtection") {
query_pairs.push(("gitForkProtection", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("search") {
query_pairs.push(("search", super::message_to_str(val)));
}
if let Some(val) = inputs.get("repo") {
query_pairs.push(("repo", super::message_to_str(val)));
}
if let Some(val) = inputs.get("repoId") {
query_pairs.push(("repoId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("repoUrl") {
query_pairs.push(("repoUrl", super::message_to_str(val)));
}
if let Some(val) = inputs.get("excludeRepos") {
query_pairs.push(("excludeRepos", super::message_to_str(val)));
}
if let Some(val) = inputs.get("edgeConfigId") {
query_pairs.push(("edgeConfigId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("edgeConfigTokenId") {
query_pairs.push(("edgeConfigTokenId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("deprecated") {
query_pairs.push(("deprecated", super::message_to_str(val)));
}
if let Some(val) = inputs.get("elasticConcurrencyEnabled") {
query_pairs.push(("elasticConcurrencyEnabled", super::message_to_str(val)));
}
if let Some(val) = inputs.get("staticIpsEnabled") {
query_pairs.push(("staticIpsEnabled", super::message_to_str(val)));
}
if let Some(val) = inputs.get("buildMachineTypes") {
query_pairs.push(("buildMachineTypes", super::message_to_str(val)));
}
if let Some(val) = inputs.get("buildQueueConfiguration") {
query_pairs.push(("buildQueueConfiguration", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v10/projects failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create one or more environment variables
///
/// Method: POST /v10/projects/{idOrName}/env
#[actor(
VercelCreateProjectEnvActor,
inports::<100>(idOrName, upsert, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_project_env(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v10/projects/{idOrName}/env".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("upsert") {
query_pairs.push(("upsert", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v10/projects/{{idOrName}}/env failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a new project
///
/// Method: POST /v11/projects
#[actor(
VercelCreateProjectActor,
inports::<100>(teamId, slug, serverlessFunctionRegion, enablePreviewFeedback, commandForIgnoringBuildStep, ssoProtection, outputDirectory, serverlessFunctionZeroConfigFailover, previewDeploymentsDisabled, gitRepository, installCommand, devCommand, name, environmentVariables, oidcTokenConfig, rootDirectory, enableAffectedProjectsDeployments, skipGitConnectDuringLink, enableProductionFeedback, buildCommand, previewDeploymentSuffix, publicSource, framework, resourceConfig),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_project(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v11/projects".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("serverlessFunctionRegion") {
body.insert("serverlessFunctionRegion".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("enablePreviewFeedback") {
body.insert("enablePreviewFeedback".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("commandForIgnoringBuildStep") {
body.insert(
"commandForIgnoringBuildStep".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("ssoProtection") {
body.insert("ssoProtection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("outputDirectory") {
body.insert("outputDirectory".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("serverlessFunctionZeroConfigFailover") {
body.insert(
"serverlessFunctionZeroConfigFailover".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("previewDeploymentsDisabled") {
body.insert("previewDeploymentsDisabled".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("gitRepository") {
body.insert("gitRepository".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("installCommand") {
body.insert("installCommand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("devCommand") {
body.insert("devCommand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("environmentVariables") {
body.insert("environmentVariables".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("oidcTokenConfig") {
body.insert("oidcTokenConfig".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("rootDirectory") {
body.insert("rootDirectory".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("enableAffectedProjectsDeployments") {
body.insert(
"enableAffectedProjectsDeployments".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("skipGitConnectDuringLink") {
body.insert("skipGitConnectDuringLink".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("enableProductionFeedback") {
body.insert("enableProductionFeedback".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("buildCommand") {
body.insert("buildCommand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("previewDeploymentSuffix") {
body.insert("previewDeploymentSuffix".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("publicSource") {
body.insert("publicSource".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("framework") {
body.insert("framework".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("resourceConfig") {
body.insert("resourceConfig".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v11/projects failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Cancel a deployment
///
/// Method: PATCH /v12/deployments/{id}/cancel
#[actor(
VercelCancelDeploymentActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_cancel_deployment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v12/deployments/{id}/cancel".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("PATCH /v12/deployments/{{id}}/cancel failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Get a deployment by ID or URL
///
/// Method: GET /v13/deployments/{idOrUrl}
#[actor(
VercelReadDeploymentActor,
inports::<100>(idOrUrl, withGitRepoInfo, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_deployment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v13/deployments/{idOrUrl}".to_string();
if let Some(val) = inputs.get("idOrUrl") {
endpoint = endpoint.replace("{{idOrUrl}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("withGitRepoInfo") {
query_pairs.push(("withGitRepoInfo", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v13/deployments/{{idOrUrl}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a Deployment
///
/// Method: DELETE /v13/deployments/{id}
#[actor(
VercelDeleteDeploymentActor,
inports::<100>(id, url, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_deployment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v13/deployments/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("url") {
query_pairs.push(("url", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v13/deployments/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete an Alias
///
/// Method: DELETE /v2/aliases/{aliasId}
#[actor(
VercelDeleteAliasActor,
inports::<100>(aliasId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_alias(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/aliases/{aliasId}".to_string();
if let Some(val) = inputs.get("aliasId") {
endpoint = endpoint.replace("{{aliasId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v2/aliases/{{aliasId}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List check runs for a deployment
///
/// Method: GET /v2/deployments/{deploymentId}/check-runs
#[actor(
VercelListDeploymentCheckRunsActor,
inports::<100>(deploymentId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_deployment_check_runs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/deployments/{deploymentId}/check-runs".to_string();
if let Some(val) = inputs.get("deploymentId") {
endpoint = endpoint.replace("{{deploymentId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v2/deployments/{{deploymentId}}/check-runs failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a check run
///
/// Method: POST /v2/deployments/{deploymentId}/check-runs
#[actor(
VercelCreateDeploymentCheckRunActor,
inports::<100>(deploymentId, teamId, slug, checkId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_deployment_check_run(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/deployments/{deploymentId}/check-runs".to_string();
if let Some(val) = inputs.get("deploymentId") {
endpoint = endpoint.replace("{{deploymentId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("checkId") {
body.insert("checkId".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v2/deployments/{{deploymentId}}/check-runs failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a check run
///
/// Method: PATCH /v2/deployments/{deploymentId}/check-runs/{checkRunId}
#[actor(
VercelUpdateDeploymentCheckRunActor,
inports::<100>(deploymentId, checkRunId, teamId, slug, status, externalUrl, completedAt, conclusion, externalId, conclusionText, output),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_deployment_check_run(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/deployments/{deploymentId}/check-runs/{checkRunId}".to_string();
if let Some(val) = inputs.get("deploymentId") {
endpoint = endpoint.replace("{{deploymentId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("checkRunId") {
endpoint = endpoint.replace("{{checkRunId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("status") {
body.insert("status".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("externalUrl") {
body.insert("externalUrl".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("completedAt") {
body.insert("completedAt".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("conclusion") {
body.insert("conclusion".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("externalId") {
body.insert("externalId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("conclusionText") {
body.insert("conclusionText".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("output") {
body.insert("output".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("PATCH /v2/deployments/{{deploymentId}}/check-runs/{{checkRunId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Get a check run
///
/// Method: GET /v2/deployments/{deploymentId}/check-runs/{checkRunId}
#[actor(
VercelReadDeploymentCheckRunActor,
inports::<100>(deploymentId, checkRunId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_deployment_check_run(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/deployments/{deploymentId}/check-runs/{checkRunId}".to_string();
if let Some(val) = inputs.get("deploymentId") {
endpoint = endpoint.replace("{{deploymentId}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("checkRunId") {
endpoint = endpoint.replace("{{checkRunId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v2/deployments/{{deploymentId}}/check-runs/{{checkRunId}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List Deployment Aliases
///
/// Method: GET /v2/deployments/{id}/aliases
#[actor(
VercelListDeploymentAliasesActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_deployment_aliases(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/deployments/{id}/aliases".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v2/deployments/{{id}}/aliases failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Assign an Alias
///
/// Method: POST /v2/deployments/{id}/aliases
#[actor(
VercelCreateAliasesActor,
inports::<100>(id, teamId, slug, redirect, alias),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_aliases(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/deployments/{id}/aliases".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("redirect") {
body.insert("redirect".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alias") {
body.insert("alias".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v2/deployments/{{id}}/aliases failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a DNS record
///
/// Method: POST /v2/domains/{domain}/records
#[actor(
VercelCreateRecordActor,
inports::<100>(domain, teamId, slug, type_),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_record(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/domains/{domain}/records".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v2/domains/{{domain}}/records failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a DNS record
///
/// Method: DELETE /v2/domains/{domain}/records/{recordId}
#[actor(
VercelDeleteRecordActor,
inports::<100>(domain, recordId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_record(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/domains/{domain}/records/{recordId}".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("recordId") {
endpoint = endpoint.replace("{{recordId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v2/domains/{{domain}}/records/{{recordId}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Upload Deployment Files
///
/// Method: POST /v2/files
#[actor(
VercelUploadFileActor,
inports::<100>(Content_Length, x_vercel_digest, x_now_digest, x_now_size, teamId, slug, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_upload_file(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v2/files".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
if let Some(val) = inputs.get("Content_Length") {
builder = builder.header("Content-Length", super::message_to_str(val));
}
if let Some(val) = inputs.get("x_vercel_digest") {
builder = builder.header("x-vercel-digest", super::message_to_str(val));
}
if let Some(val) = inputs.get("x_now_digest") {
builder = builder.header("x-now-digest", super::message_to_str(val));
}
if let Some(val) = inputs.get("x_now_size") {
builder = builder.header("x-now-size", super::message_to_str(val));
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("body") {
body.insert("body".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v2/files failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieves a list of Integration log drains (deprecated)
///
/// Method: GET /v2/integrations/log-drains
#[actor(
VercelReadIntegrationLogDrainsActor,
inports::<100>(teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_integration_log_drains(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v2/integrations/log-drains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v2/integrations/log-drains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Creates a new Integration Log Drain (deprecated)
///
/// Method: POST /v2/integrations/log-drains
#[actor(
VercelCreateLogDrainActor,
inports::<100>(teamId, slug, deliveryFormat, headers, name, projectIds, environments, url, sources, secret),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_log_drain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v2/integrations/log-drains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("deliveryFormat") {
body.insert("deliveryFormat".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("headers") {
body.insert("headers".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("projectIds") {
body.insert("projectIds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("environments") {
body.insert("environments".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("url") {
body.insert("url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sources") {
body.insert("sources".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("secret") {
body.insert("secret".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v2/integrations/log-drains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all checks for a project
///
/// Method: GET /v2/projects/{projectIdOrName}/checks
#[actor(
VercelListProjectChecksActor,
inports::<100>(projectIdOrName, blocks, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_project_checks(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/projects/{projectIdOrName}/checks".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("blocks") {
query_pairs.push(("blocks", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v2/projects/{{projectIdOrName}}/checks failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a check
///
/// Method: POST /v2/projects/{projectIdOrName}/checks
#[actor(
VercelCreateProjectCheckActor,
inports::<100>(projectIdOrName, teamId, slug, timeout, requires, name, blocks, targets, source, isRerequestable),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_project_check(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/projects/{projectIdOrName}/checks".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("timeout") {
body.insert("timeout".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("requires") {
body.insert("requires".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("blocks") {
body.insert("blocks".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("targets") {
body.insert("targets".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("isRerequestable") {
body.insert("isRerequestable".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v2/projects/{{projectIdOrName}}/checks failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete a check
///
/// Method: DELETE /v2/projects/{projectIdOrName}/checks/{checkId}
#[actor(
VercelDeleteProjectCheckActor,
inports::<100>(projectIdOrName, checkId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_project_check(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/projects/{projectIdOrName}/checks/{checkId}".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("checkId") {
endpoint = endpoint.replace("{{checkId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v2/projects/{{projectIdOrName}}/checks/{{checkId}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Get a check
///
/// Method: GET /v2/projects/{projectIdOrName}/checks/{checkId}
#[actor(
VercelReadProjectCheckActor,
inports::<100>(projectIdOrName, checkId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_project_check(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/projects/{projectIdOrName}/checks/{checkId}".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("checkId") {
endpoint = endpoint.replace("{{checkId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v2/projects/{{projectIdOrName}}/checks/{{checkId}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a check
///
/// Method: PATCH /v2/projects/{projectIdOrName}/checks/{checkId}
#[actor(
VercelUpdateProjectCheckActor,
inports::<100>(projectIdOrName, checkId, teamId, slug, name, isRerequestable, requires, timeout, targets, blocks),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_project_check(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/projects/{projectIdOrName}/checks/{checkId}".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("checkId") {
endpoint = endpoint.replace("{{checkId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("isRerequestable") {
body.insert("isRerequestable".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("requires") {
body.insert("requires".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("timeout") {
body.insert("timeout".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("targets") {
body.insert("targets".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("blocks") {
body.insert("blocks".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PATCH /v2/projects/{{projectIdOrName}}/checks/{{checkId}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List runs for a check
///
/// Method: GET /v2/projects/{projectIdOrName}/checks/{checkId}/runs
#[actor(
VercelListCheckRunsActor,
inports::<100>(projectIdOrName, checkId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_check_runs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/projects/{projectIdOrName}/checks/{checkId}/runs".to_string();
if let Some(val) = inputs.get("projectIdOrName") {
endpoint = endpoint.replace("{{projectIdOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("checkId") {
endpoint = endpoint.replace("{{checkId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v2/projects/{{projectIdOrName}}/checks/{{checkId}}/runs failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all teams
///
/// Method: GET /v2/teams
#[actor(
VercelReadTeamsActor,
inports::<100>(limit, since, until),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_teams(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v2/teams".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v2/teams failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get a Team
///
/// Method: GET /v2/teams/{teamId}
#[actor(
VercelReadTeamActor,
inports::<100>(slug, teamId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_team(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/teams/{teamId}".to_string();
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v2/teams/{{teamId}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a Team
///
/// Method: PATCH /v2/teams/{teamId}
#[actor(
VercelUpdateTeamActor,
inports::<100>(teamId, slug, remoteCaching, defaultExpirationSettings, description, enablePreviewFeedback, hideIpAddressesInLogDrains, avatar, enableProductionFeedback, regenerateInviteCode, previewDeploymentSuffix, resourceConfig, strictDeploymentProtectionSettings, sensitiveEnvironmentVariablePolicy, emailDomain, defaultDeploymentProtection, name, saml, nsnbConfig, hideIpAddresses),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_team(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v2/teams/{teamId}".to_string();
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("remoteCaching") {
body.insert("remoteCaching".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("defaultExpirationSettings") {
body.insert("defaultExpirationSettings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("enablePreviewFeedback") {
body.insert("enablePreviewFeedback".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("slug") {
body.insert("slug".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("hideIpAddressesInLogDrains") {
body.insert("hideIpAddressesInLogDrains".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("avatar") {
body.insert("avatar".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("enableProductionFeedback") {
body.insert("enableProductionFeedback".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("regenerateInviteCode") {
body.insert("regenerateInviteCode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("previewDeploymentSuffix") {
body.insert("previewDeploymentSuffix".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("resourceConfig") {
body.insert("resourceConfig".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("strictDeploymentProtectionSettings") {
body.insert(
"strictDeploymentProtectionSettings".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("sensitiveEnvironmentVariablePolicy") {
body.insert(
"sensitiveEnvironmentVariablePolicy".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("emailDomain") {
body.insert("emailDomain".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("defaultDeploymentProtection") {
body.insert(
"defaultDeploymentProtection".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("saml") {
body.insert("saml".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nsnbConfig") {
body.insert("nsnbConfig".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("hideIpAddresses") {
body.insert("hideIpAddresses".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("PATCH /v2/teams/{{teamId}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get the User
///
/// Method: GET /v2/user
#[actor(
VercelReadAuthUserActor,
inports::<100>(trigger),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_auth_user(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v2/user".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v2/user failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get deployment events
///
/// Method: GET /v3/deployments/{idOrUrl}/events
#[actor(
VercelReadDeploymentEventsActor,
inports::<100>(idOrUrl, direction, follow, limit, name, since, until, statusCode, delimiter, builds, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_deployment_events(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v3/deployments/{idOrUrl}/events".to_string();
if let Some(val) = inputs.get("idOrUrl") {
endpoint = endpoint.replace("{{idOrUrl}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("direction") {
query_pairs.push(("direction", super::message_to_str(val)));
}
if let Some(val) = inputs.get("follow") {
query_pairs.push(("follow", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("name") {
query_pairs.push(("name", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("statusCode") {
query_pairs.push(("statusCode", super::message_to_str(val)));
}
if let Some(val) = inputs.get("delimiter") {
query_pairs.push(("delimiter", super::message_to_str(val)));
}
if let Some(val) = inputs.get("builds") {
query_pairs.push(("builds", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v3/deployments/{{idOrUrl}}/events failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update or move apex domain
///
/// Method: PATCH /v3/domains/{domain}
#[actor(
VercelUpdateDomainActor,
inports::<100>(domain, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_domain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v3/domains/{domain}".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("PATCH /v3/domains/{{domain}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List User Events
///
/// Method: GET /v3/events
#[actor(
VercelListUserEventsActor,
inports::<100>(limit, since, until, types, userId, principalId, projectIds, withPayload, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_user_events(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v3/events".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("types") {
query_pairs.push(("types", super::message_to_str(val)));
}
if let Some(val) = inputs.get("userId") {
query_pairs.push(("userId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("principalId") {
query_pairs.push(("principalId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("projectIds") {
query_pairs.push(("projectIds", super::message_to_str(val)));
}
if let Some(val) = inputs.get("withPayload") {
query_pairs.push(("withPayload", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v3/events failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List team members
///
/// Method: GET /v3/teams/{teamId}/members
#[actor(
VercelReadTeamMembersActor,
inports::<100>(limit, since, until, search, role, excludeProject, eligibleMembersForProjectId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_team_members(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v3/teams/{teamId}/members".to_string();
if let Some(val) = inputs.get("teamId") {
endpoint = endpoint.replace("{{teamId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("search") {
query_pairs.push(("search", super::message_to_str(val)));
}
if let Some(val) = inputs.get("role") {
query_pairs.push(("role", super::message_to_str(val)));
}
if let Some(val) = inputs.get("excludeProject") {
query_pairs.push(("excludeProject", super::message_to_str(val)));
}
if let Some(val) = inputs.get("eligibleMembersForProjectId") {
query_pairs.push(("eligibleMembersForProjectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v3/teams/{{teamId}}/members failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create an Auth Token
///
/// Method: POST /v3/user/tokens
#[actor(
VercelCreateAuthTokenActor,
inports::<100>(teamId, slug, projectId, expiresAt, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_auth_token(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v3/user/tokens".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("projectId") {
body.insert("projectId".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expiresAt") {
body.insert("expiresAt".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v3/user/tokens failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete an authentication token
///
/// Method: DELETE /v3/user/tokens/{tokenId}
#[actor(
VercelDeleteAuthTokenActor,
inports::<100>(tokenId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_auth_token(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v3/user/tokens/{tokenId}".to_string();
if let Some(val) = inputs.get("tokenId") {
endpoint = endpoint.replace("{{tokenId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v3/user/tokens/{{tokenId}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List aliases
///
/// Method: GET /v4/aliases
#[actor(
VercelListAliasesActor,
inports::<100>(domain, from, limit, projectId, since, until, rollbackDeploymentId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_aliases(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v4/aliases".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("domain") {
query_pairs.push(("domain", super::message_to_str(val)));
}
if let Some(val) = inputs.get("from") {
query_pairs.push(("from", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("rollbackDeploymentId") {
query_pairs.push(("rollbackDeploymentId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v4/aliases failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get an Alias
///
/// Method: GET /v4/aliases/{idOrAlias}
#[actor(
VercelReadAliasActor,
inports::<100>(from, idOrAlias, projectId, since, until, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_alias(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v4/aliases/{idOrAlias}".to_string();
if let Some(val) = inputs.get("idOrAlias") {
endpoint = endpoint.replace("{{idOrAlias}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("from") {
query_pairs.push(("from", super::message_to_str(val)));
}
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v4/aliases/{{idOrAlias}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List existing DNS records
///
/// Method: GET /v4/domains/{domain}/records
#[actor(
VercelReadRecordsActor,
inports::<100>(domain, limit, since, until, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_records(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v4/domains/{domain}/records".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v4/domains/{{domain}}/records failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all the domains
///
/// Method: GET /v5/domains
#[actor(
VercelReadDomainsActor,
inports::<100>(limit, since, until, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_domains(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v5/domains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v5/domains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get Information for a Single Domain
///
/// Method: GET /v5/domains/{domain}
#[actor(
VercelReadDomainActor,
inports::<100>(domain, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_domain(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v5/domains/{domain}".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v5/domains/{{domain}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List Auth Tokens
///
/// Method: GET /v5/user/tokens
#[actor(
VercelListAuthTokensActor,
inports::<100>(trigger),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_auth_tokens(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v5/user/tokens".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v5/user/tokens failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get Auth Token Metadata
///
/// Method: GET /v5/user/tokens/{tokenId}
#[actor(
VercelReadAuthTokenActor,
inports::<100>(tokenId),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_auth_token(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v5/user/tokens/{tokenId}".to_string();
if let Some(val) = inputs.get("tokenId") {
endpoint = endpoint.replace("{{tokenId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v5/user/tokens/{{tokenId}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List deployments
///
/// Method: GET /v6/deployments
#[actor(
VercelReadDeploymentsActor,
inports::<100>(app, from, limit, projectId, projectIds, target, to, users, since, until, state, rollbackCandidate, branch, sha, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_deployments(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v6/deployments".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("app") {
query_pairs.push(("app", super::message_to_str(val)));
}
if let Some(val) = inputs.get("from") {
query_pairs.push(("from", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("projectId") {
query_pairs.push(("projectId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("projectIds") {
query_pairs.push(("projectIds", super::message_to_str(val)));
}
if let Some(val) = inputs.get("target") {
query_pairs.push(("target", super::message_to_str(val)));
}
if let Some(val) = inputs.get("to") {
query_pairs.push(("to", super::message_to_str(val)));
}
if let Some(val) = inputs.get("users") {
query_pairs.push(("users", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("state") {
query_pairs.push(("state", super::message_to_str(val)));
}
if let Some(val) = inputs.get("rollbackCandidate") {
query_pairs.push(("rollbackCandidate", super::message_to_str(val)));
}
if let Some(val) = inputs.get("branch") {
query_pairs.push(("branch", super::message_to_str(val)));
}
if let Some(val) = inputs.get("sha") {
query_pairs.push(("sha", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v6/deployments failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List Deployment Files
///
/// Method: GET /v6/deployments/{id}/files
#[actor(
VercelListDeploymentFilesActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_deployment_files(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v6/deployments/{id}/files".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v6/deployments/{{id}}/files failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Remove a domain by name
///
/// Method: DELETE /v6/domains/{domain}
#[actor(
VercelDeleteDomainActor,
inports::<100>(domain, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_domain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v6/domains/{domain}".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v6/domains/{{domain}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get a Domain's configuration
///
/// Method: GET /v6/domains/{domain}/config
#[actor(
VercelReadDomainConfigActor,
inports::<100>(domain, projectIdOrName, strict, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_domain_config(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v6/domains/{domain}/config".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("projectIdOrName") {
query_pairs.push(("projectIdOrName", super::message_to_str(val)));
}
if let Some(val) = inputs.get("strict") {
query_pairs.push(("strict", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v6/domains/{{domain}}/config failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Add an existing domain to the Vercel platform
///
/// Method: POST /v7/domains
#[actor(
VercelCreateOrTransferDomainActor,
inports::<100>(teamId, slug, method),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_or_transfer_domain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v7/domains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("method") {
body.insert("method".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v7/domains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Query information about an artifact
///
/// Method: POST /v8/artifacts
#[actor(
VercelCreateArtifactsActor,
inports::<100>(teamId, slug, hashes),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_artifacts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v8/artifacts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("hashes") {
body.insert("hashes".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v8/artifacts failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get status of Remote Caching for this principal
///
/// Method: GET /v8/artifacts/status
#[actor(
VercelListArtifactsActor,
inports::<100>(teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_list_artifacts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v8/artifacts/status".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v8/artifacts/status failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Check if a cache artifact exists
///
/// Method: HEAD /v8/artifacts/{hash}
#[actor(
VercelReadArtifactsActor,
inports::<100>(hash, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_artifacts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v8/artifacts/{hash}".to_string();
if let Some(val) = inputs.get("hash") {
endpoint = endpoint.replace("{{hash}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.head(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("HEAD /v8/artifacts/{{hash}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Download a cache artifact
///
/// Method: GET /v8/artifacts/{hash}
#[actor(
VercelDownloadArtifactActor,
inports::<100>(x_artifact_client_ci, x_artifact_client_interactive, hash, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_download_artifact(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v8/artifacts/{hash}".to_string();
if let Some(val) = inputs.get("hash") {
endpoint = endpoint.replace("{{hash}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
if let Some(val) = inputs.get("x_artifact_client_ci") {
builder = builder.header("x-artifact-client-ci", super::message_to_str(val));
}
if let Some(val) = inputs.get("x_artifact_client_interactive") {
builder = builder.header("x-artifact-client-interactive", super::message_to_str(val));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v8/artifacts/{{hash}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Upload a cache artifact
///
/// Method: PUT /v8/artifacts/{hash}
#[actor(
VercelUploadArtifactActor,
inports::<100>(Content_Length, x_artifact_duration, x_artifact_client_ci, x_artifact_client_interactive, x_artifact_tag, hash, teamId, slug, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_upload_artifact(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v8/artifacts/{hash}".to_string();
if let Some(val) = inputs.get("hash") {
endpoint = endpoint.replace("{{hash}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.put(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
if let Some(val) = inputs.get("Content_Length") {
builder = builder.header("Content-Length", super::message_to_str(val));
}
if let Some(val) = inputs.get("x_artifact_duration") {
builder = builder.header("x-artifact-duration", super::message_to_str(val));
}
if let Some(val) = inputs.get("x_artifact_client_ci") {
builder = builder.header("x-artifact-client-ci", super::message_to_str(val));
}
if let Some(val) = inputs.get("x_artifact_client_interactive") {
builder = builder.header("x-artifact-client-interactive", super::message_to_str(val));
}
if let Some(val) = inputs.get("x_artifact_tag") {
builder = builder.header("x-artifact-tag", super::message_to_str(val));
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("body") {
body.insert("body".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("PUT /v8/artifacts/{{hash}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Issue a new cert
///
/// Method: POST /v8/certs
#[actor(
VercelCreateCertsActor,
inports::<100>(teamId, slug, cns),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_certs(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v8/certs".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("cns") {
body.insert("cns".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v8/certs failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Upload a cert
///
/// Method: PUT /v8/certs
#[actor(
VercelUploadCertActor,
inports::<100>(teamId, slug, skipValidation, key, ca, cert),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_upload_cert(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v8/certs".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.put(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("skipValidation") {
body.insert("skipValidation".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("key") {
body.insert("key".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ca") {
body.insert("ca".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cert") {
body.insert("cert".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("PUT /v8/certs failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get cert by id
///
/// Method: GET /v8/certs/{id}
#[actor(
VercelReadCertByIdActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_cert_by_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v8/certs/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v8/certs/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Remove cert
///
/// Method: DELETE /v8/certs/{id}
#[actor(
VercelDeleteCertActor,
inports::<100>(id, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_cert(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v8/certs/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v8/certs/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Get Deployment File Contents
///
/// Method: GET /v8/deployments/{id}/files/{fileId}
#[actor(
VercelReadDeploymentFileContentsActor,
inports::<100>(id, fileId, path, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_deployment_file_contents(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v8/deployments/{id}/files/{fileId}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("fileId") {
endpoint = endpoint.replace("{{fileId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("path") {
query_pairs.push(("path", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v8/deployments/{{id}}/files/{{fileId}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Find a project by id or name
///
/// Method: GET /v9/projects/{idOrName}
#[actor(
VercelReadProjectActor,
inports::<100>(idOrName, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_project(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v9/projects/{idOrName}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v9/projects/{{idOrName}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update an existing project
///
/// Method: PATCH /v9/projects/{idOrName}
#[actor(
VercelUpdateProjectActor,
inports::<100>(idOrName, teamId, slug, enablePreviewFeedback, enableProductionFeedback, skipGitConnectDuringLink, previewDeploymentSuffix, resourceConfig, serverlessFunctionZeroConfigFailover, skewProtectionAllowedDomains, skewProtectionMaxAge, dismissedToasts, autoAssignCustomDomains, commandForIgnoringBuildStep, trustedIps, outputDirectory, protectedSourcemaps, buildCommand, customerSupportCodeVisibility, gitForkProtection, autoExposeSystemEnvs, previewDeploymentsDisabled, nodeVersion, autoAssignCustomDomainsUpdatedBy, enableAffectedProjectsDeployments, devCommand, passwordProtection, rootDirectory, sourceFilesOutsideRootDirectory, connectConfigurations, staticIps, directoryListing, ssoProtection, skewProtectionBoundaryAt, optionsAllowlist, oidcTokenConfig, installCommand, framework, publicSource, gitLFS, name, serverlessFunctionRegion),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_project(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v9/projects/{idOrName}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("enablePreviewFeedback") {
body.insert("enablePreviewFeedback".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("enableProductionFeedback") {
body.insert("enableProductionFeedback".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("skipGitConnectDuringLink") {
body.insert("skipGitConnectDuringLink".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("previewDeploymentSuffix") {
body.insert("previewDeploymentSuffix".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("resourceConfig") {
body.insert("resourceConfig".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("serverlessFunctionZeroConfigFailover") {
body.insert(
"serverlessFunctionZeroConfigFailover".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("skewProtectionAllowedDomains") {
body.insert(
"skewProtectionAllowedDomains".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("skewProtectionMaxAge") {
body.insert("skewProtectionMaxAge".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("dismissedToasts") {
body.insert("dismissedToasts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("autoAssignCustomDomains") {
body.insert("autoAssignCustomDomains".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("commandForIgnoringBuildStep") {
body.insert(
"commandForIgnoringBuildStep".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("trustedIps") {
body.insert("trustedIps".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("outputDirectory") {
body.insert("outputDirectory".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("protectedSourcemaps") {
body.insert("protectedSourcemaps".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("buildCommand") {
body.insert("buildCommand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customerSupportCodeVisibility") {
body.insert(
"customerSupportCodeVisibility".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("gitForkProtection") {
body.insert("gitForkProtection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("autoExposeSystemEnvs") {
body.insert("autoExposeSystemEnvs".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("previewDeploymentsDisabled") {
body.insert("previewDeploymentsDisabled".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nodeVersion") {
body.insert("nodeVersion".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("autoAssignCustomDomainsUpdatedBy") {
body.insert(
"autoAssignCustomDomainsUpdatedBy".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("enableAffectedProjectsDeployments") {
body.insert(
"enableAffectedProjectsDeployments".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("devCommand") {
body.insert("devCommand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("passwordProtection") {
body.insert("passwordProtection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("rootDirectory") {
body.insert("rootDirectory".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sourceFilesOutsideRootDirectory") {
body.insert(
"sourceFilesOutsideRootDirectory".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("connectConfigurations") {
body.insert("connectConfigurations".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("staticIps") {
body.insert("staticIps".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("directoryListing") {
body.insert("directoryListing".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ssoProtection") {
body.insert("ssoProtection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("skewProtectionBoundaryAt") {
body.insert("skewProtectionBoundaryAt".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("optionsAllowlist") {
body.insert("optionsAllowlist".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("oidcTokenConfig") {
body.insert("oidcTokenConfig".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("installCommand") {
body.insert("installCommand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("framework") {
body.insert("framework".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("publicSource") {
body.insert("publicSource".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("gitLFS") {
body.insert("gitLFS".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("serverlessFunctionRegion") {
body.insert("serverlessFunctionRegion".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("PATCH /v9/projects/{{idOrName}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a Project
///
/// Method: DELETE /v9/projects/{idOrName}
#[actor(
VercelDeleteProjectActor,
inports::<100>(idOrName, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_project(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v9/projects/{idOrName}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v9/projects/{{idOrName}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a custom environment for the current project.
///
/// Method: POST /v9/projects/{idOrName}/custom-environments
#[actor(
VercelCreateCustomEnvironmentActor,
inports::<100>(idOrName, teamId, slug, branchMatcher, description, copyEnvVarsFrom),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_create_custom_environment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v9/projects/{idOrName}/custom-environments".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("branchMatcher") {
body.insert("branchMatcher".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("slug") {
body.insert("slug".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("copyEnvVarsFrom") {
body.insert("copyEnvVarsFrom".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v9/projects/{{idOrName}}/custom-environments failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve custom environments
///
/// Method: GET /v9/projects/{idOrName}/custom-environments
#[actor(
VercelReadProjectsByIdOrNameCustomEnvironmentsActor,
inports::<100>(idOrName, gitBranch, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_projects_by_id_or_name_custom_environments(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v9/projects/{idOrName}/custom-environments".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("gitBranch") {
query_pairs.push(("gitBranch", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v9/projects/{{idOrName}}/custom-environments failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a custom environment
///
/// Method: GET /v9/projects/{idOrName}/custom-environments/{environmentSlugOrId}
#[actor(
VercelReadCustomEnvironmentActor,
inports::<100>(idOrName, environmentSlugOrId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_custom_environment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v9/projects/{idOrName}/custom-environments/{environmentSlugOrId}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("environmentSlugOrId") {
endpoint = endpoint.replace("{{environmentSlugOrId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v9/projects/{{idOrName}}/custom-environments/{{environmentSlugOrId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Remove a custom environment
///
/// Method: DELETE /v9/projects/{idOrName}/custom-environments/{environmentSlugOrId}
#[actor(
VercelDeleteCustomEnvironmentActor,
inports::<100>(idOrName, environmentSlugOrId, teamId, slug, deleteUnassignedEnvironmentVariables),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_custom_environment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v9/projects/{idOrName}/custom-environments/{environmentSlugOrId}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("environmentSlugOrId") {
endpoint = endpoint.replace("{{environmentSlugOrId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("DELETE /v9/projects/{{idOrName}}/custom-environments/{{environmentSlugOrId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Update a custom environment
///
/// Method: PATCH /v9/projects/{idOrName}/custom-environments/{environmentSlugOrId}
#[actor(
VercelUpdateCustomEnvironmentActor,
inports::<100>(idOrName, environmentSlugOrId, teamId, slug, description, branchMatcher),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_custom_environment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v9/projects/{idOrName}/custom-environments/{environmentSlugOrId}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("environmentSlugOrId") {
endpoint = endpoint.replace("{{environmentSlugOrId}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("branchMatcher") {
body.insert("branchMatcher".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("slug") {
body.insert("slug".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("PATCH /v9/projects/{{idOrName}}/custom-environments/{{environmentSlugOrId}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Retrieve project domains by project by id or name
///
/// Method: GET /v9/projects/{idOrName}/domains
#[actor(
VercelReadProjectDomainsActor,
inports::<100>(idOrName, production, target, customEnvironmentId, gitBranch, redirects, redirect, verified, limit, since, until, order, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_project_domains(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v9/projects/{idOrName}/domains".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("production") {
query_pairs.push(("production", super::message_to_str(val)));
}
if let Some(val) = inputs.get("target") {
query_pairs.push(("target", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customEnvironmentId") {
query_pairs.push(("customEnvironmentId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("gitBranch") {
query_pairs.push(("gitBranch", super::message_to_str(val)));
}
if let Some(val) = inputs.get("redirects") {
query_pairs.push(("redirects", super::message_to_str(val)));
}
if let Some(val) = inputs.get("redirect") {
query_pairs.push(("redirect", super::message_to_str(val)));
}
if let Some(val) = inputs.get("verified") {
query_pairs.push(("verified", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("since") {
query_pairs.push(("since", super::message_to_str(val)));
}
if let Some(val) = inputs.get("until") {
query_pairs.push(("until", super::message_to_str(val)));
}
if let Some(val) = inputs.get("order") {
query_pairs.push(("order", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v9/projects/{{idOrName}}/domains failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Get a project domain
///
/// Method: GET /v9/projects/{idOrName}/domains/{domain}
#[actor(
VercelReadProjectDomainActor,
inports::<100>(idOrName, domain, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_read_project_domain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v9/projects/{idOrName}/domains/{domain}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v9/projects/{{idOrName}}/domains/{{domain}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a project domain
///
/// Method: PATCH /v9/projects/{idOrName}/domains/{domain}
#[actor(
VercelUpdateProjectDomainActor,
inports::<100>(idOrName, domain, teamId, slug, gitBranch, redirectStatusCode, redirect),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_update_project_domain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v9/projects/{idOrName}/domains/{domain}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.patch(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("gitBranch") {
body.insert("gitBranch".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("redirectStatusCode") {
body.insert("redirectStatusCode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("redirect") {
body.insert("redirect".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"PATCH /v9/projects/{{idOrName}}/domains/{{domain}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Remove a domain from a project
///
/// Method: DELETE /v9/projects/{idOrName}/domains/{domain}
#[actor(
VercelDeleteProjectDomainActor,
inports::<100>(idOrName, domain, teamId, slug, removeRedirects),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_project_domain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v9/projects/{idOrName}/domains/{domain}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v9/projects/{{idOrName}}/domains/{{domain}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Verify project domain
///
/// Method: POST /v9/projects/{idOrName}/domains/{domain}/verify
#[actor(
VercelVerifyProjectsActor,
inports::<100>(idOrName, domain, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_verify_projects(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v9/projects/{idOrName}/domains/{domain}/verify".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v9/projects/{{idOrName}}/domains/{{domain}}/verify failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Remove an environment variable
///
/// Method: DELETE /v9/projects/{idOrName}/env/{id}
#[actor(
VercelDeleteProjectEnvActor,
inports::<100>(idOrName, id, customEnvironmentId, teamId, slug),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn vercel_delete_project_env(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v9/projects/{idOrName}/env/{id}".to_string();
if let Some(val) = inputs.get("idOrName") {
endpoint = endpoint.replace("{{idOrName}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("customEnvironmentId") {
query_pairs.push(("customEnvironmentId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("teamId") {
query_pairs.push(("teamId", super::message_to_str(val)));
}
if let Some(val) = inputs.get("slug") {
query_pairs.push(("slug", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v9/projects/{{idOrName}}/env/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}