go-octopusdeploy icon indicating copy to clipboard operation
go-octopusdeploy copied to clipboard

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

Open tomasmota opened this issue 2 years ago • 1 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.

tomasmota avatar Oct 05 '22 19:10 tomasmota

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:

https://github.com/OctopusDeploy/go-octopusdeploy/blob/dfe00b07649bb1a061759aad3086a372d6c6da9b/pkg/projectgroups/project_group_service.go#L111

Kind regards

Orion

borland avatar Oct 05 '22 21:10 borland