Skip to main content

harbor_api/apis/
oidc_api.rs

1/*
2 * Harbor API
3 *
4 * These APIs provide services for manipulating Harbor project.
5 *
6 * The version of the OpenAPI document: 2.0
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/// struct for passing parameters to the method [`ping_oidc`]
18#[derive(Clone, Debug)]
19pub struct PingOidcParams {
20    /// Request body for OIDC endpoint to be tested.
21    pub endpoint: models::PingOidcRequest,
22    /// An unique ID for the request
23    pub x_request_id: Option<String>
24}
25
26
27/// struct for typed errors of method [`ping_oidc`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum PingOidcError {
31    Status400(models::Errors),
32    Status401(models::Errors),
33    Status403(models::Errors),
34    UnknownValue(serde_json::Value),
35}
36
37
38/// Test the OIDC endpoint, the setting of the endpoint is provided in the request.  This API can only be called by system admin. 
39pub async fn ping_oidc(configuration: &configuration::Configuration, params: PingOidcParams) -> Result<(), Error<PingOidcError>> {
40
41    let uri_str = format!("{}/system/oidc/ping", configuration.base_path);
42    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
43
44    if let Some(ref user_agent) = configuration.user_agent {
45        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
46    }
47    if let Some(param_value) = params.x_request_id {
48        req_builder = req_builder.header("X-Request-Id", param_value.to_string());
49    }
50    if let Some(ref auth_conf) = configuration.basic_auth {
51        req_builder = req_builder.basic_auth(auth_conf.0.to_owned(), auth_conf.1.to_owned());
52    };
53    req_builder = req_builder.json(&params.endpoint);
54
55    let req = req_builder.build()?;
56    let resp = configuration.client.execute(req).await?;
57
58    let status = resp.status();
59
60    if !status.is_client_error() && !status.is_server_error() {
61        Ok(())
62    } else {
63        let content = resp.text().await?;
64        let entity: Option<PingOidcError> = serde_json::from_str(&content).ok();
65        Err(Error::ResponseError(ResponseContent { status, content, entity }))
66    }
67}
68