2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
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-09-15 18:50:11 +00:00
|
|
|
@dataSource('/:partition/:ns/:dc/nodes')
|
2021-02-23 08:56:42 +00:00
|
|
|
async findAllByDatacenter() {
|
|
|
|
return super.findAllByDatacenter(...arguments);
|
|
|
|
}
|
|
|
|
|
2022-06-23 13:16:26 +00:00
|
|
|
@dataSource('/:partition/:ns/:dc/node/:id/:peer')
|
2021-02-23 08:56:42 +00:00
|
|
|
async findBySlug() {
|
|
|
|
return super.findBySlug(...arguments);
|
|
|
|
}
|
|
|
|
|
2021-09-15 18:50:11 +00:00
|
|
|
@dataSource('/:partition/:ns/:dc/leader')
|
2021-02-23 08:56:42 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|