Edits history of script submission #20144 for ' Bulk mutate an organizations issues (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Bulk mutate an organizations issues
     * Bulk mutate various attributes on a maxmimum of 1000 issues. 
    - For non-status updates, the `id` query parameter is required. 
    - For status updates, the `id` query parameter may be omitted to update issues that match the filtering. 
    If any IDs are out of scope, the data won't be mutated but the endpoint will still produce a successful response. For example, if no issues were found matching the criteria, a HTTP 204 is returned.
     */
    export async function main(
    	auth: RT.Sentry,
    	body: Body,
    	environment?: string | undefined,
    	project?: string | undefined,
    	id?: string | undefined,
    	query?: string | undefined,
    	viewId?: string | undefined,
    	sort?: 'date' | 'freq' | 'inbox' | 'new' | 'trends' | 'user' | undefined,
    	limit?: string | undefined
    ) {
    	const url = new URL(
    		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/issues/`
    	)
    	for (const [k, v] of [
    		['environment', environment],
    		['project', project],
    		['id', id],
    		['query', query],
    		['viewId', viewId],
    		['sort', sort],
    		['limit', limit]
    	]) {
    		if (v !== undefined && v !== '') {
    			url.searchParams.append(k, v)
    		}
    	}
    	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 {
    	/**
    	 * If true, marks the issue as reviewed by the requestor.
    	 */
    	inbox: boolean
    	/**
    	 * Limit mutations to only issues with the given status.
    	 *
    	 * * `resolved`
    	 * * `unresolved`
    	 * * `ignored`
    	 * * `resolvedInNextRelease`
    	 * * `muted`
    	 */
    	status: 'resolved' | 'unresolved' | 'ignored' | 'resolvedInNextRelease' | 'muted'
    	/**
    	 * Additional details about the resolution. Status detail updates that include release data are only allowed for issues within a single project.
    	 */
    	statusDetails: {
    		/**
    		 * If true, marks the issue as resolved in the next release.
    		 */
    		inNextRelease: boolean
    		/**
    		 * The version of the release that the issue should be resolved in.If set to `latest`, the latest release will be used.
    		 */
    		inRelease: string
    		/**
    		 * The commit data that the issue should use for resolution.
    		 */
    		inCommit?: {
    			/**
    			 * The SHA of the resolving commit.
    			 */
    			commit: string
    			/**
    			 * The name of the repository (as it appears in Sentry).
    			 */
    			repository: string
    			[k: string]: unknown
    		}
    		/**
    		 * Ignore the issue until for this many minutes.
    		 */
    		ignoreDuration: number
    		/**
    		 * Ignore the issue until it has occurred this many times in `ignoreWindow` minutes.
    		 */
    		ignoreCount: number
    		/**
    		 * Ignore the issue until it has occurred `ignoreCount` times in this many minutes. (Max: 1 week)
    		 */
    		ignoreWindow: number
    		/**
    		 * Ignore the issue until it has affected this many users in `ignoreUserWindow` minutes.
    		 */
    		ignoreUserCount: number
    		/**
    		 * Ignore the issue until it has affected `ignoreUserCount` users in this many minutes. (Max: 1 week)
    		 */
    		ignoreUserWindow: number
    		[k: string]: unknown
    	}
    	/**
    	 * The new substatus of the issue.
    	 *
    	 * * `archived_until_escalating`
    	 * * `archived_until_condition_met`
    	 * * `archived_forever`
    	 * * `escalating`
    	 * * `ongoing`
    	 * * `regressed`
    	 * * `new`
    	 */
    	substatus:
    		| 'archived_until_escalating'
    		| 'archived_until_condition_met'
    		| 'archived_forever'
    		| 'escalating'
    		| 'ongoing'
    		| 'regressed'
    		| 'new'
    		| null
    	/**
    	 * If true, marks the issue as seen by the requestor.
    	 */
    	hasSeen: boolean
    	/**
    	 * If true, bookmarks the issue for the requestor.
    	 */
    	isBookmarked: boolean
    	/**
    	 * If true, publishes the issue.
    	 */
    	isPublic: boolean
    	/**
    	 * If true, subscribes the requestor to the issue.
    	 */
    	isSubscribed: boolean
    	/**
    	 * If true, merges the issues together.
    	 */
    	merge: boolean
    	/**
    	 * If true, discards the issues instead of updating them.
    	 */
    	discard: boolean
    	/**
    	 * The user or team that should be assigned to the issues. Values take the form of `<user_id>`, `user:<user_id>`, `<username>`, `<user_primary_email>`, or `team:<team_id>`.
    	 */
    	assignedTo: string
    	/**
    	 * The priority that should be set for the issues
    	 *
    	 * * `low`
    	 * * `medium`
    	 * * `high`
    	 */
    	priority: 'low' | 'medium' | 'high'
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago