Skip to main content

openapi_service_fabric/apis/
mesh_code_packages_api.rs

1/*
2 * Service Fabric Client APIs
3 *
4 * Service Fabric REST Client APIs allows management of Service Fabric clusters, applications and services.
5 *
6 * The version of the OpenAPI document: 8.2
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`mesh_code_package_get_container_logs`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum MeshCodePackageGetContainerLogsError {
20    DefaultResponse(models::FabricError),
21    UnknownValue(serde_json::Value),
22}
23
24/// Gets the logs for the container of the specified code package of the service replica.
25pub async fn mesh_code_package_get_container_logs(
26    configuration: &configuration::Configuration,
27    api_version: &str,
28    application_resource_name: &str,
29    service_resource_name: &str,
30    replica_name: &str,
31    code_package_name: &str,
32    tail: Option<&str>,
33) -> Result<models::ContainerLogs, Error<MeshCodePackageGetContainerLogsError>> {
34    // add a prefix to parameters to efficiently prevent name collisions
35    let p_query_api_version = api_version;
36    let p_path_application_resource_name = application_resource_name;
37    let p_path_service_resource_name = service_resource_name;
38    let p_path_replica_name = replica_name;
39    let p_path_code_package_name = code_package_name;
40    let p_query_tail = tail;
41
42    let uri_str = format!("{}/Resources/Applications/{applicationResourceName}/Services/{serviceResourceName}/Replicas/{replicaName}/CodePackages/{codePackageName}/Logs", configuration.base_path, applicationResourceName=crate::apis::urlencode(p_path_application_resource_name), serviceResourceName=crate::apis::urlencode(p_path_service_resource_name), replicaName=crate::apis::urlencode(p_path_replica_name), codePackageName=crate::apis::urlencode(p_path_code_package_name));
43    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
44
45    req_builder = req_builder.query(&[("api-version", &p_query_api_version.to_string())]);
46    if let Some(ref param_value) = p_query_tail {
47        req_builder = req_builder.query(&[("Tail", &param_value.to_string())]);
48    }
49    if let Some(ref user_agent) = configuration.user_agent {
50        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
51    }
52
53    let req = req_builder.build()?;
54    let resp = configuration.client.execute(req).await?;
55
56    let status = resp.status();
57    let content_type = resp
58        .headers()
59        .get("content-type")
60        .and_then(|v| v.to_str().ok())
61        .unwrap_or("application/octet-stream");
62    let content_type = super::ContentType::from(content_type);
63
64    if !status.is_client_error() && !status.is_server_error() {
65        let content = resp.text().await?;
66        match content_type {
67            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
68            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ContainerLogs`"))),
69            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::ContainerLogs`")))),
70        }
71    } else {
72        let content = resp.text().await?;
73        let entity: Option<MeshCodePackageGetContainerLogsError> =
74            serde_json::from_str(&content).ok();
75        Err(Error::ResponseError(ResponseContent {
76            status,
77            content,
78            entity,
79        }))
80    }
81}