memos_api/apis/
workspace_service_api.rs

1/*
2 * Memos API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.0.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`workspace_service_get_workspace_profile`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum WorkspaceServiceGetWorkspaceProfileError {
22    DefaultResponse(models::GooglerpcStatus),
23    UnknownValue(serde_json::Value),
24}
25
26
27pub fn workspace_service_get_workspace_profile(configuration: &configuration::Configuration, ) -> Result<models::V1WorkspaceProfile, Error<WorkspaceServiceGetWorkspaceProfileError>> {
28    let local_var_configuration = configuration;
29
30    let local_var_client = &local_var_configuration.client;
31
32    let local_var_uri_str = format!("{}/api/v1/workspace/profile", local_var_configuration.base_path);
33    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
34
35    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
36        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
37    }
38
39    let local_var_req = local_var_req_builder.build()?;
40    let local_var_resp = local_var_client.execute(local_var_req)?;
41
42    let local_var_status = local_var_resp.status();
43    let local_var_content = local_var_resp.text()?;
44
45    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
46        serde_json::from_str(&local_var_content).map_err(Error::from)
47    } else {
48        let local_var_entity: Option<WorkspaceServiceGetWorkspaceProfileError> = serde_json::from_str(&local_var_content).ok();
49        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
50        Err(Error::ResponseError(local_var_error))
51    }
52}
53