Edits history of script submission #20153 for ' Create a new project (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create a new project
     * Create a new project bound to a team.
    
            Note: If your organization has disabled member project creation, the `org:write` or `team:admin` scope is required.
            
     */
    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/teams/${auth.organizationSlug}/${team_id_or_slug}/projects/`
    	)
    
    	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.
     */
    
    export interface Body {
    	/**
    	 * The name for the project.
    	 */
    	name: string
    	/**
    	 * Uniquely identifies a project and is used for the interface.
    	 *         If not provided, it is automatically generated from the name.
    	 */
    	slug?: string
    	/**
    	 * The platform for the project.
    	 */
    	platform?: string
    	/**
    	 *
    	 * Defaults to true where the behavior is to alert the user on every new
    	 * issue. Setting this to false will turn this off and the user must create
    	 * their own alerts to be notified of new issues.
    	 *
    	 */
    	default_rules?: boolean
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago