forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequests.go
32 lines (26 loc) · 799 Bytes
/
requests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package http
import (
"context"
"net/http"
platform "github.com/influxdata/influxdb"
)
const (
// OrgName is the http query parameter to specify an organization by name.
OrgName = "org"
// OrgID is the http query parameter to specify an organization by ID.
OrgID = "orgID"
)
// queryOrganization returns the organization for any http request.
func queryOrganization(ctx context.Context, r *http.Request, svc platform.OrganizationService) (o *platform.Organization, err error) {
filter := platform.OrganizationFilter{}
if reqID := r.URL.Query().Get(OrgID); reqID != "" {
filter.ID, err = platform.IDFromString(reqID)
if err != nil {
return nil, err
}
}
if name := r.URL.Query().Get(OrgName); name != "" {
filter.Name = &name
}
return svc.FindOrganization(ctx, filter)
}