Merge pull request #10964 from influxdata/view-label-links

fix(http): add labels to view links responses
pull/10974/head
Jade McGough 2019-01-10 12:51:58 -08:00 committed by GitHub
commit dcf606da9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -72,7 +72,8 @@ func NewViewHandler(mappingService platform.UserResourceMappingService, labelSer
}
type viewLinks struct {
Self string `json:"self"`
Self string `json:"self"`
Labels string `json:"labels"`
}
type viewResponse struct {
@ -100,7 +101,8 @@ func (r viewResponse) MarshalJSON() ([]byte, error) {
func newViewResponse(c *platform.View) viewResponse {
return viewResponse{
Links: viewLinks{
Self: fmt.Sprintf("/api/v2/views/%s", c.ID),
Self: fmt.Sprintf("/api/v2/views/%s", c.ID),
Labels: fmt.Sprintf("/api/v2/views/%s/labels", c.ID),
},
View: *c,
}

View File

@ -77,6 +77,7 @@ func TestService_handleGetViews(t *testing.T) {
"id": "7365637465747572",
"name": "hello",
"links": {
"labels": "/api/v2/views/7365637465747572/labels",
"self": "/api/v2/views/7365637465747572"
},
"properties": {
@ -95,6 +96,7 @@ func TestService_handleGetViews(t *testing.T) {
"id": "6167697474697320",
"name": "example",
"links": {
"labels": "/api/v2/views/6167697474697320/labels",
"self": "/api/v2/views/6167697474697320"
},
"properties": {
@ -210,6 +212,7 @@ func TestService_handleGetView(t *testing.T) {
"id": "020f755c3c082000",
"name": "example",
"links": {
"labels": "/api/v2/views/020f755c3c082000/labels",
"self": "/api/v2/views/020f755c3c082000"
},
"properties": {
@ -326,6 +329,7 @@ func TestService_handlePostViews(t *testing.T) {
"id": "020f755c3c082000",
"name": "hello",
"links": {
"labels": "/api/v2/views/020f755c3c082000/labels",
"self": "/api/v2/views/020f755c3c082000"
},
"properties": {
@ -529,6 +533,7 @@ func TestService_handlePatchView(t *testing.T) {
"id": "020f755c3c082000",
"name": "example",
"links": {
"labels": "/api/v2/views/020f755c3c082000/labels",
"self": "/api/v2/views/020f755c3c082000"
},
"properties": {