Edits history of script submission #20324 for ' Update an organization members team role (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Update an organization members team role
     * The relevant organization member must already be a part of the team.
    
    Note that for organization admins, managers, and owners, they are
    automatically granted a minimum team role of `admin` on all teams they
    are part of. Read more about [team roles](https://docs.sentry.io/product/teams/roles/).
     */
    export async function main(
    	auth: RT.Sentry,
    	member_id: string,
    	team_id_or_slug: string,
    	body: Body
    ) {
    	const url = new URL(
    		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/members/${member_id}/teams/${team_id_or_slug}/`
    	)
    
    	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 team-level role to switch to. Valid roles include:
    	 *
    	 * * `contributor` - Contributors can view and act on events, as well as view most other data within the team's projects.
    	 * * `admin` - Admin privileges on the team. They can create and remove projects, and can manage the team's memberships.
    	 */
    	teamRole?: 'contributor' | 'admin'
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago