func (p *PagerDuty) Do(c context.Context) error {
	if config.PagerDutyKey == "" {
		return errors.New("pagerduty key not set in config")
	}
	if p.Key == "" {
		p.Key = c.Name
	}
	body := map[string]interface{}{
		"service_key":  config.PagerDutyKey,
		"event_type":   "trigger",
		"description":  p.Description,
		"incident_key": p.Key,
		"details":      p.Details,
	}
	bodyb, err := json.Marshal(&body)
	if err != nil {
		return err
	}
	u := "https://events.pagerduty.com/generic/2010-04-15/create_event.json"
	r, err := http.NewRequest("POST", u, bytes.NewBuffer(bodyb))
	if err != nil {
		return err
	}
	r.Header.Set("Content-Type", "application/json")
	resp, err := http.DefaultClient.Do(r)
	if err != nil {
		return err
	}
	resp.Body.Close()
	return nil
}
Do performs the actual trigger request to the pagerduty api
package action
import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"net/http"
	"strings"
	"github.com/levenlabs/go-llog"
	"github.com/levenlabs/thumper/config"
	"github.com/levenlabs/thumper/context"
	"github.com/mitchellh/mapstructure"
)
type Actioner interface {
	Do(context.Context) error
}
type Action struct {
	Type string
	Actioner
}
func ToActioner(in interface{}) (Action, error) {
	min, ok := in.(map[string]interface{})
	if !ok {
		return Action{}, errors.New("action definition is not an object")
	}
	var a Actioner
	typ, _ := min["type"].(string)
	typ = strings.ToLower(typ)
	switch typ {
	case "log":
		a = &Log{}
	case "http":
		a = &HTTP{}
	case "pagerduty":
		a = &PagerDuty{}
	case "opsgenie":
		a = &OpsGenie{}
	default:
		return Action{}, fmt.Errorf("unknown action type: %q", typ)
	}
	if err := mapstructure.Decode(min, a); err != nil {
		return Action{}, err
	}
	return Action{Type: typ, Actioner: a}, nil
}
type Log struct {
	Message string `mapstructure:"message"`
}
func (l *Log) Do(_ context.Context) error {
	llog.Info("doing log action", llog.KV{"message": l.Message})
	return nil
}
type HTTP struct {
	Method  string            `mapstructure:"method"`
	URL     string            `mapstructure:"url"`
	Headers map[string]string `mapstructure:"headers"`
	Body    string            `mapstructure:"body"`
}
func (h *HTTP) Do(_ context.Context) error {
	r, err := http.NewRequest(h.Method, h.URL, bytes.NewBufferString(h.Body))
	if err != nil {
		return err
	}
	if h.Headers != nil {
		for k, v := range h.Headers {
			r.Header.Set(k, v)
		}
	}
	resp, err := http.DefaultClient.Do(r)
	if err != nil {
		return err
	}
	resp.Body.Close()
	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		return fmt.Errorf("non 2xx response code returned: %d", resp.StatusCode)
	}
	return nil
}
type PagerDuty struct {
	Key         string                 `mapstructure:"incident_key"`
	Description string                 `mapstructure:"description"`
	Details     map[string]interface{} `mapstructure:"details"`
}