OctopusDeploy / go-octopusdeploy

| Public | Go API Client for Octopus Deploy :octopus:

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to get projects within a project group and releases within a project

tomasmota opened this issue · comments

problem
Maybe I am missing something, but I am not able to get all projects within a project group. I would also like to get releases within a specific project and deployments for a given release. This sounds like a basic thing to ask for, but it does seem like the rest api does not really support this either...

solutions
I would either like to be able to get a list of project ID's within a project group, like so:
(pg *ProjectGroup) GetProjects() []*Project
or
(pg *ProjectGroup) GetProjectIDs() []someid

Another option would be through the services, adding a field to the query, for the projects it would look like this instead:
type ProjectsQuery struct { . . ProjectGroupID string . . }

It is really frustrating that there is no way to do this out of the box, please let me know if there is and I just did not find it.

Hi Tomas

The ProjectGroupService has a GetProjects method on it, which returns a list of all the projects within that group.

The invocation should look something like this:

var err error
var group1 *projectgroups.ProjectGroup
var projectsInGroup1 []*projects.Project

group1, err = octopusApiClient.ProjectGroups.GetById("ProjectGroups-1")
projectsInGroup1, err = octopusApiClient.ProjectGroups.GetProjects(group1)

[Disclaimer: the above code is a rough example, it may contain minor syntax errors]

Here's the function itself in the API client:

func (s *ProjectGroupService) GetProjects(projectGroup *ProjectGroup) ([]*projects.Project, error) {

Kind regards

Orion