Edits history of script submission #20314 for ' Update a teams attributes (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Update a teams attributes
     * Update a team's attributes with a SCIM Group PATCH Request.
     */
    export async function main(auth: RT.Sentry, team_id_or_slug: string, body: Body) {
    	const url = new URL(
    		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/scim/v2/Groups/${team_id_or_slug}`
    	)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		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.text()
    }
    
    /* 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 list of operations to perform. Valid operations are:
    	 * * Renaming a team:
    	 * ```json
    	 * {
    	 *     "Operations": [{
    	 *         "op": "replace",
    	 *         "value": {
    	 *             "id": 23,
    	 *             "displayName": "newName"
    	 *         }
    	 *     }]
    	 * }
    	 * ```
    	 * * Adding a member to a team:
    	 * ```json
    	 * {
    	 *     "Operations": [{
    	 *         "op": "add",
    	 *         "path": "members",
    	 *         "value": [
    	 *             {
    	 *                 "value": 23,
    	 *                 "display": "testexample@example.com"
    	 *             }
    	 *         ]
    	 *     }]
    	 * }
    	 * ```
    	 * * Removing a member from a team:
    	 * ```json
    	 * {
    	 *     "Operations": [{
    	 *         "op": "remove",
    	 *         "path": "members[value eq "23"]"
    	 *     }]
    	 * }
    	 * ```
    	 * * Replacing an entire member set of a team:
    	 * ```json
    	 * {
    	 *     "Operations": [{
    	 *         "op": "replace",
    	 *         "path": "members",
    	 *         "value": [
    	 *             {
    	 *                 "value": 23,
    	 *                 "display": "testexample2@sentry.io"
    	 *             },
    	 *             {
    	 *                 "value": 24,
    	 *                 "display": "testexample3@sentry.io"
    	 *             }
    	 *         ]
    	 *     }]
    	 * }
    	 * ```
    	 *
    	 */
    	Operations: {
    		op: string
    		value?: {
    			[k: string]: unknown
    		}
    		path?: string
    		[k: string]: unknown
    	}[]
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago