mirror of
https://github.com/openziti/zrok.git
synced 2024-11-21 23:53:19 +01:00
api reshuffle
This commit is contained in:
parent
23896ab3fa
commit
53b7c3c7b7
@ -28,7 +28,7 @@ var apiVersionCmd = &cobra.Command{
|
|||||||
transport.Producers["application/zrok.v1+json"] = runtime.JSONProducer()
|
transport.Producers["application/zrok.v1+json"] = runtime.JSONProducer()
|
||||||
transport.Consumers["application/zrok.v1+json"] = runtime.JSONConsumer()
|
transport.Consumers["application/zrok.v1+json"] = runtime.JSONConsumer()
|
||||||
zrok := rest_zrok_client.New(transport, strfmt.Default)
|
zrok := rest_zrok_client.New(transport, strfmt.Default)
|
||||||
resp, err := zrok.Metadata.Get(metadata.NewGetParams())
|
resp, err := zrok.Metadata.Version(metadata.NewVersionParams())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ func Run(cfg *Config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
api := operations.NewZrokAPI(swaggerSpec)
|
api := operations.NewZrokAPI(swaggerSpec)
|
||||||
api.MetadataGetHandler = metadata.GetHandlerFunc(func(params metadata.GetParams) middleware.Responder {
|
api.MetadataVersionHandler = metadata.VersionHandlerFunc(func(_ metadata.VersionParams) middleware.Responder {
|
||||||
return metadata.NewGetOK().WithPayload(&rest_model.Version{Version: "v0.0.0; sk3tch"})
|
return metadata.NewGetOK().WithPayload(&rest_model.Version{Version: "v0.0.0; sk3tch"})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -30,28 +30,28 @@ type ClientOption func(*runtime.ClientOperation)
|
|||||||
|
|
||||||
// ClientService is the interface for Client methods
|
// ClientService is the interface for Client methods
|
||||||
type ClientService interface {
|
type ClientService interface {
|
||||||
Get(params *GetParams, opts ...ClientOption) (*GetOK, error)
|
Version(params *VersionParams, opts ...ClientOption) (*VersionOK, error)
|
||||||
|
|
||||||
SetTransport(transport runtime.ClientTransport)
|
SetTransport(transport runtime.ClientTransport)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get get API
|
Version version API
|
||||||
*/
|
*/
|
||||||
func (a *Client) Get(params *GetParams, opts ...ClientOption) (*GetOK, error) {
|
func (a *Client) Version(params *VersionParams, opts ...ClientOption) (*VersionOK, error) {
|
||||||
// TODO: Validate the params before sending
|
// TODO: Validate the params before sending
|
||||||
if params == nil {
|
if params == nil {
|
||||||
params = NewGetParams()
|
params = NewVersionParams()
|
||||||
}
|
}
|
||||||
op := &runtime.ClientOperation{
|
op := &runtime.ClientOperation{
|
||||||
ID: "Get",
|
ID: "version",
|
||||||
Method: "GET",
|
Method: "GET",
|
||||||
PathPattern: "/",
|
PathPattern: "/version",
|
||||||
ProducesMediaTypes: []string{"application/zrok.v1+json"},
|
ProducesMediaTypes: []string{"application/zrok.v1+json"},
|
||||||
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
|
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
|
||||||
Schemes: []string{"http"},
|
Schemes: []string{"http"},
|
||||||
Params: params,
|
Params: params,
|
||||||
Reader: &GetReader{formats: a.formats},
|
Reader: &VersionReader{formats: a.formats},
|
||||||
Context: params.Context,
|
Context: params.Context,
|
||||||
Client: params.HTTPClient,
|
Client: params.HTTPClient,
|
||||||
}
|
}
|
||||||
@ -63,13 +63,13 @@ func (a *Client) Get(params *GetParams, opts ...ClientOption) (*GetOK, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
success, ok := result.(*GetOK)
|
success, ok := result.(*VersionOK)
|
||||||
if ok {
|
if ok {
|
||||||
return success, nil
|
return success, nil
|
||||||
}
|
}
|
||||||
// unexpected success response
|
// unexpected success response
|
||||||
// safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue
|
// 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 Get: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
msg := fmt.Sprintf("unexpected success response for version: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||||
panic(msg)
|
panic(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
126
rest_zrok_client/metadata/version_parameters.go
Normal file
126
rest_zrok_client/metadata/version_parameters.go
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewVersionParams creates a new VersionParams 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 NewVersionParams() *VersionParams {
|
||||||
|
return &VersionParams{
|
||||||
|
timeout: cr.DefaultTimeout,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVersionParamsWithTimeout creates a new VersionParams object
|
||||||
|
// with the ability to set a timeout on a request.
|
||||||
|
func NewVersionParamsWithTimeout(timeout time.Duration) *VersionParams {
|
||||||
|
return &VersionParams{
|
||||||
|
timeout: timeout,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVersionParamsWithContext creates a new VersionParams object
|
||||||
|
// with the ability to set a context for a request.
|
||||||
|
func NewVersionParamsWithContext(ctx context.Context) *VersionParams {
|
||||||
|
return &VersionParams{
|
||||||
|
Context: ctx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVersionParamsWithHTTPClient creates a new VersionParams object
|
||||||
|
// with the ability to set a custom HTTPClient for a request.
|
||||||
|
func NewVersionParamsWithHTTPClient(client *http.Client) *VersionParams {
|
||||||
|
return &VersionParams{
|
||||||
|
HTTPClient: client,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* VersionParams contains all the parameters to send to the API endpoint
|
||||||
|
for the version operation.
|
||||||
|
|
||||||
|
Typically these are written to a http.Request.
|
||||||
|
*/
|
||||||
|
type VersionParams struct {
|
||||||
|
timeout time.Duration
|
||||||
|
Context context.Context
|
||||||
|
HTTPClient *http.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithDefaults hydrates default values in the version params (not the query body).
|
||||||
|
//
|
||||||
|
// All values with no default are reset to their zero value.
|
||||||
|
func (o *VersionParams) WithDefaults() *VersionParams {
|
||||||
|
o.SetDefaults()
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDefaults hydrates default values in the version params (not the query body).
|
||||||
|
//
|
||||||
|
// All values with no default are reset to their zero value.
|
||||||
|
func (o *VersionParams) SetDefaults() {
|
||||||
|
// no default values defined for this parameter
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithTimeout adds the timeout to the version params
|
||||||
|
func (o *VersionParams) WithTimeout(timeout time.Duration) *VersionParams {
|
||||||
|
o.SetTimeout(timeout)
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTimeout adds the timeout to the version params
|
||||||
|
func (o *VersionParams) SetTimeout(timeout time.Duration) {
|
||||||
|
o.timeout = timeout
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithContext adds the context to the version params
|
||||||
|
func (o *VersionParams) WithContext(ctx context.Context) *VersionParams {
|
||||||
|
o.SetContext(ctx)
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetContext adds the context to the version params
|
||||||
|
func (o *VersionParams) SetContext(ctx context.Context) {
|
||||||
|
o.Context = ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithHTTPClient adds the HTTPClient to the version params
|
||||||
|
func (o *VersionParams) WithHTTPClient(client *http.Client) *VersionParams {
|
||||||
|
o.SetHTTPClient(client)
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetHTTPClient adds the HTTPClient to the version params
|
||||||
|
func (o *VersionParams) SetHTTPClient(client *http.Client) {
|
||||||
|
o.HTTPClient = client
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteToRequest writes these params to a swagger request
|
||||||
|
func (o *VersionParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||||
|
|
||||||
|
if err := r.SetTimeout(o.timeout); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
67
rest_zrok_client/metadata/version_responses.go
Normal file
67
rest_zrok_client/metadata/version_responses.go
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// 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 (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/go-openapi/runtime"
|
||||||
|
"github.com/go-openapi/strfmt"
|
||||||
|
|
||||||
|
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VersionReader is a Reader for the Version structure.
|
||||||
|
type VersionReader struct {
|
||||||
|
formats strfmt.Registry
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadResponse reads a server response into the received o.
|
||||||
|
func (o *VersionReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||||
|
switch response.Code() {
|
||||||
|
case 200:
|
||||||
|
result := NewVersionOK()
|
||||||
|
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
default:
|
||||||
|
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVersionOK creates a VersionOK with default headers values
|
||||||
|
func NewVersionOK() *VersionOK {
|
||||||
|
return &VersionOK{}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* VersionOK describes a response with status code 200, with default header values.
|
||||||
|
|
||||||
|
retrieve the current server version
|
||||||
|
*/
|
||||||
|
type VersionOK struct {
|
||||||
|
Payload *rest_model.Version
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *VersionOK) Error() string {
|
||||||
|
return fmt.Sprintf("[GET /version][%d] versionOK %+v", 200, o.Payload)
|
||||||
|
}
|
||||||
|
func (o *VersionOK) GetPayload() *rest_model.Version {
|
||||||
|
return o.Payload
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *VersionOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
o.Payload = new(rest_model.Version)
|
||||||
|
|
||||||
|
// response payload
|
||||||
|
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
@ -9,10 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-openapi/errors"
|
"github.com/go-openapi/errors"
|
||||||
"github.com/go-openapi/runtime"
|
"github.com/go-openapi/runtime"
|
||||||
"github.com/go-openapi/runtime/middleware"
|
|
||||||
|
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations"
|
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations"
|
||||||
"github.com/openziti-test-kitchen/zrok/rest_zrok_server/operations/metadata"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate swagger generate server --target ../../zrok --name Zrok --spec ../specs/zrok.yml --model-package rest_model --server-package rest_zrok_server --principal interface{}
|
//go:generate swagger generate server --target ../../zrok --name Zrok --spec ../specs/zrok.yml --model-package rest_model --server-package rest_zrok_server --principal interface{}
|
||||||
@ -28,12 +25,6 @@ func configureAPI(api *operations.ZrokAPI) http.Handler {
|
|||||||
api.JSONConsumer = runtime.JSONConsumer()
|
api.JSONConsumer = runtime.JSONConsumer()
|
||||||
api.JSONProducer = runtime.JSONProducer()
|
api.JSONProducer = runtime.JSONProducer()
|
||||||
|
|
||||||
if api.MetadataGetHandler == nil {
|
|
||||||
api.MetadataGetHandler = metadata.GetHandlerFunc(func(params metadata.GetParams) middleware.Responder {
|
|
||||||
return middleware.NotImplemented("operation metadata.Get has not yet been implemented")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
api.PreServerShutdown = func() {}
|
api.PreServerShutdown = func() {}
|
||||||
|
|
||||||
api.ServerShutdown = func() {}
|
api.ServerShutdown = func() {}
|
||||||
|
@ -34,21 +34,6 @@ func init() {
|
|||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
"/": {
|
|
||||||
"get": {
|
|
||||||
"tags": [
|
|
||||||
"metadata"
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "retrieve the current server version",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/account": {
|
"/account": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@ -73,6 +58,22 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/version": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"metadata"
|
||||||
|
],
|
||||||
|
"operationId": "version",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "retrieve the current server version",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
@ -122,21 +123,6 @@ func init() {
|
|||||||
"version": "1.0.0"
|
"version": "1.0.0"
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
"/": {
|
|
||||||
"get": {
|
|
||||||
"tags": [
|
|
||||||
"metadata"
|
|
||||||
],
|
|
||||||
"responses": {
|
|
||||||
"200": {
|
|
||||||
"description": "retrieve the current server version",
|
|
||||||
"schema": {
|
|
||||||
"$ref": "#/definitions/version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/account": {
|
"/account": {
|
||||||
"post": {
|
"post": {
|
||||||
"tags": [
|
"tags": [
|
||||||
@ -161,6 +147,22 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/version": {
|
||||||
|
"get": {
|
||||||
|
"tags": [
|
||||||
|
"metadata"
|
||||||
|
],
|
||||||
|
"operationId": "version",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "retrieve the current server version",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
|
56
rest_zrok_server/operations/metadata/version.go
Normal file
56
rest_zrok_server/operations/metadata/version.go
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// 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 (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/go-openapi/runtime/middleware"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VersionHandlerFunc turns a function with the right signature into a version handler
|
||||||
|
type VersionHandlerFunc func(VersionParams) middleware.Responder
|
||||||
|
|
||||||
|
// Handle executing the request and returning a response
|
||||||
|
func (fn VersionHandlerFunc) Handle(params VersionParams) middleware.Responder {
|
||||||
|
return fn(params)
|
||||||
|
}
|
||||||
|
|
||||||
|
// VersionHandler interface for that can handle valid version params
|
||||||
|
type VersionHandler interface {
|
||||||
|
Handle(VersionParams) middleware.Responder
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVersion creates a new http.Handler for the version operation
|
||||||
|
func NewVersion(ctx *middleware.Context, handler VersionHandler) *Version {
|
||||||
|
return &Version{Context: ctx, Handler: handler}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Version swagger:route GET /version metadata version
|
||||||
|
|
||||||
|
Version version API
|
||||||
|
|
||||||
|
*/
|
||||||
|
type Version struct {
|
||||||
|
Context *middleware.Context
|
||||||
|
Handler VersionHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *Version) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||||
|
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||||
|
if rCtx != nil {
|
||||||
|
*r = *rCtx
|
||||||
|
}
|
||||||
|
var Params = NewVersionParams()
|
||||||
|
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)
|
||||||
|
|
||||||
|
}
|
46
rest_zrok_server/operations/metadata/version_parameters.go
Normal file
46
rest_zrok_server/operations/metadata/version_parameters.go
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// 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/middleware"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewVersionParams creates a new VersionParams object
|
||||||
|
//
|
||||||
|
// There are no default values defined in the spec.
|
||||||
|
func NewVersionParams() VersionParams {
|
||||||
|
|
||||||
|
return VersionParams{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// VersionParams contains all the bound params for the version operation
|
||||||
|
// typically these are obtained from a http.Request
|
||||||
|
//
|
||||||
|
// swagger:parameters version
|
||||||
|
type VersionParams struct {
|
||||||
|
|
||||||
|
// HTTP Request Object
|
||||||
|
HTTPRequest *http.Request `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 NewVersionParams() beforehand.
|
||||||
|
func (o *VersionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||||
|
var res []error
|
||||||
|
|
||||||
|
o.HTTPRequest = r
|
||||||
|
|
||||||
|
if len(res) > 0 {
|
||||||
|
return errors.CompositeValidationError(res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
58
rest_zrok_server/operations/metadata/version_responses.go
Normal file
58
rest_zrok_server/operations/metadata/version_responses.go
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// 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"
|
||||||
|
|
||||||
|
"github.com/openziti-test-kitchen/zrok/rest_model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VersionOKCode is the HTTP code returned for type VersionOK
|
||||||
|
const VersionOKCode int = 200
|
||||||
|
|
||||||
|
/*VersionOK retrieve the current server version
|
||||||
|
|
||||||
|
swagger:response versionOK
|
||||||
|
*/
|
||||||
|
type VersionOK struct {
|
||||||
|
|
||||||
|
/*
|
||||||
|
In: Body
|
||||||
|
*/
|
||||||
|
Payload *rest_model.Version `json:"body,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVersionOK creates VersionOK with default headers values
|
||||||
|
func NewVersionOK() *VersionOK {
|
||||||
|
|
||||||
|
return &VersionOK{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPayload adds the payload to the version o k response
|
||||||
|
func (o *VersionOK) WithPayload(payload *rest_model.Version) *VersionOK {
|
||||||
|
o.Payload = payload
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPayload sets the payload to the version o k response
|
||||||
|
func (o *VersionOK) SetPayload(payload *rest_model.Version) {
|
||||||
|
o.Payload = payload
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteResponse to the client
|
||||||
|
func (o *VersionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||||
|
|
||||||
|
rw.WriteHeader(200)
|
||||||
|
if o.Payload != nil {
|
||||||
|
payload := o.Payload
|
||||||
|
if err := producer.Produce(rw, payload); err != nil {
|
||||||
|
panic(err) // let the recovery middleware deal with this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
84
rest_zrok_server/operations/metadata/version_urlbuilder.go
Normal file
84
rest_zrok_server/operations/metadata/version_urlbuilder.go
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VersionURL generates an URL for the version operation
|
||||||
|
type VersionURL 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 *VersionURL) WithBasePath(bp string) *VersionURL {
|
||||||
|
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 *VersionURL) SetBasePath(bp string) {
|
||||||
|
o._basePath = bp
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build a url path and query string
|
||||||
|
func (o *VersionURL) Build() (*url.URL, error) {
|
||||||
|
var _result url.URL
|
||||||
|
|
||||||
|
var _path = "/version"
|
||||||
|
|
||||||
|
_basePath := o._basePath
|
||||||
|
_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 *VersionURL) 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 *VersionURL) String() string {
|
||||||
|
return o.Must(o.Build()).String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// BuildFull builds a full url with scheme, host, path and query string
|
||||||
|
func (o *VersionURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||||
|
if scheme == "" {
|
||||||
|
return nil, errors.New("scheme is required for a full url on VersionURL")
|
||||||
|
}
|
||||||
|
if host == "" {
|
||||||
|
return nil, errors.New("host is required for a full url on VersionURL")
|
||||||
|
}
|
||||||
|
|
||||||
|
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 *VersionURL) StringFull(scheme, host string) string {
|
||||||
|
return o.Must(o.BuildFull(scheme, host)).String()
|
||||||
|
}
|
@ -45,12 +45,12 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
|
|||||||
|
|
||||||
JSONProducer: runtime.JSONProducer(),
|
JSONProducer: runtime.JSONProducer(),
|
||||||
|
|
||||||
MetadataGetHandler: metadata.GetHandlerFunc(func(params metadata.GetParams) middleware.Responder {
|
|
||||||
return middleware.NotImplemented("operation metadata.Get has not yet been implemented")
|
|
||||||
}),
|
|
||||||
IdentityCreateAccountHandler: identity.CreateAccountHandlerFunc(func(params identity.CreateAccountParams) middleware.Responder {
|
IdentityCreateAccountHandler: identity.CreateAccountHandlerFunc(func(params identity.CreateAccountParams) middleware.Responder {
|
||||||
return middleware.NotImplemented("operation identity.CreateAccount has not yet been implemented")
|
return middleware.NotImplemented("operation identity.CreateAccount has not yet been implemented")
|
||||||
}),
|
}),
|
||||||
|
MetadataVersionHandler: metadata.VersionHandlerFunc(func(params metadata.VersionParams) middleware.Responder {
|
||||||
|
return middleware.NotImplemented("operation metadata.Version has not yet been implemented")
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,10 +87,10 @@ type ZrokAPI struct {
|
|||||||
// - application/zrok.v1+json
|
// - application/zrok.v1+json
|
||||||
JSONProducer runtime.Producer
|
JSONProducer runtime.Producer
|
||||||
|
|
||||||
// MetadataGetHandler sets the operation handler for the get operation
|
|
||||||
MetadataGetHandler metadata.GetHandler
|
|
||||||
// IdentityCreateAccountHandler sets the operation handler for the create account operation
|
// IdentityCreateAccountHandler sets the operation handler for the create account operation
|
||||||
IdentityCreateAccountHandler identity.CreateAccountHandler
|
IdentityCreateAccountHandler identity.CreateAccountHandler
|
||||||
|
// MetadataVersionHandler sets the operation handler for the version operation
|
||||||
|
MetadataVersionHandler metadata.VersionHandler
|
||||||
|
|
||||||
// ServeError is called when an error is received, there is a default handler
|
// ServeError is called when an error is received, there is a default handler
|
||||||
// but you can set your own with this
|
// but you can set your own with this
|
||||||
@ -168,12 +168,12 @@ func (o *ZrokAPI) Validate() error {
|
|||||||
unregistered = append(unregistered, "JSONProducer")
|
unregistered = append(unregistered, "JSONProducer")
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.MetadataGetHandler == nil {
|
|
||||||
unregistered = append(unregistered, "metadata.GetHandler")
|
|
||||||
}
|
|
||||||
if o.IdentityCreateAccountHandler == nil {
|
if o.IdentityCreateAccountHandler == nil {
|
||||||
unregistered = append(unregistered, "identity.CreateAccountHandler")
|
unregistered = append(unregistered, "identity.CreateAccountHandler")
|
||||||
}
|
}
|
||||||
|
if o.MetadataVersionHandler == nil {
|
||||||
|
unregistered = append(unregistered, "metadata.VersionHandler")
|
||||||
|
}
|
||||||
|
|
||||||
if len(unregistered) > 0 {
|
if len(unregistered) > 0 {
|
||||||
return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", "))
|
return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", "))
|
||||||
@ -262,14 +262,14 @@ func (o *ZrokAPI) initHandlerCache() {
|
|||||||
o.handlers = make(map[string]map[string]http.Handler)
|
o.handlers = make(map[string]map[string]http.Handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.handlers["GET"] == nil {
|
|
||||||
o.handlers["GET"] = make(map[string]http.Handler)
|
|
||||||
}
|
|
||||||
o.handlers["GET"][""] = metadata.NewGet(o.context, o.MetadataGetHandler)
|
|
||||||
if o.handlers["POST"] == nil {
|
if o.handlers["POST"] == nil {
|
||||||
o.handlers["POST"] = make(map[string]http.Handler)
|
o.handlers["POST"] = make(map[string]http.Handler)
|
||||||
}
|
}
|
||||||
o.handlers["POST"]["/account"] = identity.NewCreateAccount(o.context, o.IdentityCreateAccountHandler)
|
o.handlers["POST"]["/account"] = identity.NewCreateAccount(o.context, o.IdentityCreateAccountHandler)
|
||||||
|
if o.handlers["GET"] == nil {
|
||||||
|
o.handlers["GET"] = make(map[string]http.Handler)
|
||||||
|
}
|
||||||
|
o.handlers["GET"]["/version"] = metadata.NewVersion(o.context, o.MetadataVersionHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serve creates a http handler to serve the API over HTTP
|
// Serve creates a http handler to serve the API over HTTP
|
||||||
|
@ -4,15 +4,6 @@ info:
|
|||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/:
|
|
||||||
get:
|
|
||||||
tags:
|
|
||||||
- metadata
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: retrieve the current server version
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/version"
|
|
||||||
/account:
|
/account:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
@ -28,6 +19,16 @@ paths:
|
|||||||
description: account created
|
description: account created
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/accountResponse"
|
$ref: "#/definitions/accountResponse"
|
||||||
|
/version:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- metadata
|
||||||
|
operationId: version
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: retrieve the current server version
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/version"
|
||||||
|
|
||||||
definitions:
|
definitions:
|
||||||
version:
|
version:
|
||||||
|
Loading…
Reference in New Issue
Block a user