Edits history of script submission #18277 for ' Edit job (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Edit job
     * - To edit the job you must have the admin permission.
    
     */
    export async function main(auth: RT.Qovery, jobId: string, body: Body) {
    	const url = new URL(`https://api.qovery.com/job/${jobId}`)
    
    	const response = await fetch(url, {
    		method: 'PUT',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Token ' + auth.apiKey
    		},
    		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 type Body = {
    	/**
    	 * name is case insensitive
    	 */
    	name: string
    	description?: string
    	/**
    	 * unit is millicores (m). 1000m = 1 cpu
    	 */
    	cpu?: number
    	/**
    	 * unit is MB. 1024 MB = 1GB
    	 */
    	memory?: number
    	gpu?: number
    	/**
    	 * Maximum number of restart allowed before the job is considered as failed
    	 * 0 means that no restart/crash of the job is allowed
    	 *
    	 */
    	max_nb_restart?: number
    	/**
    	 * Maximum number of seconds allowed for the job to run before killing it and mark it as failed
    	 *
    	 */
    	max_duration_seconds?: number
    	/**
    	 * Indicates if the 'environment preview option' is enabled for this container.
    	 * If enabled, a preview environment will be automatically cloned when `/preview` endpoint is called.
    	 * If not specified, it takes the value of the `auto_preview` property from the associated environment.
    	 *
    	 */
    	auto_preview?: boolean
    	/**
    	 * Port where to run readiness and liveliness probes checks. The port will not be exposed externally
    	 */
    	port?: number
    	source?: {
    		image?: {
    			/**
    			 * The image name pattern differs according to chosen container registry provider:
    			 * * `ECR`: `repository`
    			 * * `SCALEWAY_CR`: `namespace/image`
    			 * * `DOCKER_HUB`: `image` or `repository/image`
    			 * * `PUBLIC_ECR`: `registry_alias/repository`
    			 *
    			 */
    			image_name?: string
    			/**
    			 * tag of the image container
    			 */
    			tag?: string
    			/**
    			 * tag of the image container
    			 */
    			registry_id?: string
    			[k: string]: unknown
    		}
    		docker?: {
    			git_repository?: {
    				/**
    				 * application git repository URL
    				 */
    				url: string
    				/**
    				 * Name of the branch to use. This is optional
    				 * If not specified, then the branch used is the `main` or `master` one
    				 *
    				 */
    				branch?: string
    				/**
    				 * indicates the root path of the application.
    				 */
    				root_path?: string
    				/**
    				 * The git token id on Qovery side
    				 */
    				git_token_id?: string
    				provider: 'BITBUCKET' | 'GITHUB' | 'GITLAB'
    				[k: string]: unknown
    			}
    			/**
    			 * The path of the associated Dockerfile. Only if you are using build_mode = DOCKER
    			 */
    			dockerfile_path?: string
    			/**
    			 * The content of your dockerfile if it is not stored inside your git repository
    			 */
    			dockerfile_raw?: string
    			/**
    			 * The target build stage in the Dockerfile to build
    			 */
    			docker_target_build_stage?: string
    			[k: string]: unknown
    		}
    		[k: string]: unknown
    	}
    	healthchecks: {
    		readiness_probe?: {
    			type?: {
    				tcp?: {
    					port?: number
    					host?: string
    					[k: string]: unknown
    				}
    				http?: {
    					path?: string
    					scheme?: string
    					port?: number
    					[k: string]: unknown
    				}
    				exec?: {
    					command?: string[]
    					[k: string]: unknown
    				}
    				grpc?: {
    					service?: string
    					port?: number
    					[k: string]: unknown
    				}
    				[k: string]: unknown
    			}
    			initial_delay_seconds?: number
    			period_seconds?: number
    			timeout_seconds?: number
    			success_threshold?: number
    			failure_threshold?: number
    			[k: string]: unknown
    		}
    		liveness_probe?: {
    			type?: {
    				tcp?: {
    					port?: number
    					host?: string
    					[k: string]: unknown
    				}
    				http?: {
    					path?: string
    					scheme?: string
    					port?: number
    					[k: string]: unknown
    				}
    				exec?: {
    					command?: string[]
    					[k: string]: unknown
    				}
    				grpc?: {
    					service?: string
    					port?: number
    					[k: string]: unknown
    				}
    				[k: string]: unknown
    			}
    			initial_delay_seconds?: number
    			period_seconds?: number
    			timeout_seconds?: number
    			success_threshold?: number
    			failure_threshold?: number
    			[k: string]: unknown
    		}
    		[k: string]: unknown
    	}
    	/**
    	 * If you want to define a Cron job, only the `cronjob` property must be filled
    	 * A Lifecycle job should contain at least one property `on_XXX` among the 3 properties: `on_start`, `on_stop`, `on_delete`
    	 *
    	 */
    	schedule?: {
    		on_start?: {
    			arguments?: string[]
    			/**
    			 * optional entrypoint when launching container
    			 */
    			entrypoint?: string
    			[k: string]: unknown
    		}
    		on_stop?: {
    			arguments?: string[]
    			/**
    			 * optional entrypoint when launching container
    			 */
    			entrypoint?: string
    			[k: string]: unknown
    		}
    		on_delete?: {
    			arguments?: string[]
    			/**
    			 * optional entrypoint when launching container
    			 */
    			entrypoint?: string
    			[k: string]: unknown
    		}
    		cronjob?: {
    			arguments?: string[]
    			/**
    			 * optional entrypoint when launching container
    			 */
    			entrypoint?: string
    			/**
    			 * Specify a timezone identifier to run the schedule at. By default Etc/UTC
    			 */
    			timezone?: string
    			/**
    			 * Can only be set if the event is CRON.
    			 * Represent the cron format for the job schedule without seconds.
    			 * For example: `* * * * *` represent the cron to launch the job every minute.
    			 * See https://crontab.guru/ to WISIWIG interface.
    			 * Timezone is UTC
    			 *
    			 */
    			scheduled_at: string
    			[k: string]: unknown
    		}
    		lifecycle_type?: JobLifecycleTypeEnum
    		[k: string]: unknown
    	}
    	/**
    	 * Specify if the job will be automatically updated after receiving a new image tag or a new commit according to the source type.
    	 * The new image tag shall be communicated via the "Auto Deploy job" endpoint https://api-doc.qovery.com/#tag/Jobs/operation/autoDeployJobEnvironments
    	 *
    	 */
    	auto_deploy?: boolean
    	annotations_groups?: {
    		id: string
    		[k: string]: unknown
    	}[]
    	labels_groups?: {
    		id: string
    		[k: string]: unknown
    	}[]
    	/**
    	 * Icon URI representing the job.
    	 */
    	icon_uri?: string
    	[k: string]: unknown
    }
    export type JobLifecycleTypeEnum = 'GENERIC' | 'TERRAFORM' | 'CLOUDFORMATION'
    

    Submitted by hugo697 235 days ago