ShareResourceWithPrincipal
client.groups.shares.create(ShareCreateParams { principal, principalId, resourceId, 2 more } body, RequestOptionsoptions?): ShareCreateResponse
POST/gitpod.v1.GroupService/ShareResourceWithPrincipal
Shares a resource directly with a principal (user or service account).
Use this method to:
- Grant a user or service account direct access to a runner, project, or other resource
- Share resources without creating and managing groups manually
Examples
-
Share a runner with a user:
Grants admin access to a runner for a specific user.
resourceType: RESOURCE_TYPE_RUNNER resourceId: "d2c94c27-3b76-4a42-b88c-95a85e392c68" principal: PRINCIPAL_USER principalId: "f53d2330-3795-4c5d-a1f3-453121af9c60" role: RESOURCE_ROLE_RUNNER_ADMIN -
Share a runner with a service account:
Grants user access to a runner for a service account.
resourceType: RESOURCE_TYPE_RUNNER resourceId: "d2c94c27-3b76-4a42-b88c-95a85e392c68" principal: PRINCIPAL_SERVICE_ACCOUNT principalId: "a1b2c3d4-5678-90ab-cdef-1234567890ab" role: RESOURCE_ROLE_RUNNER_USER
Authorization
Requires admin role on the specific resource.
ShareResourceWithPrincipal
import Gitpod from '@gitpod/sdk';
const client = new Gitpod({
bearerToken: process.env['GITPOD_API_KEY'], // This is the default and can be omitted
});
const share = await client.groups.shares.create({
principal: 'PRINCIPAL_SERVICE_ACCOUNT',
principalId: 'a1b2c3d4-5678-90ab-cdef-1234567890ab',
resourceId: 'd2c94c27-3b76-4a42-b88c-95a85e392c68',
resourceType: 'RESOURCE_TYPE_RUNNER',
role: 'RESOURCE_ROLE_RUNNER_USER',
});
console.log(share);{}Returns Examples
{}