diff --git a/rest_client_zrok/identity/identity_client.go b/rest_client_zrok/identity/identity_client.go index 8a42e3d2..2abbeefe 100644 --- a/rest_client_zrok/identity/identity_client.go +++ b/rest_client_zrok/identity/identity_client.go @@ -38,6 +38,8 @@ type ClientService interface { Login(params *LoginParams, opts ...ClientOption) (*LoginOK, error) + Register(params *RegisterParams, opts ...ClientOption) (*RegisterOK, error) + Verify(params *VerifyParams, opts ...ClientOption) (*VerifyOK, error) SetTransport(transport runtime.ClientTransport) @@ -197,6 +199,44 @@ func (a *Client) Login(params *LoginParams, opts ...ClientOption) (*LoginOK, err panic(msg) } +/* +Register register API +*/ +func (a *Client) Register(params *RegisterParams, opts ...ClientOption) (*RegisterOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewRegisterParams() + } + op := &runtime.ClientOperation{ + ID: "register", + Method: "POST", + PathPattern: "/register", + ProducesMediaTypes: []string{"application/zrok.v1+json"}, + ConsumesMediaTypes: []string{"application/zrok.v1+json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &RegisterReader{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.(*RegisterOK) + 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 register: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* Verify verify API */ diff --git a/rest_client_zrok/identity/register_parameters.go b/rest_client_zrok/identity/register_parameters.go new file mode 100644 index 00000000..abb1e4a9 --- /dev/null +++ b/rest_client_zrok/identity/register_parameters.go @@ -0,0 +1,150 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package identity + +// 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" + + "github.com/openziti-test-kitchen/zrok/rest_model_zrok" +) + +// NewRegisterParams creates a new RegisterParams 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 NewRegisterParams() *RegisterParams { + return &RegisterParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewRegisterParamsWithTimeout creates a new RegisterParams object +// with the ability to set a timeout on a request. +func NewRegisterParamsWithTimeout(timeout time.Duration) *RegisterParams { + return &RegisterParams{ + timeout: timeout, + } +} + +// NewRegisterParamsWithContext creates a new RegisterParams object +// with the ability to set a context for a request. +func NewRegisterParamsWithContext(ctx context.Context) *RegisterParams { + return &RegisterParams{ + Context: ctx, + } +} + +// NewRegisterParamsWithHTTPClient creates a new RegisterParams object +// with the ability to set a custom HTTPClient for a request. +func NewRegisterParamsWithHTTPClient(client *http.Client) *RegisterParams { + return &RegisterParams{ + HTTPClient: client, + } +} + +/* +RegisterParams contains all the parameters to send to the API endpoint + + for the register operation. + + Typically these are written to a http.Request. +*/ +type RegisterParams struct { + + // Body. + Body *rest_model_zrok.RegisterRequest + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the register params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RegisterParams) WithDefaults() *RegisterParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the register params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *RegisterParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the register params +func (o *RegisterParams) WithTimeout(timeout time.Duration) *RegisterParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the register params +func (o *RegisterParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the register params +func (o *RegisterParams) WithContext(ctx context.Context) *RegisterParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the register params +func (o *RegisterParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the register params +func (o *RegisterParams) WithHTTPClient(client *http.Client) *RegisterParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the register params +func (o *RegisterParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the register params +func (o *RegisterParams) WithBody(body *rest_model_zrok.RegisterRequest) *RegisterParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the register params +func (o *RegisterParams) SetBody(body *rest_model_zrok.RegisterRequest) { + o.Body = body +} + +// WriteToRequest writes these params to a swagger request +func (o *RegisterParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client_zrok/identity/register_responses.go b/rest_client_zrok/identity/register_responses.go new file mode 100644 index 00000000..b9068146 --- /dev/null +++ b/rest_client_zrok/identity/register_responses.go @@ -0,0 +1,210 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package identity + +// 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_zrok" +) + +// RegisterReader is a Reader for the Register structure. +type RegisterReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *RegisterReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewRegisterOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 404: + result := NewRegisterNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewRegisterInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + 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()) + } +} + +// NewRegisterOK creates a RegisterOK with default headers values +func NewRegisterOK() *RegisterOK { + return &RegisterOK{} +} + +/* +RegisterOK describes a response with status code 200, with default header values. + +account created +*/ +type RegisterOK struct { +} + +// IsSuccess returns true when this register o k response has a 2xx status code +func (o *RegisterOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this register o k response has a 3xx status code +func (o *RegisterOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this register o k response has a 4xx status code +func (o *RegisterOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this register o k response has a 5xx status code +func (o *RegisterOK) IsServerError() bool { + return false +} + +// IsCode returns true when this register o k response a status code equal to that given +func (o *RegisterOK) IsCode(code int) bool { + return code == 200 +} + +func (o *RegisterOK) Error() string { + return fmt.Sprintf("[POST /register][%d] registerOK ", 200) +} + +func (o *RegisterOK) String() string { + return fmt.Sprintf("[POST /register][%d] registerOK ", 200) +} + +func (o *RegisterOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewRegisterNotFound creates a RegisterNotFound with default headers values +func NewRegisterNotFound() *RegisterNotFound { + return &RegisterNotFound{} +} + +/* +RegisterNotFound describes a response with status code 404, with default header values. + +request not found +*/ +type RegisterNotFound struct { +} + +// IsSuccess returns true when this register not found response has a 2xx status code +func (o *RegisterNotFound) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this register not found response has a 3xx status code +func (o *RegisterNotFound) IsRedirect() bool { + return false +} + +// IsClientError returns true when this register not found response has a 4xx status code +func (o *RegisterNotFound) IsClientError() bool { + return true +} + +// IsServerError returns true when this register not found response has a 5xx status code +func (o *RegisterNotFound) IsServerError() bool { + return false +} + +// IsCode returns true when this register not found response a status code equal to that given +func (o *RegisterNotFound) IsCode(code int) bool { + return code == 404 +} + +func (o *RegisterNotFound) Error() string { + return fmt.Sprintf("[POST /register][%d] registerNotFound ", 404) +} + +func (o *RegisterNotFound) String() string { + return fmt.Sprintf("[POST /register][%d] registerNotFound ", 404) +} + +func (o *RegisterNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewRegisterInternalServerError creates a RegisterInternalServerError with default headers values +func NewRegisterInternalServerError() *RegisterInternalServerError { + return &RegisterInternalServerError{} +} + +/* +RegisterInternalServerError describes a response with status code 500, with default header values. + +internal server error +*/ +type RegisterInternalServerError struct { + Payload rest_model_zrok.ErrorMessage +} + +// IsSuccess returns true when this register internal server error response has a 2xx status code +func (o *RegisterInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this register internal server error response has a 3xx status code +func (o *RegisterInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this register internal server error response has a 4xx status code +func (o *RegisterInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this register internal server error response has a 5xx status code +func (o *RegisterInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this register internal server error response a status code equal to that given +func (o *RegisterInternalServerError) IsCode(code int) bool { + return code == 500 +} + +func (o *RegisterInternalServerError) Error() string { + return fmt.Sprintf("[POST /register][%d] registerInternalServerError %+v", 500, o.Payload) +} + +func (o *RegisterInternalServerError) String() string { + return fmt.Sprintf("[POST /register][%d] registerInternalServerError %+v", 500, o.Payload) +} + +func (o *RegisterInternalServerError) GetPayload() rest_model_zrok.ErrorMessage { + return o.Payload +} + +func (o *RegisterInternalServerError) 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 +} diff --git a/rest_model_zrok/register_request.go b/rest_model_zrok/register_request.go new file mode 100644 index 00000000..b141dacc --- /dev/null +++ b/rest_model_zrok/register_request.go @@ -0,0 +1,53 @@ +// 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" +) + +// RegisterRequest register request +// +// swagger:model registerRequest +type RegisterRequest struct { + + // password + Password string `json:"password,omitempty"` + + // token + Token string `json:"token,omitempty"` +} + +// Validate validates this register request +func (m *RegisterRequest) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this register request based on context it is used +func (m *RegisterRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RegisterRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RegisterRequest) UnmarshalBinary(b []byte) error { + var res RegisterRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/rest_server_zrok/embedded_spec.go b/rest_server_zrok/embedded_spec.go index 5ab87572..d5004105 100644 --- a/rest_server_zrok/embedded_spec.go +++ b/rest_server_zrok/embedded_spec.go @@ -205,6 +205,37 @@ func init() { } } }, + "/register": { + "post": { + "tags": [ + "identity" + ], + "operationId": "register", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/registerRequest" + } + } + ], + "responses": { + "200": { + "description": "account created" + }, + "404": { + "description": "request not found" + }, + "500": { + "description": "internal server error", + "schema": { + "$ref": "#/definitions/errorMessage" + } + } + } + } + }, "/tunnel": { "post": { "security": [ @@ -478,6 +509,17 @@ func init() { } } }, + "registerRequest": { + "type": "object", + "properties": { + "password": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, "service": { "type": "object", "properties": { @@ -762,6 +804,37 @@ func init() { } } }, + "/register": { + "post": { + "tags": [ + "identity" + ], + "operationId": "register", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "$ref": "#/definitions/registerRequest" + } + } + ], + "responses": { + "200": { + "description": "account created" + }, + "404": { + "description": "request not found" + }, + "500": { + "description": "internal server error", + "schema": { + "$ref": "#/definitions/errorMessage" + } + } + } + } + }, "/tunnel": { "post": { "security": [ @@ -1035,6 +1108,17 @@ func init() { } } }, + "registerRequest": { + "type": "object", + "properties": { + "password": { + "type": "string" + }, + "token": { + "type": "string" + } + } + }, "service": { "type": "object", "properties": { diff --git a/rest_server_zrok/operations/identity/register.go b/rest_server_zrok/operations/identity/register.go new file mode 100644 index 00000000..d6ab12bf --- /dev/null +++ b/rest_server_zrok/operations/identity/register.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package identity + +// 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" +) + +// RegisterHandlerFunc turns a function with the right signature into a register handler +type RegisterHandlerFunc func(RegisterParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RegisterHandlerFunc) Handle(params RegisterParams) middleware.Responder { + return fn(params) +} + +// RegisterHandler interface for that can handle valid register params +type RegisterHandler interface { + Handle(RegisterParams) middleware.Responder +} + +// NewRegister creates a new http.Handler for the register operation +func NewRegister(ctx *middleware.Context, handler RegisterHandler) *Register { + return &Register{Context: ctx, Handler: handler} +} + +/* + Register swagger:route POST /register identity register + +Register register API +*/ +type Register struct { + Context *middleware.Context + Handler RegisterHandler +} + +func (o *Register) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewRegisterParams() + 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) + +} diff --git a/rest_server_zrok/operations/identity/register_parameters.go b/rest_server_zrok/operations/identity/register_parameters.go new file mode 100644 index 00000000..614787fc --- /dev/null +++ b/rest_server_zrok/operations/identity/register_parameters.go @@ -0,0 +1,76 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package identity + +// 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" + + "github.com/openziti-test-kitchen/zrok/rest_model_zrok" +) + +// NewRegisterParams creates a new RegisterParams object +// +// There are no default values defined in the spec. +func NewRegisterParams() RegisterParams { + + return RegisterParams{} +} + +// RegisterParams contains all the bound params for the register operation +// typically these are obtained from a http.Request +// +// swagger:parameters register +type RegisterParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: body + */ + Body *rest_model_zrok.RegisterRequest +} + +// 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 NewRegisterParams() beforehand. +func (o *RegisterParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body rest_model_zrok.RegisterRequest + 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 +} diff --git a/rest_server_zrok/operations/identity/register_responses.go b/rest_server_zrok/operations/identity/register_responses.go new file mode 100644 index 00000000..3fedebff --- /dev/null +++ b/rest_server_zrok/operations/identity/register_responses.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package identity + +// 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_zrok" +) + +// RegisterOKCode is the HTTP code returned for type RegisterOK +const RegisterOKCode int = 200 + +/* +RegisterOK account created + +swagger:response registerOK +*/ +type RegisterOK struct { +} + +// NewRegisterOK creates RegisterOK with default headers values +func NewRegisterOK() *RegisterOK { + + return &RegisterOK{} +} + +// WriteResponse to the client +func (o *RegisterOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(200) +} + +// RegisterNotFoundCode is the HTTP code returned for type RegisterNotFound +const RegisterNotFoundCode int = 404 + +/* +RegisterNotFound request not found + +swagger:response registerNotFound +*/ +type RegisterNotFound struct { +} + +// NewRegisterNotFound creates RegisterNotFound with default headers values +func NewRegisterNotFound() *RegisterNotFound { + + return &RegisterNotFound{} +} + +// WriteResponse to the client +func (o *RegisterNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(404) +} + +// RegisterInternalServerErrorCode is the HTTP code returned for type RegisterInternalServerError +const RegisterInternalServerErrorCode int = 500 + +/* +RegisterInternalServerError internal server error + +swagger:response registerInternalServerError +*/ +type RegisterInternalServerError struct { + + /* + In: Body + */ + Payload rest_model_zrok.ErrorMessage `json:"body,omitempty"` +} + +// NewRegisterInternalServerError creates RegisterInternalServerError with default headers values +func NewRegisterInternalServerError() *RegisterInternalServerError { + + return &RegisterInternalServerError{} +} + +// WithPayload adds the payload to the register internal server error response +func (o *RegisterInternalServerError) WithPayload(payload rest_model_zrok.ErrorMessage) *RegisterInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the register internal server error response +func (o *RegisterInternalServerError) SetPayload(payload rest_model_zrok.ErrorMessage) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RegisterInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} diff --git a/rest_server_zrok/operations/identity/register_urlbuilder.go b/rest_server_zrok/operations/identity/register_urlbuilder.go new file mode 100644 index 00000000..13011db1 --- /dev/null +++ b/rest_server_zrok/operations/identity/register_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package identity + +// 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" +) + +// RegisterURL generates an URL for the register operation +type RegisterURL 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 *RegisterURL) WithBasePath(bp string) *RegisterURL { + 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 *RegisterURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RegisterURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/register" + + _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 *RegisterURL) 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 *RegisterURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RegisterURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RegisterURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RegisterURL") + } + + 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 *RegisterURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server_zrok/operations/zrok_api.go b/rest_server_zrok/operations/zrok_api.go index b4dac62a..73d65b57 100644 --- a/rest_server_zrok/operations/zrok_api.go +++ b/rest_server_zrok/operations/zrok_api.go @@ -62,6 +62,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI { MetadataOverviewHandler: metadata.OverviewHandlerFunc(func(params metadata.OverviewParams, principal *rest_model_zrok.Principal) middleware.Responder { return middleware.NotImplemented("operation metadata.Overview has not yet been implemented") }), + IdentityRegisterHandler: identity.RegisterHandlerFunc(func(params identity.RegisterParams) middleware.Responder { + return middleware.NotImplemented("operation identity.Register has not yet been implemented") + }), TunnelTunnelHandler: tunnel.TunnelHandlerFunc(func(params tunnel.TunnelParams, principal *rest_model_zrok.Principal) middleware.Responder { return middleware.NotImplemented("operation tunnel.Tunnel has not yet been implemented") }), @@ -134,6 +137,8 @@ type ZrokAPI struct { IdentityLoginHandler identity.LoginHandler // MetadataOverviewHandler sets the operation handler for the overview operation MetadataOverviewHandler metadata.OverviewHandler + // IdentityRegisterHandler sets the operation handler for the register operation + IdentityRegisterHandler identity.RegisterHandler // TunnelTunnelHandler sets the operation handler for the tunnel operation TunnelTunnelHandler tunnel.TunnelHandler // TunnelUntunnelHandler sets the operation handler for the untunnel operation @@ -238,6 +243,9 @@ func (o *ZrokAPI) Validate() error { if o.MetadataOverviewHandler == nil { unregistered = append(unregistered, "metadata.OverviewHandler") } + if o.IdentityRegisterHandler == nil { + unregistered = append(unregistered, "identity.RegisterHandler") + } if o.TunnelTunnelHandler == nil { unregistered = append(unregistered, "tunnel.TunnelHandler") } @@ -372,6 +380,10 @@ func (o *ZrokAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } + o.handlers["POST"]["/register"] = identity.NewRegister(o.context, o.IdentityRegisterHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } o.handlers["POST"]["/tunnel"] = tunnel.NewTunnel(o.context, o.TunnelTunnelHandler) if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) diff --git a/specs/zrok.yml b/specs/zrok.yml index fd627e85..8df6e4fb 100644 --- a/specs/zrok.yml +++ b/specs/zrok.yml @@ -12,6 +12,9 @@ securityDefinitions: name: x-token paths: +# +# identity +# /account: post: tags: @@ -119,6 +122,26 @@ paths: schema: $ref: "#/definitions/errorMessage" + /register: + post: + tags: + - identity + operationId: register + parameters: + - name: body + in: body + schema: + $ref: "#/definitions/registerRequest" + responses: + 200: + description: account created + 404: + description: request not found + 500: + description: internal server error + schema: + $ref: "#/definitions/errorMessage" + /tunnel: post: tags: @@ -301,6 +324,14 @@ definitions: token: type: string + registerRequest: + type: object + properties: + token: + type: string + password: + type: string + services: type: array items: diff --git a/ui/src/api/identity.js b/ui/src/api/identity.js index 8306d31b..2a2b3d66 100644 --- a/ui/src/api/identity.js +++ b/ui/src/api/identity.js @@ -62,6 +62,21 @@ export function login(options) { return gateway.request(loginOperation, parameters) } +/** + * @param {object} options Optional options + * @param {module:types.registerRequest} [options.body] + * @return {Promise} account created + */ +export function register(options) { + if (!options) options = {} + const parameters = { + body: { + body: options.body + } + } + return gateway.request(registerOperation, parameters) +} + /** * @param {object} options Optional options * @param {module:types.verifyRequest} [options.body] @@ -111,6 +126,12 @@ const loginOperation = { method: 'post' } +const registerOperation = { + path: '/register', + contentTypes: ['application/zrok.v1+json'], + method: 'post' +} + const verifyOperation = { path: '/verify', contentTypes: ['application/zrok.v1+json'], diff --git a/ui/src/api/types.js b/ui/src/api/types.js index e46460ec..be7e210c 100644 --- a/ui/src/api/types.js +++ b/ui/src/api/types.js @@ -85,6 +85,14 @@ * @property {string} token */ +/** + * @typedef registerRequest + * @memberof module:types + * + * @property {string} token + * @property {string} password + */ + /** * @typedef service * @memberof module:types