api.js refactor using classes (#250)

Refactor api.js into an api module where endpoint specific models can be imported and used in components.
This commit is contained in:
Michael Abashian
2019-06-07 15:48:09 -04:00
committed by GitHub
parent a8c51670af
commit 2ae93261d1
51 changed files with 839 additions and 727 deletions

View File

@@ -0,0 +1,15 @@
const InstanceGroupsMixin = (parent) => class extends parent {
readInstanceGroups (resourceId, params = {}) {
return this.http.get(`${this.baseUrl}${resourceId}/instance_groups/`, { params });
}
associateInstanceGroup (resourceId, instanceGroupId) {
return this.http.post(`${this.baseUrl}${resourceId}/instance_groups/`, { id: instanceGroupId });
}
disassociateInstanceGroup (resourceId, instanceGroupId) {
return this.http.post(`${this.baseUrl}${resourceId}/instance_groups/`, { id: instanceGroupId, disassociate: true });
}
};
export default InstanceGroupsMixin;

View File

@@ -0,0 +1,31 @@
const NotificationsMixin = (parent) => class extends parent {
readNotificationTemplates (id, params = {}) {
return this.http.get(`${this.baseUrl}${id}/notification_templates/`, { params });
}
readNotificationTemplatesSuccess (id, params = {}) {
return this.http.get(`${this.baseUrl}${id}/notification_templates_success/`, { params });
}
readNotificationTemplatesError (id, params = {}) {
return this.http.get(`${this.baseUrl}${id}/notification_templates_error/`, { params });
}
associateNotificationTemplatesSuccess (resourceId, notificationId) {
return this.http.post(`${this.baseUrl}${resourceId}/notification_templates_success/`, { id: notificationId });
}
disassociateNotificationTemplatesSuccess (resourceId, notificationId) {
return this.http.post(`${this.baseUrl}${resourceId}/notification_templates_success/`, { id: notificationId, disassociate: true });
}
associateNotificationTemplatesError (resourceId, notificationId) {
return this.http.post(`${this.baseUrl}${resourceId}/notification_templates_error/`, { id: notificationId });
}
disassociateNotificationTemplatesError (resourceId, notificationId) {
return this.http.post(`${this.baseUrl}${resourceId}/notification_templates_error/`, { id: notificationId, disassociate: true });
}
};
export default NotificationsMixin;