From 46dcf7b0cbc08ca1b7d5148cbf9585f3461f7086 Mon Sep 17 00:00:00 2001 From: "stonezdj(Daojun Zhang)" <stonezdj@gmail.com> Date: Tue, 27 Apr 2021 12:35:00 +0800 Subject: [PATCH] Add missing operationId in swagger.yaml (#14722) Add operationId for systeminfo api Add operationId for configure api Update api test after adding operationId Fixes #14617 Signed-off-by: stonezdj <stonezdj@gmail.com> --- api/v2.0/swagger.yaml | 6 ++++++ src/server/v2.0/handler/config.go | 4 ++-- src/server/v2.0/handler/systeminfo.go | 12 ++++++------ tests/apitests/python/library/configurations.py | 4 ++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/api/v2.0/swagger.yaml b/api/v2.0/swagger.yaml index 455c7ea42f..bbd5ed7671 100644 --- a/api/v2.0/swagger.yaml +++ b/api/v2.0/swagger.yaml @@ -196,6 +196,7 @@ paths: /internalconfig: get: summary: Get internal configurations. + operationId: getInternalconfig description: | This endpoint is for retrieving system configurations that only provides for internal api call. tags: @@ -216,6 +217,7 @@ paths: /configurations: get: summary: Get system configurations. + operationId: getConfigurations description: | This endpoint is for retrieving system configurations that only provides for admin user. tags: @@ -235,6 +237,7 @@ paths: description: Unexpected internal errors. put: summary: Modify system configurations. + operationId: updateConfigurations description: | This endpoint is for modifying system configurations that only provides for admin user. tags: @@ -3607,6 +3610,7 @@ paths: /systeminfo: get: summary: Get general system info + operationId: getSystemInfo description: | This API is for retrieving general system info, this can be called by anonymous request. Some attributes will be omitted in the response when this API is called by anonymous request. tags: @@ -3621,6 +3625,7 @@ paths: /systeminfo/volumes: get: summary: Get system volume info (total/free size). + operationId: getVolumes description: | This endpoint is for retrieving system volume info that only provides for admin user. Note that the response only reflects the storage status of local disk. tags: @@ -3641,6 +3646,7 @@ paths: /systeminfo/getcert: get: summary: Get default root certificate. + operationId: getCert description: | This endpoint is for downloading a default root certificate. tags: diff --git a/src/server/v2.0/handler/config.go b/src/server/v2.0/handler/config.go index f50d45991e..fbe0b9cdfb 100644 --- a/src/server/v2.0/handler/config.go +++ b/src/server/v2.0/handler/config.go @@ -70,7 +70,7 @@ func (c *configAPI) GetConfigurations(ctx context.Context, params configure.GetC return configure.NewGetConfigurationsOK().WithPayload(payload) } -func (c *configAPI) PutConfigurations(ctx context.Context, params configure.PutConfigurationsParams) middleware.Responder { +func (c *configAPI) UpdateConfigurations(ctx context.Context, params configure.UpdateConfigurationsParams) middleware.Responder { if err := c.RequireSystemAccess(ctx, rbac.ActionUpdate, rbac.ResourceConfiguration); err != nil { return c.SendError(ctx, err) } @@ -82,7 +82,7 @@ func (c *configAPI) PutConfigurations(ctx context.Context, params configure.PutC if err != nil { return c.SendError(ctx, err) } - return configure.NewPutConfigurationsOK() + return configure.NewUpdateConfigurationsOK() } func (c *configAPI) GetInternalconfig(ctx context.Context, params configure.GetInternalconfigParams) middleware.Responder { diff --git a/src/server/v2.0/handler/systeminfo.go b/src/server/v2.0/handler/systeminfo.go index c794bf30f1..e29afc5dd6 100644 --- a/src/server/v2.0/handler/systeminfo.go +++ b/src/server/v2.0/handler/systeminfo.go @@ -22,7 +22,7 @@ func newSystemInfoAPI() *sysInfoAPI { } } -func (s *sysInfoAPI) GetSysteminfo(ctx context.Context, params systeminfo.GetSysteminfoParams) middleware.Responder { +func (s *sysInfoAPI) GetSystemInfo(ctx context.Context, params systeminfo.GetSystemInfoParams) middleware.Responder { opt := si.Options{} sc, ok := security.FromContext(ctx) if ok && sc.IsAuthenticated() { @@ -32,18 +32,18 @@ func (s *sysInfoAPI) GetSysteminfo(ctx context.Context, params systeminfo.GetSys if err != nil { return s.SendError(ctx, err) } - return systeminfo.NewGetSysteminfoOK().WithPayload(s.convertInfo(data)) + return systeminfo.NewGetSystemInfoOK().WithPayload(s.convertInfo(data)) } -func (s *sysInfoAPI) GetSysteminfoGetcert(ctx context.Context, params systeminfo.GetSysteminfoGetcertParams) middleware.Responder { +func (s *sysInfoAPI) GetCert(ctx context.Context, params systeminfo.GetCertParams) middleware.Responder { f, err := s.ctl.GetCA(ctx) if err != nil { return s.SendError(ctx, err) } - return systeminfo.NewGetSysteminfoGetcertOK().WithContentDisposition("attachment; filename=ca.crt").WithPayload(f) + return systeminfo.NewGetCertOK().WithContentDisposition("attachment; filename=ca.crt").WithPayload(f) } -func (s *sysInfoAPI) GetSysteminfoVolumes(ctx context.Context, params systeminfo.GetSysteminfoVolumesParams) middleware.Responder { +func (s *sysInfoAPI) GetVolumes(ctx context.Context, params systeminfo.GetVolumesParams) middleware.Responder { if err := s.RequireSystemAccess(ctx, rbac.ActionRead, rbac.ResourceSystemVolumes); err != nil { return s.SendError(ctx, err) } @@ -51,7 +51,7 @@ func (s *sysInfoAPI) GetSysteminfoVolumes(ctx context.Context, params systeminfo if err != nil { return s.SendError(ctx, err) } - return systeminfo.NewGetSysteminfoVolumesOK().WithPayload(&models.SystemInfo{ + return systeminfo.NewGetVolumesOK().WithPayload(&models.SystemInfo{ Storage: []*models.Storage{ { Free: c.Free, diff --git a/tests/apitests/python/library/configurations.py b/tests/apitests/python/library/configurations.py index caec7d65c1..5e880651f2 100644 --- a/tests/apitests/python/library/configurations.py +++ b/tests/apitests/python/library/configurations.py @@ -27,7 +27,7 @@ def set_configurations(client, expect_status_code = 200, expect_response_body = conf["ldap_group_admin_dn"] = config.get("ldap_group_admin_dn") try: - _, status_code, _ = client.configurations_put_with_http_info(conf) + _, status_code, _ = client.update_configurations_with_http_info(conf) except ApiException as e: base._assert_status_code(expect_status_code, e.status) if expect_response_body is not None: @@ -44,7 +44,7 @@ class Configurations(base.Base, object): client = self._get_client(**kwargs) try: - data, status_code, _ = client.configurations_get_with_http_info() + data, status_code, _ = client.get_configurations_with_http_info() except ApiException as e: base._assert_status_code(expect_status_code, e.status) if expect_response_body is not None: