From 4626ea1a0c0d087ee4937f601361e95a13b9e9a6 Mon Sep 17 00:00:00 2001 From: "docmerlin (j. Emrys Landivar)" Date: Wed, 18 Nov 2020 11:44:18 -0600 Subject: [PATCH 1/2] fix(api): make the dbrp api match the swagger spec The swagger spec is the source of truth for the API, and the DBRP api was divergent from this spec. This change should make it meet the spec. --- dbrp/http_server_dbrp.go | 6 +++--- dbrp/http_server_dbrp_test.go | 16 ++++++++-------- dbrp_mapping.go | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dbrp/http_server_dbrp.go b/dbrp/http_server_dbrp.go index 90bba898bc0..f36dc090f22 100644 --- a/dbrp/http_server_dbrp.go +++ b/dbrp/http_server_dbrp.go @@ -59,9 +59,9 @@ type createDBRPRequest struct { Database string `json:"database"` RetentionPolicy string `json:"retention_policy"` Default bool `json:"default"` - Org string `json:"organization"` - OrganizationID influxdb.ID `json:"organization_id"` - BucketID influxdb.ID `json:"bucket_id"` + Org string `json:"org"` + OrganizationID influxdb.ID `json:"orgID"` + BucketID influxdb.ID `json:"bucketID"` } func (h *Handler) handlePostDBRP(w http.ResponseWriter, r *http.Request) { diff --git a/dbrp/http_server_dbrp_test.go b/dbrp/http_server_dbrp_test.go index fca3c414376..aaa24aa7cd4 100644 --- a/dbrp/http_server_dbrp_test.go +++ b/dbrp/http_server_dbrp_test.go @@ -59,8 +59,8 @@ func Test_handlePostDBRP(t *testing.T) { { Name: "Create valid dbrp", Input: strings.NewReader(`{ - "bucket_id": "5555f7ed2a035555", - "organization_id": "059af7ed2a034000", + "bucketID": "5555f7ed2a035555", + "orgID": "059af7ed2a034000", "database": "mydb", "retention_policy": "autogen", "default": false @@ -72,8 +72,8 @@ func Test_handlePostDBRP(t *testing.T) { { Name: "Create valid dbrp by org name", Input: strings.NewReader(`{ - "bucket_id": "5555f7ed2a035555", - "organization": "org", + "bucketID": "5555f7ed2a035555", + "org": "org", "database": "mydb", "retention_policy": "autogen", "default": false @@ -85,8 +85,8 @@ func Test_handlePostDBRP(t *testing.T) { { Name: "Create with invalid orgID", Input: strings.NewReader(`{ - "bucket_id": "5555f7ed2a035555", - "organization_id": "invalid", + "bucketID": "5555f7ed2a035555", + "orgID": "invalid", "database": "mydb", "retention_policy": "autogen", "default": false @@ -100,8 +100,8 @@ func Test_handlePostDBRP(t *testing.T) { { Name: "Create with invalid org name", Input: strings.NewReader(`{ - "bucket_id": "5555f7ed2a035555", - "organization": "invalid", + "bucketID": "5555f7ed2a035555", + "org": "invalid", "database": "mydb", "retention_policy": "autogen", "default": false diff --git a/dbrp_mapping.go b/dbrp_mapping.go index c1c69c11394..34089da02de 100644 --- a/dbrp_mapping.go +++ b/dbrp_mapping.go @@ -33,8 +33,8 @@ type DBRPMappingV2 struct { // Default indicates if this mapping is the default for the cluster and database. Default bool `json:"default"` - OrganizationID ID `json:"organization_id"` - BucketID ID `json:"bucket_id"` + OrganizationID ID `json:"orgID"` + BucketID ID `json:"bucketID"` } // Validate reports any validation errors for the mapping. From 2b6ff95637d24ab34937ece60e6fe3abac3f3602 Mon Sep 17 00:00:00 2001 From: "docmerlin (j. Emrys Landivar)" Date: Wed, 18 Nov 2020 11:46:53 -0600 Subject: [PATCH 2/2] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c2faa5d63b..b304acd1929 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ 1. [20047](https://github.com/influxdata/influxdb/pull/20047): Allow scraper to ignore insecure certificates on a target. Thanks @cmackenzie1! 1. [20076](https://github.com/influxdata/influxdb/pull/20076): Remove internal `influxd upgrade` subcommands from help text. 1. [20074](https://github.com/influxdata/influxdb/pull/20074): Use default DBRP mapping on V1 write when no RP is specified. +1. [20091](https://github.com/influxdata/influxdb/pull/20091): Make the DBRP http API match the swagger spec. ## v2.0.1 [2020-11-10]