mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-07 16:41:48 -05:00
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:
15
src/api/mixins/InstanceGroups.mixin.js
Normal file
15
src/api/mixins/InstanceGroups.mixin.js
Normal 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;
|
||||
31
src/api/mixins/Notifications.mixin.js
Normal file
31
src/api/mixins/Notifications.mixin.js
Normal 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;
|
||||
Reference in New Issue
Block a user