remove service03 type; consolidated service type (#119)

This commit is contained in:
Michael Quigley 2022-12-01 12:54:14 -05:00
parent b80eb4f837
commit 44f4e37e83
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
10 changed files with 62 additions and 167 deletions

View File

@ -40,12 +40,14 @@ func getServiceHandler(params service.GetServiceParams, principal *rest_model_zr
return service.NewGetServiceNotFound() return service.NewGetServiceNotFound()
} }
svc := &rest_model_zrok.Service03{ svc := &rest_model_zrok.Service{
Token: ssvc.Token, Token: ssvc.Token,
ZID: ssvc.ZId, ZID: ssvc.ZId,
ShareMode: ssvc.ShareMode, ShareMode: ssvc.ShareMode,
BackendMode: ssvc.BackendMode, BackendMode: ssvc.BackendMode,
Reserved: ssvc.Reserved, Reserved: ssvc.Reserved,
CreatedAt: ssvc.CreatedAt.UnixMilli(),
UpdatedAt: ssvc.UpdatedAt.UnixMilli(),
} }
if ssvc.FrontendSelection != nil { if ssvc.FrontendSelection != nil {
svc.FrontendSelection = *ssvc.FrontendSelection svc.FrontendSelection = *ssvc.FrontendSelection

View File

@ -45,22 +45,30 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ
return metadata.NewOverviewInternalServerError() return metadata.NewOverviewInternalServerError()
} }
for _, svc := range svcs { for _, svc := range svcs {
fe := "" feEndpoint := ""
if svc.FrontendEndpoint != nil { if svc.FrontendEndpoint != nil {
fe = *svc.FrontendEndpoint feEndpoint = *svc.FrontendEndpoint
} }
be := "" feSelection := ""
if svc.FrontendSelection != nil {
feSelection = *svc.FrontendSelection
}
beProxyEndpoint := ""
if svc.BackendProxyEndpoint != nil { if svc.BackendProxyEndpoint != nil {
be = *svc.BackendProxyEndpoint beProxyEndpoint = *svc.BackendProxyEndpoint
} }
es.Services = append(es.Services, &rest_model_zrok.Service{ 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, 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], Metrics: sparkData[svc.Token],
CreatedAt: svc.CreatedAt.UnixMilli(),
UpdatedAt: svc.UpdatedAt.UnixMilli(),
}) })
} }
out = append(out, es) out = append(out, es)

View File

