Edits history of script submission #18156 for ' Create an application (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create an application
     *
     */
    export async function main(auth: RT.Qovery, environmentId: string, body: Body) {
    	const url = new URL(`https://api.qovery.com/environment/${environmentId}/application`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		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 = {
    	storage?: {
    		id?: string
    		type: 'FAST_SSD'
    		/**
    		 * unit is GB
    		 * Minimum size is 4 GB
    		 *
    		 */
    		size: number
    		mount_point: string
    		[k: string]: unknown
    	}[]
    	[k: string]: unknown
    } & {
    	ports?: {
    		id?: string
    		name?: string
    		/**
    		 * The listening port of your service.
    		 */
    		internal_port: number
    		/**
    		 * The exposed port for your service. This is optional. If not set a default port will be used.
    		 */
    		external_port?: number
    		/**
    		 * Expose the port to the world
    		 */
    		publicly_accessible: boolean
    		/**
    		 * is the default port to use for domain
    		 */
    		is_default?: boolean
    		protocol?: 'HTTP' | 'GRPC' | 'TCP' | 'UDP'
    		/**
    		 * Indicate the path or regex that must match for traffic to be accepted on your service
    		 * i.e: /api/ will only accept http calls that start with /api/
    		 * Only valid for publicly_accessible HTTP or GRPC ports.
    		 */
    		public_path?: string
    		/**
    		 * Indicate the new path that will be used to reach your service after replacement
    		 * i.e: public_path -> /(.*)  public_path_rewrite -> /api/$1 will append /api/ on all externaly requested url when reaching the service
    		 * external/use url -> example.com/foobar  -> url seen by the service -> example.com/api/foobar
    		 * Only valid for publicly_accessible HTTP or GRPC ports.
    		 */
    		public_path_rewrite?: string
    		[k: string]: unknown
    	}[]
    	[k: string]: unknown
    } & {
    	/**
    	 * name is case insensitive
    	 */
    	name: string
    	/**
    	 * give a description to this application
    	 */
    	description?: string
    	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
    	}
    	/**
    	 * `DOCKER` requires `dockerfile_path`
    	 *
    	 */
    	build_mode?: 'DOCKER'
    	/**
    	 * The path of the associated Dockerfile. Only if you are using build_mode = DOCKER
    	 */
    	dockerfile_path?: string
    	/**
    	 * unit is millicores (m). 1000m = 1 cpu
    	 */
    	cpu?: number
    	/**
    	 * unit is MB. 1024 MB = 1GB
    	 */
    	memory?: number
    	gpu?: number
    	/**
    	 * Minimum number of instances running. This resource auto-scale based on the CPU and Memory consumption.
    	 * Note: 0 means that there is no application running.
    	 *
    	 */
    	min_running_instances?: number
    	/**
    	 * Maximum number of instances running. This resource auto-scale based on the CPU and Memory consumption.
    	 * Note: -1 means that there is no limit.
    	 *
    	 */
    	max_running_instances?: number
    	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
    	}
    	/**
    	 * Specify if the environment preview option is activated or not for this application.
    	 * If activated, a preview environment will be automatically cloned at each pull request.
    	 * If not specified, it takes the value of the `auto_preview` property from the associated environment.
    	 *
    	 */
    	auto_preview?: boolean
    	arguments?: string[]
    	/**
    	 * optional entrypoint when launching container
    	 */
    	entrypoint?: string
    	/**
    	 * Specify if the application will be automatically updated after receiving a new commit.
    	 */
    	auto_deploy?: boolean
    	annotations_groups?: {
    		id: string
    		[k: string]: unknown
    	}[]
    	labels_groups?: {
    		id: string
    		[k: string]: unknown
    	}[]
    	/**
    	 * Icon URI representing the application.
    	 */
    	icon_uri?: string
    	/**
    	 * The target build stage in the Dockerfile to build
    	 */
    	docker_target_build_stage?: string
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago