Edits history of script submission #20190 for ' Edit an organizations custom dashboard (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Edit an organizations custom dashboard
     * Edit an organization's custom dashboard as well as any bulk
    edits on widgets that may have been made. (For example, widgets
    that have been rearranged, updated queries and fields, specific
    display types, and so on.)
     */
    export async function main(auth: RT.Sentry, dashboard_id: string, body: Body) {
    	const url = new URL(
    		`https://${auth.region}.sentry.io/api/0/organizations/${auth.organizationSlug}/dashboards/${dashboard_id}/`
    	)
    
    	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.
     */
    
    /**
     * Allows parameters to be defined in snake case, but passed as camel case.
     *
     * Errors are output in camel case.
     */
    export interface Body {
    	/**
    	 * A dashboard's unique id.
    	 */
    	id?: string
    	/**
    	 * The user-defined dashboard title.
    	 */
    	title?: string
    	/**
    	 * A json list of widgets saved in this dashboard.
    	 */
    	widgets?: {
    		id?: string
    		title?: string
    		description?: string
    		thresholds?: {
    			[k: string]: unknown
    		}
    		/**
    		 * * `line`
    		 * * `area`
    		 * * `stacked_area`
    		 * * `bar`
    		 * * `table`
    		 * * `big_number`
    		 * * `top_n`
    		 */
    		display_type?: 'line' | 'area' | 'stacked_area' | 'bar' | 'table' | 'big_number' | 'top_n'
    		interval?: string
    		queries?: {
    			id?: string
    			fields?: string[]
    			aggregates?: string[]
    			columns?: string[]
    			field_aliases?: string[]
    			name?: string
    			conditions?: string
    			orderby?: string
    			is_hidden?: boolean
    			/**
    			 * Allows parameters to be defined in snake case, but passed as camel case.
    			 *
    			 * Errors are output in camel case.
    			 */
    			on_demand_extraction?: {
    				extraction_state?: string
    				enabled?: boolean
    				[k: string]: unknown
    			}
    			on_demand_extraction_disabled?: boolean
    			selected_aggregate?: number
    			[k: string]: unknown
    		}[]
    		/**
    		 * * `discover`
    		 * * `issue`
    		 * * `metrics`
    		 * * `error-events`
    		 * * `transaction-like`
    		 * * `spans`
    		 * * `logs`
    		 */
    		widget_type?:
    			| 'discover'
    			| 'issue'
    			| 'metrics'
    			| 'error-events'
    			| 'transaction-like'
    			| 'spans'
    			| 'logs'
    		limit?: number
    		layout?: {
    			[k: string]: unknown
    		}
    		[k: string]: unknown
    	}[]
    	/**
    	 * The saved projects filter for this dashboard.
    	 */
    	projects?: number[]
    	/**
    	 * The saved environment filter for this dashboard.
    	 */
    	environment?: string[]
    	/**
    	 * The saved time range period for this dashboard.
    	 */
    	period?: string
    	/**
    	 * The saved start time for this dashboard.
    	 */
    	start?: string
    	/**
    	 * The saved end time for this dashboard.
    	 */
    	end?: string
    	/**
    	 * The saved filters for this dashboard.
    	 */
    	filters?: {
    		[k: string]: unknown
    	}
    	/**
    	 * Setting that lets you display saved time range for this dashboard in UTC.
    	 */
    	utc?: boolean
    	/**
    	 * Permissions that restrict users from editing dashboards
    	 */
    	permissions?: {
    		/**
    		 * Whether the dashboard is editable by everyone.
    		 */
    		is_editable_by_everyone: boolean
    		/**
    		 * List of team IDs that have edit access to a dashboard.
    		 */
    		teams_with_edit_access?: number[]
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago