Skip to content
Ona Docs

ListMemberships

client.Groups.Memberships.List(ctx, params) (*MembersPage[GroupMembership], error)
POST/gitpod.v1.GroupService/ListMemberships

Lists all memberships of a group.

Use this method to:

  • View all members of a group
  • Audit group membership

Examples

  • List group members:

    Shows all members of a specific group.

    groupId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
    pagination:
      pageSize: 20

Authorization

All organization members can view group membership (transparency model).

ParametersExpand Collapse
params GroupMembershipListParams
Token param.Field[string]Optional

Query param

PageSize param.Field[int64]Optional

Query param

maximum100
minimum0
Filter param.Field[GroupMembershipListParamsFilter]Optional

Body param: filter contains options for filtering the list of memberships.

GroupID param.Field[string]Optional

Body param

formatuuid
ReturnsExpand Collapse
type GroupMembership struct{…}

GroupMembership represents a subject’s membership in a group

ID stringOptional

Unique identifier for the group membership

formatuuid
AvatarURL stringOptional

Subject’s avatar URL

GroupID stringOptional

Group identifier

formatuuid
Name stringOptional

Subject’s display name

Subject SubjectOptional

Subject (user, runner, environment, service account, etc.)

ID stringOptional

id is the UUID of the subject

formatuuid
Principal PrincipalOptional

Principal is the principal of the subject

One of the following:
const PrincipalUnspecified Principal = "PRINCIPAL_UNSPECIFIED"
const PrincipalAccount Principal = "PRINCIPAL_ACCOUNT"
const PrincipalUser Principal = "PRINCIPAL_USER"
const PrincipalRunner Principal = "PRINCIPAL_RUNNER"
const PrincipalEnvironment Principal = "PRINCIPAL_ENVIRONMENT"
const PrincipalServiceAccount Principal = "PRINCIPAL_SERVICE_ACCOUNT"
const PrincipalRunnerManager Principal = "PRINCIPAL_RUNNER_MANAGER"

ListMemberships

package main

import (
  "context"
  "fmt"

  "github.com/gitpod-io/gitpod-sdk-go"
  "github.com/gitpod-io/gitpod-sdk-go/option"
)

func main() {
  client := gitpod.NewClient(
    option.WithBearerToken("My Bearer Token"),
  )
  page, err := client.Groups.Memberships.List(context.TODO(), gitpod.GroupMembershipListParams{
    GroupID: gitpod.F("d2c94c27-3b76-4a42-b88c-95a85e392c68"),
    Pagination: gitpod.F(gitpod.GroupMembershipListParamsPagination{
      PageSize: gitpod.F(int64(20)),
    }),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
{
  "members": [
    {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "avatarUrl": "avatarUrl",
      "groupId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "name": "name",
      "subject": {
        "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
        "principal": "PRINCIPAL_UNSPECIFIED"
      }
    }
  ],
  "pagination": {
    "nextToken": "nextToken"
  }
}
Returns Examples
{
  "members": [
    {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "avatarUrl": "avatarUrl",
      "groupId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "name": "name",
      "subject": {
        "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
        "principal": "PRINCIPAL_UNSPECIFIED"
      }
    }
  ],
  "pagination": {
    "nextToken": "nextToken"
  }
}