#![allow(dead_code)]
use anyhow::Context;
use atlassian_cli_api::ApiClient;
use atlassian_cli_output::OutputRenderer;
use serde::Deserialize;
pub struct BambooContext<'a> {
pub client: ApiClient,
pub renderer: &'a OutputRenderer,
}
impl BambooContext<'_> {
pub async fn verify_auth(&self) -> anyhow::Result<()> {
let _: serde_json::Value = self
.client
.get("/rest/api/latest/info")
.await
.context("Failed to verify Bamboo access. Run: atlassian-cli auth test")?;
Ok(())
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct Project {
pub key: String,
pub name: String,
#[serde(default)]
pub description: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Plan {
pub key: String,
#[serde(rename = "shortKey")]
pub short_key: Option<String>,
pub name: String,
#[serde(default)]
pub description: Option<String>,
#[serde(rename = "projectKey")]
pub project_key: Option<String>,
#[serde(rename = "projectName")]
pub project_name: Option<String>,
pub enabled: Option<bool>,
#[serde(rename = "isBuilding")]
pub is_building: Option<bool>,
#[serde(rename = "averageBuildTimeInSeconds")]
pub average_build_time: Option<i64>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Branch {
pub key: String,
#[serde(rename = "shortKey")]
pub short_key: Option<String>,
pub name: String,
#[serde(default)]
pub description: Option<String>,
pub enabled: Option<bool>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct BuildResult {
#[serde(rename = "buildResultKey")]
pub build_result_key: String,
#[serde(rename = "planKey")]
pub plan_key: Option<PlanKey>,
#[serde(rename = "buildNumber")]
pub build_number: i64,
#[serde(rename = "buildState")]
pub build_state: Option<String>,
pub state: Option<String>,
#[serde(rename = "lifeCycleState")]
pub life_cycle_state: Option<String>,
#[serde(rename = "buildStartedTime")]
pub build_started_time: Option<String>,
#[serde(rename = "buildCompletedTime")]
pub build_completed_time: Option<String>,
#[serde(rename = "buildDurationInSeconds")]
pub build_duration: Option<i64>,
#[serde(rename = "reasonSummary")]
pub reason_summary: Option<String>,
#[serde(rename = "successfulTestCount")]
pub successful_test_count: Option<i64>,
#[serde(rename = "failedTestCount")]
pub failed_test_count: Option<i64>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct PlanKey {
pub key: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Agent {
pub id: i64,
pub name: String,
#[serde(rename = "type")]
pub agent_type: Option<String>,
pub active: Option<bool>,
pub enabled: Option<bool>,
pub busy: Option<bool>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct DeploymentProject {
pub id: i64,
pub name: String,
#[serde(default)]
pub description: Option<String>,
#[serde(rename = "planKey")]
pub plan_key: Option<PlanKeyWrapper>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct PlanKeyWrapper {
pub key: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Environment {
pub id: i64,
pub name: String,
#[serde(default)]
pub description: Option<String>,
#[serde(rename = "deploymentProjectId")]
pub deployment_project_id: Option<i64>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct DeploymentResult {
pub id: i64,
#[serde(rename = "deploymentVersion")]
pub deployment_version: Option<DeploymentVersion>,
#[serde(rename = "deploymentVersionName")]
pub deployment_version_name: Option<String>,
#[serde(rename = "deploymentState")]
pub deployment_state: Option<String>,
#[serde(rename = "lifeCycleState")]
pub life_cycle_state: Option<String>,
#[serde(rename = "startedDate")]
pub started_date: Option<i64>,
#[serde(rename = "finishedDate")]
pub finished_date: Option<i64>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct DeploymentVersion {
pub id: i64,
pub name: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ServerInfo {
pub version: Option<String>,
pub edition: Option<String>,
#[serde(rename = "buildDate")]
pub build_date: Option<String>,
#[serde(rename = "buildNumber")]
pub build_number: Option<String>,
pub state: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ListResponse<T> {
pub size: Option<i64>,
#[serde(rename = "max-result")]
pub max_result: Option<i64>,
#[serde(rename = "start-index")]
pub start_index: Option<i64>,
#[serde(flatten)]
pub items: T,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ProjectsWrapper {
pub project: Option<Vec<Project>>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct PlansWrapper {
pub plan: Option<Vec<Plan>>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct BranchesWrapper {
pub branch: Option<Vec<Branch>>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ResultsWrapper {
pub result: Option<Vec<BuildResult>>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ResultsContainer {
pub results: ResultsWrapper,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Artifact {
pub name: String,
pub link: Option<ArtifactLink>,
#[serde(rename = "producerJobKey")]
pub producer_job_key: Option<String>,
pub shared: Option<bool>,
pub size: Option<i64>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ArtifactLink {
pub href: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ArtifactsContainer {
pub artifact: Option<Vec<Artifact>>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct BuildWithArtifacts {
#[serde(rename = "buildResultKey")]
pub build_result_key: String,
pub artifacts: Option<ArtifactsContainer>,
}