0

Edit an organization custom role

by
Published Oct 17, 2025

Edit an organization custom role

Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Edit an organization custom role
4
 * Edit an organization custom role
5
 */
6
export async function main(
7
	auth: RT.Qovery,
8
	organizationId: string,
9
	customRoleId: string,
10
	body: Body
11
) {
12
	const url = new URL(
13
		`https://api.qovery.com/organization/${organizationId}/customRole/${customRoleId}`
14
	)
15

16
	const response = await fetch(url, {
17
		method: 'PUT',
18
		headers: {
19
			'Content-Type': 'application/json',
20
			Authorization: 'Token ' + auth.apiKey
21
		},
22
		body: JSON.stringify(body)
23
	})
24
	if (!response.ok) {
25
		const text = await response.text()
26
		throw new Error(`${response.status} ${text}`)
27
	}
28
	return await response.json()
29
}
30

31
/* eslint-disable */
32
/**
33
 * This file was automatically generated by json-schema-to-typescript.
34
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
35
 * and run json-schema-to-typescript to regenerate this file.
36
 */
37

38
export interface Body {
39
	name: string
40
	description?: string
41
	/**
42
	 * Should contain an entry for every existing cluster
43
	 */
44
	cluster_permissions: {
45
		cluster_id?: string
46
		/**
47
		 * Indicates the permission for a target cluster, from the lowest to the highest:
48
		 * - `VIEWER` user has only read access on target cluster
49
		 * - `ENV_CREATOR` user can deploy on the cluster
50
		 * - `ADMIN` user can modify the cluster settings
51
		 *
52
		 */
53
		permission?: 'VIEWER' | 'ENV_CREATOR' | 'ADMIN'
54
		[k: string]: unknown
55
	}[]
56
	/**
57
	 * Should contain an entry for every existing project
58
	 */
59
	project_permissions: {
60
		project_id?: string
61
		/**
62
		 * If `is_admin` is `true`, the user is:
63
		 * - automatically `MANAGER` for each environment type
64
		 * - allowed to manage project deployment rules
65
		 * - able to delete the project
66
		 *
67
		 * Note that `permissions` can then be ignored for this project
68
		 *
69
		 */
70
		is_admin?: boolean
71
		/**
72
		 * Mandatory if `is_admin` is `false`
73
		 * Should contain an entry for every environment type:
74
		 * - `DEVELOPMENT`
75
		 * - `PREVIEW`
76
		 * - `STAGING`
77
		 * - `PRODUCTION`
78
		 *
79
		 */
80
		permissions?: {
81
			environment_type?: 'DEVELOPMENT' | 'PREVIEW' | 'PRODUCTION' | 'STAGING'
82
			/**
83
			 * Indicates the permission for a target project and a given environment type, from the lowest to the highest:
84
			 * - `NO_ACCESS` user has no access
85
			 * - `VIEWER` user can access the environment (and applications / containers / databases / variables)
86
			 * - `DEPLOYER` user can deploy the environment (dependent on the required cluster permission `ENV_CREATOR`)
87
			 * - `MANAGER` user can create an environment (and applications / containers / databases / variables)
88
			 *
89
			 */
90
			permission?: 'NO_ACCESS' | 'VIEWER' | 'DEPLOYER' | 'MANAGER'
91
			[k: string]: unknown
92
		}[]
93
		[k: string]: unknown
94
	}[]
95
	[k: string]: unknown
96
}
97