Skip to content
Ona Docs

CreateRunnerPolicy

client.Runners.Policies.New(ctx, body) (*RunnerPolicyNewResponse, error)
POST/gitpod.v1.RunnerService/CreateRunnerPolicy

Creates a new policy for a runner.

Use this method to:

  • Set up access controls
  • Define group permissions
  • Configure role-based access

Examples

  • Create admin policy:

    Grants admin access to a group.

    runnerId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
    groupId: "f53d2330-3795-4c5d-a1f3-453121af9c60"
    role: RUNNER_ROLE_ADMIN
ParametersExpand Collapse
body RunnerPolicyNewParams
GroupID param.Field[string]Optional

group_id specifies the group_id identifier

formatuuid
Role param.Field[RunnerRole]Optional
RunnerID param.Field[string]Optional

runner_id specifies the project identifier

formatuuid
ReturnsExpand Collapse
type RunnerPolicyNewResponse struct{…}
GroupID stringOptional
formatuuid
Role RunnerRoleOptional

role is the role assigned to the group

One of the following:
const RunnerRoleUnspecified RunnerRole = "RUNNER_ROLE_UNSPECIFIED"
const RunnerRoleAdmin RunnerRole = "RUNNER_ROLE_ADMIN"
const RunnerRoleUser RunnerRole = "RUNNER_ROLE_USER"

CreateRunnerPolicy

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"),
  )
  policy, err := client.Runners.Policies.New(context.TODO(), gitpod.RunnerPolicyNewParams{
    GroupID: gitpod.F("f53d2330-3795-4c5d-a1f3-453121af9c60"),
    Role: gitpod.F(gitpod.RunnerRoleAdmin),
    RunnerID: gitpod.F("d2c94c27-3b76-4a42-b88c-95a85e392c68"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", policy.Policy)
}
{
  "policy": {
    "groupId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "role": "RUNNER_ROLE_UNSPECIFIED"
  }
}
Returns Examples
{
  "policy": {
    "groupId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
    "role": "RUNNER_ROLE_UNSPECIFIED"
  }
}