Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Remove unused methods for actions manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasponce committed Sep 16, 2015
1 parent 7c56c74 commit 6fa24db
Showing 1 changed file with 11 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ module HawkularMetrics {
}

export interface IHawkularAlertsManager {
addEmailAction(email: EmailType): ng.IPromise<void>;
createAction(email: EmailType): ng.IPromise<void>;

getAction(email: EmailType): ng.IPromise<void>;
getActions(triggerId: TriggerId): ng.IPromise<void>;
setEmail(triggerId: TriggerId, email: EmailType): ng.IPromise<void>;

// Alerts

/**
* @name addEmailAction
* @desc Check if a previous email action exists, or it creates a new one
* @param email - recipient of the email action
*/
addEmailAction(email: EmailType): ng.IPromise<void>;

/**
* @name queryAllAlerts
* @desc Fetch all Alerts with status OPEN
Expand Down Expand Up @@ -392,14 +393,14 @@ module HawkularMetrics {
return this.$q.all(Array.prototype.concat(emailPromise, dampeningPromises, conditionPromises));
}

public getAction(email: EmailType): ng.IPromise<void> {
private getEmailAction(email: EmailType): ng.IPromise<void> {
return this.HawkularAlert.Action.get({
pluginId: 'email',
actionId: email
}).$promise;
}

public createAction(email: EmailType): ng.IPromise<void> {
private createEmailAction(email: EmailType): ng.IPromise<void> {
return this.HawkularAlert.Action.save({
actionPlugin: 'email',
actionId: email,
Expand All @@ -409,13 +410,13 @@ module HawkularMetrics {
}

public addEmailAction(email: EmailType): ng.IPromise<void> {
return this.getAction(email).then((promiseValue: any) => {
return this.getEmailAction(email).then((promiseValue: any) => {
return promiseValue;
}, (reason: any) => {
// Create a default email action
if (reason.status === 404) {
this.$log.debug('Action does not exist, creating one');
return this.createAction(email);
return this.createEmailAction(email);
}
});
}
Expand All @@ -429,33 +430,6 @@ module HawkularMetrics {
}).$promise;
}

public getActions(triggerId:TriggerId): ng.IPromise<void> {
return undefined;
}

public setEmail(triggerId:TriggerId, email:EmailType):ng.IPromise<void> {
let actions = this.getActions(triggerId);
return actions.then((actions)=> {

if (!actions) {
// If action for this email does not exist, create one
return this.HawkularAlert.Action.save({

}).$promise;

} else {
// If it exists, just use it
return this.HawkularAlert.Action.put({
actionId: ''
}, {

}).$promise;
}

});
}



}

Expand Down

0 comments on commit 6fa24db

Please sign in to comment.