diff --git a/addons/api/addon/models/target.js b/addons/api/addon/models/target.js index e9d3ac018..99e1f3d16 100644 --- a/addons/api/addon/models/target.js +++ b/addons/api/addon/models/target.js @@ -32,14 +32,15 @@ export default class TargetModel extends GeneratedTargetModel { /** * Adds host sets via the `add-host-sets` method. * See serializer and adapter for more information. + * @param {[string]} hostSetIDs * @param {object} options * @param {object} options.adapterOptions * @return {Promise} */ - addHostSets(hostSets, options={ adapterOptions: {} }) { + addHostSets(hostSetIDs, options={ adapterOptions: {} }) { const defaultAdapterOptions = { method: 'add-host-sets', - hostSets + hostSetIDs }; // There is no "deep merge" in ES. // All of this nonsense is here to ensure we get @@ -56,14 +57,15 @@ export default class TargetModel extends GeneratedTargetModel { /** * Delete host sets via the `delete-host-sets` method. * See serializer and adapter for more information. + * @param {[string]} hostSetIDs * @param {object} options * @param {object} options.adapterOptions * @return {Promise} */ - deleteHostSets(hostSets, options={ adapterOptions: {} }) { + deleteHostSets(hostSetIDs, options={ adapterOptions: {} }) { const defaultAdapterOptions = { method: 'delete-host-sets', - hostSets + hostSetIDs }; // There is no "deep merge" in ES. // All of this nonsense is here to ensure we get diff --git a/addons/api/addon/serializers/target.js b/addons/api/addon/serializers/target.js index 5d45fec4d..7fc436df5 100644 --- a/addons/api/addon/serializers/target.js +++ b/addons/api/addon/serializers/target.js @@ -14,22 +14,23 @@ export default class TargetSerializer extends ApplicationSerializer { */ serialize(snapshot) { let serialized = super.serialize(...arguments); - const hostSets = snapshot?.adapterOptions?.hostSets; - if (hostSets) serialized = this.serializeWithHostSets(snapshot, hostSets); + const hostSets = snapshot?.adapterOptions?.hostSetIDs; + if (hostSetIDs) serialized = + this.serializeWithHostSets(snapshot, hostSetIDs); return serialized; } /** - * Returns a payload containing only the host_set_ids array using host sets + * Returns a payload containing only the host_set_ids array using IDs * passed into the function (rather than existing host sets on the model). * @param {Snapshot} snapshot - * @param {[HostSetModel]} hostSets + * @param {[string]} hostSetIDs * @return {object} */ - serializeWithHostSets(snapshot, hostSets) { + serializeWithHostSets(snapshot, hostSetIDs) { return { version: snapshot.attr('version'), - host_set_ids: hostSets.map(({ id }) => id) + host_set_ids: hostSetIDs }; }