hatchet-sdk 0.2.8

This is an unofficial Rust SDK for Hatchet, a distributed, fault-tolerant task queue.
Documentation
/*
 * Hatchet API
 *
 * The Hatchet API
 *
 * The version of the OpenAPI document: 1.0.0
 *
 * Generated by: https://openapi-generator.tech
 */

use super::{ContentType, Error, configuration};
use crate::clients::rest::{apis::ResponseContent, models};
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};

/// struct for typed errors of method [`sns_update`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SnsUpdateError {
    Status400(models::V1TaskGet400Response),
    Status401(models::V1TaskGet400Response),
    Status405(models::V1TaskGet400Response),
    UnknownValue(serde_json::Value),
}

/// SNS event
pub async fn sns_update(
    configuration: &configuration::Configuration,
    tenant: &str,
    event: &str,
) -> Result<(), Error<SnsUpdateError>> {
    // add a prefix to parameters to efficiently prevent name collisions
    let p_tenant = tenant;
    let p_event = event;

    let uri_str = format!(
        "{}/api/v1/sns/{tenant}/{event}",
        configuration.base_path,
        tenant = crate::clients::rest::apis::urlencode(p_tenant),
        event = crate::clients::rest::apis::urlencode(p_event)
    );
    let mut req_builder = configuration
        .client
        .request(reqwest::Method::POST, &uri_str);

    if let Some(ref user_agent) = configuration.user_agent {
        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
    }

    let req = req_builder.build()?;
    let resp = configuration.client.execute(req).await?;

    let status = resp.status();

    if !status.is_client_error() && !status.is_server_error() {
        Ok(())
    } else {
        let content = resp.text().await?;
        let entity: Option<SnsUpdateError> = serde_json::from_str(&content).ok();
        Err(Error::ResponseError(ResponseContent {
            status,
            content,
            entity,
        }))
    }
}