Edits history of script submission #20159 for ' Create an external user (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create an external user
     * Link a user from an external provider to a Sentry user.
     */
    export async function main(auth: RT.Sentry, body: Body) {
    	const url = new URL(
    		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/external-users/`
    	)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		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.
     */
    
    /**
     * Allows parameters to be defined in snake case, but passed as camel case.
     *
     * Errors are output in camel case.
     */
    export interface Body {
    	/**
    	 * The user ID in Sentry.
    	 */
    	user_id: number
    	/**
    	 * The associated name for the provider.
    	 */
    	external_name: string
    	/**
    	 * The provider of the external actor.
    	 *
    	 * * `github`
    	 * * `github_enterprise`
    	 * * `jira_server`
    	 * * `slack`
    	 * * `gitlab`
    	 * * `msteams`
    	 * * `custom_scm`
    	 */
    	provider:
    		| 'github'
    		| 'github_enterprise'
    		| 'jira_server'
    		| 'slack'
    		| 'gitlab'
    		| 'msteams'
    		| 'custom_scm'
    	/**
    	 * The Integration ID.
    	 */
    	integration_id: number
    	/**
    	 * The external actor ID.
    	 */
    	id: number
    	/**
    	 * The associated user ID for provider.
    	 */
    	external_id?: string
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago