// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!

use serde::{Deserialize, Serialize};
use serde_urlencoded;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ProjectMetric {
    pub metric_type: ProjectMetricMetricType,
    pub count: u32,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct MetricsRequest {}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MetricsResponse {
    pub request_id: String,
    pub project_id: String,
    pub metrics: std::vec::Vec<ProjectMetric>,
    #[serde(with = "http_serde::status_code")]
    pub status_code: http::StatusCode,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub enum ProjectMetricMetricType {
    #[serde(rename = "UNKNOWN")]
    #[default]
    UNKNOWN,
    #[serde(rename = "USER_COUNT")]
    USERCOUNT,
    #[serde(rename = "ORGANIZATION_COUNT")]
    ORGANIZATIONCOUNT,
    #[serde(rename = "MEMBER_COUNT")]
    MEMBERCOUNT,
    #[serde(rename = "M2M_CLIENT_COUNT")]
    M2MCLIENTCOUNT,
}

pub struct Project {
    http_client: crate::client::Client,
}

impl Project {
    pub fn new(http_client: crate::client::Client) -> Self {
        Self {
            http_client: http_client.clone(),
        }
    }

    pub async fn metrics(&self, body: MetricsRequest) -> crate::Result<MetricsResponse> {
        let path = format!(
            "/v1/projects/metrics?{}",
            serde_urlencoded::to_string(body).unwrap()
        );
        self.http_client
            .send(crate::Request {
                method: http::Method::GET,
                path,
                body: serde_json::json!({}),
            })
            .await
    }
}
