Recreate dashboard using API

I’m looking to embed some info about the status of deployments on a different internal site and was wondering if the 1.6 version of the rest API could easily let me recreate the current Octopus Dashboard? This would mean a couple of calls to get list of projects and the current release of that project for each environment. I don’t see a real easy way to look up this info in the API.

1 Like

Hi,

You can use /api/projects' and/api/environments` to get the projects and environments. Each project resource also includes a link to its ‘most recent deployments’ resource. You can GET that to see the latest deployments per environment (this is what you need for the dashboard items).

Hope that helps,

Paul

I see, didn’t realize that recent deployments was filtered down to the most recent deployment per environment and not just the last 10 deployments. The name threw me off.

Thanks

Sweet, I created a simple JS widget that will recreate the dashboard version widget.
Here is jsfiddle, you need to replace the server info with your info, but works great.
Thanks!

http://jsfiddle.net/JKMHD/

Hi Groberts,

The jsfiddle is not available anymore. Can you share it again?

Thank you!

Hi,

Thanks for reaching out. I’m not sure what was on the jsfiddle, but judging from the rest of the conversation, what you are looking for is for a way to re-create the Octopus dashboard, is that correct?

If that is the case, do a GET to /api/dashboard and you’ll get a big JSON with all the content needed to re-create it.

Let me know if that’s now what you were looking for

Dalmiro

I’ve done something with the Octopus.Client .net client for work to provide view access to the deployment details for users that do not have access to our prod network and setup cache and timer to refresh the data on a specific interval.

using Octopus.Client;
using Octopus.Client.Model;

private List<Octopus.Client.Model.ProjectResource> source;
public Octopus.Client.Model.DashboardResource deployments { get; set; }
public Dictionary<string, string> projects { get; set; }
public Dictionary<string, string> environments { get; set; }
public Dictionary<string, string> projectGroups { get; set; }
public Dictionary<string, string> projectsByGroup { get; set; }
...
OctopusRepository octopus;
octopus = new OctopusRepository(new OctopusServerEndpoint(serverURL, serverAPIKey));
source = octopus.Projects.FindAll();
projects = source.ToDictionary(p => p.Id, p => p.Name);
projectsByGroup = source.ToDictionary(p => p.Id, p => p.ProjectGroupId);
projectGroups = octopus.ProjectGroups.FindAll().ToDictionary(p => p.Id, p => p.Name);
environments = octopus.Environments.FindAll().ToDictionary(p => p.Id, p => p.Name);
deployments = octopus.Dashboards.GetDynamicDashboard(projects.Keys.ToArray(), environments.Keys.ToArray());
log.InfoFormat("Deployments Count: {0}", deployments.Items.Count);

From the above data, we just build the code to present the information that we wanted from the various elements.

Hope this helps.

Hi Dalmiro,

Is it still possible to get JSON in this way? I tried last month and it was working. But now I get page not found message. Kindly check the attachment.

Waiting for your response!

The problem is solved. The issue was my address. :slight_smile: