Merge pull request #862 from openziti/version_compatibility

Version Protocol Changes (#859)
This commit is contained in:
Michael Quigley 2025-02-10 16:44:15 -05:00 committed by GitHub
commit 20fa4cd663
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
38 changed files with 1598 additions and 26 deletions

View File

@ -18,6 +18,8 @@ CHANGE: Refactored API implementation. Cleanup, lint removal, additional data el
CHANGE: Deprecated the `passwords` configuration stanza. The zrok controller and API console now use a hard-coded set of (what we believe to be) reasonable assumptions about password quality (https://github.com/openziti/zrok/issues/834)
CHANGE: The protocol for determining valid client versions has been changed. Previously a zrok client would do a `GET` against the `/api/v1/version` endpoint and do a local version string comparison (as a normal precondition to any API call) to see if the controller version matched. The protocol has been amended so that any out-of-date client using the old protocol will receive a version string indicating that they need to uprade their client. New clients will do a `POST` against the `/api/v1/version` endpoint, posting their client version, and the server will check for compatibility. Does not change the security posture in any significant way, but gives more flexibility on the server side for managing client compatibility. Provides a better, cleared out-of-date error message for old clients when accessing `v1.0.0`+ (https://github.com/openziti/zrok/issues/859)
## v0.4.48
FIX: the Python SDK erroneously assumed the enabled zrok environment contained a config.json file, and was changed to only load it if the file was present (https://github.com/openziti/zrok/pull/853/).

View File

@ -67,9 +67,10 @@ func Run(inCfg *config.Config) error {
api.AdminUpdateFrontendHandler = newUpdateFrontendHandler()
api.EnvironmentEnableHandler = newEnableHandler()
api.EnvironmentDisableHandler = newDisableHandler()
api.MetadataConfigurationHandler = newConfigurationHandler(cfg)
api.MetadataClientVersionCheckHandler = metadata.ClientVersionCheckHandlerFunc(clientVersionCheckHandler)
api.MetadataGetAccountDetailHandler = newAccountDetailHandler()
api.MetadataGetSparklinesHandler = newSparklinesHandler()
api.MetadataConfigurationHandler = newConfigurationHandler(cfg)
if cfg.Metrics != nil && cfg.Metrics.Influx != nil {
api.MetadataGetAccountMetricsHandler = newGetAccountMetricsHandler(cfg.Metrics.Influx)
api.MetadataGetEnvironmentMetricsHandler = newGetEnvironmentMetricsHandler(cfg.Metrics.Influx)

View File

@ -1,12 +1,28 @@
package controller
import (
"fmt"
"github.com/go-openapi/runtime/middleware"
"github.com/openziti/zrok/build"
"github.com/openziti/zrok/rest_model_zrok"
"github.com/openziti/zrok/rest_server_zrok/operations/metadata"
"github.com/sirupsen/logrus"
"regexp"
)
func versionHandler(_ metadata.VersionParams) middleware.Responder {
return metadata.NewVersionOK().WithPayload(rest_model_zrok.Version(build.String()))
outOfDate := "your local zrok installation is out of date and needs to be upgraded! " +
"please visit 'https://github.com/openziti/zrok/releases' for the latest build!"
return metadata.NewVersionOK().WithPayload(rest_model_zrok.Version(outOfDate))
}
func clientVersionCheckHandler(params metadata.ClientVersionCheckParams) middleware.Responder {
logrus.Debugf("client sent version '%v'", params.Body.ClientVersion)
// allow reported version string to be optionally prefixed with
// "refs/heads/" or "refs/tags/"
re := regexp.MustCompile(`^(refs/(heads|tags)/)?` + build.Series)
if !re.MatchString(params.Body.ClientVersion) {
return metadata.NewClientVersionCheckBadRequest().WithPayload(fmt.Sprintf("expecting a zrok client version matching '%v' version, received: '%v'; please visit 'https://github.com/openziti/zrok/releases' to make sure you're running the correct client version!", build.Series, params.Body.ClientVersion))
}
return metadata.NewClientVersionCheckOK()
}

View File

@ -7,11 +7,11 @@ import (
"github.com/openziti/zrok/build"
"github.com/openziti/zrok/environment/env_core"
"github.com/openziti/zrok/rest_client_zrok"
metadata2 "github.com/openziti/zrok/rest_client_zrok/metadata"
"github.com/pkg/errors"
"net/url"
"os"
"path/filepath"
"regexp"
"strconv"
)
@ -49,15 +49,13 @@ func (r *Root) Client() (*rest_client_zrok.Zrok, error) {
transport.Consumers["application/zrok.v1+json"] = runtime.JSONConsumer()
zrok := rest_client_zrok.New(transport, strfmt.Default)
v, err := zrok.Metadata.Version(nil)
_, err = zrok.Metadata.ClientVersionCheck(&metadata2.ClientVersionCheckParams{
Body: metadata2.ClientVersionCheckBody{
ClientVersion: build.String(),
},
})
if err != nil {
return nil, errors.Wrapf(err, "error getting version from api endpoint '%v': %v", apiEndpoint, err)
}
// allow reported version string to be optionally prefixed with
// "refs/heads/" or "refs/tags/"
re := regexp.MustCompile(`^(refs/(heads|tags)/)?` + build.Series)
if !re.MatchString(string(v.Payload)) {
return nil, errors.Errorf("expected a '%v' version, received: '%v'", build.Series, v.Payload)
return nil, errors.Wrapf(err, "client version error accessing api endpoint '%v': %v", apiEndpoint, err)
}
return zrok, nil

View File

@ -7,11 +7,12 @@ import (
"github.com/openziti/zrok/build"
"github.com/openziti/zrok/environment/env_core"
"github.com/openziti/zrok/rest_client_zrok"
metadata2 "github.com/openziti/zrok/rest_client_zrok/metadata"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"net/url"
"os"
"path/filepath"
"regexp"
"strconv"
)
@ -48,18 +49,16 @@ func (r *Root) Client() (*rest_client_zrok.Zrok, error) {
transport.Producers["application/zrok.v1+json"] = runtime.JSONProducer()
transport.Consumers["application/zrok.v1+json"] = runtime.JSONConsumer()
logrus.Infof("version = %v", build.Version)
zrok := rest_client_zrok.New(transport, strfmt.Default)
v, err := zrok.Metadata.Version(nil)
_, err = zrok.Metadata.ClientVersionCheck(&metadata2.ClientVersionCheckParams{
Body: metadata2.ClientVersionCheckBody{
ClientVersion: build.String(),
},
})
if err != nil {
return nil, errors.Wrapf(err, "error getting version from api endpoint '%v': %v", apiEndpoint, err)
return nil, errors.Wrapf(err, "client version error accessing api endpoint '%v': %v", apiEndpoint, err)
}
// allow reported version string to be optionally prefixed with
// "refs/heads/" or "refs/tags/"
re := regexp.MustCompile(`^(refs/(heads|tags)/)?` + build.Series)
if !re.MatchString(string(v.Payload)) {
return nil, errors.Errorf("expected a '%v' version, received: '%v'", build.Series, v.Payload)
}
return zrok, nil
}

View File

@ -0,0 +1,146 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// NewClientVersionCheckParams creates a new ClientVersionCheckParams object,
// with the default timeout for this client.
//
// Default values are not hydrated, since defaults are normally applied by the API server side.
//
// To enforce default values in parameter, use SetDefaults or WithDefaults.
func NewClientVersionCheckParams() *ClientVersionCheckParams {
return &ClientVersionCheckParams{
timeout: cr.DefaultTimeout,
}
}
// NewClientVersionCheckParamsWithTimeout creates a new ClientVersionCheckParams object
// with the ability to set a timeout on a request.
func NewClientVersionCheckParamsWithTimeout(timeout time.Duration) *ClientVersionCheckParams {
return &ClientVersionCheckParams{
timeout: timeout,
}
}
// NewClientVersionCheckParamsWithContext creates a new ClientVersionCheckParams object
// with the ability to set a context for a request.
func NewClientVersionCheckParamsWithContext(ctx context.Context) *ClientVersionCheckParams {
return &ClientVersionCheckParams{
Context: ctx,
}
}
// NewClientVersionCheckParamsWithHTTPClient creates a new ClientVersionCheckParams object
// with the ability to set a custom HTTPClient for a request.
func NewClientVersionCheckParamsWithHTTPClient(client *http.Client) *ClientVersionCheckParams {
return &ClientVersionCheckParams{
HTTPClient: client,
}
}
/*
ClientVersionCheckParams contains all the parameters to send to the API endpoint
for the client version check operation.
Typically these are written to a http.Request.
*/
type ClientVersionCheckParams struct {
// Body.
Body ClientVersionCheckBody
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithDefaults hydrates default values in the client version check params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ClientVersionCheckParams) WithDefaults() *ClientVersionCheckParams {
o.SetDefaults()
return o
}
// SetDefaults hydrates default values in the client version check params (not the query body).
//
// All values with no default are reset to their zero value.
func (o *ClientVersionCheckParams) SetDefaults() {
// no default values defined for this parameter
}
// WithTimeout adds the timeout to the client version check params
func (o *ClientVersionCheckParams) WithTimeout(timeout time.Duration) *ClientVersionCheckParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the client version check params
func (o *ClientVersionCheckParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the client version check params
func (o *ClientVersionCheckParams) WithContext(ctx context.Context) *ClientVersionCheckParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the client version check params
func (o *ClientVersionCheckParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the client version check params
func (o *ClientVersionCheckParams) WithHTTPClient(client *http.Client) *ClientVersionCheckParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the client version check params
func (o *ClientVersionCheckParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the client version check params
func (o *ClientVersionCheckParams) WithBody(body ClientVersionCheckBody) *ClientVersionCheckParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the client version check params
func (o *ClientVersionCheckParams) SetBody(body ClientVersionCheckBody) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *ClientVersionCheckParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,201 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// ClientVersionCheckReader is a Reader for the ClientVersionCheck structure.
type ClientVersionCheckReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ClientVersionCheckReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewClientVersionCheckOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
case 400:
result := NewClientVersionCheckBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
default:
return nil, runtime.NewAPIError("[POST /version] clientVersionCheck", response, response.Code())
}
}
// NewClientVersionCheckOK creates a ClientVersionCheckOK with default headers values
func NewClientVersionCheckOK() *ClientVersionCheckOK {
return &ClientVersionCheckOK{}
}
/*
ClientVersionCheckOK describes a response with status code 200, with default header values.
compatible
*/
type ClientVersionCheckOK struct {
}
// IsSuccess returns true when this client version check o k response has a 2xx status code
func (o *ClientVersionCheckOK) IsSuccess() bool {
return true
}
// IsRedirect returns true when this client version check o k response has a 3xx status code
func (o *ClientVersionCheckOK) IsRedirect() bool {
return false
}
// IsClientError returns true when this client version check o k response has a 4xx status code
func (o *ClientVersionCheckOK) IsClientError() bool {
return false
}
// IsServerError returns true when this client version check o k response has a 5xx status code
func (o *ClientVersionCheckOK) IsServerError() bool {
return false
}
// IsCode returns true when this client version check o k response a status code equal to that given
func (o *ClientVersionCheckOK) IsCode(code int) bool {
return code == 200
}
// Code gets the status code for the client version check o k response
func (o *ClientVersionCheckOK) Code() int {
return 200
}
func (o *ClientVersionCheckOK) Error() string {
return fmt.Sprintf("[POST /version][%d] clientVersionCheckOK ", 200)
}
func (o *ClientVersionCheckOK) String() string {
return fmt.Sprintf("[POST /version][%d] clientVersionCheckOK ", 200)
}
func (o *ClientVersionCheckOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewClientVersionCheckBadRequest creates a ClientVersionCheckBadRequest with default headers values
func NewClientVersionCheckBadRequest() *ClientVersionCheckBadRequest {
return &ClientVersionCheckBadRequest{}
}
/*
ClientVersionCheckBadRequest describes a response with status code 400, with default header values.
not compatible
*/
type ClientVersionCheckBadRequest struct {
Payload string
}
// IsSuccess returns true when this client version check bad request response has a 2xx status code
func (o *ClientVersionCheckBadRequest) IsSuccess() bool {
return false
}
// IsRedirect returns true when this client version check bad request response has a 3xx status code
func (o *ClientVersionCheckBadRequest) IsRedirect() bool {
return false
}
// IsClientError returns true when this client version check bad request response has a 4xx status code
func (o *ClientVersionCheckBadRequest) IsClientError() bool {
return true
}
// IsServerError returns true when this client version check bad request response has a 5xx status code
func (o *ClientVersionCheckBadRequest) IsServerError() bool {
return false
}
// IsCode returns true when this client version check bad request response a status code equal to that given
func (o *ClientVersionCheckBadRequest) IsCode(code int) bool {
return code == 400
}
// Code gets the status code for the client version check bad request response
func (o *ClientVersionCheckBadRequest) Code() int {
return 400
}
func (o *ClientVersionCheckBadRequest) Error() string {
return fmt.Sprintf("[POST /version][%d] clientVersionCheckBadRequest %+v", 400, o.Payload)
}
func (o *ClientVersionCheckBadRequest) String() string {
return fmt.Sprintf("[POST /version][%d] clientVersionCheckBadRequest %+v", 400, o.Payload)
}
func (o *ClientVersionCheckBadRequest) GetPayload() string {
return o.Payload
}
func (o *ClientVersionCheckBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}
/*
ClientVersionCheckBody client version check body
swagger:model ClientVersionCheckBody
*/
type ClientVersionCheckBody struct {
// client version
ClientVersion string `json:"clientVersion,omitempty"`
}
// Validate validates this client version check body
func (o *ClientVersionCheckBody) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this client version check body based on context it is used
func (o *ClientVersionCheckBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (o *ClientVersionCheckBody) MarshalBinary() ([]byte, error) {
if o == nil {
return nil, nil
}
return swag.WriteJSON(o)
}
// UnmarshalBinary interface implementation
func (o *ClientVersionCheckBody) UnmarshalBinary(b []byte) error {
var res ClientVersionCheckBody
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*o = res
return nil
}

View File

@ -30,6 +30,8 @@ type ClientOption func(*runtime.ClientOperation)
// ClientService is the interface for Client methods
type ClientService interface {
ClientVersionCheck(params *ClientVersionCheckParams, opts ...ClientOption) (*ClientVersionCheckOK, error)
Configuration(params *ConfigurationParams, opts ...ClientOption) (*ConfigurationOK, error)
GetAccountDetail(params *GetAccountDetailParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAccountDetailOK, error)
@ -61,6 +63,44 @@ type ClientService interface {
SetTransport(transport runtime.ClientTransport)
}
/*
ClientVersionCheck client version check API
*/
func (a *Client) ClientVersionCheck(params *ClientVersionCheckParams, opts ...ClientOption) (*ClientVersionCheckOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewClientVersionCheckParams()
}
op := &runtime.ClientOperation{
ID: "clientVersionCheck",
Method: "POST",
PathPattern: "/version",
ProducesMediaTypes: []string{"application/zrok.v1+json"},
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
Schemes: []string{"http"},
Params: params,
Reader: &ClientVersionCheckReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
}
for _, opt := range opts {
opt(op)
}
result, err := a.transport.Submit(op)
if err != nil {
return nil, err
}
success, ok := result.(*ClientVersionCheckOK)
if ok {
return success, nil
}
// unexpected success response
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
msg := fmt.Sprintf("unexpected success response for clientVersionCheck: API contract not enforced by server. Client expected to get an error, but got: %T", result)
panic(msg)
}
/*
Configuration configuration API
*/

View File

@ -42,7 +42,7 @@ func NewVersionOK() *VersionOK {
/*
VersionOK describes a response with status code 200, with default header values.
current server version
legacy upgrade required
*/
type VersionOK struct {
Payload rest_model_zrok.Version

View File

@ -1903,12 +1903,42 @@ func init() {
"operationId": "version",
"responses": {
"200": {
"description": "current server version",
"description": "legacy upgrade required",
"schema": {
"$ref": "#/definitions/version"
}
}
}
},
"post": {
"tags": [
"metadata"
],
"operationId": "clientVersionCheck",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"properties": {
"clientVersion": {
"type": "string"
}
}
}
}
],
"responses": {
"200": {
"description": "compatible"
},
"400": {
"description": "not compatible",
"schema": {
"type": "string"
}
}
}
}
}
},
@ -4108,12 +4138,42 @@ func init() {
"operationId": "version",
"responses": {
"200": {
"description": "current server version",
"description": "legacy upgrade required",
"schema": {
"$ref": "#/definitions/version"
}
}
}
},
"post": {
"tags": [
"metadata"
],
"operationId": "clientVersionCheck",
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"properties": {
"clientVersion": {
"type": "string"
}
}
}
}
],
"responses": {
"200": {
"description": "compatible"
},
"400": {
"description": "not compatible",
"schema": {
"type": "string"
}
}
}
}
}
},

View File

@ -0,0 +1,96 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"context"
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// ClientVersionCheckHandlerFunc turns a function with the right signature into a client version check handler
type ClientVersionCheckHandlerFunc func(ClientVersionCheckParams) middleware.Responder
// Handle executing the request and returning a response
func (fn ClientVersionCheckHandlerFunc) Handle(params ClientVersionCheckParams) middleware.Responder {
return fn(params)
}
// ClientVersionCheckHandler interface for that can handle valid client version check params
type ClientVersionCheckHandler interface {
Handle(ClientVersionCheckParams) middleware.Responder
}
// NewClientVersionCheck creates a new http.Handler for the client version check operation
func NewClientVersionCheck(ctx *middleware.Context, handler ClientVersionCheckHandler) *ClientVersionCheck {
return &ClientVersionCheck{Context: ctx, Handler: handler}
}
/*
ClientVersionCheck swagger:route POST /version metadata clientVersionCheck
ClientVersionCheck client version check API
*/
type ClientVersionCheck struct {
Context *middleware.Context
Handler ClientVersionCheckHandler
}
func (o *ClientVersionCheck) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewClientVersionCheckParams()
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}
// ClientVersionCheckBody client version check body
//
// swagger:model ClientVersionCheckBody
type ClientVersionCheckBody struct {
// client version
ClientVersion string `json:"clientVersion,omitempty"`
}
// Validate validates this client version check body
func (o *ClientVersionCheckBody) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this client version check body based on context it is used
func (o *ClientVersionCheckBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (o *ClientVersionCheckBody) MarshalBinary() ([]byte, error) {
if o == nil {
return nil, nil
}
return swag.WriteJSON(o)
}
// UnmarshalBinary interface implementation
func (o *ClientVersionCheckBody) UnmarshalBinary(b []byte) error {
var res ClientVersionCheckBody
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*o = res
return nil
}

View File

@ -0,0 +1,74 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/validate"
)
// NewClientVersionCheckParams creates a new ClientVersionCheckParams object
//
// There are no default values defined in the spec.
func NewClientVersionCheckParams() ClientVersionCheckParams {
return ClientVersionCheckParams{}
}
// ClientVersionCheckParams contains all the bound params for the client version check operation
// typically these are obtained from a http.Request
//
// swagger:parameters clientVersionCheck
type ClientVersionCheckParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: body
*/
Body ClientVersionCheckBody
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewClientVersionCheckParams() beforehand.
func (o *ClientVersionCheckParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if runtime.HasBody(r) {
defer r.Body.Close()
var body ClientVersionCheckBody
if err := route.Consumer.Consume(r.Body, &body); err != nil {
res = append(res, errors.NewParseError("body", "body", "", err))
} else {
// validate body object
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
ctx := validate.WithOperationRequest(r.Context())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Body = body
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,80 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
)
// ClientVersionCheckOKCode is the HTTP code returned for type ClientVersionCheckOK
const ClientVersionCheckOKCode int = 200
/*
ClientVersionCheckOK compatible
swagger:response clientVersionCheckOK
*/
type ClientVersionCheckOK struct {
}
// NewClientVersionCheckOK creates ClientVersionCheckOK with default headers values
func NewClientVersionCheckOK() *ClientVersionCheckOK {
return &ClientVersionCheckOK{}
}
// WriteResponse to the client
func (o *ClientVersionCheckOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(200)
}
// ClientVersionCheckBadRequestCode is the HTTP code returned for type ClientVersionCheckBadRequest
const ClientVersionCheckBadRequestCode int = 400
/*
ClientVersionCheckBadRequest not compatible
swagger:response clientVersionCheckBadRequest
*/
type ClientVersionCheckBadRequest struct {
/*
In: Body
*/
Payload string `json:"body,omitempty"`
}
// NewClientVersionCheckBadRequest creates ClientVersionCheckBadRequest with default headers values
func NewClientVersionCheckBadRequest() *ClientVersionCheckBadRequest {
return &ClientVersionCheckBadRequest{}
}
// WithPayload adds the payload to the client version check bad request response
func (o *ClientVersionCheckBadRequest) WithPayload(payload string) *ClientVersionCheckBadRequest {
o.Payload = payload
return o
}
// SetPayload sets the payload to the client version check bad request response
func (o *ClientVersionCheckBadRequest) SetPayload(payload string) {
o.Payload = payload
}
// WriteResponse to the client
func (o *ClientVersionCheckBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(400)
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}

View File

@ -0,0 +1,87 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// ClientVersionCheckURL generates an URL for the client version check operation
type ClientVersionCheckURL struct {
_basePath string
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *ClientVersionCheckURL) WithBasePath(bp string) *ClientVersionCheckURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *ClientVersionCheckURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *ClientVersionCheckURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/version"
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *ClientVersionCheckURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *ClientVersionCheckURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *ClientVersionCheckURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on ClientVersionCheckURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on ClientVersionCheckURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *ClientVersionCheckURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@ -17,7 +17,7 @@ import (
const VersionOKCode int = 200
/*
VersionOK current server version
VersionOK legacy upgrade required
swagger:response versionOK
*/

View File

@ -58,6 +58,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
AccountChangePasswordHandler: account.ChangePasswordHandlerFunc(func(params account.ChangePasswordParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation account.ChangePassword has not yet been implemented")
}),
MetadataClientVersionCheckHandler: metadata.ClientVersionCheckHandlerFunc(func(params metadata.ClientVersionCheckParams) middleware.Responder {
return middleware.NotImplemented("operation metadata.ClientVersionCheck has not yet been implemented")
}),
MetadataConfigurationHandler: metadata.ConfigurationHandlerFunc(func(params metadata.ConfigurationParams) middleware.Responder {
return middleware.NotImplemented("operation metadata.Configuration has not yet been implemented")
}),
@ -237,6 +240,8 @@ type ZrokAPI struct {
AdminAddOrganizationMemberHandler admin.AddOrganizationMemberHandler
// AccountChangePasswordHandler sets the operation handler for the change password operation
AccountChangePasswordHandler account.ChangePasswordHandler
// MetadataClientVersionCheckHandler sets the operation handler for the client version check operation
MetadataClientVersionCheckHandler metadata.ClientVersionCheckHandler
// MetadataConfigurationHandler sets the operation handler for the configuration operation
MetadataConfigurationHandler metadata.ConfigurationHandler
// AdminCreateAccountHandler sets the operation handler for the create account operation
@ -409,6 +414,9 @@ func (o *ZrokAPI) Validate() error {
if o.AccountChangePasswordHandler == nil {
unregistered = append(unregistered, "account.ChangePasswordHandler")
}
if o.MetadataClientVersionCheckHandler == nil {
unregistered = append(unregistered, "metadata.ClientVersionCheckHandler")
}
if o.MetadataConfigurationHandler == nil {
unregistered = append(unregistered, "metadata.ConfigurationHandler")
}
@ -643,6 +651,10 @@ func (o *ZrokAPI) initHandlerCache() {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/changePassword"] = account.NewChangePassword(o.context, o.AccountChangePasswordHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/version"] = metadata.NewClientVersionCheck(o.context, o.MetadataClientVersionCheckHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}

View File

@ -12,6 +12,7 @@ model/accessRequest.ts
model/addOrganizationMemberRequest.ts
model/authUser.ts
model/changePasswordRequest.ts
model/clientVersionCheckRequest.ts
model/configuration.ts
model/createFrontend201Response.ts
model/createFrontendRequest.ts

View File

@ -15,6 +15,7 @@ import localVarRequest from 'request';
import http from 'http';
/* tslint:disable:no-unused-locals */
import { ClientVersionCheckRequest } from '../model/clientVersionCheckRequest';
import { Configuration } from '../model/configuration';
import { Environment } from '../model/environment';
import { EnvironmentAndResources } from '../model/environmentAndResources';
@ -99,6 +100,68 @@ export class MetadataApi {
this.interceptors.push(interceptor);
}
/**
*
* @param body
*/
public async clientVersionCheck (body?: ClientVersionCheckRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> {
const localVarPath = this.basePath + '/version';
let localVarQueryParameters: any = {};
let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
const produces = ['application/zrok.v1+json'];
// give precedence to 'application/json'
if (produces.indexOf('application/json') >= 0) {
localVarHeaderParams.Accept = 'application/json';
} else {
localVarHeaderParams.Accept = produces.join(',');
}
let localVarFormParams: any = {};
(<any>Object).assign(localVarHeaderParams, options.headers);
let localVarUseFormData = false;
let localVarRequestOptions: localVarRequest.Options = {
method: 'POST',
qs: localVarQueryParameters,
headers: localVarHeaderParams,
uri: localVarPath,
useQuerystring: this._useQuerystring,
json: true,
body: ObjectSerializer.serialize(body, "ClientVersionCheckRequest")
};
let authenticationPromise = Promise.resolve();
authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
let interceptorPromise = authenticationPromise;
for (const interceptor of this.interceptors) {
interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
}
return interceptorPromise.then(() => {
if (Object.keys(localVarFormParams).length) {
if (localVarUseFormData) {
(<any>localVarRequestOptions).formData = localVarFormParams;
} else {
localVarRequestOptions.form = localVarFormParams;
}
}
return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => {
localVarRequest(localVarRequestOptions, (error, response, body) => {
if (error) {
reject(error);
} else {
if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
resolve({ response: response, body: body });
} else {
reject(new HttpError(response, body, response.statusCode));
}
}
});
});
});
}
/**
*
*/

View File

@ -0,0 +1,31 @@
/**
* zrok
* zrok client access
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { RequestFile } from './models';
export class ClientVersionCheck400Response {
'message'?: string;
static discriminator: string | undefined = undefined;
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "message",
"baseName": "message",
"type": "string"
} ];
static getAttributeTypeMap() {
return ClientVersionCheck400Response.attributeTypeMap;
}
}

View File

@ -0,0 +1,31 @@
/**
* zrok
* zrok client access
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { RequestFile } from './models';
export class ClientVersionCheckRequest {
'clientVersion'?: string;
static discriminator: string | undefined = undefined;
static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [
{
"name": "clientVersion",
"baseName": "clientVersion",
"type": "string"
} ];
static getAttributeTypeMap() {
return ClientVersionCheckRequest.attributeTypeMap;
}
}

View File

@ -5,6 +5,7 @@ export * from './accessRequest';
export * from './addOrganizationMemberRequest';
export * from './authUser';
export * from './changePasswordRequest';
export * from './clientVersionCheckRequest';
export * from './configuration';
export * from './createFrontend201Response';
export * from './createFrontendRequest';
@ -68,6 +69,7 @@ import { AccessRequest } from './accessRequest';
import { AddOrganizationMemberRequest } from './addOrganizationMemberRequest';
import { AuthUser } from './authUser';
import { ChangePasswordRequest } from './changePasswordRequest';
import { ClientVersionCheckRequest } from './clientVersionCheckRequest';
import { Configuration } from './configuration';
import { CreateFrontend201Response } from './createFrontend201Response';
import { CreateFrontendRequest } from './createFrontendRequest';
@ -139,6 +141,7 @@ let typeMap: {[index: string]: any} = {
"AddOrganizationMemberRequest": AddOrganizationMemberRequest,
"AuthUser": AuthUser,
"ChangePasswordRequest": ChangePasswordRequest,
"ClientVersionCheckRequest": ClientVersionCheckRequest,
"Configuration": Configuration,
"CreateFrontend201Response": CreateFrontend201Response,
"CreateFrontendRequest": CreateFrontendRequest,

View File

@ -170,6 +170,7 @@ Class | Method | HTTP request | Description
*AdminApi* | [**update_frontend**](docs/AdminApi.md#update_frontend) | **PATCH** /frontend |
*EnvironmentApi* | [**disable**](docs/EnvironmentApi.md#disable) | **POST** /disable |
*EnvironmentApi* | [**enable**](docs/EnvironmentApi.md#enable) | **POST** /enable |
*MetadataApi* | [**client_version_check**](docs/MetadataApi.md#client_version_check) | **POST** /version |
*MetadataApi* | [**configuration**](docs/MetadataApi.md#configuration) | **GET** /configuration |
*MetadataApi* | [**get_account_detail**](docs/MetadataApi.md#get_account_detail) | **GET** /detail/account |
*MetadataApi* | [**get_account_metrics**](docs/MetadataApi.md#get_account_metrics) | **GET** /metrics/account |
@ -254,6 +255,7 @@ Class | Method | HTTP request | Description
- [UnshareBody](docs/UnshareBody.md)
- [VerifyBody](docs/VerifyBody.md)
- [Version](docs/Version.md)
- [VersionBody](docs/VersionBody.md)
## Documentation For Authorization

View File

@ -0,0 +1,9 @@
# InlineResponse400
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**message** | **str** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -4,6 +4,7 @@ All URIs are relative to */api/v1*
Method | HTTP request | Description
------------- | ------------- | -------------
[**client_version_check**](MetadataApi.md#client_version_check) | **POST** /version |
[**configuration**](MetadataApi.md#configuration) | **GET** /configuration |
[**get_account_detail**](MetadataApi.md#get_account_detail) | **GET** /detail/account |
[**get_account_metrics**](MetadataApi.md#get_account_metrics) | **GET** /metrics/account |
@ -19,6 +20,50 @@ Method | HTTP request | Description
[**overview**](MetadataApi.md#overview) | **GET** /overview |
[**version**](MetadataApi.md#version) | **GET** /version |
# **client_version_check**
> client_version_check(body=body)
### Example
```python
from __future__ import print_function
import time
import zrok_api
from zrok_api.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = zrok_api.MetadataApi()
body = zrok_api.VersionBody() # VersionBody | (optional)
try:
api_instance.client_version_check(body=body)
except ApiException as e:
print("Exception when calling MetadataApi->client_version_check: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**VersionBody**](VersionBody.md)| | [optional]
### Return type
void (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/zrok.v1+json
- **Accept**: application/zrok.v1+json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **configuration**
> Configuration configuration()

View File

@ -0,0 +1,9 @@
# VersionBody
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**client_version** | **str** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,39 @@
# coding: utf-8
"""
zrok
zrok client access # noqa: E501
OpenAPI spec version: 1.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import unittest
import zrok_api
from zrok_api.models.inline_response400 import InlineResponse400 # noqa: E501
from zrok_api.rest import ApiException
class TestInlineResponse400(unittest.TestCase):
"""InlineResponse400 unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testInlineResponse400(self):
"""Test InlineResponse400"""
# FIXME: construct object with mandatory attributes with example values
# model = zrok_api.models.inline_response400.InlineResponse400() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,39 @@
# coding: utf-8
"""
zrok
zrok client access # noqa: E501
OpenAPI spec version: 1.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
from __future__ import absolute_import
import unittest
import zrok_api
from zrok_api.models.version_body import VersionBody # noqa: E501
from zrok_api.rest import ApiException
class TestVersionBody(unittest.TestCase):
"""VersionBody unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def testVersionBody(self):
"""Test VersionBody"""
# FIXME: construct object with mandatory attributes with example values
# model = zrok_api.models.version_body.VersionBody() # noqa: E501
pass
if __name__ == '__main__':
unittest.main()

View File

@ -85,3 +85,4 @@ from zrok_api.models.unaccess_body import UnaccessBody
from zrok_api.models.unshare_body import UnshareBody
from zrok_api.models.verify_body import VerifyBody
from zrok_api.models.version import Version
from zrok_api.models.version_body import VersionBody

View File

@ -32,6 +32,99 @@ class MetadataApi(object):
api_client = ApiClient()
self.api_client = api_client
def client_version_check(self, **kwargs): # noqa: E501
"""client_version_check # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.client_version_check(async_req=True)
>>> result = thread.get()
:param async_req bool
:param VersionBody body:
:return: None
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.client_version_check_with_http_info(**kwargs) # noqa: E501
else:
(data) = self.client_version_check_with_http_info(**kwargs) # noqa: E501
return data
def client_version_check_with_http_info(self, **kwargs): # noqa: E501
"""client_version_check # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.client_version_check_with_http_info(async_req=True)
>>> result = thread.get()
:param async_req bool
:param VersionBody body:
:return: None
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['body'] # noqa: E501
all_params.append('async_req')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method client_version_check" % key
)
params[key] = val
del params['kwargs']
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if 'body' in params:
body_params = params['body']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/zrok.v1+json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/zrok.v1+json']) # noqa: E501
# Authentication setting
auth_settings = [] # noqa: E501
return self.api_client.call_api(
'/version', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None, # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
_preload_content=params.get('_preload_content', True),
_request_timeout=params.get('_request_timeout'),
collection_formats=collection_formats)
def configuration(self, **kwargs): # noqa: E501
"""configuration # noqa: E501

View File

@ -75,3 +75,4 @@ from zrok_api.models.unaccess_body import UnaccessBody
from zrok_api.models.unshare_body import UnshareBody
from zrok_api.models.verify_body import VerifyBody
from zrok_api.models.version import Version
from zrok_api.models.version_body import VersionBody

View File

@ -0,0 +1,110 @@
# coding: utf-8
"""
zrok
zrok client access # noqa: E501
OpenAPI spec version: 1.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
class InlineResponse400(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
swagger_types = {
'message': 'str'
}
attribute_map = {
'message': 'message'
}
def __init__(self, message=None): # noqa: E501
"""InlineResponse400 - a model defined in Swagger""" # noqa: E501
self._message = None
self.discriminator = None
if message is not None:
self.message = message
@property
def message(self):
"""Gets the message of this InlineResponse400. # noqa: E501
:return: The message of this InlineResponse400. # noqa: E501
:rtype: str
"""
return self._message
@message.setter
def message(self, message):
"""Sets the message of this InlineResponse400.
:param message: The message of this InlineResponse400. # noqa: E501
:type: str
"""
self._message = message
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
if issubclass(InlineResponse400, dict):
for key, value in self.items():
result[key] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, InlineResponse400):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other

View File

@ -0,0 +1,110 @@
# coding: utf-8
"""
zrok
zrok client access # noqa: E501
OpenAPI spec version: 1.0.0
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
class VersionBody(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
"""
Attributes:
swagger_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
swagger_types = {
'client_version': 'str'
}
attribute_map = {
'client_version': 'clientVersion'
}
def __init__(self, client_version=None): # noqa: E501
"""VersionBody - a model defined in Swagger""" # noqa: E501
self._client_version = None
self.discriminator = None
if client_version is not None:
self.client_version = client_version
@property
def client_version(self):
"""Gets the client_version of this VersionBody. # noqa: E501
:return: The client_version of this VersionBody. # noqa: E501
:rtype: str
"""
return self._client_version
@client_version.setter
def client_version(self, client_version):
"""Sets the client_version of this VersionBody.
:param client_version: The client_version of this VersionBody. # noqa: E501
:type: str
"""
self._client_version = client_version
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
if issubclass(VersionBody, dict):
for key, value in self.items():
result[key] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, VersionBody):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other

View File

@ -988,9 +988,27 @@ paths:
operationId: version
responses:
200:
description: current server version
description: legacy upgrade required
schema:
$ref: "#/definitions/version"
post:
tags:
- metadata
operationId: clientVersionCheck
parameters:
- name: body
in: body
schema:
properties:
clientVersion:
type: string
responses:
200:
description: compatible
400:
description: not compatible
schema:
type: string
#
# share

View File

@ -10,6 +10,7 @@ models/AccessRequest.ts
models/AddOrganizationMemberRequest.ts
models/AuthUser.ts
models/ChangePasswordRequest.ts
models/ClientVersionCheckRequest.ts
models/CreateFrontend201Response.ts
models/CreateFrontendRequest.ts
models/CreateIdentity201Response.ts

View File

@ -15,6 +15,7 @@
import * as runtime from '../runtime';
import type {
ClientVersionCheckRequest,
Environment,
EnvironmentAndResources,
Frontend,
@ -28,6 +29,8 @@ import type {
Share,
} from '../models/index';
import {
ClientVersionCheckRequestFromJSON,
ClientVersionCheckRequestToJSON,
EnvironmentFromJSON,
EnvironmentToJSON,
EnvironmentAndResourcesFromJSON,
@ -52,6 +55,10 @@ import {
ShareToJSON,
} from '../models/index';
export interface ClientVersionCheckOperationRequest {
body?: ClientVersionCheckRequest;
}
export interface GetAccountMetricsRequest {
duration?: string;
}
@ -120,6 +127,32 @@ export class MetadataApi extends runtime.BaseAPI {
return await response.value();
}
/**
*/
async clientVersionCheckRaw(requestParameters: ClientVersionCheckOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/zrok.v1+json';
const response = await this.request({
path: `/version`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: ClientVersionCheckRequestToJSON(requestParameters['body']),
}, initOverrides);
return new runtime.VoidApiResponse(response);
}
/**
*/
async clientVersionCheck(requestParameters: ClientVersionCheckOperationRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
await this.clientVersionCheckRaw(requestParameters, initOverrides);
}
/**
*/
async getAccountDetailRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<Environment>>> {

View File

@ -0,0 +1,60 @@
/* tslint:disable */
/* eslint-disable */
/**
* zrok
* zrok client access
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
/**
*
* @export
* @interface ClientVersionCheck400Response
*/
export interface ClientVersionCheck400Response {
/**
*
* @type {string}
* @memberof ClientVersionCheck400Response
*/
message?: string;
}
/**
* Check if a given object implements the ClientVersionCheck400Response interface.
*/
export function instanceOfClientVersionCheck400Response(value: object): value is ClientVersionCheck400Response {
return true;
}
export function ClientVersionCheck400ResponseFromJSON(json: any): ClientVersionCheck400Response {
return ClientVersionCheck400ResponseFromJSONTyped(json, false);
}
export function ClientVersionCheck400ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ClientVersionCheck400Response {
if (json == null) {
return json;
}
return {
'message': json['message'] == null ? undefined : json['message'],
};
}
export function ClientVersionCheck400ResponseToJSON(value?: ClientVersionCheck400Response | null): any {
if (value == null) {
return value;
}
return {
'message': value['message'],
};
}

View File

@ -0,0 +1,60 @@
/* tslint:disable */
/* eslint-disable */
/**
* zrok
* zrok client access
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime';
/**
*
* @export
* @interface ClientVersionCheckRequest
*/
export interface ClientVersionCheckRequest {
/**
*
* @type {string}
* @memberof ClientVersionCheckRequest
*/
clientVersion?: string;
}
/**
* Check if a given object implements the ClientVersionCheckRequest interface.
*/
export function instanceOfClientVersionCheckRequest(value: object): value is ClientVersionCheckRequest {
return true;
}
export function ClientVersionCheckRequestFromJSON(json: any): ClientVersionCheckRequest {
return ClientVersionCheckRequestFromJSONTyped(json, false);
}
export function ClientVersionCheckRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): ClientVersionCheckRequest {
if (json == null) {
return json;
}
return {
'clientVersion': json['clientVersion'] == null ? undefined : json['clientVersion'],
};
}
export function ClientVersionCheckRequestToJSON(value?: ClientVersionCheckRequest | null): any {
if (value == null) {
return value;
}
return {
'clientVersion': value['clientVersion'],
};
}

View File

@ -5,6 +5,7 @@ export * from './AccessRequest';
export * from './AddOrganizationMemberRequest';
export * from './AuthUser';
export * from './ChangePasswordRequest';
export * from './ClientVersionCheckRequest';
export * from './CreateFrontend201Response';
export * from './CreateFrontendRequest';
export * from './CreateIdentity201Response';