Skip to content
Ona Docs

SetRole

client.Organizations.SetRole(ctx, body) (*OrganizationSetRoleResponse, error)
POST/gitpod.v1.OrganizationService/SetRole

Manages organization membership and roles by setting a user’s role within the organization.

Use this method to:

  • Promote members to admin role
  • Change member permissions
  • Demote admins to regular members

Examples

  • Promote to admin:

    Makes a user an organization administrator.

    organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
    userId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
    role: ORGANIZATION_ROLE_ADMIN
  • Change to member:

    Changes a user’s role to regular member.

    organizationId: "b0e12f6c-4c67-429d-a4a6-d9838b5da047"
    userId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
    role: ORGANIZATION_ROLE_MEMBER
ParametersExpand Collapse
body OrganizationSetRoleParams
OrganizationID param.Field[string]
formatuuid
UserID param.Field[string]
formatuuid
Role param.Field[OrganizationRole]Optional
ReturnsExpand Collapse
type OrganizationSetRoleResponse interface{…}

SetRole

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"),
  )
  response, err := client.Organizations.SetRole(context.TODO(), gitpod.OrganizationSetRoleParams{
    OrganizationID: gitpod.F("b0e12f6c-4c67-429d-a4a6-d9838b5da047"),
    UserID: gitpod.F("f53d2330-3795-4c5d-a1f3-453121af9c60"),
    Role: gitpod.F(shared.OrganizationRoleMember),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response)
}
{}
Returns Examples
{}