Add channels and platforms to job_show API endpoint
@@ -22,7 +22,7 @@ use bld_core;
use bld_core::api::{channels_for_package_ident, platforms_for_package_ident,
promote_job_group_to_channel};
use depot::server::check_origin_access;
-use hab_core::package::Plan;
+use hab_core::package::{Identifiable, Plan};
use hab_core::event::*;
use hab_net;
use hab_net::http::controller::*;
@@ -248,7 +248,25 @@ pub fn job_show(req: &mut Request) -> IronResult<Response> {
let mut request = JobGet::new();
request.set_id(id);
match conn.route::<JobGet, Job>(&request) {
- Ok(job) => Ok(render_json(status::Ok, &job)),
+ Ok(job) => {
+ if job.get_package_ident().fully_qualified() {
+ let channels = channels_for_package_ident(job.get_package_ident());
+ let platforms = platforms_for_package_ident(job.get_package_ident());
+ let mut job_json = serde_json::to_value(job).unwrap();
+
+ if channels.is_some() {
+ job_json["channels"] = json!(channels);
+ }
+
+ if platforms.is_some() {
+ job_json["platforms"] = json!(platforms);
+ }
+
+ Ok(render_json(status::Ok, &job_json))
+ } else {
+ Ok(render_json(status::Ok, &job))
+ }
+ }
Err(err) => Ok(render_net_error(&err)),
}
}
