package sensu

import "fmt"

// GetEvents Return all the current events
func (s *Sensu) GetEvents() ([]interface{}, error) {
	return s.GetList("events", 0, 0)
}

// GetEventsForClient Returns the current events for given client
func (s *Sensu) GetEventsForClient(client string) ([]interface{}, error) {
	//return s.Get("events", client)
	// TODO  is this the correct way? need validation??
	return s.GetList(fmt.Sprintf("events/%s", client), 0, 0)
}

// GetEventsCheckForClient Returns the event for a check for a client
func (s *Sensu) GetEventsCheckForClient(client string, check string) ([]interface{}, error) {
	//return s.Get("events", client)
	// TODO  is this the correct way? need validation??
	return s.GetList(fmt.Sprintf("events/%s/%s", client, check), 0, 0)
}

// ResolveEvent Resolves an event (delayed action)
func (s *Sensu) ResolveEvent(client string, check string) (map[string]interface{}, error) {
	return s.Delete(fmt.Sprintf("events/%s/%s", client, check))
}

package sensu

import (
	"encoding/json"
	"fmt"
)

// GetEvents Return all the current events
func (s *Sensu) GetEvents() ([]interface{}, error) {
	return s.GetList("events", 0, 0)
}

// GetEventsForClient Returns the current events for given client
func (s *Sensu) GetEventsForClient(client string) ([]interface{}, error) {
	//return s.Get("events", client)
	// TODO  is this the correct way? need validation??
	return s.GetList(fmt.Sprintf("events/%s", client), 0, 0)
}

// GetEventsCheckForClient Returns the event for a check for a client
func (s *Sensu) GetEventsCheckForClient(client string, check string) ([]interface{}, error) {
	//return s.Get("events", client)
	// TODO  is this the correct way? need validation??
	return s.GetList(fmt.Sprintf("events/%s/%s", client, check), 0, 0)
}

// ResolveEvent delete an event
func (s *Sensu) ResolveEvent(payload interface{}) (map[string]interface{}, error) {
	//	return s.Post(fmt.Sprintf("stashes/create"), payload)
	payloadstr, err := json.Marshal(payload)
	if err != nil {
		return nil, fmt.Errorf("Stash parsing error: %q returned: %v", err, err)
	}
	return s.PostPayload("resolve", string(payloadstr[:]))
}

Add ResolveEvent function that use POST instead of DELETE
Add ResolveEvent function that use POST instead of DELETE
