//native
/**
* List variables
* Returns a list of variables. The result can be filtered by using the query parameters.
*/
export async function main(
auth: RT.Qovery,
parent_id: string | undefined,
scope:
| 'APPLICATION'
| 'BUILT_IN'
| 'ENVIRONMENT'
| 'PROJECT'
| 'CONTAINER'
| 'JOB'
| 'HELM'
| 'TERRAFORM'
| undefined,
is_secret?: string | undefined
) {
const url = new URL(`https://api.qovery.com/variable`)
for (const [k, v] of [
['parent_id', parent_id],
['scope', scope],
['is_secret', is_secret]
]) {
if (v !== undefined && v !== '') {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Token ' + auth.apiKey
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago