// Code generated by oagen. DO NOT EDIT.

use crate::client::Retab;
#[allow(unused_imports)]
use crate::enums::*;
use crate::error::Error;
#[allow(unused_imports)]
use crate::models::*;
use serde::Serialize;

pub struct ExperimentRunMetricsApi<'a> {
    pub(crate) client: &'a Retab,
}

#[derive(Debug, Clone, Serialize)]
pub struct GetParams {
    /// Required.
    pub run_id: String,
    /// Defaults to `summary`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub view: Option<ExperimentRunMetricsView>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub document_id: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub target_path: Option<String>,
    /// Defaults to `true`.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub include_prior: Option<bool>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub prior_run_id: Option<String>,
}

impl GetParams {
    /// Construct a new `GetParams` with the required fields set.
    #[allow(deprecated)]
    pub fn new(run_id: impl Into<String>) -> Self {
        Self {
            run_id: run_id.into(),
            view: Some(ExperimentRunMetricsView::Summary),
            document_id: Default::default(),
            target_path: Default::default(),
            include_prior: Some(true),
            prior_run_id: Default::default(),
        }
    }
}

impl<'a> ExperimentRunMetricsApi<'a> {
    /// Get Experiment Metrics For Run
    pub async fn get(&self, params: GetParams) -> Result<serde_json::Value, Error> {
        self.get_with_options(params, None).await
    }

    /// Variant of [`Self::get`] that accepts per-request [`crate::RequestOptions`].
    pub async fn get_with_options(
        &self,
        params: GetParams,
        options: Option<&crate::RequestOptions>,
    ) -> Result<serde_json::Value, Error> {
        let path = "/v1/workflows/experiments/metrics".to_string();
        let method = http::Method::GET;
        self.client
            .request_with_query_opts(method, &path, &params, options)
            .await
    }
}
