baasic-sdk-javascript
Version:
JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
127 lines (126 loc) • 6.71 kB
JavaScript
;
/* globals module */
/**
* @module userProfileACLClient
* @description User Profile ACL Client provides an easy way to consume User Profile REST API end-points. In order to obtain needed routes `userProfileACLClient` uses `userProfileACLRoute`.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var inversify_1 = require("inversify");
;
var httpApi_1 = require("../../httpApi");
var _1 = require("./");
var UserProfileACLClient = /** @class */ (function () {
function UserProfileACLClient(userProfileACLRoute, apiClient) {
this.userProfileACLRoute = userProfileACLRoute;
this.apiClient = apiClient;
}
Object.defineProperty(UserProfileACLClient.prototype, "routeDefinition", {
get: function () {
return this.userProfileACLRoute;
},
enumerable: true,
configurable: true
});
/**
* Returns a promise that is resolved once the get action has been performed. Success response returns a list of ACL policies established for the specified user profile resource.
* @method
* @param options Query resource options object.
* @returns A promise that is resolved once the get action has been performed.
* @example userProfileACLClient.get({id: '<profile-id>'})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
UserProfileACLClient.prototype.get = function (options) {
return this.apiClient.get(this.routeDefinition.get(options));
};
/**
* Returns a promise that is resolved once the update acl action has been performed, this action creates new ACL policy for the specified user profile resource.
* @method
* @param options ACL options object.
* @returns A promise that is resolved once the update acl action has been performed.
* @example let options = {id : '<profile-id>'};
let aclObj = { actionId: '<action-id'>, roleId: '<roleId>', userId: '<userId>' };
options[baasicConstants.modelPropertyName] = aclObj;
userProfileACLClient.update(options)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
UserProfileACLClient.prototype.update = function (options) {
return this.apiClient.put(this.routeDefinition.update(options), this.routeDefinition.updateParams(options));
};
/**
* Returns a promise that is resolved once the removeByUser action has been performed. This action deletes ACL policy assigned to the specified user and user profile resource.
* @method
* @param profileId User profile id which uniquely identifies user profile resource whose security privileges need to be retrieved and updated.
* @param action Action abbreviation which identifies ACL policy assigned to the specified user and user profile resource.
* Supported Values:
* "Create"
* "Delete"
* "Read"
* "Update"
* @param user A value that uniquely identifies user for which ACL policy needs to be removed.
* @param data ACL policy object used to delete specified ACL policy resource.
* @returns A promise that is resolved once the removeByUser action has been performed.
* @example userProfileACLClient.removeByUser('<profile-id>', '<access-action>', '<username>')
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
UserProfileACLClient.prototype.removeByUser = function (profileId, action, user, data) {
return this.apiClient.delete(this.userProfileACLRoute.deleteByUser(profileId, action, user, data));
};
/**
* Returns a promise that is resolved once the removeByRole action has been performed. This action deletes ACL policy assigned to the specified role and user profile resource.
* @method
* @param profileId User profile id which uniquely identifies user profile resource whose security privileges need to be retrieved and updated.
* @param action Action abbreviation which identifies ACL policy assigned to the specified user and user profile resource.
* Supported Values:
* "Create"
* "Delete"
* "Read"
* "Update"
* @param role A value that uniquely identifies role for which ACL policy needs to be removed.
* @param data ACL policy object used to delete specified ACL policy resource.
* @returns A promise that is resolved once the removeByRole action has been performed.
* @example userProfileACLClient.removeByRole('<profile-id>', '<access-action>', '<role-name>')
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
UserProfileACLClient.prototype.removeByRole = function (profileId, action, role, data) {
return this.apiClient.delete(this.userProfileACLRoute.deleteByRole(profileId, action, role, data));
};
UserProfileACLClient = tslib_1.__decorate([
inversify_1.injectable(),
tslib_1.__param(0, inversify_1.inject(_1.TYPES.UserProfileACLRoute)),
tslib_1.__param(1, inversify_1.inject(httpApi_1.httpTYPES.ApiClient)),
tslib_1.__metadata("design:paramtypes", [_1.UserProfileACLRoute,
httpApi_1.ApiClient])
], UserProfileACLClient);
return UserProfileACLClient;
}());
exports.UserProfileACLClient = UserProfileACLClient;
/**
* @copyright (c) 2017 Mono Ltd
* @license MIT
* @author Mono Ltd
* @overview
***Notes:**
- Refer to the [Baasic REST API](http://dev.baasic.com/api/reference/home) for detailed information about available Baasic REST API end-points.
- All end-point objects are transformed by the associated route service.
*/