From a914cea4372d6d2ad8fbea79e3ba34cb10548089 Mon Sep 17 00:00:00 2001 From: Alirie Gray Date: Mon, 27 Jul 2020 15:44:51 -0700 Subject: [PATCH] refactor: remove nested orgs labels route --- cmd/influxd/launcher/launcher.go | 2 +- http/swagger.yml | 95 -------------------------------- tenant/http_server_org.go | 3 +- tenant/http_server_org_test.go | 2 +- tenant/service.go | 5 +- 5 files changed, 5 insertions(+), 102 deletions(-) diff --git a/cmd/influxd/launcher/launcher.go b/cmd/influxd/launcher/launcher.go index 11d05aef6da..7839164abce 100644 --- a/cmd/influxd/launcher/launcher.go +++ b/cmd/influxd/launcher/launcher.go @@ -1114,7 +1114,7 @@ func (m *Launcher) run(ctx context.Context) (err error) { sessionHTTPServer = session.NewSessionHandler(m.log.With(zap.String("handler", "session")), sessionSvc, ts.UserSvc, ts.PasswordSvc) } - orgHTTPServer := ts.NewOrgHTTPHandler(m.log, labelSvc, secret.NewAuthedService(secretSvc)) + orgHTTPServer := ts.NewOrgHTTPHandler(m.log, secret.NewAuthedService(secretSvc)) bucketHTTPServer := ts.NewBucketHTTPHandler(m.log, labelSvc) diff --git a/http/swagger.yml b/http/swagger.yml index 290b30bc54e..435d6c6a0ba 100644 --- a/http/swagger.yml +++ b/http/swagger.yml @@ -4083,101 +4083,6 @@ paths: application/json: schema: $ref: "#/components/schemas/Error" - "/orgs/{orgID}/labels": - get: - operationId: GetOrgsIDLabels - tags: - - Organizations - summary: List all labels for a organization - parameters: - - $ref: "#/components/parameters/TraceSpan" - - in: path - name: orgID - schema: - type: string - required: true - description: The organization ID. - responses: - "200": - description: A list of all labels for an organization - content: - application/json: - schema: - $ref: "#/components/schemas/LabelsResponse" - default: - description: Unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - post: - operationId: PostOrgsIDLabels - tags: - - Organizations - summary: Add a label to an organization - parameters: - - $ref: "#/components/parameters/TraceSpan" - - in: path - name: orgID - schema: - type: string - required: true - description: The organization ID. - requestBody: - description: Label to add - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/LabelMapping" - responses: - "201": - description: Returns the created label - content: - application/json: - schema: - $ref: "#/components/schemas/LabelResponse" - default: - description: Unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - "/orgs/{orgID}/labels/{labelID}": - delete: - operationId: DeleteOrgsIDLabelsID - tags: - - Organizations - summary: Delete a label from an organization - parameters: - - $ref: "#/components/parameters/TraceSpan" - - in: path - name: orgID - schema: - type: string - required: true - description: The organization ID. - - in: path - name: labelID - schema: - type: string - required: true - description: The label ID. - responses: - "204": - description: Delete has been accepted - "404": - description: Organization not found - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - default: - description: Unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" "/orgs/{orgID}/secrets": get: operationId: GetOrgsIDSecrets diff --git a/tenant/http_server_org.go b/tenant/http_server_org.go index 4ab66122320..402803d5f9f 100644 --- a/tenant/http_server_org.go +++ b/tenant/http_server_org.go @@ -29,7 +29,7 @@ func (h *OrgHandler) Prefix() string { } // NewHTTPOrgHandler constructs a new http server. -func NewHTTPOrgHandler(log *zap.Logger, orgService influxdb.OrganizationService, urm http.Handler, labelHandler http.Handler, secretHandler http.Handler) *OrgHandler { +func NewHTTPOrgHandler(log *zap.Logger, orgService influxdb.OrganizationService, urm http.Handler, secretHandler http.Handler) *OrgHandler { svr := &OrgHandler{ api: kithttp.NewAPI(kithttp.WithLog(log)), log: log, @@ -56,7 +56,6 @@ func NewHTTPOrgHandler(log *zap.Logger, orgService influxdb.OrganizationService, mountableRouter := r.With(kithttp.ValidResource(svr.api, svr.lookupOrgByID)) mountableRouter.Mount("/members", urm) mountableRouter.Mount("/owners", urm) - mountableRouter.Mount("/labels", labelHandler) mountableRouter.Mount("/secrets", secretHandler) }) }) diff --git a/tenant/http_server_org_test.go b/tenant/http_server_org_test.go index b1ec4ab020e..c51d1ee01e3 100644 --- a/tenant/http_server_org_test.go +++ b/tenant/http_server_org_test.go @@ -30,7 +30,7 @@ func initHttpOrgService(f itesting.OrganizationFields, t *testing.T) (influxdb.O } } - handler := tenant.NewHTTPOrgHandler(zaptest.NewLogger(t), svc, nil, nil, nil) + handler := tenant.NewHTTPOrgHandler(zaptest.NewLogger(t), svc, nil, nil) r := chi.NewRouter() r.Mount(handler.Prefix(), handler) server := httptest.NewServer(r) diff --git a/tenant/service.go b/tenant/service.go index 15e19585eb1..d1fd597ee76 100644 --- a/tenant/service.go +++ b/tenant/service.go @@ -38,11 +38,10 @@ func NewSystem(store *Store, log *zap.Logger, reg prometheus.Registerer, metricO } } -func (ts *TenantSystem) NewOrgHTTPHandler(log *zap.Logger, labelSvc influxdb.LabelService, secretSvc influxdb.SecretService) *OrgHandler { +func (ts *TenantSystem) NewOrgHTTPHandler(log *zap.Logger, secretSvc influxdb.SecretService) *OrgHandler { secretHandler := secret.NewHandler(log, "id", secret.NewAuthedService(secretSvc)) urmHandler := NewURMHandler(log.With(zap.String("handler", "urm")), influxdb.OrgsResourceType, "id", ts.UserSvc, NewAuthedURMService(ts.OrgSvc, ts.UrmSvc)) - labelHandler := label.NewHTTPEmbeddedHandler(log.With(zap.String("handler", "label")), influxdb.OrgsResourceType, labelSvc) - return NewHTTPOrgHandler(log.With(zap.String("handler", "org")), NewAuthedOrgService(ts.OrgSvc), urmHandler, labelHandler, secretHandler) + return NewHTTPOrgHandler(log.With(zap.String("handler", "org")), NewAuthedOrgService(ts.OrgSvc), urmHandler, secretHandler) } func (ts *TenantSystem) NewBucketHTTPHandler(log *zap.Logger, labelSvc influxdb.LabelService) *BucketHandler {