Files
threshold-ui/addons/api/addon/models/host-set.js
T

44 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-08-13 17:05:09 -04:00
import GeneratedHostSetModel from '../generated/models/host-set';
2020-08-19 18:38:18 -04:00
import { fragmentArray } from 'ember-data-model-fragments/attributes';
2020-08-13 17:05:09 -04:00
2020-08-19 18:38:18 -04:00
export default class HostSetModel extends GeneratedHostSetModel {
// =attributes
/**
* Grants is read-only _most_ under normal circumstances. But grants can
* be persisted via a dedicated call to `saveGrants()`.
*/
@fragmentArray('fragment-string', {readOnly: true}) host_ids;
// =methods
/**
* Saves the `host_ids` array on the host set via the `set-hosts` method.
* See serializer and adapter for more information.
2020-08-20 12:04:54 -04:00
* @param {object} options
* @param {object} options.adapterOptions
* @param {string} options.adapterOptions.hostCatalogID
2020-08-19 18:38:18 -04:00
* @return {Promise}
*/
2020-08-20 12:04:54 -04:00
saveHostIDs(options={ adapterOptions: {} }) {
const defaultOptions = {
2020-08-19 18:38:18 -04:00
adapterOptions: {
method: 'set-hosts',
serializeHostIDs: true
}
2020-08-20 12:04:54 -04:00
};
// There is no "deep merge" in ES.
// All of this nonsense is here to ensure we get
// a decent merge of `adapterOptions`.
return this.save({
...defaultOptions,
...options,
adapterOptions: {
...defaultOptions.adapterOptions,
...options.adapterOptions
}
2020-08-19 18:38:18 -04:00
});
}
}