mirror of https://github.com/status-im/consul.git
38 lines
947 B
JavaScript
38 lines
947 B
JavaScript
import RepositoryService from 'consul-ui/services/repository';
|
|
import statusFactory from 'consul-ui/utils/acls-status';
|
|
import isValidServerErrorFactory from 'consul-ui/utils/http/acl/is-valid-server-error';
|
|
import { PRIMARY_KEY, SLUG_KEY } from 'consul-ui/models/role';
|
|
import dataSource from 'consul-ui/decorators/data-source';
|
|
|
|
const isValidServerError = isValidServerErrorFactory();
|
|
const status = statusFactory(isValidServerError, Promise);
|
|
const MODEL_NAME = 'role';
|
|
|
|
export default class RoleService extends RepositoryService {
|
|
getModelName() {
|
|
return MODEL_NAME;
|
|
}
|
|
|
|
getPrimaryKey() {
|
|
return PRIMARY_KEY;
|
|
}
|
|
|
|
getSlugKey() {
|
|
return SLUG_KEY;
|
|
}
|
|
|
|
@dataSource('/:ns/:dc/roles')
|
|
async findAllByDatacenter() {
|
|
return super.findAllByDatacenter(...arguments);
|
|
}
|
|
|
|
@dataSource('/:ns/:dc/role/:id')
|
|
async findBySlug() {
|
|
return super.findBySlug(...arguments);
|
|
}
|
|
|
|
status(obj) {
|
|
return status(obj);
|
|
}
|
|
}
|