chore: 🤖 add set-hosts mock endpoint

This commit is contained in:
Randall Morey committed 2020-08-20 12:04:54 -04:00
1 parent 7c8c2ff14e
commit da7a2e651a
3 files changed
+29 -2

No files matched your search

+16 -2
View File
@@ -16,14 +16,28 @@ export default class HostSetModel extends GeneratedHostSetModel {
/**
* Saves the `host_ids` array on the host set via the `set-hosts` method.
* See serializer and adapter for more information.
* @param {object} options
* @param {object} options.adapterOptions
* @param {string} options.adapterOptions.hostCatalogID
* @return {Promise}
*/
saveHostIDs() {
return this.save({
saveHostIDs(options={ adapterOptions: {} }) {
const defaultOptions = {
adapterOptions: {
method: 'set-hosts',
serializeHostIDs: true
}
};
// 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
}
});
}
@@ -12,6 +12,12 @@ export default class ScopesScopeProjectsProjectHostCatalogsHostCatalogRoute exte
*/
async model({ host_catalog_id }) {
const { id: scopeID } = this.modelFor('scopes.scope');
this.store.findAll('host-set', {
adapterOptions: {
scopeID,
hostCatalogID: host_catalog_id
}
})
return this.store.findRecord('host-catalog', host_catalog_id, {
adapterOptions: { scopeID },
});
+7
View File
@@ -115,6 +115,13 @@ export default function() {
this.get('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets/:id');
this.patch('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets/:id');
this.del('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets/:id');
this.post('/scopes/:scope_id/host-catalogs/:hostCatalogId/host-sets/:idMethod', function ({ hostSets }, { params: { idMethod } }) {
const attrs = this.normalizedRequestAttrs();
const id = idMethod.split(':')[0];
const hostSet = hostSets.find(id);
attrs.id = id;
return hostSet.update(attrs);
});
// Uncomment the following line and the Response import above
// Then change the response code to simulate error responses.