@dasch-swiss/dsp-js
Version:
TypeScript client library for DSP-API
193 lines • 8.07 kB
JavaScript
import { catchError, map } from 'rxjs';
import { KeywordsResponse } from '../../../models/admin/keywords-response';
import { MembersResponse } from '../../../models/admin/members-response';
import { ProjectResponse } from '../../../models/admin/project-response';
import { ProjectRestrictedViewSettingsResponse } from '../../../models/admin/project-restricted-view-settings-response';
import { ProjectsResponse } from '../../../models/admin/projects-response';
import { ApiResponseData } from '../../../models/api-response-data';
import { Endpoint } from '../../endpoint';
/**
* An endpoint for working with Knora projects.
* @deprecated Use open API docs instead
* @category Endpoint Admin
*/
export class ProjectsEndpointAdmin extends Endpoint {
/**
* Returns a list of all projects.
*/
getProjects() {
return this.httpGet('', undefined).pipe(map(ajaxResponse => ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectsResponse, this.jsonConvert)), catchError(error => this.handleError(error)));
}
/**
* Creates a project.
*
* @param project The project to be created.
*/
createProject(project) {
return this.httpPost('', this.jsonConvert.serializeObject(project), undefined, undefined).pipe(map(ajaxResponse => ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectResponse, this.jsonConvert)), catchError(error => this.handleError(error)));
}
/**
* Gets all the unique keywords for all projects.
*/
getKeywords() {
return this.httpGet('/Keywords').pipe(map(ajaxResponse => ApiResponseData.fromAjaxResponse(ajaxResponse, KeywordsResponse, this.jsonConvert)), catchError(error => this.handleError(error)));
}
/**
* Gets all the keywords for a project.
*
* @param iri The IRI of the project.
*/
getProjectKeywords(iri) {
return this.httpGet(`/iri/${encodeURIComponent(iri)}/Keywords`).pipe(map(ajaxResponse => ApiResponseData.fromAjaxResponse(ajaxResponse, KeywordsResponse, this.jsonConvert)), catchError(error => this.handleError(error)));
}
/**
* Updates a project.
*
* @param iri The IRI of the project to be updated.
* @param projectInfo The project info to be updated.
*/
updateProject(iri, projectInfo) {
return this.httpPut(`/iri/${encodeURIComponent(iri)}`, this.jsonConvert.serializeObject(projectInfo)).pipe(map(ajaxResponse => ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectResponse, this.jsonConvert)), catchError(error => this.handleError(error)));
}
/**
* Deletes a project. This method does not actually delete a project, but sets the status to false.
*
* @param iri The project IRI.
*/
deleteProject(iri) {
return this.httpDelete(`/iri/${encodeURIComponent(iri)}`).pipe(map(ajaxResponse => ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectResponse, this.jsonConvert)), catchError(error => this.handleError(error)));
}
/**
* Gets a project by a property.
*
* @param property The name of the property by which the project is identified.
* @param value The value of the property by which the project is identified.
*/
getProject(property, value) {
return this.httpGet(`/${encodeURIComponent(property)}/${encodeURIComponent(value)}`, undefined).pipe(map(ajaxResponse => ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectResponse, this.jsonConvert)), catchError(error => this.handleError(error)));
}
/**
* Gets a project by IRI.
*
* @param iri The IRI of the project.
*/
getProjectByIri(iri) {
return this.getProject('iri', iri);
}
/**
* Gets a project by shortname.
*
* @param shortname The shortname of the project.
*/
getProjectByShortname(shortname) {
return this.getProject('shortname', shortname);
}
/**
* Gets a project by shortcode.
*
* @param shortcode The shortcode of the project.
*/
getProjectByShortcode(shortcode) {
return this.getProject('shortcode', shortcode);
}
/**
* Gets a project's members by a property.
*
* @param property The name of the property by which the project is identified.
* @param value The value of the property by which the project is identified.
*/
getProjectMembers(property, value) {
return this.httpGet(`/${encodeURIComponent(property)}/${encodeURIComponent(value)}/members`).pipe(map(ajaxResponse => ApiResponseData.fromAjaxResponse(ajaxResponse, MembersResponse, this.jsonConvert)), catchError(error => this.handleError(error)));
}
/**
* Gets the members of a project by IRI.
*
* @param iri The IRI of the project.
*/
getProjectMembersByIri(iri) {
return this.getProjectMembers('iri', iri);
}
/**
* Gets a project's members by shortname.
*
* @param shortname The shortname of the project.
*/
getProjectMembersByShortname(shortname) {
return this.getProjectMembers('shortname', shortname);
}
/**
* Gets a project's members by shortcode.
*
* @param shortcode The shortcode of the project.
*/
getProjectMembersByShortcode(shortcode) {
return this.getProjectMembers('shortcode', shortcode);
}
/**
* Gets a project's admin members by a property.
*
* @param property The name of the property by which the project is identified.
* @param value The value of the property by which the project is identified.
*/
getProjectAdminMembers(property, value) {
return this.httpGet(`/${encodeURIComponent(property)}/${encodeURIComponent(value)}/admin-members`).pipe(map(ajaxResponse => ApiResponseData.fromAjaxResponse(ajaxResponse, MembersResponse, this.jsonConvert)), catchError(error => this.handleError(error)));
}
/**
* Gets the admin members of a project by IRI.
*
* @param iri The IRI of the project.
*/
getProjectAdminMembersByIri(iri) {
return this.getProjectAdminMembers('iri', iri);
}
/**
* Gets a project's admin members by shortname.
*
* @param shortname The shortname of the project.
*/
getProjectAdminMembersByShortname(shortname) {
return this.getProjectAdminMembers('shortname', shortname);
}
/**
* Gets a project's admin members by shortcode.
*
* @param shortcode The shortcode of the project.
*/
getProjectAdminMembersByShortcode(shortcode) {
return this.getProjectAdminMembers('shortcode', shortcode);
}
/**
* Gets a project's restricted view settings by a property.
*
* @param property The name of the property by which the project is identified.
* @param value The value of the property by which the project is identified.
*/
getProjectRestrictedViewSettings(property, value) {
return this.httpGet(`/${encodeURIComponent(property)}/${encodeURIComponent(value)}/RestrictedViewSettings`).pipe(map(ajaxResponse => ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectRestrictedViewSettingsResponse, this.jsonConvert)), catchError(error => this.handleError(error)));
}
/**
* Gets a project's restricted view settings by IRI.
*
* @param iri The IRI of the project.
*/
getProjectRestrictedViewSettingByIri(iri) {
return this.getProjectRestrictedViewSettings('iri', iri);
}
/**
* Gets a project's restricted view settings by shortname.
*
* @param shortname The shortname of the project.
*/
getProjectRestrictedViewSettingByShortname(shortname) {
return this.getProjectRestrictedViewSettings('shortname', shortname);
}
/**
* Gets a project's restricted view settings by shortcode.
*
* @param shortcode The shortcode of the project.
*/
getProjectRestrictedViewSettingByShortcode(shortcode) {
return this.getProjectRestrictedViewSettings('shortcode', shortcode);
}
}
//# sourceMappingURL=projects-endpoint-admin.js.map