Skip to content

Commit

Permalink
metrics collections as path param and not query param
Browse files Browse the repository at this point in the history
Signed-off-by: David Echelberger <david.echelberger@kaleido.io>
David Echelberger committed Dec 3, 2021
1 parent a6a9c26 commit 59e4f15
Showing 3 changed files with 14 additions and 13 deletions.
13 changes: 7 additions & 6 deletions docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
@@ -931,7 +931,7 @@ paths:
description: Success
default:
description: ""
/namespaces/{ns}/charts/histogram:
/namespaces/{ns}/charts/histogram/{collection}:
get:
description: 'TODO: Description'
operationId: getChartHistogram
@@ -943,6 +943,12 @@ paths:
schema:
example: default
type: string
- description: 'TODO: Description'
in: path
name: collection
required: true
schema:
type: string
- description: Start time of the data to be fetched
in: query
name: startTime
@@ -958,11 +964,6 @@ paths:
name: buckets
schema:
type: string
- description: Collection to fetch
in: query
name: collection
schema:
type: string
- description: Server-side request timeout (millseconds, or set a custom suffix
like 10s)
in: header
6 changes: 3 additions & 3 deletions internal/apiserver/route_get_chart_histogram.go
Original file line number Diff line number Diff line change
@@ -29,16 +29,16 @@ import (

var getChartHistogram = &oapispec.Route{
Name: "getChartHistogram",
Path: "namespaces/{ns}/charts/histogram",
Path: "namespaces/{ns}/charts/histogram/{collection}",
Method: http.MethodGet,
PathParams: []*oapispec.PathParam{
{Name: "ns", ExampleFromConf: config.NamespacesDefault, Description: i18n.MsgTBD},
{Name: "collection", Description: i18n.MsgTBD},
},
QueryParams: []*oapispec.QueryParam{
{Name: "startTime", Description: i18n.MsgHistogramStartTimeParam, IsBool: false},
{Name: "endTime", Description: i18n.MsgHistogramEndTimeParam, IsBool: false},
{Name: "buckets", Description: i18n.MsgHistogramBucketsParam, IsBool: false},
{Name: "collection", Description: i18n.MsgHistogramCollectionParam, IsBool: false},
},
FilterFactory: nil,
Description: i18n.MsgTBD,
@@ -58,6 +58,6 @@ var getChartHistogram = &oapispec.Route{
if err != nil {
return nil, i18n.NewError(r.Ctx, i18n.MsgInvalidChartNumberParam, "buckets")
}
return r.Or.GetChartHistogram(r.Ctx, r.PP["ns"], startTime.UnixNano(), endTime.UnixNano(), buckets, database.CollectionName(r.QP["collection"]))
return r.Or.GetChartHistogram(r.Ctx, r.PP["ns"], startTime.UnixNano(), endTime.UnixNano(), buckets, database.CollectionName(r.PP["collection"]))
},
}
8 changes: 4 additions & 4 deletions internal/apiserver/route_get_chart_histogram_test.go
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ import (

func TestGetChartHistogramBadStartTime(t *testing.T) {
_, r := newTestAPIServer()
req := httptest.NewRequest("GET", "/api/v1/namespaces/mynamespace/charts/histogram?collection=test&startTime=abc&endTime=456&buckets=30", nil)
req := httptest.NewRequest("GET", "/api/v1/namespaces/mynamespace/charts/histogram/test?startTime=abc&endTime=456&buckets=30", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

@@ -39,7 +39,7 @@ func TestGetChartHistogramBadStartTime(t *testing.T) {

func TestGetChartHistogramBadEndTime(t *testing.T) {
_, r := newTestAPIServer()
req := httptest.NewRequest("GET", "/api/v1/namespaces/mynamespace/charts/histogram?collection=test&startTime=123&endTime=abc&buckets=30", nil)
req := httptest.NewRequest("GET", "/api/v1/namespaces/mynamespace/charts/histogram/test?startTime=123&endTime=abc&buckets=30", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

@@ -50,7 +50,7 @@ func TestGetChartHistogramBadEndTime(t *testing.T) {

func TestGetChartHistogramBadBuckets(t *testing.T) {
_, r := newTestAPIServer()
req := httptest.NewRequest("GET", "/api/v1/namespaces/mynamespace/charts/histogram?collection=test&startTime=123&endTime=456&buckets=abc", nil)
req := httptest.NewRequest("GET", "/api/v1/namespaces/mynamespace/charts/histogram/test?startTime=123&endTime=456&buckets=abc", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

@@ -61,7 +61,7 @@ func TestGetChartHistogramBadBuckets(t *testing.T) {

func TestGetChartHistogramSuccess(t *testing.T) {
o, r := newTestAPIServer()
req := httptest.NewRequest("GET", "/api/v1/namespaces/mynamespace/charts/histogram?collection=test&startTime=1234567890&endTime=1234567891&buckets=30", nil)
req := httptest.NewRequest("GET", "/api/v1/namespaces/mynamespace/charts/histogram/test?startTime=1234567890&endTime=1234567891&buckets=30", nil)
req.Header.Set("Content-Type", "application/json; charset=utf-8")
res := httptest.NewRecorder()

0 comments on commit 59e4f15

Please sign in to comment.