2019-05-01 18:09:29 +00:00
|
|
|
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';
|
2021-02-23 08:56:42 +00:00
|
|
|
import dataSource from 'consul-ui/decorators/data-source';
|
2019-05-01 18:09:29 +00:00
|
|
|
|
|
|
|
const isValidServerError = isValidServerErrorFactory();
|
|
|
|
const status = statusFactory(isValidServerError, Promise);
|
|
|
|
const MODEL_NAME = 'role';
|
|
|
|
|
2020-11-09 09:25:35 +00:00
|
|
|
export default class RoleService extends RepositoryService {
|
|
|
|
getModelName() {
|
2019-05-01 18:09:29 +00:00
|
|
|
return MODEL_NAME;
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getPrimaryKey() {
|
2019-05-01 18:09:29 +00:00
|
|
|
return PRIMARY_KEY;
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getSlugKey() {
|
2019-05-01 18:09:29 +00:00
|
|
|
return SLUG_KEY;
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-23 08:56:42 +00:00
|
|
|
@dataSource('/:ns/:dc/roles')
|
|
|
|
async findAllByDatacenter() {
|
|
|
|
return super.findAllByDatacenter(...arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
@dataSource('/:ns/:dc/role/:id')
|
|
|
|
async findBySlug() {
|
|
|
|
return super.findBySlug(...arguments);
|
|
|
|
}
|
|
|
|
|
2020-11-09 09:25:35 +00:00
|
|
|
status(obj) {
|
2019-05-01 18:09:29 +00:00
|
|
|
return status(obj);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
}
|