octocrab
octocrab copied to clipboard
Add method for downloading job logs
The existing download_workflow_run_logs method in actions() allows downloading logs for the full run.
It would be great to be able to download logs for a job: https://api.github.com/repos/:owner/:repo/actions/jobs/:job_id/logs
My workaround:
pub async fn get_job_logs(repo: &Repository, job_id: u64) -> Result<hyper::body::Bytes> {
let client = octocrab::instance();
let route = format!(
"/repos/{owner}/{repo}/actions/jobs/{job_id}/logs",
owner = repo.owner,
repo = repo.name,
job_id = job_id,
);
let uri = Uri::builder().path_and_query(route).build()?;
let data_response = client
.follow_location_to_data(client._get(uri).await?)
.await?;
let body = data_response.into_body();
body::to_bytes(body).await.map_err(Into::into)
}
Good thing the internal methods like _get and follow_location_to_data are exposed.
Thank you for your issue! I don't have time to add this myself, but I'd be happy to review and accept a PR adding it (generally the convention should follow octokit.js)
Good thing the internal methods like _get and follow_location_to_data are exposed.
Yes, this is an intentional design decision so that you never have to fork Octocrab to add a method that might be new or missing.
Hi, I'd like to work on this one if you don't mind @XAMPPRocky
Feel free to make a PR 🙂