UNPKG

@dasch-swiss/dsp-js

Version:

JavaScript library that handles API requests to Knora

223 lines 12 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { catchError, map } from "rxjs/operators"; import { ApiResponseData } from "../../../models/api-response-data"; import { Endpoint } from "../../endpoint"; import { GroupsResponse } from "../../../models/admin/groups-response"; import { ProjectsResponse } from "../../../models/admin/projects-response"; import { UserResponse } from "../../../models/admin/user-response"; import { UsersResponse } from "../../../models/admin/users-response"; /** * An endpoint for working with Knora users. * @deprecated Use open API docs instead * @category Endpoint Admin */ var UsersEndpointAdmin = /** @class */ (function (_super) { __extends(UsersEndpointAdmin, _super); function UsersEndpointAdmin() { return _super !== null && _super.apply(this, arguments) || this; } /** * Returns a list of all users. */ UsersEndpointAdmin.prototype.getUsers = function () { var _this = this; return this.httpGet("").pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UsersResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets a user by a property. * * @param property The name of the property by which the user is identified. * @param value The value of the property by which the user is identified. */ UsersEndpointAdmin.prototype.getUser = function (property, value) { var _this = this; return this.httpGet("/" + encodeURIComponent(property) + "/" + encodeURIComponent(value)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets a user by IRI. * * @param iri The IRI of the user. */ UsersEndpointAdmin.prototype.getUserByIri = function (iri) { return this.getUser("iri", iri); }; /** * Gets a user by email address. * * @param email The email address of the user. */ UsersEndpointAdmin.prototype.getUserByEmail = function (email) { return this.getUser("email", email); }; /** * Gets a user by username. * * @param username The username of the user. */ UsersEndpointAdmin.prototype.getUserByUsername = function (username) { return this.getUser("username", username); }; /** * Gets a user's group memberships. * * @param iri The user's IRI. */ UsersEndpointAdmin.prototype.getUserGroupMemberships = function (iri) { var _this = this; return this.httpGet("/iri/" + encodeURIComponent(iri) + "/group-memberships").pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, GroupsResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets a user's project memberships. * * @param iri The IRI of the user. */ UsersEndpointAdmin.prototype.getUserProjectMemberships = function (iri) { var _this = this; return this.httpGet("/iri/" + encodeURIComponent(iri) + "/project-memberships").pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectsResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Gets a user's project admin memberships. * * @param iri The user's IRI. */ UsersEndpointAdmin.prototype.getUserProjectAdminMemberships = function (iri) { var _this = this; return this.httpGet("/iri/" + encodeURIComponent(iri) + "/project-admin-memberships").pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, ProjectsResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Creates a user. * * @param user The user to be created. */ UsersEndpointAdmin.prototype.createUser = function (user) { var _this = this; return this.httpPost("", this.jsonConvert.serializeObject(user)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates an existing user's basic information. * * @param iri The IRI of the user to be updated. * @param userInfo The user information to be updated. */ UsersEndpointAdmin.prototype.updateUserBasicInformation = function (iri, userInfo) { var _this = this; return this.httpPut("/iri/" + encodeURIComponent(iri) + "/BasicUserInformation", this.jsonConvert.serializeObject(userInfo)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates a user's status. * * @param iri The user's IRI. * @param status The user's new status. */ UsersEndpointAdmin.prototype.updateUserStatus = function (iri, status) { var _this = this; return this.httpPut("/iri/" + encodeURIComponent(iri) + "/Status", { status: status }).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates a user's password. * * @param iri The IRI of the user to be updated. * @param requesterPassword The requesting user's current password. * @param newPassword The specified user's new password. */ UsersEndpointAdmin.prototype.updateUserPassword = function (iri, requesterPassword, newPassword) { var _this = this; return this.httpPut("/iri/" + encodeURIComponent(iri) + "/Password", { requesterPassword: requesterPassword, newPassword: newPassword }).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Adds a user to a group. * * @param userIri The IRI of the user. * @param groupIri The IRI of the group. */ UsersEndpointAdmin.prototype.addUserToGroupMembership = function (userIri, groupIri) { var _this = this; return this.httpPost("/iri/" + encodeURIComponent(userIri) + "/group-memberships/" + encodeURIComponent(groupIri)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Removes a user from a project. * * @param userIri The IRI of the user. * @param groupIri The IRI of the group. */ UsersEndpointAdmin.prototype.removeUserFromGroupMembership = function (userIri, groupIri) { var _this = this; return this.httpDelete("/iri/" + encodeURIComponent(userIri) + "/group-memberships/" + encodeURIComponent(groupIri)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Adds a user to a project. * * @param userIri The user's IRI. * @param projectIri The project's IRI. */ UsersEndpointAdmin.prototype.addUserToProjectMembership = function (userIri, projectIri) { var _this = this; return this.httpPost("/iri/" + encodeURIComponent(userIri) + "/project-memberships/" + encodeURIComponent(projectIri)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Removes a user from a project. * * @param userIri The user's IRI. * @param projectIri The project's IRI. */ UsersEndpointAdmin.prototype.removeUserFromProjectMembership = function (userIri, projectIri) { var _this = this; return this.httpDelete("/iri/" + encodeURIComponent(userIri) + "/project-memberships/" + encodeURIComponent(projectIri)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Makes a user a project administrator. * * @param userIri The IRI of the user. * @param projectIri The IRI of the project. */ UsersEndpointAdmin.prototype.addUserToProjectAdminMembership = function (userIri, projectIri) { var _this = this; return this.httpPost("/iri/" + encodeURIComponent(userIri) + "/project-admin-memberships/" + encodeURIComponent(projectIri)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Removes a user's project administrator status. * * @param userIri The IRI of the user. * @param projectIri The IRI of the project. */ UsersEndpointAdmin.prototype.removeUserFromProjectAdminMembership = function (userIri, projectIri) { var _this = this; return this.httpDelete("/iri/" + encodeURIComponent(userIri) + "/project-admin-memberships/" + encodeURIComponent(projectIri)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Updates a user's SystemAdmin membership. * * @param iri The IRI of the user to be updated. * @param systemAdmin True if the user should be a system admin */ UsersEndpointAdmin.prototype.updateUserSystemAdminMembership = function (iri, systemAdmin) { var _this = this; return this.httpPut("/iri/" + encodeURIComponent(iri) + "/SystemAdmin", { systemAdmin: systemAdmin }).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; /** * Deletes a user. This method does not actually delete a user, but sets the status to false. * * @param iri The IRI of the user to be deleted. */ UsersEndpointAdmin.prototype.deleteUser = function (iri) { var _this = this; return this.httpDelete("/iri/" + encodeURIComponent(iri)).pipe(map(function (ajaxResponse) { return ApiResponseData.fromAjaxResponse(ajaxResponse, UserResponse, _this.jsonConvert); }), catchError(function (error) { return _this.handleError(error); })); }; return UsersEndpointAdmin; }(Endpoint)); export { UsersEndpointAdmin }; //# sourceMappingURL=users-endpoint-admin.js.map