2019-01-08 00:37:16 +00:00
|
|
|
package influxdb
|
2018-12-08 13:14:57 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
2018-12-09 15:21:05 +00:00
|
|
|
const (
|
|
|
|
DefaultPageSize = 20
|
|
|
|
MaxPageSize = 100
|
|
|
|
)
|
|
|
|
|
2018-12-08 13:14:57 +00:00
|
|
|
// PagingFilter represents a filter containing url query params.
|
|
|
|
type PagingFilter interface {
|
|
|
|
// QueryParams returns a map containing url query params.
|
|
|
|
QueryParams() map[string][]string
|
|
|
|
}
|
|
|
|
|
|
|
|
// PagingLinks represents paging links.
|
|
|
|
type PagingLinks struct {
|
2018-12-12 16:01:16 +00:00
|
|
|
Prev string `json:"prev,omitempty"`
|
2018-12-12 15:22:24 +00:00
|
|
|
Self string `json:"self"`
|
2018-12-12 16:01:16 +00:00
|
|
|
Next string `json:"next,omitempty"`
|
2018-12-08 13:14:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FindOptions represents options passed to all find methods with multiple results.
|
|
|
|
type FindOptions struct {
|
|
|
|
Limit int
|
|
|
|
Offset int
|
|
|
|
SortBy string
|
|
|
|
Descending bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// QueryParams returns a map containing url query params.
|
|
|
|
func (f FindOptions) QueryParams() map[string][]string {
|
|
|
|
qp := map[string][]string{
|
2018-12-21 21:17:18 +00:00
|
|
|
"descending": {strconv.FormatBool(f.Descending)},
|
2019-12-10 03:11:53 +00:00
|
|
|
"offset": {strconv.Itoa(f.Offset)},
|
2018-12-08 13:14:57 +00:00
|
|
|
}
|
|
|
|
|
2018-12-30 10:07:11 +00:00
|
|
|
if f.Limit > 0 {
|
|
|
|
qp["limit"] = []string{strconv.Itoa(f.Limit)}
|
|
|
|
}
|
|
|
|
|
|
|
|
if f.SortBy != "" {
|
|
|
|
qp["sortBy"] = []string{f.SortBy}
|
|
|
|
}
|
|
|
|
|
2018-12-08 13:14:57 +00:00
|
|
|
return qp
|
|
|
|
}
|