From 44f4e37e834da68ca2ac96b91cb848f3731089a4 Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Thu, 1 Dec 2022 12:54:14 -0500 Subject: [PATCH] remove service03 type; consolidated service type (#119) --- controller/get_service.go | 4 +- controller/overview.go | 26 ++++--- .../service/get_service_responses.go | 6 +- rest_model_zrok/service.go | 12 +++ rest_model_zrok/service03.go | 71 ------------------ rest_server_zrok/embedded_spec.go | 74 +++++-------------- .../service/get_service_responses.go | 6 +- specs/zrok.yml | 16 +--- ui/src/api/service.js | 2 +- ui/src/api/types.js | 12 +-- 10 files changed, 62 insertions(+), 167 deletions(-) delete mode 100644 rest_model_zrok/service03.go diff --git a/controller/get_service.go b/controller/get_service.go index b4a3b251..f19286be 100644 --- a/controller/get_service.go +++ b/controller/get_service.go @@ -40,12 +40,14 @@ func getServiceHandler(params service.GetServiceParams, principal *rest_model_zr return service.NewGetServiceNotFound() } - svc := &rest_model_zrok.Service03{ + svc := &rest_model_zrok.Service{ Token: ssvc.Token, ZID: ssvc.ZId, ShareMode: ssvc.ShareMode, BackendMode: ssvc.BackendMode, Reserved: ssvc.Reserved, + CreatedAt: ssvc.CreatedAt.UnixMilli(), + UpdatedAt: ssvc.UpdatedAt.UnixMilli(), } if ssvc.FrontendSelection != nil { svc.FrontendSelection = *ssvc.FrontendSelection diff --git a/controller/overview.go b/controller/overview.go index c7e9c801..5df1aaac 100644 --- a/controller/overview.go +++ b/controller/overview.go @@ -45,22 +45,30 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ return metadata.NewOverviewInternalServerError() } for _, svc := range svcs { - fe := "" + feEndpoint := "" if svc.FrontendEndpoint != nil { - fe = *svc.FrontendEndpoint + feEndpoint = *svc.FrontendEndpoint } - be := "" + feSelection := "" + if svc.FrontendSelection != nil { + feSelection = *svc.FrontendSelection + } + beProxyEndpoint := "" if svc.BackendProxyEndpoint != nil { - be = *svc.BackendProxyEndpoint + beProxyEndpoint = *svc.BackendProxyEndpoint } es.Services = append(es.Services, &rest_model_zrok.Service{ - CreatedAt: svc.CreatedAt.UnixMilli(), - FrontendEndpoint: fe, - BackendProxyEndpoint: be, - UpdatedAt: svc.UpdatedAt.UnixMilli(), - ZID: svc.ZId, Token: svc.Token, + ZID: svc.ZId, + ShareMode: svc.ShareMode, + BackendMode: svc.BackendMode, + FrontendSelection: feSelection, + FrontendEndpoint: feEndpoint, + BackendProxyEndpoint: beProxyEndpoint, + Reserved: svc.Reserved, Metrics: sparkData[svc.Token], + CreatedAt: svc.CreatedAt.UnixMilli(), + UpdatedAt: svc.UpdatedAt.UnixMilli(), }) } out = append(out, es) diff --git a/rest_client_zrok/service/get_service_responses.go b/rest_client_zrok/service/get_service_responses.go index 670ad85e..c41aedf4 100644 --- a/rest_client_zrok/service/get_service_responses.go +++ b/rest_client_zrok/service/get_service_responses.go @@ -63,7 +63,7 @@ GetServiceOK describes a response with status code 200, with default header valu ok */ type GetServiceOK struct { - Payload *rest_model_zrok.Service03 + Payload *rest_model_zrok.Service } // IsSuccess returns true when this get service o k response has a 2xx status code @@ -99,13 +99,13 @@ func (o *GetServiceOK) String() string { return fmt.Sprintf("[GET /service][%d] getServiceOK %+v", 200, o.Payload) } -func (o *GetServiceOK) GetPayload() *rest_model_zrok.Service03 { +func (o *GetServiceOK) GetPayload() *rest_model_zrok.Service { return o.Payload } func (o *GetServiceOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - o.Payload = new(rest_model_zrok.Service03) + o.Payload = new(rest_model_zrok.Service) // response payload if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { diff --git a/rest_model_zrok/service.go b/rest_model_zrok/service.go index c56de2f8..478bd8b3 100644 --- a/rest_model_zrok/service.go +++ b/rest_model_zrok/service.go @@ -18,6 +18,9 @@ import ( // swagger:model service type Service struct { + // backend mode + BackendMode string `json:"backendMode,omitempty"` + // backend proxy endpoint BackendProxyEndpoint string `json:"backendProxyEndpoint,omitempty"` @@ -27,9 +30,18 @@ type Service struct { // frontend endpoint FrontendEndpoint string `json:"frontendEndpoint,omitempty"` + // frontend selection + FrontendSelection string `json:"frontendSelection,omitempty"` + // metrics Metrics ServiceMetrics `json:"metrics,omitempty"` + // reserved + Reserved bool `json:"reserved,omitempty"` + + // share mode + ShareMode string `json:"shareMode,omitempty"` + // token Token string `json:"token,omitempty"` diff --git a/rest_model_zrok/service03.go b/rest_model_zrok/service03.go deleted file mode 100644 index 5ef1a311..00000000 --- a/rest_model_zrok/service03.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package rest_model_zrok - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// Service03 service03 -// -// swagger:model service03 -type Service03 struct { - - // backend mode - BackendMode string `json:"backendMode,omitempty"` - - // backend proxy endpoint - BackendProxyEndpoint string `json:"backendProxyEndpoint,omitempty"` - - // frontend endpoint - FrontendEndpoint string `json:"frontendEndpoint,omitempty"` - - // frontend selection - FrontendSelection string `json:"frontendSelection,omitempty"` - - // reserved - Reserved bool `json:"reserved,omitempty"` - - // share mode - ShareMode string `json:"shareMode,omitempty"` - - // token - Token string `json:"token,omitempty"` - - // z Id - ZID string `json:"zId,omitempty"` -} - -// Validate validates this service03 -func (m *Service03) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this service03 based on context it is used -func (m *Service03) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *Service03) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *Service03) UnmarshalBinary(b []byte) error { - var res Service03 - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/rest_server_zrok/embedded_spec.go b/rest_server_zrok/embedded_spec.go index d3254355..99567025 100644 --- a/rest_server_zrok/embedded_spec.go +++ b/rest_server_zrok/embedded_spec.go @@ -284,7 +284,7 @@ func init() { "200": { "description": "ok", "schema": { - "$ref": "#/definitions/service03" + "$ref": "#/definitions/service" } }, "401": { @@ -632,6 +632,9 @@ func init() { "service": { "type": "object", "properties": { + "backendMode": { + "type": "string" + }, "backendProxyEndpoint": { "type": "string" }, @@ -641,35 +644,12 @@ func init() { "frontendEndpoint": { "type": "string" }, - "metrics": { - "$ref": "#/definitions/serviceMetrics" - }, - "token": { - "type": "string" - }, - "updatedAt": { - "type": "integer" - }, - "zId": { - "type": "string" - } - } - }, - "service03": { - "type": "object", - "properties": { - "backendMode": { - "type": "string" - }, - "backendProxyEndpoint": { - "type": "string" - }, - "frontendEndpoint": { - "type": "string" - }, "frontendSelection": { "type": "string" }, + "metrics": { + "$ref": "#/definitions/serviceMetrics" + }, "reserved": { "type": "boolean" }, @@ -679,6 +659,9 @@ func init() { "token": { "type": "string" }, + "updatedAt": { + "type": "integer" + }, "zId": { "type": "string" } @@ -1085,7 +1068,7 @@ func init() { "200": { "description": "ok", "schema": { - "$ref": "#/definitions/service03" + "$ref": "#/definitions/service" } }, "401": { @@ -1433,6 +1416,9 @@ func init() { "service": { "type": "object", "properties": { + "backendMode": { + "type": "string" + }, "backendProxyEndpoint": { "type": "string" }, @@ -1442,35 +1428,12 @@ func init() { "frontendEndpoint": { "type": "string" }, - "metrics": { - "$ref": "#/definitions/serviceMetrics" - }, - "token": { - "type": "string" - }, - "updatedAt": { - "type": "integer" - }, - "zId": { - "type": "string" - } - } - }, - "service03": { - "type": "object", - "properties": { - "backendMode": { - "type": "string" - }, - "backendProxyEndpoint": { - "type": "string" - }, - "frontendEndpoint": { - "type": "string" - }, "frontendSelection": { "type": "string" }, + "metrics": { + "$ref": "#/definitions/serviceMetrics" + }, "reserved": { "type": "boolean" }, @@ -1480,6 +1443,9 @@ func init() { "token": { "type": "string" }, + "updatedAt": { + "type": "integer" + }, "zId": { "type": "string" } diff --git a/rest_server_zrok/operations/service/get_service_responses.go b/rest_server_zrok/operations/service/get_service_responses.go index 738bd5bf..5de48837 100644 --- a/rest_server_zrok/operations/service/get_service_responses.go +++ b/rest_server_zrok/operations/service/get_service_responses.go @@ -26,7 +26,7 @@ type GetServiceOK struct { /* In: Body */ - Payload *rest_model_zrok.Service03 `json:"body,omitempty"` + Payload *rest_model_zrok.Service `json:"body,omitempty"` } // NewGetServiceOK creates GetServiceOK with default headers values @@ -36,13 +36,13 @@ func NewGetServiceOK() *GetServiceOK { } // WithPayload adds the payload to the get service o k response -func (o *GetServiceOK) WithPayload(payload *rest_model_zrok.Service03) *GetServiceOK { +func (o *GetServiceOK) WithPayload(payload *rest_model_zrok.Service) *GetServiceOK { o.Payload = payload return o } // SetPayload sets the payload to the get service o k response -func (o *GetServiceOK) SetPayload(payload *rest_model_zrok.Service03) { +func (o *GetServiceOK) SetPayload(payload *rest_model_zrok.Service) { o.Payload = payload } diff --git a/specs/zrok.yml b/specs/zrok.yml index c80ac9b8..6c21ed9e 100644 --- a/specs/zrok.yml +++ b/specs/zrok.yml @@ -211,7 +211,7 @@ paths: 200: description: ok schema: - $ref: "#/definitions/service03" + $ref: "#/definitions/service" 401: description: unauthorized 404: @@ -414,7 +414,7 @@ definitions: token: type: string - service03: + service: type: object properties: token: @@ -433,18 +433,6 @@ definitions: type: string reserved: type: boolean - - service: - type: object - properties: - zId: - type: string - token: - type: string - frontendEndpoint: - type: string - backendProxyEndpoint: - type: string metrics: $ref: "#/definitions/serviceMetrics" createdAt: diff --git a/ui/src/api/service.js b/ui/src/api/service.js index d60ea918..a3e9a0f3 100644 --- a/ui/src/api/service.js +++ b/ui/src/api/service.js @@ -20,7 +20,7 @@ export function access(options) { /** * @param {object} options Optional options * @param {module:types.serviceRequest} [options.body] - * @return {Promise} ok + * @return {Promise} ok */ export function getService(options) { if (!options) options = {} diff --git a/ui/src/api/types.js b/ui/src/api/types.js index 8678bf2c..bf86fd89 100644 --- a/ui/src/api/types.js +++ b/ui/src/api/types.js @@ -108,7 +108,7 @@ */ /** - * @typedef service03 + * @typedef service * @memberof module:types * * @property {string} token @@ -119,16 +119,6 @@ * @property {string} frontendEndpoint * @property {string} backendProxyEndpoint * @property {boolean} reserved - */ - -/** - * @typedef service - * @memberof module:types - * - * @property {string} zId - * @property {string} token - * @property {string} frontendEndpoint - * @property {string} backendProxyEndpoint * @property {module:types.serviceMetrics} metrics * @property {number} createdAt * @property {number} updatedAt