list_projects/
list-projects.rs

1use anyhow::{Context, Result};
2use circulo::{
3    ApiToken, Client, Insights, Pipeline, PipelineListRequest,
4    WorkflowListRequest, WorkflowTimeseriesRequest,
5};
6
7#[tokio::main]
8async fn main() -> Result<()> {
9    let client = Client::new(&ApiToken::from_env()?)?;
10    //eprintln!("{:?}", &client);
11
12    let res = client
13        .list_pipelines(PipelineListRequest {
14            org_slug: "gh/remind101".into(),
15            ..Default::default()
16        })
17        .await
18        .context("error listing pipelines")?;
19    //eprintln!("{:?}", &res);
20
21    for pipeline in res.items {
22        println!("{}", pipeline.project_slug);
23        let res = client
24            .list_workflows_by_pipeline_id(WorkflowListRequest {
25                pipeline_id: pipeline.id,
26                ..Default::default()
27            })
28            .await
29            .context("error getting workflows for pipeline")?;
30        //eprintln!("{:?}", &res);
31
32        for workflow in res.items {
33            println!("{}", workflow.name);
34
35            let res =
36                client.get_workflow_timeseries(WorkflowTimeseriesRequest {
37                    project_slug: workflow.project_slug,
38                    branch: Some("master".into()),
39                    ..Default::default()
40                });
41            //eprintln!("{:?}", &res);
42        }
43    }
44
45    Ok(())
46}