// Incidents fetches all incidents from PagerDuty with the specified filters.
167925
func (acct *account) Incidents(params map[string]string) (incidents []Incident, err error) {
	var (
		buf  []byte
		req  *http.Request
		resp *http.Response
	)

	endpoint := "api/v1/incidents"

	if len(params) > 0 {
		values := url.Values{}
		for k, v := range params {
			values.Set(k, v)
		}
		endpoint = fmt.Sprintf("%s?%s", endpoint, values.Encode())
	}

	if req, err = acct.getRequest(endpoint); err != nil {
		return
	}

	if resp, err = http.DefaultClient.Do(req); err != nil {
		return
	}

	if buf, err = ioutil.ReadAll(resp.Body); err != nil {
		return
	}

	defer resp.Body.Close()

	response := &IncidentsResponse{}

	if err = json.Unmarshal(buf, response); err != nil {
		return
	}

	incidents = response.Incidents
	return
}
511935
func (p *Session) All() (ret int) {
	p.db.Query("select count(*) from " + TABLE_NAME).Row(&ret)
	return
}
138748
func (r *Report) GetAllIssues() []*issue.Issue {
	var issues []*issue.Issue
	switch r.Type {
	case TypeMulti:
		for _, subReport := range r.Multi {
			issues = append(issues, subReport.GetAllIssues()...)
		}
	case TypeIssues:
		issues = append(issues, r.Issues...)
	}
	return issues
}
1313043
func Errors() HandlerFunc {
	return func(ctx *Context) {
		switch res := ctx.Result.(type) {
		case AbortError:
			ctx.WriteHeader(res.Code())
			ctx.WriteString(res.Error())
		case error:
			ctx.WriteHeader(http.StatusInternalServerError)
			ctx.WriteString(res.Error())
		default:
			ctx.WriteHeader(http.StatusInternalServerError)
			ctx.WriteString(http.StatusText(http.StatusInternalServerError))
		}
	}
}
685181
func (client *Client) GetRouteMappings(filters ...Filter) ([]RouteMapping, Warnings, error) {
	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.GetRouteMappingsRequest,
		Query:       ConvertFilterParameters(filters),
	})
	if err != nil {
		return nil, nil, err
	}

	var fullRouteMappingsList []RouteMapping
	warnings, err := client.paginate(request, RouteMapping{}, func(item interface{}) error {
		if routeMapping, ok := item.(RouteMapping); ok {
			fullRouteMappingsList = append(fullRouteMappingsList, routeMapping)
		} else {
			return ccerror.UnknownObjectInListError{
				Expected:   RouteMapping{},
				Unexpected: item,
			}
		}
		return nil
	})

	return fullRouteMappingsList, warnings, err
}
486973
func (env *environ) Instances(ctx context.ProviderCallContext, ids []instance.Id) (instances []instances.Instance, err error) {
	if len(ids) == 0 {
		return nil, environs.ErrNoInstances
	}
	err = env.withSession(ctx, func(env *sessionEnviron) error {
		instances, err = env.Instances(ctx, ids)
		return err
	})
	return instances, err
}
686508
func Filters(f ...Filter) Modifier {
	return func(r *http.Request) error {
		for _, filter := range f {
			filter(r)
		}
		return nil // Or should filter return err?
	}
}
1168356
func (s *DeleteByQueryService) Conflicts(conflicts string) *DeleteByQueryService {
	s.conflicts = conflicts
	return s
}
1028531
func (o *VRS) Alarms(info *bambou.FetchingInfo) (AlarmsList, *bambou.Error) {

	var list AlarmsList
	err := bambou.CurrentSession().FetchChildren(o, AlarmIdentity, &list, info)
	return list, err
}
1345495
func Filters(f filter.Filter) func(Call) error {
	return func(hc Call) error {
		if c, ok := hc.(hasQueryOptions); ok {
			pbF, err := f.ConstructPBFilter()
			if err != nil {
				return err
			}
			c.setFilter(pbF)
			return nil
		}
		return errors.New("'Filters' option can only be used with Get or Scan request")
	}
}
1298181
func (i *GetAPIEventsFilterInput) formatEventFilters() map[string]string {
	result := map[string]string{}
	pairings := map[string]interface{}{
		"filter[customer_id]": i.CustomerID,
		"filter[service_id]":  i.ServiceID,
		"filter[event_type]":  i.EventType,
		"filter[user_id]":     i.UserID,
		"page[size]":          i.MaxResults,
		"page[number]":        i.PageNumber, // starts at 1, not 0
	}
	// NOTE: This setup means we will not be able to send the zero value
	// of any of these filters. It doesn't appear we would need to at present.

	for key, value := range pairings {
		switch t := reflect.TypeOf(value).String(); t {
		case "string":
			if value != "" {
				result[key] = value.(string)
			}
		case "int":
			if value != 0 {
				result[key] = strconv.Itoa(value.(int))
			}
		}

	}
	return result
}
996602
func (w Week) Occurrences(tr TimeRange) chan time.Time {
	return occurrencesFor(w, tr)
}
695270
func (rpc *EthRPC) EthGetFilterChanges(filterID string) ([]Log, error) {
	var logs = []Log{}
	err := rpc.call("eth_getFilterChanges", &logs, filterID)
	return logs, err
}
1060051
func (api *Client) ListReactions(params ListReactionsParameters) ([]ReactedItem, *Paging, error) {
	return api.ListReactionsContext(context.Background(), params)
}
1065374
func HandleParseErrors(rawConfig []byte, to interface{}) (report.Report, error) {
	err := json.Unmarshal(rawConfig, to)
	if err == nil {
		return report.Report{}, nil
	}

	// Handle json syntax and type errors first, since they are fatal but have offset info
	if serr, ok := err.(*json.SyntaxError); ok {
		line, col, highlight := util.Highlight(rawConfig, serr.Offset)
		return report.Report{
				Entries: []report.Entry{{
					Kind:      report.EntryError,
					Message:   serr.Error(),
					Line:      line,
					Column:    col,
					Highlight: highlight,
				}},
			},
			errors.ErrInvalid
	}

	if terr, ok := err.(*json.UnmarshalTypeError); ok {
		line, col, highlight := util.Highlight(rawConfig, terr.Offset)
		return report.Report{
				Entries: []report.Entry{{
					Kind:      report.EntryError,
					Message:   terr.Error(),
					Line:      line,
					Column:    col,
					Highlight: highlight,
				}},
			},
			errors.ErrInvalid
	}

	return report.ReportFromError(err, report.EntryError), errors.ErrInvalid
}
1011945
func (handler *Handler) Events() []*event.Event {
	handler.mutex.Lock()
	dst := make([]*event.Event, len(handler.events))
	_ = copy(dst, handler.events)
	handler.mutex.Unlock()

	return dst
}
1181485
func (h *errorHandler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
	rcode, err := plugin.NextOrFailure(h.Name(), h.Next, ctx, w, r)

	if err != nil {
		strErr := err.Error()
		for i := range h.patterns {
			if h.patterns[i].pattern.MatchString(strErr) {
				if h.inc(i) {
					return rcode, err
				}
				break
			}
		}
		state := request.Request{W: w, Req: r}
		log.Errorf("%d %s %s: %s", rcode, state.Name(), state.Type(), strErr)
	}

	return rcode, err
}