Edits history of script submission #18273 for ' Edit container (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Edit container
     * - To edit the container you must have the admin permission.
    - For port edition, if you provide a port id, we will update the corresponding port. If you don't we will create a new one. If you remove a port from the payload, we will delete it.
    - For storage edition, if you provide a storage id, we will update the corresponding storage. If you don't we will create a new one. If you remove a storage from the payload, we will delete it.
    
     */
    export async function main(auth: RT.Qovery, containerId: string, body: Body) {
    	const url = new URL(`https://api.qovery.com/container/${containerId}`)
    
    	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 = {
    	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 container
    	 */
    	description?: string
    	/**
    	 * id of the linked registry
    	 */
    	registry_id: string
    	/**
    	 * 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
    	arguments?: string[]
    	/**
    	 * optional entrypoint when launching container
    	 */
    	entrypoint?: 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 container 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
    	}
    	/**
    	 * 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
    	/**
    	 * Specify if the container will be automatically updated after receiving a new image tag.
    	 * The new image tag shall be communicated via the "Auto Deploy container" endpoint https://api-doc.qovery.com/#tag/Containers/operation/autoDeployContainerEnvironments
    	 *
    	 */
    	auto_deploy?: boolean
    	annotations_groups?: {
    		id: string
    		[k: string]: unknown
    	}[]
    	labels_groups?: {
    		id: string
    		[k: string]: unknown
    	}[]
    	/**
    	 * Icon URI representing the container.
    	 */
    	icon_uri?: string
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago