Edits history of script submission #18149 for ' Create a terraform (qovery)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create a terraform
     *
     */
    export async function main(auth: RT.Qovery, environmentId: string, body: TerraformRequest) {
    	const url = new URL(`https://api.qovery.com/environment/${environmentId}/terraform`)
    
    	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 interface TerraformRequest {
    	name: string
    	description: string
    	auto_deploy: boolean
    	terraform_files_source: {
    		git_repository?: TerraformGitRepositoryRequest
    		[k: string]: unknown
    	}
    	terraform_variables_source: TerraformVariablesSourceRequest
    	/**
    	 * Configuration for Terraform backend - exactly one backend type must be specified
    	 */
    	backend:
    		| {
    				/**
    				 * Kubernetes-specific backend configuration
    				 */
    				kubernetes: {
    					[k: string]: unknown
    				}
    				[k: string]: unknown
    		  }
    		| {
    				/**
    				 * User-provided backend configuration
    				 */
    				user_provided: {
    					[k: string]: unknown
    				}
    				[k: string]: unknown
    		  }
    	provider: 'TERRAFORM'
    	provider_version: TerraformProviderVersion
    	timeout_sec?: number
    	icon_uri?: string
    	job_resources: TerraformRequestJobResources
    	use_cluster_credentials?: boolean
    	/**
    	 * The key represent the action command name i.e: "plan"
    	 * The value represent the extra arguments to pass to this command
    	 *
    	 * i.e: {"apply", ["-lock=false"]} is going to prepend `-lock=false` to terraform apply commands
    	 */
    	action_extra_arguments?: {
    		[k: string]: string[]
    	}
    	[k: string]: unknown
    }
    export interface TerraformGitRepositoryRequest {
    	url: string
    	branch?: string
    	root_path?: string
    	git_token_id?: string
    	[k: string]: unknown
    }
    export interface TerraformVariablesSourceRequest {
    	tf_var_file_paths: string[]
    	tf_vars: TerraformVarKeyValue[]
    	[k: string]: unknown
    }
    /**
     * A Terraform input variable
     */
    export interface TerraformVarKeyValue {
    	key?: string
    	value?: string
    	secret?: boolean
    	[k: string]: unknown
    }
    export interface TerraformProviderVersion {
    	read_from_terraform_block?: boolean
    	explicit_version: string
    	[k: string]: unknown
    }
    export interface TerraformRequestJobResources {
    	cpu_milli: number
    	ram_mib: number
    	gpu: number
    	storage_gib: number
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago