baasic-sdk-javascript
Version:
JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
116 lines (115 loc) • 6.09 kB
JavaScript
;
/**
* @module dynamicResourceACLClient
* @description Dynamic Resource ACL Client provides an easy way to consume Dynamic Resource REST API end-points. In order to obtain needed routes `dynamicResourceACLClient` uses `dynamicResourceACLRoute`.
*/
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 DynamicResourceACLClient = /** @class */ (function () {
function DynamicResourceACLClient(dynamicResourceACLRoute, apiClient) {
this.dynamicResourceACLRoute = dynamicResourceACLRoute;
this.apiClient = apiClient;
}
Object.defineProperty(DynamicResourceACLClient.prototype, "routeDefinition", {
get: function () {
return this.dynamicResourceACLRoute;
},
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 dynamic resource.
* @method
* @param options Options object.
* @example dynamicResourceACLClient.get({id: '<dynamic-resource-id>', schemaName: '<schema-name>'})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
DynamicResourceACLClient.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 dynamic resource.
* @method
* @param options Options object.
* @example dynamicResourceACLClient.update({id: '<dynamic-resource-id>', schemaName: '<schema-name>'})
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
DynamicResourceACLClient.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 dynamic resource.
* @method
* @param action Action abbreviation which identifies ACL policy assigned to the specified user and dynamic resource.
* Supported Values:
* "Create"
* "Delete"
* "Read"
* "Update"
* @param user Username which uniquely identifies user for which ACL policy needs to be removed.
* @param data ACL Policy whose security privileges need to be retrieved and updated.
* @example // dynamicResource is a resource previously fetched using get action.
dynamicResourceACLClient.removeByUser('<access-action>', '<username>', dynamicResource)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
DynamicResourceACLClient.prototype.removeByUser = function (action, user, data) {
return this.apiClient.delete(this.dynamicResourceACLRoute.deleteByUser(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 dynamic resource.
* @method
* @param action Action abbreviation which identifies ACL policy assigned to the specified role and dynamic resource.
* Supported Values:
* "Create"
* "Delete"
* "Read"
* "Update"
* @param role Role's name which uniquely identifies role for which ACL policy needs to be removed.
* @param data ACL Policy whose security privileges need to be retrieved and updated.
* @example // dynamicResource is a resource previously fetched using get action.
dynamicResourceACLClient.removeByRole('<access-action>', '<role-name>', dynamicResource)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
DynamicResourceACLClient.prototype.removeByRole = function (action, role, data) {
return this.apiClient.delete(this.dynamicResourceACLRoute.deleteByRole(action, role, data));
};
DynamicResourceACLClient = tslib_1.__decorate([
inversify_1.injectable(),
tslib_1.__param(0, inversify_1.inject(_1.TYPES.DynamicResourceACLRoute)),
tslib_1.__param(1, inversify_1.inject(httpApi_1.httpTYPES.ApiClient)),
tslib_1.__metadata("design:paramtypes", [_1.DynamicResourceACLRoute,
httpApi_1.ApiClient])
], DynamicResourceACLClient);
return DynamicResourceACLClient;
}());
exports.DynamicResourceACLClient = DynamicResourceACLClient;
/**
* @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.
*/