mirror of
https://github.com/openziti/zrok.git
synced 2024-12-22 06:40:50 +01:00
'verify' api endpoint (#50)
This commit is contained in:
parent
4a69e03a5b
commit
3d9cc7d1b3
@ -38,6 +38,8 @@ type ClientService interface {
|
||||
|
||||
Login(params *LoginParams, opts ...ClientOption) (*LoginOK, error)
|
||||
|
||||
Verify(params *VerifyParams, opts ...ClientOption) (*VerifyOK, error)
|
||||
|
||||
SetTransport(transport runtime.ClientTransport)
|
||||
}
|
||||
|
||||
@ -195,6 +197,44 @@ func (a *Client) Login(params *LoginParams, opts ...ClientOption) (*LoginOK, err
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
/*
|
||||
Verify verify API
|
||||
*/
|
||||
func (a *Client) Verify(params *VerifyParams, opts ...ClientOption) (*VerifyOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewVerifyParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "verify",
|
||||
Method: "GET",
|
||||
PathPattern: "/verify",
|
||||
ProducesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
ConsumesMediaTypes: []string{"application/zrok.v1+json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &VerifyReader{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.(*VerifyOK)
|
||||
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 verify: API contract not enforced by server. Client expected to get an error, but got: %T", result)
|
||||
panic(msg)
|
||||
}
|
||||
|
||||
// SetTransport changes the transport on the client
|
||||
func (a *Client) SetTransport(transport runtime.ClientTransport) {
|
||||
a.transport = transport
|
||||
|
150
rest_client_zrok/identity/verify_parameters.go
Normal file
150
rest_client_zrok/identity/verify_parameters.go
Normal file
@ -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"
|
||||
)
|
||||
|
||||
// NewVerifyParams creates a new VerifyParams 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 NewVerifyParams() *VerifyParams {
|
||||
return &VerifyParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewVerifyParamsWithTimeout creates a new VerifyParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewVerifyParamsWithTimeout(timeout time.Duration) *VerifyParams {
|
||||
return &VerifyParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewVerifyParamsWithContext creates a new VerifyParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewVerifyParamsWithContext(ctx context.Context) *VerifyParams {
|
||||
return &VerifyParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewVerifyParamsWithHTTPClient creates a new VerifyParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewVerifyParamsWithHTTPClient(client *http.Client) *VerifyParams {
|
||||
return &VerifyParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
VerifyParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the verify operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type VerifyParams struct {
|
||||
|
||||
// Body.
|
||||
Body *rest_model_zrok.VerifyRequest
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the verify params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *VerifyParams) WithDefaults() *VerifyParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the verify params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *VerifyParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the verify params
|
||||
func (o *VerifyParams) WithTimeout(timeout time.Duration) *VerifyParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the verify params
|
||||
func (o *VerifyParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the verify params
|
||||
func (o *VerifyParams) WithContext(ctx context.Context) *VerifyParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the verify params
|
||||
func (o *VerifyParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the verify params
|
||||
func (o *VerifyParams) WithHTTPClient(client *http.Client) *VerifyParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the verify params
|
||||
func (o *VerifyParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithBody adds the body to the verify params
|
||||
func (o *VerifyParams) WithBody(body *rest_model_zrok.VerifyRequest) *VerifyParams {
|
||||
o.SetBody(body)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetBody adds the body to the verify params
|
||||
func (o *VerifyParams) SetBody(body *rest_model_zrok.VerifyRequest) {
|
||||
o.Body = body
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *VerifyParams) 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
|
||||
}
|
222
rest_client_zrok/identity/verify_responses.go
Normal file
222
rest_client_zrok/identity/verify_responses.go
Normal file
@ -0,0 +1,222 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// VerifyReader is a Reader for the Verify structure.
|
||||
type VerifyReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *VerifyReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewVerifyOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 404:
|
||||
result := NewVerifyNotFound()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, result
|
||||
case 500:
|
||||
result := NewVerifyInternalServerError()
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
// NewVerifyOK creates a VerifyOK with default headers values
|
||||
func NewVerifyOK() *VerifyOK {
|
||||
return &VerifyOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
VerifyOK describes a response with status code 200, with default header values.
|
||||
|
||||
token ready
|
||||
*/
|
||||
type VerifyOK struct {
|
||||
Payload *rest_model_zrok.VerifyResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this verify o k response has a 2xx status code
|
||||
func (o *VerifyOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this verify o k response has a 3xx status code
|
||||
func (o *VerifyOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this verify o k response has a 4xx status code
|
||||
func (o *VerifyOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this verify o k response has a 5xx status code
|
||||
func (o *VerifyOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this verify o k response a status code equal to that given
|
||||
func (o *VerifyOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
func (o *VerifyOK) Error() string {
|
||||
return fmt.Sprintf("[GET /verify][%d] verifyOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *VerifyOK) String() string {
|
||||
return fmt.Sprintf("[GET /verify][%d] verifyOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *VerifyOK) GetPayload() *rest_model_zrok.VerifyResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *VerifyOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(rest_model_zrok.VerifyResponse)
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewVerifyNotFound creates a VerifyNotFound with default headers values
|
||||
func NewVerifyNotFound() *VerifyNotFound {
|
||||
return &VerifyNotFound{}
|
||||
}
|
||||
|
||||
/*
|
||||
VerifyNotFound describes a response with status code 404, with default header values.
|
||||
|
||||
token not found
|
||||
*/
|
||||
type VerifyNotFound struct {
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this verify not found response has a 2xx status code
|
||||
func (o *VerifyNotFound) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this verify not found response has a 3xx status code
|
||||
func (o *VerifyNotFound) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this verify not found response has a 4xx status code
|
||||
func (o *VerifyNotFound) IsClientError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsServerError returns true when this verify not found response has a 5xx status code
|
||||
func (o *VerifyNotFound) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this verify not found response a status code equal to that given
|
||||
func (o *VerifyNotFound) IsCode(code int) bool {
|
||||
return code == 404
|
||||
}
|
||||
|
||||
func (o *VerifyNotFound) Error() string {
|
||||
return fmt.Sprintf("[GET /verify][%d] verifyNotFound ", 404)
|
||||
}
|
||||
|
||||
func (o *VerifyNotFound) String() string {
|
||||
return fmt.Sprintf("[GET /verify][%d] verifyNotFound ", 404)
|
||||
}
|
||||
|
||||
func (o *VerifyNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewVerifyInternalServerError creates a VerifyInternalServerError with default headers values
|
||||
func NewVerifyInternalServerError() *VerifyInternalServerError {
|
||||
return &VerifyInternalServerError{}
|
||||
}
|
||||
|
||||
/*
|
||||
VerifyInternalServerError describes a response with status code 500, with default header values.
|
||||
|
||||
internal server error
|
||||
*/
|
||||
type VerifyInternalServerError struct {
|
||||
Payload rest_model_zrok.ErrorMessage
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this verify internal server error response has a 2xx status code
|
||||
func (o *VerifyInternalServerError) IsSuccess() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this verify internal server error response has a 3xx status code
|
||||
func (o *VerifyInternalServerError) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this verify internal server error response has a 4xx status code
|
||||
func (o *VerifyInternalServerError) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this verify internal server error response has a 5xx status code
|
||||
func (o *VerifyInternalServerError) IsServerError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsCode returns true when this verify internal server error response a status code equal to that given
|
||||
func (o *VerifyInternalServerError) IsCode(code int) bool {
|
||||
return code == 500
|
||||
}
|
||||
|
||||
func (o *VerifyInternalServerError) Error() string {
|
||||
return fmt.Sprintf("[GET /verify][%d] verifyInternalServerError %+v", 500, o.Payload)
|
||||
}
|
||||
|
||||
func (o *VerifyInternalServerError) String() string {
|
||||
return fmt.Sprintf("[GET /verify][%d] verifyInternalServerError %+v", 500, o.Payload)
|
||||
}
|
||||
|
||||
func (o *VerifyInternalServerError) GetPayload() rest_model_zrok.ErrorMessage {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *VerifyInternalServerError) 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
|
||||
}
|
@ -42,7 +42,7 @@ func NewVersionOK() *VersionOK {
|
||||
/*
|
||||
VersionOK describes a response with status code 200, with default header values.
|
||||
|
||||
retrieve the current server version
|
||||
current server version
|
||||
*/
|
||||
type VersionOK struct {
|
||||
Payload rest_model_zrok.Version
|
||||
|
50
rest_model_zrok/verify_request.go
Normal file
50
rest_model_zrok/verify_request.go
Normal file
@ -0,0 +1,50 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// VerifyRequest verify request
|
||||
//
|
||||
// swagger:model verifyRequest
|
||||
type VerifyRequest struct {
|
||||
|
||||
// token
|
||||
Token string `json:"token,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this verify request
|
||||
func (m *VerifyRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this verify request based on context it is used
|
||||
func (m *VerifyRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *VerifyRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *VerifyRequest) UnmarshalBinary(b []byte) error {
|
||||
var res VerifyRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
50
rest_model_zrok/verify_response.go
Normal file
50
rest_model_zrok/verify_response.go
Normal file
@ -0,0 +1,50 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// VerifyResponse verify response
|
||||
//
|
||||
// swagger:model verifyResponse
|
||||
type VerifyResponse struct {
|
||||
|
||||
// email
|
||||
Email string `json:"email,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this verify response
|
||||
func (m *VerifyResponse) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this verify response based on context it is used
|
||||
func (m *VerifyResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *VerifyResponse) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *VerifyResponse) UnmarshalBinary(b []byte) error {
|
||||
var res VerifyResponse
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
@ -286,6 +286,40 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/verify": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"identity"
|
||||
],
|
||||
"operationId": "verify",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/verifyRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "token ready",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/verifyResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "token not found"
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/errorMessage"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/version": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@ -294,7 +328,7 @@ func init() {
|
||||
"operationId": "version",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "retrieve the current server version",
|
||||
"description": "current server version",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/version"
|
||||
}
|
||||
@ -512,6 +546,22 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"verifyRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"token": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"verifyResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"version": {
|
||||
"type": "string"
|
||||
}
|
||||
@ -793,6 +843,40 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/verify": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"identity"
|
||||
],
|
||||
"operationId": "verify",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/verifyRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "token ready",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/verifyResponse"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "token not found"
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/errorMessage"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/version": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@ -801,7 +885,7 @@ func init() {
|
||||
"operationId": "version",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "retrieve the current server version",
|
||||
"description": "current server version",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/version"
|
||||
}
|
||||
@ -1019,6 +1103,22 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"verifyRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"token": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"verifyResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"version": {
|
||||
"type": "string"
|
||||
}
|
||||
|
56
rest_server_zrok/operations/identity/verify.go
Normal file
56
rest_server_zrok/operations/identity/verify.go
Normal file
@ -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"
|
||||
)
|
||||
|
||||
// VerifyHandlerFunc turns a function with the right signature into a verify handler
|
||||
type VerifyHandlerFunc func(VerifyParams) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn VerifyHandlerFunc) Handle(params VerifyParams) middleware.Responder {
|
||||
return fn(params)
|
||||
}
|
||||
|
||||
// VerifyHandler interface for that can handle valid verify params
|
||||
type VerifyHandler interface {
|
||||
Handle(VerifyParams) middleware.Responder
|
||||
}
|
||||
|
||||
// NewVerify creates a new http.Handler for the verify operation
|
||||
func NewVerify(ctx *middleware.Context, handler VerifyHandler) *Verify {
|
||||
return &Verify{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
Verify swagger:route GET /verify identity verify
|
||||
|
||||
Verify verify API
|
||||
*/
|
||||
type Verify struct {
|
||||
Context *middleware.Context
|
||||
Handler VerifyHandler
|
||||
}
|
||||
|
||||
func (o *Verify) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewVerifyParams()
|
||||
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)
|
||||
|
||||
}
|
76
rest_server_zrok/operations/identity/verify_parameters.go
Normal file
76
rest_server_zrok/operations/identity/verify_parameters.go
Normal file
@ -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"
|
||||
)
|
||||
|
||||
// NewVerifyParams creates a new VerifyParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewVerifyParams() VerifyParams {
|
||||
|
||||
return VerifyParams{}
|
||||
}
|
||||
|
||||
// VerifyParams contains all the bound params for the verify operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters verify
|
||||
type VerifyParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
In: body
|
||||
*/
|
||||
Body *rest_model_zrok.VerifyRequest
|
||||
}
|
||||
|
||||
// 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 NewVerifyParams() beforehand.
|
||||
func (o *VerifyParams) 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.VerifyRequest
|
||||
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
|
||||
}
|
127
rest_server_zrok/operations/identity/verify_responses.go
Normal file
127
rest_server_zrok/operations/identity/verify_responses.go
Normal file
@ -0,0 +1,127 @@
|
||||
// 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"
|
||||
)
|
||||
|
||||
// VerifyOKCode is the HTTP code returned for type VerifyOK
|
||||
const VerifyOKCode int = 200
|
||||
|
||||
/*
|
||||
VerifyOK token ready
|
||||
|
||||
swagger:response verifyOK
|
||||
*/
|
||||
type VerifyOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *rest_model_zrok.VerifyResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewVerifyOK creates VerifyOK with default headers values
|
||||
func NewVerifyOK() *VerifyOK {
|
||||
|
||||
return &VerifyOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the verify o k response
|
||||
func (o *VerifyOK) WithPayload(payload *rest_model_zrok.VerifyResponse) *VerifyOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the verify o k response
|
||||
func (o *VerifyOK) SetPayload(payload *rest_model_zrok.VerifyResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *VerifyOK) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// VerifyNotFoundCode is the HTTP code returned for type VerifyNotFound
|
||||
const VerifyNotFoundCode int = 404
|
||||
|
||||
/*
|
||||
VerifyNotFound token not found
|
||||
|
||||
swagger:response verifyNotFound
|
||||
*/
|
||||
type VerifyNotFound struct {
|
||||
}
|
||||
|
||||
// NewVerifyNotFound creates VerifyNotFound with default headers values
|
||||
func NewVerifyNotFound() *VerifyNotFound {
|
||||
|
||||
return &VerifyNotFound{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *VerifyNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(404)
|
||||
}
|
||||
|
||||
// VerifyInternalServerErrorCode is the HTTP code returned for type VerifyInternalServerError
|
||||
const VerifyInternalServerErrorCode int = 500
|
||||
|
||||
/*
|
||||
VerifyInternalServerError internal server error
|
||||
|
||||
swagger:response verifyInternalServerError
|
||||
*/
|
||||
type VerifyInternalServerError struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload rest_model_zrok.ErrorMessage `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewVerifyInternalServerError creates VerifyInternalServerError with default headers values
|
||||
func NewVerifyInternalServerError() *VerifyInternalServerError {
|
||||
|
||||
return &VerifyInternalServerError{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the verify internal server error response
|
||||
func (o *VerifyInternalServerError) WithPayload(payload rest_model_zrok.ErrorMessage) *VerifyInternalServerError {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the verify internal server error response
|
||||
func (o *VerifyInternalServerError) SetPayload(payload rest_model_zrok.ErrorMessage) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *VerifyInternalServerError) 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
|
||||
}
|
||||
}
|
87
rest_server_zrok/operations/identity/verify_urlbuilder.go
Normal file
87
rest_server_zrok/operations/identity/verify_urlbuilder.go
Normal file
@ -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"
|
||||
)
|
||||
|
||||
// VerifyURL generates an URL for the verify operation
|
||||
type VerifyURL 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 *VerifyURL) WithBasePath(bp string) *VerifyURL {
|
||||
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 *VerifyURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *VerifyURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/verify"
|
||||
|
||||
_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 *VerifyURL) 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 *VerifyURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *VerifyURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on VerifyURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on VerifyURL")
|
||||
}
|
||||
|
||||
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 *VerifyURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
@ -17,7 +17,7 @@ import (
|
||||
const VersionOKCode int = 200
|
||||
|
||||
/*
|
||||
VersionOK retrieve the current server version
|
||||
VersionOK current server version
|
||||
|
||||
swagger:response versionOK
|
||||
*/
|
||||
|
@ -68,6 +68,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
|
||||
TunnelUntunnelHandler: tunnel.UntunnelHandlerFunc(func(params tunnel.UntunnelParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation tunnel.Untunnel has not yet been implemented")
|
||||
}),
|
||||
IdentityVerifyHandler: identity.VerifyHandlerFunc(func(params identity.VerifyParams) middleware.Responder {
|
||||
return middleware.NotImplemented("operation identity.Verify 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")
|
||||
}),
|
||||
@ -135,6 +138,8 @@ type ZrokAPI struct {
|
||||
TunnelTunnelHandler tunnel.TunnelHandler
|
||||
// TunnelUntunnelHandler sets the operation handler for the untunnel operation
|
||||
TunnelUntunnelHandler tunnel.UntunnelHandler
|
||||
// IdentityVerifyHandler sets the operation handler for the verify operation
|
||||
IdentityVerifyHandler identity.VerifyHandler
|
||||
// MetadataVersionHandler sets the operation handler for the version operation
|
||||
MetadataVersionHandler metadata.VersionHandler
|
||||
|
||||
@ -239,6 +244,9 @@ func (o *ZrokAPI) Validate() error {
|
||||
if o.TunnelUntunnelHandler == nil {
|
||||
unregistered = append(unregistered, "tunnel.UntunnelHandler")
|
||||
}
|
||||
if o.IdentityVerifyHandler == nil {
|
||||
unregistered = append(unregistered, "identity.VerifyHandler")
|
||||
}
|
||||
if o.MetadataVersionHandler == nil {
|
||||
unregistered = append(unregistered, "metadata.VersionHandler")
|
||||
}
|
||||
@ -372,6 +380,10 @@ func (o *ZrokAPI) initHandlerCache() {
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/verify"] = identity.NewVerify(o.context, o.IdentityVerifyHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/version"] = metadata.NewVersion(o.context, o.MetadataVersionHandler)
|
||||
}
|
||||
|
||||
|
@ -168,6 +168,28 @@ paths:
|
||||
schema:
|
||||
$ref: "#/definitions/errorMessage"
|
||||
|
||||
/verify:
|
||||
get:
|
||||
tags:
|
||||
- identity
|
||||
operationId: verify
|
||||
parameters:
|
||||
- name: body
|
||||
in: body
|
||||
schema:
|
||||
$ref: "#/definitions/verifyRequest"
|
||||
responses:
|
||||
200:
|
||||
description: token ready
|
||||
schema:
|
||||
$ref: "#/definitions/verifyResponse"
|
||||
404:
|
||||
description: token not found
|
||||
500:
|
||||
description: internal server error
|
||||
schema:
|
||||
$ref: "#/definitions/errorMessage"
|
||||
|
||||
/version:
|
||||
get:
|
||||
tags:
|
||||
@ -175,7 +197,7 @@ paths:
|
||||
operationId: version
|
||||
responses:
|
||||
200:
|
||||
description: retrieve the current server version
|
||||
description: current server version
|
||||
schema:
|
||||
$ref: "#/definitions/version"
|
||||
|
||||
@ -326,6 +348,17 @@ definitions:
|
||||
service:
|
||||
type: string
|
||||
|
||||
verifyRequest:
|
||||
type: object
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
verifyResponse:
|
||||
type: object
|
||||
properties:
|
||||
email:
|
||||
type: string
|
||||
|
||||
version:
|
||||
type: string
|
||||
|
||||
|
@ -42,5 +42,5 @@
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"proxy": "https://api.zrok.io"
|
||||
"proxy": "http://127.0.0.1:18080"
|
||||
}
|
||||
|
@ -62,6 +62,21 @@ export function login(options) {
|
||||
return gateway.request(loginOperation, parameters)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} options Optional options
|
||||
* @param {module:types.verifyRequest} [options.body]
|
||||
* @return {Promise<module:types.verifyResponse>} token ready
|
||||
*/
|
||||
export function verify(options) {
|
||||
if (!options) options = {}
|
||||
const parameters = {
|
||||
body: {
|
||||
body: options.body
|
||||
}
|
||||
}
|
||||
return gateway.request(verifyOperation, parameters)
|
||||
}
|
||||
|
||||
const createAccountOperation = {
|
||||
path: '/account',
|
||||
contentTypes: ['application/zrok.v1+json'],
|
||||
@ -95,3 +110,9 @@ const loginOperation = {
|
||||
contentTypes: ['application/zrok.v1+json'],
|
||||
method: 'post'
|
||||
}
|
||||
|
||||
const verifyOperation = {
|
||||
path: '/verify',
|
||||
contentTypes: ['application/zrok.v1+json'],
|
||||
method: 'get'
|
||||
}
|
||||
|
@ -121,3 +121,17 @@
|
||||
* @property {string} zitiIdentityId
|
||||
* @property {string} service
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef verifyRequest
|
||||
* @memberof module:types
|
||||
*
|
||||
* @property {string} token
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef verifyResponse
|
||||
* @memberof module:types
|
||||
*
|
||||
* @property {string} email
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user