/*
* Tapis Pods Service
*
* The Pods Service is a web service and distributed computing platform providing pods-as-a-service (PaaS). The service implements a message broker and processor model that requests pods, alongside a health module to poll for pod data, including logs, status, and health. The primary use of this service is to have quick to deploy long-lived services based on Docker images that are exposed via HTTP or TCP endpoints listed by the API. **The Pods service provides functionality for two types of pod solutions:** * **Templated Pods** for run-as-is popular images. Neo4J is one example, the template manages TCP ports, user creation, and permissions. * **Custom Pods** for arbitrary docker images with less functionality. In this case we will expose port 5000 and do nothing else. The live-docs act as the most up-to-date API reference. Visit the [documentation for more information](https://tapis.readthedocs.io/en/latest/technical/pods.html).
*
* The version of the OpenAPI document: 26Q1.1
* Contact: cicsupport@tacc.utexas.edu
* Generated by: https://openapi-generator.tech
*/
use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
/// struct for typed errors of method [`add_template`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddTemplateError {
Status422(models::HttpValidationError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`add_template_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddTemplateTagError {
Status422(models::HttpValidationError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_template`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteTemplateError {
Status422(models::HttpValidationError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_template_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteTemplateTagError {
Status422(models::HttpValidationError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_template`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetTemplateError {
Status422(models::HttpValidationError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_template_tag`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetTemplateTagError {
Status422(models::HttpValidationError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_template_tags`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTemplateTagsError {
Status422(models::HttpValidationError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_templates`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTemplatesError {
Status422(models::HttpValidationError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_templates_and_tags`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListTemplatesAndTagsError {
Status422(models::HttpValidationError),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_template`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateTemplateError {
Status422(models::HttpValidationError),
UnknownValue(serde_json::Value),
}
/// Add a template with inputted information. Returns new template object.
pub async fn add_template(
configuration: &configuration::Configuration,
new_template: models::NewTemplate,
) -> Result<models::TemplateResponse, Error<AddTemplateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_new_template = new_template;
let uri_str = format!("{}/pods/templates", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_new_template);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TemplateResponse`"))),
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TemplateResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AddTemplateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Add a new tag to a template. Template tags can include a ``pod_definition`` with ``secret_map`` to define placeholders that users must or can optionally override when creating pods from this template. Secret Placeholders (25Q4 Feature): - ``${pods:default:value:?description}`` - Placeholder with a default value - ``${:?description}`` - Required placeholder (pod creation fails if not overridden) - ``${secret:name}`` - Direct secret reference (for templates with pre-configured secrets) When users create pods from this template, they can override placeholders with actual secret references in their pod's ``secret_map``. Returns new template tag object.
pub async fn add_template_tag(
configuration: &configuration::Configuration,
template_id: &str,
new_template_tag: models::NewTemplateTag,
) -> Result<models::TemplateTagResponse, Error<AddTemplateTagError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_template_id = template_id;
let p_body_new_template_tag = new_template_tag;
let uri_str = format!(
"{}/pods/templates/{template_id}/tags",
configuration.base_path,
template_id = crate::apis::urlencode(p_path_template_id)
);
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());
}
req_builder = req_builder.json(&p_body_new_template_tag);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TemplateTagResponse`"))),
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TemplateTagResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AddTemplateTagError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Delete a template. Returns \"\".
pub async fn delete_template(
configuration: &configuration::Configuration,
template_id: &str,
) -> Result<models::TemplateDeleteResponse, Error<DeleteTemplateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_template_id = template_id;
let uri_str = format!(
"{}/pods/templates/{template_id}",
configuration.base_path,
template_id = p_path_template_id
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TemplateDeleteResponse`"))),
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TemplateDeleteResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteTemplateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Delete a specific template tag. (Admin only) If the tag has dependent pods or other template tags that inherit from it, deletion will fail unless the `force=true` query parameter is provided. Returns the deleted tag information.
pub async fn delete_template_tag(
configuration: &configuration::Configuration,
template_id: &str,
tag_id: &str,
force: Option<bool>,
) -> Result<models::TemplateTagDeleteResponse, Error<DeleteTemplateTagError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_template_id = template_id;
let p_path_tag_id = tag_id;
let p_query_force = force;
let uri_str = format!(
"{}/pods/templates/{template_id}/tags/{tag_id}",
configuration.base_path,
template_id = crate::apis::urlencode(p_path_template_id),
tag_id = crate::apis::urlencode(p_path_tag_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
if let Some(ref param_value) = p_query_force {
req_builder = req_builder.query(&[("force", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TemplateTagDeleteResponse`"))),
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TemplateTagDeleteResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteTemplateTagError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a template. Returns retrieved templates object.
pub async fn get_template(
configuration: &configuration::Configuration,
template_id: &str,
include_dependencies: Option<bool>,
) -> Result<models::ResponseGetTemplate, Error<GetTemplateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_template_id = template_id;
let p_query_include_dependencies = include_dependencies;
let uri_str = format!(
"{}/pods/templates/{template_id}",
configuration.base_path,
template_id = crate::apis::urlencode(p_path_template_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_include_dependencies {
req_builder = req_builder.query(&[("include_dependencies", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ResponseGetTemplate`"))),
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ResponseGetTemplate`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetTemplateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get a specific tag entry the template has Returns the tag entry
pub async fn get_template_tag(
configuration: &configuration::Configuration,
template_id: &str,
tag_id: &str,
include_configs: Option<bool>,
include_dependencies: Option<bool>,
) -> Result<models::ResponseGetTemplateTag, Error<GetTemplateTagError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_template_id = template_id;
let p_path_tag_id = tag_id;
let p_query_include_configs = include_configs;
let p_query_include_dependencies = include_dependencies;
let uri_str = format!(
"{}/pods/templates/{template_id}/tags/{tag_id}",
configuration.base_path,
template_id = crate::apis::urlencode(p_path_template_id),
tag_id = crate::apis::urlencode(p_path_tag_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_include_configs {
req_builder = req_builder.query(&[("include_configs", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_dependencies {
req_builder = req_builder.query(&[("include_dependencies", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ResponseGetTemplateTag`"))),
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ResponseGetTemplateTag`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetTemplateTagError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// List tag entries the template has Returns the ledger of template tags
pub async fn list_template_tags(
configuration: &configuration::Configuration,
template_id: &str,
full: Option<bool>,
include_configs: Option<bool>,
include_dependencies: Option<bool>,
) -> Result<models::ResponseListTemplateTags, Error<ListTemplateTagsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_template_id = template_id;
let p_query_full = full;
let p_query_include_configs = include_configs;
let p_query_include_dependencies = include_dependencies;
let uri_str = format!(
"{}/pods/templates/{template_id}/tags",
configuration.base_path,
template_id = crate::apis::urlencode(p_path_template_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_configs {
req_builder = req_builder.query(&[("include_configs", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_dependencies {
req_builder = req_builder.query(&[("include_dependencies", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ResponseListTemplateTags`"))),
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ResponseListTemplateTags`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListTemplateTagsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get all templates allowed globally + in respective tenant + for specific user. Returns a list of templates.
pub async fn list_templates(
configuration: &configuration::Configuration,
include_dependencies: Option<bool>,
) -> Result<models::ResponseListTemplates, Error<ListTemplatesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_include_dependencies = include_dependencies;
let uri_str = format!("{}/pods/templates", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_include_dependencies {
req_builder = req_builder.query(&[("include_dependencies", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ResponseListTemplates`"))),
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ResponseListTemplates`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListTemplatesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Get all templates and their tags for the user. Returns a dictionary with templates and their tags.
pub async fn list_templates_and_tags(
configuration: &configuration::Configuration,
full: Option<bool>,
include_dependencies: Option<bool>,
) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ListTemplatesAndTagsError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_query_full = full;
let p_query_include_dependencies = include_dependencies;
let uri_str = format!("{}/pods/templates/tags", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_full {
req_builder = req_builder.query(&[("full", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_include_dependencies {
req_builder = req_builder.query(&[("include_dependencies", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`"))),
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap<String, serde_json::Value>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListTemplatesAndTagsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Update a template. Note: - Fields that change template id cannot be modified. Please recreate your template in that case. Returns updated template object.
pub async fn update_template(
configuration: &configuration::Configuration,
template_id: &str,
update_template: models::UpdateTemplate,
) -> Result<models::TemplateResponse, Error<UpdateTemplateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_template_id = template_id;
let p_body_update_template = update_template;
let uri_str = format!(
"{}/pods/templates/{template_id}",
configuration.base_path,
template_id = p_path_template_id
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body_update_template);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::TemplateResponse`"))),
ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::TemplateResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateTemplateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}