Edits history of script submission #18269 for ' Edit an organization custom role (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Edit an organization custom role
     * Edit an organization custom role
     */
    export async function main(
    	auth: RT.Qovery,
    	organizationId: string,
    	customRoleId: string,
    	body: Body
    ) {
    	const url = new URL(
    		`https://api.qovery.com/organization/${organizationId}/customRole/${customRoleId}`
    	)
    
    	const response = await fetch(url, {
    		method: 'PUT',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Token ' + auth.apiKey
    		},
    		body: JSON.stringify(body)
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    
    /* eslint-disable */
    /**
     * This file was automatically generated by json-schema-to-typescript.
     * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
     * and run json-schema-to-typescript to regenerate this file.
     */
    
    export interface Body {
    	name: string
    	description?: string
    	/**
    	 * Should contain an entry for every existing cluster
    	 */
    	cluster_permissions: {
    		cluster_id?: string
    		/**
    		 * Indicates the permission for a target cluster, from the lowest to the highest:
    		 * - `VIEWER` user has only read access on target cluster
    		 * - `ENV_CREATOR` user can deploy on the cluster
    		 * - `ADMIN` user can modify the cluster settings
    		 *
    		 */
    		permission?: 'VIEWER' | 'ENV_CREATOR' | 'ADMIN'
    		[k: string]: unknown
    	}[]
    	/**
    	 * Should contain an entry for every existing project
    	 */
    	project_permissions: {
    		project_id?: string
    		/**
    		 * If `is_admin` is `true`, the user is:
    		 * - automatically `MANAGER` for each environment type
    		 * - allowed to manage project deployment rules
    		 * - able to delete the project
    		 *
    		 * Note that `permissions` can then be ignored for this project
    		 *
    		 */
    		is_admin?: boolean
    		/**
    		 * Mandatory if `is_admin` is `false`
    		 * Should contain an entry for every environment type:
    		 * - `DEVELOPMENT`
    		 * - `PREVIEW`
    		 * - `STAGING`
    		 * - `PRODUCTION`
    		 *
    		 */
    		permissions?: {
    			environment_type?: 'DEVELOPMENT' | 'PREVIEW' | 'PRODUCTION' | 'STAGING'
    			/**
    			 * Indicates the permission for a target project and a given environment type, from the lowest to the highest:
    			 * - `NO_ACCESS` user has no access
    			 * - `VIEWER` user can access the environment (and applications / containers / databases / variables)
    			 * - `DEPLOYER` user can deploy the environment (dependent on the required cluster permission `ENV_CREATOR`)
    			 * - `MANAGER` user can create an environment (and applications / containers / databases / variables)
    			 *
    			 */
    			permission?: 'NO_ACCESS' | 'VIEWER' | 'DEPLOYER' | 'MANAGER'
    			[k: string]: unknown
    		}[]
    		[k: string]: unknown
    	}[]
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago