CreateRoleAssignment
client.Groups.RoleAssignments.New(ctx, body) (*GroupRoleAssignmentNewResponse, error)
POST/gitpod.v1.GroupService/CreateRoleAssignment
Creates a role assignment for a group on a resource.
Use this method to:
- Assign specific roles to groups on runners, projects, or environments
- Grant group-based access to resources
Examples
-
Assign admin role on a runner:
Grants the group admin access to a runner.
groupId: "d2c94c27-3b76-4a42-b88c-95a85e392c68" resourceType: RESOURCE_TYPE_RUNNER resourceId: "f53d2330-3795-4c5d-a1f3-453121af9c60" resourceRole: RESOURCE_ROLE_RUNNER_ADMIN -
Assign user role on a project:
Grants the group user access to a project.
groupId: "d2c94c27-3b76-4a42-b88c-95a85e392c68" resourceType: RESOURCE_TYPE_PROJECT resourceId: "a1b2c3d4-5678-90ab-cdef-1234567890ab" resourceRole: RESOURCE_ROLE_PROJECT_USER
Authorization
Requires admin role on the specific resource.
ParametersExpand Collapse
ReturnsExpand Collapse
type GroupRoleAssignmentNewResponse struct{…}
type GroupRoleAssignmentNewResponse struct{…}
RoleAssignment represents a role assigned to a group on a specific resource
RoleAssignment represents a role assigned to a group on a specific resource
The org-level role that created this assignment, if any.
RESOURCE_ROLE_UNSPECIFIED means this is a direct share (manually created).
Non-zero (e.g., ORG_PROJECTS_ADMIN, ORG_RUNNERS_ADMIN) means this
assignment was derived from an org-level role.
The org-level role that created this assignment, if any. RESOURCE_ROLE_UNSPECIFIED means this is a direct share (manually created). Non-zero (e.g., ORG_PROJECTS_ADMIN, ORG_RUNNERS_ADMIN) means this assignment was derived from an org-level role.
One of the following:
const ResourceRoleRunnerConfigurationReader ResourceRole = "RESOURCE_ROLE_RUNNER_CONFIGURATION_READER"
const ResourceRoleHostAuthenticationTokenAdmin ResourceRole = "RESOURCE_ROLE_HOST_AUTHENTICATION_TOKEN_ADMIN"
const ResourceRoleHostAuthenticationTokenUpdater ResourceRole = "RESOURCE_ROLE_HOST_AUTHENTICATION_TOKEN_UPDATER"
const ResourceRoleEnvironmentServiceViewer ResourceRole = "RESOURCE_ROLE_ENVIRONMENT_SERVICE_VIEWER"
const ResourceRoleAgentExecutionOutputsReporter ResourceRole = "RESOURCE_ROLE_AGENT_EXECUTION_OUTPUTS_REPORTER"
Role assigned to the group on this resource
Role assigned to the group on this resource
One of the following:
const ResourceRoleRunnerConfigurationReader ResourceRole = "RESOURCE_ROLE_RUNNER_CONFIGURATION_READER"
const ResourceRoleHostAuthenticationTokenAdmin ResourceRole = "RESOURCE_ROLE_HOST_AUTHENTICATION_TOKEN_ADMIN"
const ResourceRoleHostAuthenticationTokenUpdater ResourceRole = "RESOURCE_ROLE_HOST_AUTHENTICATION_TOKEN_UPDATER"
const ResourceRoleEnvironmentServiceViewer ResourceRole = "RESOURCE_ROLE_ENVIRONMENT_SERVICE_VIEWER"
const ResourceRoleAgentExecutionOutputsReporter ResourceRole = "RESOURCE_ROLE_AGENT_EXECUTION_OUTPUTS_REPORTER"
Type of resource (runner, project, environment, etc.)
Type of resource (runner, project, environment, etc.)
One of the following:
const ResourceTypeOrganizationLlmIntegration ResourceType = "RESOURCE_TYPE_ORGANIZATION_LLM_INTEGRATION"
CreateRoleAssignment
package main
import (
"context"
"fmt"
"github.com/gitpod-io/gitpod-sdk-go"
"github.com/gitpod-io/gitpod-sdk-go/option"
"github.com/gitpod-io/gitpod-sdk-go/shared"
)
func main() {
client := gitpod.NewClient(
option.WithBearerToken("My Bearer Token"),
)
roleAssignment, err := client.Groups.RoleAssignments.New(context.TODO(), gitpod.GroupRoleAssignmentNewParams{
GroupID: gitpod.F("d2c94c27-3b76-4a42-b88c-95a85e392c68"),
ResourceID: gitpod.F("f53d2330-3795-4c5d-a1f3-453121af9c60"),
ResourceRole: gitpod.F(shared.ResourceRoleRunnerAdmin),
ResourceType: gitpod.F(shared.ResourceTypeRunner),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", roleAssignment.Assignment)
}
{
"assignment": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"derivedFromOrgRole": "RESOURCE_ROLE_UNSPECIFIED",
"groupId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"organizationId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"resourceId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"resourceRole": "RESOURCE_ROLE_UNSPECIFIED",
"resourceType": "RESOURCE_TYPE_UNSPECIFIED"
}
}Returns Examples
{
"assignment": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"derivedFromOrgRole": "RESOURCE_ROLE_UNSPECIFIED",
"groupId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"organizationId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"resourceId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"resourceRole": "RESOURCE_ROLE_UNSPECIFIED",
"resourceType": "RESOURCE_TYPE_UNSPECIFIED"
}
}