Select Git revision
project-api.ts
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
project-api.ts 2.21 KiB
const axios = require('axios');
import apiConnectionBasic from '../basic/api-connection-basic';
function getProjectApiUrl() {
return (
'https://' + apiConnectionBasic.getHostName() + '/coscine/api/Coscine.Api.Project/Project/'
);
}
export class ProjectApi {
public static getProjectInformation(
projectId: string,
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch
) {
apiConnectionBasic.setHeader();
return axios
.get(getProjectApiUrl() + projectId)
.then(thenHandler)
.catch(catchHandler);
}
public static storeProject(
body: any,
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch
) {
apiConnectionBasic.setHeader();
return axios
.post(getProjectApiUrl(), body)
.then(thenHandler)
.catch(catchHandler);
}
public static updateProject(
projectId: string,
body: any,
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch
) {
apiConnectionBasic.setHeader();
return axios
.post(getProjectApiUrl() + projectId, body)
.then(thenHandler)
.catch(catchHandler);
}
public static getResources(
parentId: string,
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch
) {
apiConnectionBasic.setHeader();
return axios
.get(getProjectApiUrl() + parentId + '/resources')
.then(thenHandler)
.catch(catchHandler);
}
public static deleteProject(
projectId: string,
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch
) {
apiConnectionBasic.setHeader();
return axios
.delete(getProjectApiUrl() + projectId)
.then(thenHandler)
.catch(catchHandler);
}
public static getProjects(
thenHandler: any = apiConnectionBasic.defaultThenHandler,
catchHandler: any = apiConnectionBasic.defaultOnCatch ) {
apiConnectionBasic.setHeader();
return axios
.get(getProjectApiUrl())
.then(thenHandler)
.catch(catchHandler);
}
}