2020-08-14 15:16:35 -04:00
|
|
|
import GeneratedHostModel from '../generated/models/host';
|
2020-09-09 13:04:17 -04:00
|
|
|
import { fragment } from 'ember-data-model-fragments/attributes';
|
2020-08-14 15:16:35 -04:00
|
|
|
|
2020-09-09 13:04:17 -04:00
|
|
|
export default class HostModel extends GeneratedHostModel {
|
|
|
|
|
/**
|
|
|
|
|
* Attributes of this resource, if any, represented as a JSON fragment.
|
|
|
|
|
* @type {FragmentHostAttributesModel}
|
|
|
|
|
*/
|
|
|
|
|
@fragment('fragment-host-attributes', { defaultValue: {} }) attributes;
|
2022-01-26 08:52:14 -08:00
|
|
|
|
|
|
|
|
/**
|
2022-01-26 14:06:22 -08:00
|
|
|
* True if the host is static.
|
2022-01-26 08:52:14 -08:00
|
|
|
* @type {boolean}
|
|
|
|
|
*/
|
|
|
|
|
get isStatic() {
|
|
|
|
|
return this.type === 'static';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-01-26 14:06:22 -08:00
|
|
|
* True if the host is plugin.
|
2022-01-26 08:52:14 -08:00
|
|
|
* @type {boolean}
|
|
|
|
|
*/
|
|
|
|
|
get isPlugin() {
|
|
|
|
|
return this.type === 'plugin';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-01-26 14:06:22 -08:00
|
|
|
* True if the host plugin type is AWS.
|
2022-01-26 08:52:14 -08:00
|
|
|
* @type {boolean}
|
|
|
|
|
*/
|
|
|
|
|
get isAWS() {
|
|
|
|
|
return this.compositeType === 'aws';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-01-26 14:06:22 -08:00
|
|
|
* True if the host plugin type is Azure.
|
2022-01-26 08:52:14 -08:00
|
|
|
* @type {boolean}
|
|
|
|
|
*/
|
|
|
|
|
get isAzure() {
|
|
|
|
|
return this.compositeType === 'azure';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-01-26 14:06:22 -08:00
|
|
|
* If host is a plugin return `plugin.name`,
|
|
|
|
|
* otherwise return the host type.
|
2022-01-26 08:52:14 -08:00
|
|
|
* @type {string}
|
|
|
|
|
*/
|
|
|
|
|
get compositeType() {
|
|
|
|
|
return this.isPlugin ? this.plugin.name : this.type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2022-01-26 14:06:22 -08:00
|
|
|
* Sets `type`. If type is different than `static`, sets `type` to `plugin`
|
|
|
|
|
* and `plugin.name` to the specified type.
|
2022-01-26 08:52:14 -08:00
|
|
|
*/
|
|
|
|
|
set compositeType(type) {
|
|
|
|
|
if (type === 'static') {
|
|
|
|
|
this.type = 'static';
|
|
|
|
|
} else {
|
|
|
|
|
this.type = 'plugin';
|
|
|
|
|
this.plugin = { name: type };
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-09-09 13:04:17 -04:00
|
|
|
}
|