Edits history of script submission #20323 for ' Update an organization members roles (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Update an organization members roles
     * Update a member's [organization-level](https://docs.
     */
    export async function main(auth: RT.Sentry, member_id: string, body: Body) {
    	const url = new URL(
    		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/members/${member_id}/`
    	)
    
    	const response = await fetch(url, {
    		method: 'PUT',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.token
    		},
    		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 {
    	/**
    	 * The organization role of the member. The options are:
    	 *
    	 * * `billing` - Can manage payment and compliance details.
    	 * * `member` - Can view and act on events, as well as view most other data within the organization.
    	 * * `manager` - Has full management access to all teams and projects. Can also manage
    	 *         the organization's membership.
    	 * * `owner` - Has unrestricted access to the organization, its data, and its
    	 *         settings. Can add, modify, and delete projects and members, as well as
    	 *         make billing and plan changes.
    	 * * `admin` - Can edit global integrations, manage projects, and add/remove teams.
    	 *         They automatically assume the Team Admin role for teams they join.
    	 *         Note: This role can no longer be assigned in Business and Enterprise plans. Use `TeamRoles` instead.
    	 *
    	 */
    	orgRole?: 'billing' | 'member' | 'manager' | 'owner' | 'admin'
    	/**
    	 *
    	 * Configures the team role of the member. The two roles are:
    	 * - `contributor` - Can view and act on issues. Depending on organization settings, they can also add team members.
    	 * - `admin` - Has full management access to their team's membership and projects.
    	 * ```json
    	 * {
    	 *     "teamRoles": [
    	 *         {
    	 *             "teamSlug": "ancient-gabelers",
    	 *             "role": "admin"
    	 *         },
    	 *         {
    	 *             "teamSlug": "powerful-abolitionist",
    	 *             "role": "contributor"
    	 *         }
    	 *     ]
    	 * }
    	 * ```
    	 *
    	 */
    	teamRoles?: {
    		[k: string]: unknown
    	}[]
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago