github.com/hernad/nomad@v1.6.112/ui/app/models/service.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  // @ts-check
     7  import { attr, belongsTo } from '@ember-data/model';
     8  import Model from '@ember-data/model';
     9  import { alias } from '@ember/object/computed';
    10  
    11  export default class Service extends Model {
    12    @belongsTo('allocation') allocation;
    13    @belongsTo('job') job;
    14    @belongsTo('node') node;
    15  
    16    @attr('string') address;
    17    @attr('number') createIndex;
    18    @attr('string') datacenter;
    19    @attr('number') modifyIndex;
    20    @attr('string') namespace;
    21    @attr('number') port;
    22    @attr('string') serviceName;
    23    @attr() tags;
    24    @attr() canary_tags;
    25  
    26    @alias('serviceName') name;
    27  
    28    // Services can exist at either Group or Task level.
    29    // While our endpoints to get them do not explicitly tell us this,
    30    // we can infer it from the service's ID:
    31    get derivedLevel() {
    32      const idWithoutServiceName = this.id.replace(this.serviceName, '');
    33      if (idWithoutServiceName.includes('group-')) {
    34        return 'group';
    35      } else {
    36        return 'task';
    37      }
    38    }
    39  }