All checks were successful
Auto Tag Develop / tag (push) Successful in 6s
Reviewed-on: #1 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import type { Environment, EnvironmentWrite } from './dto/application'
|
|
|
|
export function createEnvironment(appSlug: string, data: EnvironmentWrite): Promise<Environment> {
|
|
return useApi().post<Environment>(`/applications/${appSlug}/environments`, data, {
|
|
toastSuccessKey: 'success.environments.create',
|
|
toastErrorKey: 'errors.environments.create',
|
|
})
|
|
}
|
|
|
|
export function updateEnvironment(id: number, data: Partial<EnvironmentWrite>): Promise<Environment> {
|
|
return useApi().patch<Environment>(`/environments/${id}`, data, {
|
|
toastSuccessKey: 'success.environments.update',
|
|
toastErrorKey: 'errors.environments.update',
|
|
})
|
|
}
|
|
|
|
export function deleteEnvironment(id: number): Promise<void> {
|
|
return useApi().delete<void>(`/environments/${id}`, undefined, {
|
|
toastSuccessKey: 'success.environments.delete',
|
|
toastErrorKey: 'errors.environments.delete',
|
|
})
|
|
}
|
|
|
|
export function toggleMaintenance(id: number, maintenance: boolean): Promise<Environment> {
|
|
const successKey = maintenance
|
|
? 'success.environments.activateMaintenance'
|
|
: 'success.environments.deactivateMaintenance'
|
|
const errorKey = maintenance
|
|
? 'errors.environments.activateMaintenance'
|
|
: 'errors.environments.deactivateMaintenance'
|
|
|
|
return useApi().post<Environment>(`/environments/${id}/maintenance`, { maintenance }, {
|
|
toastSuccessKey: successKey,
|
|
toastErrorKey: errorKey,
|
|
})
|
|
}
|