2018-10-26 16:36:15 +00:00
|
|
|
import RepositoryService from 'consul-ui/services/repository';
|
2021-02-23 08:56:42 +00:00
|
|
|
import dataSource from 'consul-ui/decorators/data-source';
|
2019-08-12 15:43:18 +00:00
|
|
|
|
2018-10-26 16:36:15 +00:00
|
|
|
const modelName = 'node';
|
2020-11-09 09:25:35 +00:00
|
|
|
export default class NodeService extends RepositoryService {
|
|
|
|
getModelName() {
|
2018-10-26 16:36:15 +00:00
|
|
|
return modelName;
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-23 08:56:42 +00:00
|
|
|
@dataSource('/:ns/:dc/nodes')
|
|
|
|
async findAllByDatacenter() {
|
|
|
|
return super.findAllByDatacenter(...arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
@dataSource('/:ns/:dc/node/:id')
|
|
|
|
async findBySlug() {
|
|
|
|
return super.findBySlug(...arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
@dataSource('/:ns/:dc/leader')
|
|
|
|
findLeader(params, configuration = {}) {
|
2020-10-06 13:26:44 +00:00
|
|
|
if (typeof configuration.refresh !== 'undefined') {
|
2021-02-23 08:56:42 +00:00
|
|
|
params.uri = configuration.uri;
|
2020-10-06 13:26:44 +00:00
|
|
|
}
|
2021-02-23 08:56:42 +00:00
|
|
|
return this.store.queryLeader(this.getModelName(), params);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
}
|