influxdata / influxdata/influxdb
Complete notification endpoint HTTP client
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
__UPDATE__ see comment below https://github.com/influxdata/influxdb/issues/17023#issuecomment-592073363.
See `influxdb/http/notification_endpoint.go`.
The client covers (has methods for soliciting) these URIs:
```
const (
prefixNotificationEndpoints = "/api/v2/notificationEndpoints"
notificationEndpointsIDPath = "/api/v2/notificationEndpoints/:id"
```
But not these:
```
notificationEndpointsIDMembersPath = "/api/v2/notificationEndpoints/:id/members"
notificationEndpointsIDMembersIDPath = "/api/v2/notificationEndpoints/:id/members/:userID"
notificationEndpointsIDOwnersPath = "/api/v2/notificationEndpoints/:id/owners"
notificationEndpointsIDOwnersIDPath = "/api/v2/notificationEndpoints/:id/owners/:userID"
notificationEndpointsIDLabelsPath = "/api/v2/notificationEndpoints/:id/labels"
notificationEndpointsIDLabelsIDPath = "/api/v2/notificationEndpoints/:id/labels/:lid"
)
```
Even if there are handlers mounted for those:
```
h.HandlerFunc("POST", notificationEndpointsIDMembersPath, newPostMemberHandler(memberBackend))
h.HandlerFunc("GET", notificationEndpointsIDMembersPath, newGetMembersHandler(memberBackend))
h.HandlerFunc("DELETE", notificationEndpointsIDMembersIDPath, newDeleteMemberHandler(memberBackend))
...
```
Also it is not clear to me why the HTTP client __is__ also a `UserResourceMappingService` and a `OrganizationService`:
```
type NotificationEndpointService struct {
Client *httpc.Client
*UserResourceMappingService
*OrganizationService
}
```
Those clients executes http requests not to the URIs above, but to the "standard ones"; e.g.
```
func resourceIDPath(resourceType influxdb.ResourceType, resourceID influxdb.ID, p string) string {
return path.Join("/api/v2/", string(resourceType), resourceID.String(), p)
}
```
Also, those methods cannot be overridden, otherwise, when used in a `*http.Service` they would break the actual implementation of those individual services.
The client should not embed those clients:
```
type NotificationEndpointService struct {
Client *httpc.Client
urms *UserResourceMappingService
os *OrganizationService
}
```
And provide a different prefix URIs to those services.
Then, provide different methods also to limit the surface of what one can do (URMService and Org actually expose more surface).
Contributor guide
Assessment
This issue has not been assessed yet.