Skip to main content

hanzo_client/apis/
help_api.rs

1/*
2 * Hanzo Cloud API
3 *
4 * The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
5 *
6 * The version of the OpenAPI document: v1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`get_help_articles`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetHelpArticlesError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_help_articles_by_slug`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetHelpArticlesBySlugError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_help_categories`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetHelpCategoriesError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`post_help_tickets`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum PostHelpTicketsError {
43    UnknownValue(serde_json::Value),
44}
45
46
47/// Returns the public knowledge base: the help center's Published, publicly-visible articles as cards. The org is server-fixed and the status/is_public filter is server-set, so neither the tenant nor the visibility can be widened by the caller. A deployment with no help center answers 404.
48pub async fn get_help_articles(configuration: &configuration::Configuration, category: Option<&str>, limit: Option<i32>) -> Result<models::HelpArticleList, Error<GetHelpArticlesError>> {
49    // add a prefix to parameters to efficiently prevent name collisions
50    let p_category = category;
51    let p_limit = limit;
52
53    let uri_str = format!("{}/v1/help/articles", configuration.base_path);
54    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
55
56    if let Some(ref param_value) = p_category {
57        req_builder = req_builder.query(&[("category", &param_value.to_string())]);
58    }
59    if let Some(ref param_value) = p_limit {
60        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
61    }
62    if let Some(ref user_agent) = configuration.user_agent {
63        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
64    }
65    if let Some(ref token) = configuration.bearer_access_token {
66        req_builder = req_builder.bearer_auth(token.to_owned());
67    };
68
69    let req = req_builder.build()?;
70    let resp = configuration.client.execute(req).await?;
71
72    let status = resp.status();
73    let content_type = resp
74        .headers()
75        .get("content-type")
76        .and_then(|v| v.to_str().ok())
77        .unwrap_or("application/octet-stream");
78    let content_type = super::ContentType::from(content_type);
79
80    if !status.is_client_error() && !status.is_server_error() {
81        let content = resp.text().await?;
82        match content_type {
83            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
84            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::HelpArticleList`"))),
85            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::HelpArticleList`")))),
86        }
87    } else {
88        let content = resp.text().await?;
89        let entity: Option<GetHelpArticlesError> = serde_json::from_str(&content).ok();
90        Err(Error::ResponseError(ResponseContent { status, content, entity }))
91    }
92}
93
94/// Returns one public article by slug, with its body. A missing, Draft, or internal (non-public) article is 404 — fail-closed, so this route is no existence oracle for anything beyond \"published and public\".
95pub async fn get_help_articles_by_slug(configuration: &configuration::Configuration, slug: &str) -> Result<models::HelpArticle, Error<GetHelpArticlesBySlugError>> {
96    // add a prefix to parameters to efficiently prevent name collisions
97    let p_slug = slug;
98
99    let uri_str = format!("{}/v1/help/articles/{slug}", configuration.base_path, slug=crate::apis::urlencode(p_slug));
100    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
101
102    if let Some(ref user_agent) = configuration.user_agent {
103        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
104    }
105    if let Some(ref token) = configuration.bearer_access_token {
106        req_builder = req_builder.bearer_auth(token.to_owned());
107    };
108
109    let req = req_builder.build()?;
110    let resp = configuration.client.execute(req).await?;
111
112    let status = resp.status();
113    let content_type = resp
114        .headers()
115        .get("content-type")
116        .and_then(|v| v.to_str().ok())
117        .unwrap_or("application/octet-stream");
118    let content_type = super::ContentType::from(content_type);
119
120    if !status.is_client_error() && !status.is_server_error() {
121        let content = resp.text().await?;
122        match content_type {
123            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
124            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::HelpArticle`"))),
125            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::HelpArticle`")))),
126        }
127    } else {
128        let content = resp.text().await?;
129        let entity: Option<GetHelpArticlesBySlugError> = serde_json::from_str(&content).ok();
130        Err(Error::ResponseError(ResponseContent { status, content, entity }))
131    }
132}
133
134/// Returns the knowledge-base sections for the public center's navigation — but ONLY the sections that front at least one Published, public article, so an internal (agent-only) category name or description never leaks. A section with no public article is invisible; a center with no public articles has no sections, which is an empty list rather than an error.
135pub async fn get_help_categories(configuration: &configuration::Configuration, ) -> Result<models::HelpCategoryList, Error<GetHelpCategoriesError>> {
136
137    let uri_str = format!("{}/v1/help/categories", configuration.base_path);
138    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
139
140    if let Some(ref user_agent) = configuration.user_agent {
141        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
142    }
143    if let Some(ref token) = configuration.bearer_access_token {
144        req_builder = req_builder.bearer_auth(token.to_owned());
145    };
146
147    let req = req_builder.build()?;
148    let resp = configuration.client.execute(req).await?;
149
150    let status = resp.status();
151    let content_type = resp
152        .headers()
153        .get("content-type")
154        .and_then(|v| v.to_str().ok())
155        .unwrap_or("application/octet-stream");
156    let content_type = super::ContentType::from(content_type);
157
158    if !status.is_client_error() && !status.is_server_error() {
159        let content = resp.text().await?;
160        match content_type {
161            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
162            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::HelpCategoryList`"))),
163            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::HelpCategoryList`")))),
164        }
165    } else {
166        let content = resp.text().await?;
167        let entity: Option<GetHelpCategoriesError> = serde_json::from_str(&content).ok();
168        Err(Error::ResponseError(ResponseContent { status, content, entity }))
169    }
170}
171
172/// Files a customer support ticket into the public help center. It creates the ticket (status Open, source portal) with the customer's message on the description, then records that same message as the opening entry of the ticket's conversation thread; the description carries it regardless, so failing to write that entry loses nothing. Answers 201 with an opaque reference.  A deployment with no help center answers 404, one whose center has not installed the Help model answers 503, and a body over 64 KiB answers 413 — in that order, which is the order the route has always decided them in.
173pub async fn post_help_tickets(configuration: &configuration::Configuration, help_ticket_intake: models::HelpTicketIntake) -> Result<models::HelpTicketFiled, Error<PostHelpTicketsError>> {
174    // add a prefix to parameters to efficiently prevent name collisions
175    let p_help_ticket_intake = help_ticket_intake;
176
177    let uri_str = format!("{}/v1/help/tickets", configuration.base_path);
178    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
179
180    if let Some(ref user_agent) = configuration.user_agent {
181        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
182    }
183    if let Some(ref token) = configuration.bearer_access_token {
184        req_builder = req_builder.bearer_auth(token.to_owned());
185    };
186    req_builder = req_builder.json(&p_help_ticket_intake);
187
188    let req = req_builder.build()?;
189    let resp = configuration.client.execute(req).await?;
190
191    let status = resp.status();
192    let content_type = resp
193        .headers()
194        .get("content-type")
195        .and_then(|v| v.to_str().ok())
196        .unwrap_or("application/octet-stream");
197    let content_type = super::ContentType::from(content_type);
198
199    if !status.is_client_error() && !status.is_server_error() {
200        let content = resp.text().await?;
201        match content_type {
202            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
203            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::HelpTicketFiled`"))),
204            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::HelpTicketFiled`")))),
205        }
206    } else {
207        let content = resp.text().await?;
208        let entity: Option<PostHelpTicketsError> = serde_json::from_str(&content).ok();
209        Err(Error::ResponseError(ResponseContent { status, content, entity }))
210    }
211}
212