Edits history of script submission #20310 for ' Update a projects symbol source (sentry)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Update a projects symbol source
     * Update a custom symbol source in a project.
     */
    export async function main(
    	auth: RT.Sentry,
    	project_id_or_slug: string,
    	id: string | undefined,
    	body: Body
    ) {
    	const url = new URL(
    		`https://${auth.region}.sentry.io/api/0/projects/${auth.organizationSlug}/${project_id_or_slug}/symbol-sources/`
    	)
    	for (const [k, v] of [['id', id]]) {
    		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 {
    	/**
    	 * The type of the source.
    	 *
    	 * * `http` - SymbolServer (HTTP)
    	 * * `gcs` - Google Cloud Storage
    	 * * `s3` - Amazon S3
    	 */
    	type: 'http' | 'gcs' | 's3'
    	/**
    	 * The human-readable name of the source.
    	 */
    	name: string
    	/**
    	 * The internal ID of the source. Must be distinct from all other source IDs and cannot start with '`sentry:`'. If this is not provided, a new UUID will be generated.
    	 */
    	id?: string
    	/**
    	 * Layout settings for the source. This is required for HTTP, GCS, and S3 sources.
    	 *
    	 * **`type`** ***(string)*** - The layout of the folder structure. The options are:
    	 * - `native` - Platform-Specific (SymStore / GDB / LLVM)
    	 * - `symstore` - Microsoft SymStore
    	 * - `symstore_index2` - Microsoft SymStore (with index2.txt)
    	 * - `ssqp` - Microsoft SSQP
    	 * - `unified` - Unified Symbol Server Layout
    	 * - `debuginfod` - debuginfod
    	 *
    	 * **`casing`** ***(string)*** - The layout of the folder structure. The options are:
    	 * - `default` - Default (mixed case)
    	 * - `uppercase` - Uppercase
    	 * - `lowercase` - Lowercase
    	 *
    	 * ```json
    	 * {
    	 *     "layout": {
    	 *         "type": "native"
    	 *         "casing": "default"
    	 *     }
    	 * }
    	 * ```
    	 */
    	layout?: {
    		/**
    		 * The source's layout type.
    		 *
    		 * * `native`
    		 * * `symstore`
    		 * * `symstore_index2`
    		 * * `ssqp`
    		 * * `unified`
    		 * * `debuginfod`
    		 * * `slashsymbols`
    		 */
    		type:
    			| 'native'
    			| 'symstore'
    			| 'symstore_index2'
    			| 'ssqp'
    			| 'unified'
    			| 'debuginfod'
    			| 'slashsymbols'
    		/**
    		 * The source's casing rules.
    		 *
    		 * * `lowercase`
    		 * * `uppercase`
    		 * * `default`
    		 */
    		casing: 'lowercase' | 'uppercase' | 'default'
    		[k: string]: unknown
    	}
    	/**
    	 * Filter settings for the source. This is optional for all sources.
    	 *
    	 * **`filetypes`** ***(list)*** - A list of file types that can be found on this source. If this is left empty, all file types will be enabled. The options are:
    	 * - `pe` - Windows executable files
    	 * - `pdb` - Windows debug files
    	 * - `portablepdb` - .NET portable debug files
    	 * - `mach_code` - MacOS executable files
    	 * - `mach_debug` - MacOS debug files
    	 * - `elf_code` - ELF executable files
    	 * - `elf_debug` - ELF debug files
    	 * - `wasm_code` - WASM executable files
    	 * - `wasm_debug` - WASM debug files
    	 * - `breakpad` - Breakpad symbol files
    	 * - `sourcebundle` - Source code bundles
    	 * - `uuidmap` - Apple UUID mapping files
    	 * - `bcsymbolmap` - Apple bitcode symbol maps
    	 * - `il2cpp` - Unity IL2CPP mapping files
    	 * - `proguard` - ProGuard mapping files
    	 *
    	 * **`path_patterns`** ***(list)*** - A list of glob patterns to check against the debug and code file paths of debug files. Only files that match one of these patterns will be requested from the source. If this is left empty, no path-based filtering takes place.
    	 *
    	 * **`requires_checksum`** ***(boolean)*** - Whether this source requires a debug checksum to be sent with each request. Defaults to `false`.
    	 *
    	 * ```json
    	 * {
    	 *     "filters": {
    	 *         "filetypes": ["pe", "pdb", "portablepdb"],
    	 *         "path_patterns": ["*ffmpeg*"]
    	 *     }
    	 * }
    	 * ```
    	 */
    	filters?: {
    		/**
    		 * The file types enabled for the source.
    		 */
    		filetypes?: (
    			| 'pe'
    			| 'pdb'
    			| 'portablepdb'
    			| 'mach_debug'
    			| 'mach_code'
    			| 'elf_debug'
    			| 'elf_code'
    			| 'wasm_debug'
    			| 'wasm_code'
    			| 'breakpad'
    			| 'sourcebundle'
    			| 'uuidmap'
    			| 'bcsymbolmap'
    			| 'il2cpp'
    			| 'proguard'
    			| 'dartsymbolmap'
    		)[]
    		/**
    		 * The debug and code file paths enabled for the source.
    		 */
    		path_patterns?: string[]
    		/**
    		 * Whether the source requires debug checksums.
    		 */
    		requires_checksum?: boolean
    		[k: string]: unknown
    	}
    	/**
    	 * The source's URL. Optional for HTTP sources, invalid for all others.
    	 */
    	url?: string
    	/**
    	 * The user name for accessing the source. Optional for HTTP sources, invalid for all others.
    	 */
    	username?: string
    	/**
    	 * The password for accessing the source. Optional for HTTP sources, invalid for all others.
    	 */
    	password?: string
    	/**
    	 * The GCS or S3 bucket where the source resides. Required for GCS and S3 source, invalid for HTTP sources.
    	 */
    	bucket?: string
    	/**
    	 * The source's [S3 region](https://docs.aws.amazon.com/general/latest/gr/s3.html). Required for S3 sources, invalid for all others.
    	 *
    	 * * `us-east-2` - US East (Ohio)
    	 * * `us-east-1` - US East (N. Virginia)
    	 * * `us-west-1` - US West (N. California)
    	 * * `us-west-2` - US West (Oregon)
    	 * * `ap-east-1` - Asia Pacific (Hong Kong)
    	 * * `ap-south-1` - Asia Pacific (Mumbai)
    	 * * `ap-northeast-2` - Asia Pacific (Seoul)
    	 * * `ap-southeast-1` - Asia Pacific (Singapore)
    	 * * `ap-southeast-2` - Asia Pacific (Sydney)
    	 * * `ap-northeast-1` - Asia Pacific (Tokyo)
    	 * * `ca-central-1` - Canada (Central)
    	 * * `cn-north-1` - China (Beijing)
    	 * * `cn-northwest-1` - China (Ningxia)
    	 * * `eu-central-1` - EU (Frankfurt)
    	 * * `eu-west-1` - EU (Ireland)
    	 * * `eu-west-2` - EU (London)
    	 * * `eu-west-3` - EU (Paris)
    	 * * `eu-north-1` - EU (Stockholm)
    	 * * `sa-east-1` - South America (São Paulo)
    	 * * `us-gov-east-1` - AWS GovCloud (US-East)
    	 * * `us-gov-west-1` - AWS GovCloud (US)
    	 */
    	region?:
    		| 'us-east-2'
    		| 'us-east-1'
    		| 'us-west-1'
    		| 'us-west-2'
    		| 'ap-east-1'
    		| 'ap-south-1'
    		| 'ap-northeast-2'
    		| 'ap-southeast-1'
    		| 'ap-southeast-2'
    		| 'ap-northeast-1'
    		| 'ca-central-1'
    		| 'cn-north-1'
    		| 'cn-northwest-1'
    		| 'eu-central-1'
    		| 'eu-west-1'
    		| 'eu-west-2'
    		| 'eu-west-3'
    		| 'eu-north-1'
    		| 'sa-east-1'
    		| 'us-gov-east-1'
    		| 'us-gov-west-1'
    	/**
    	 * The [AWS Access Key](https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds.html#access-keys-and-secret-access-keys).Required for S3 sources, invalid for all others.
    	 */
    	access_key?: string
    	/**
    	 * The [AWS Secret Access Key](https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds.html#access-keys-and-secret-access-keys).Required for S3 sources, invalid for all others.
    	 */
    	secret_key?: string
    	/**
    	 * The GCS or [S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-prefixes.html) prefix. Optional for GCS and S3 sourcse, invalid for HTTP.
    	 */
    	prefix?: string
    	/**
    	 * The GCS email address for authentication. Required for GCS sources, invalid for all others.
    	 */
    	client_email?: string
    	/**
    	 * The GCS private key. Required for GCS sources if not using impersonated tokens. Invalid for all others.
    	 */
    	private_key?: string
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago