2022-08-26 03:22:55 +00:00
|
|
|
// @ts-check
|
|
|
|
import { attr, belongsTo } from '@ember-data/model';
|
|
|
|
import Model from '@ember-data/model';
|
|
|
|
import { alias } from '@ember/object/computed';
|
2019-09-04 14:39:56 +00:00
|
|
|
|
2022-08-26 03:22:55 +00:00
|
|
|
export default class Service extends Model {
|
|
|
|
@belongsTo('allocation') allocation;
|
|
|
|
@belongsTo('job') job;
|
|
|
|
@belongsTo('node') node;
|
|
|
|
|
|
|
|
@attr('string') address;
|
|
|
|
@attr('number') createIndex;
|
|
|
|
@attr('string') datacenter;
|
|
|
|
@attr('number') modifyIndex;
|
|
|
|
@attr('string') namespace;
|
|
|
|
@attr('number') port;
|
|
|
|
@attr('string') serviceName;
|
2020-06-10 13:49:16 +00:00
|
|
|
@attr() tags;
|
2022-08-26 03:22:55 +00:00
|
|
|
|
|
|
|
@alias('serviceName') name;
|
|
|
|
|
|
|
|
// Services can exist at either Group or Task level.
|
|
|
|
// While our endpoints to get them do not explicitly tell us this,
|
|
|
|
// we can infer it from the service's ID:
|
|
|
|
get derivedLevel() {
|
|
|
|
const idWithoutServiceName = this.id.replace(this.serviceName, '');
|
|
|
|
if (idWithoutServiceName.includes('group-')) {
|
|
|
|
return 'group';
|
|
|
|
} else {
|
|
|
|
return 'task';
|
|
|
|
}
|
|
|
|
}
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|