@ -63,7 +63,7 @@ GetServiceOK describes a response with status code 200, with default header valu
ok ok
*/ */
type GetServiceOK struct { 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 // 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) 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 return o.Payload
} }
func (o *GetServiceOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { 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 // response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {

View File

@ -18,6 +18,9 @@ import (
// swagger:model service // swagger:model service
type Service struct { type Service struct {
// backend mode
BackendMode string `json:"backendMode,omitempty"`
// backend proxy endpoint // backend proxy endpoint
BackendProxyEndpoint string `json:"backendProxyEndpoint,omitempty"` BackendProxyEndpoint string `json:"backendProxyEndpoint,omitempty"`
@ -27,9 +30,18 @@ type Service struct {
// frontend endpoint // frontend endpoint
FrontendEndpoint string `json:"frontendEndpoint,omitempty"` FrontendEndpoint string `json:"frontendEndpoint,omitempty"`
// frontend selection
FrontendSelection string `json:"frontendSelection,omitempty"`
// metrics // metrics
Metrics ServiceMetrics `json:"metrics,omitempty"` Metrics ServiceMetrics `json:"metrics,omitempty"`
// reserved
Reserved bool `json:"reserved,omitempty"`
// share mode
ShareMode string `json:"shareMode,omitempty"`
// token // token
Token string `json:"token,omitempty"` Token string `json:"token,omitempty"`

View File

@ -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
}

View File

@ -284,7 +284,7 @@ func init() {
"200": { "200": {
"description": "ok", "description": "ok",
"schema": { "schema": {
"$ref": "#/definitions/service03" "$ref": "#/definitions/service"
} }
}, },
"401": { "401": {
@ -632,6 +632,9 @@ func init() {
"service": { "service": {
"type": "object", "type": "object",
"properties": { "properties": {
"backendMode": {
"type": "string"
},
"backendProxyEndpoint": { "backendProxyEndpoint": {
"type": "string" "type": "string"
}, },
@ -641,35 +644,12 @@ func init() {
"frontendEndpoint": { "frontendEndpoint": {
"type": "string" "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": { "frontendSelection": {
"type": "string" "type": "string"
}, },
"metrics": {
"$ref": "#/definitions/serviceMetrics"
},
"reserved": { "reserved": {
"type": "boolean" "type": "boolean"
}, },
@ -679,6 +659,9 @@ func init() {
"token": { "token": {
"type": "string" "type": "string"
}, },
"updatedAt": {
"type": "integer"
},
"zId": { "zId": {
"type": "string" "type": "string"
} }
@ -1085,7 +1068,7 @@ func init() {
"200": { "200": {
"description": "ok", "description": "ok",
"schema": { "schema": {
"$ref": "#/definitions/service03" "$ref": "#/definitions/service"
} }
}, },
"401": { "401": {
@ -1433,6 +1416,9 @@ func init() {
"service": { "service": {
"type": "object", "type": "object",
"properties": { "properties": {
"backendMode": {
"type": "string"
},
"backendProxyEndpoint": { "backendProxyEndpoint": {
"type": "string" "type": "string"
}, },
@ -1442,35 +1428,12 @@ func init() {
"frontendEndpoint": { "frontendEndpoint": {
"type": "string" "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": { "frontendSelection": {
"type": "string" "type": "string"
}, },
"metrics": {
"$ref": "#/definitions/serviceMetrics"
},
"reserved": { "reserved": {
"type": "boolean" "type": "boolean"
}, },
@ -1480,6 +1443,9 @@ func init() {
"token": { "token": {
"type": "string" "type": "string"
}, },
"updatedAt": {
"type": "integer"
},
"zId": { "zId": {
"type": "string" "type": "string"
} }

View File

@ -26,7 +26,7 @@ type GetServiceOK struct {
/* /*
In: Body 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 // 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 // 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 o.Payload = payload
return o return o
} }
// SetPayload sets the payload to the get service o k response // 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 o.Payload = payload
} }

View File

@ -211,7 +211,7 @@ paths:
200: 200:
description: ok description: ok
schema: schema:
$ref: "#/definitions/service03" $ref: "#/definitions/service"
401: 401:
description: unauthorized description: unauthorized
404: 404:
@ -414,7 +414,7 @@ definitions:
token: token:
type: string type: string
service03: service:
type: object type: object
properties: properties:
token: token:
@ -433,18 +433,6 @@ definitions:
type: string type: string
reserved: reserved:
type: boolean type: boolean
service:
type: object
properties:
zId:
type: string
token:
type: string
frontendEndpoint:
type: string
backendProxyEndpoint:
type: string
metrics: metrics:
$ref: "#/definitions/serviceMetrics" $ref: "#/definitions/serviceMetrics"
createdAt: createdAt:

View File

@ -20,7 +20,7 @@ export function access(options) {
/** /**
* @param {object} options Optional options * @param {object} options Optional options
* @param {module:types.serviceRequest} [options.body] * @param {module:types.serviceRequest} [options.body]
* @return {Promise<module:types.service03>} ok * @return {Promise<module:types.service>} ok
*/ */
export function getService(options) { export function getService(options) {
if (!options) options = {} if (!options) options = {}

View File

@ -108,7 +108,7 @@
*/ */
/** /**
* @typedef service03 * @typedef service
* @memberof module:types * @memberof module:types
* *
* @property {string} token * @property {string} token
@ -119,16 +119,6 @@
* @property {string} frontendEndpoint * @property {string} frontendEndpoint
* @property {string} backendProxyEndpoint * @property {string} backendProxyEndpoint
* @property {boolean} reserved * @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 {module:types.serviceMetrics} metrics
* @property {number} createdAt * @property {number} createdAt
* @property {number} updatedAt * @property {number} updatedAt