diff --git a/rest_client_zrok/metrics/get_account_metrics_parameters.go b/rest_client_zrok/metrics/get_account_metrics_parameters.go new file mode 100644 index 00000000..5af21fb7 --- /dev/null +++ b/rest_client_zrok/metrics/get_account_metrics_parameters.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" +) + +// NewGetAccountMetricsParams creates a new GetAccountMetricsParams 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 NewGetAccountMetricsParams() *GetAccountMetricsParams { + return &GetAccountMetricsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetAccountMetricsParamsWithTimeout creates a new GetAccountMetricsParams object +// with the ability to set a timeout on a request. +func NewGetAccountMetricsParamsWithTimeout(timeout time.Duration) *GetAccountMetricsParams { + return &GetAccountMetricsParams{ + timeout: timeout, + } +} + +// NewGetAccountMetricsParamsWithContext creates a new GetAccountMetricsParams object +// with the ability to set a context for a request. +func NewGetAccountMetricsParamsWithContext(ctx context.Context) *GetAccountMetricsParams { + return &GetAccountMetricsParams{ + Context: ctx, + } +} + +// NewGetAccountMetricsParamsWithHTTPClient creates a new GetAccountMetricsParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetAccountMetricsParamsWithHTTPClient(client *http.Client) *GetAccountMetricsParams { + return &GetAccountMetricsParams{ + HTTPClient: client, + } +} + +/* +GetAccountMetricsParams contains all the parameters to send to the API endpoint + + for the get account metrics operation. + + Typically these are written to a http.Request. +*/ +type GetAccountMetricsParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the get account metrics params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAccountMetricsParams) WithDefaults() *GetAccountMetricsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get account metrics params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAccountMetricsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get account metrics params +func (o *GetAccountMetricsParams) WithTimeout(timeout time.Duration) *GetAccountMetricsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get account metrics params +func (o *GetAccountMetricsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get account metrics params +func (o *GetAccountMetricsParams) WithContext(ctx context.Context) *GetAccountMetricsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get account metrics params +func (o *GetAccountMetricsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get account metrics params +func (o *GetAccountMetricsParams) WithHTTPClient(client *http.Client) *GetAccountMetricsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get account metrics params +func (o *GetAccountMetricsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *GetAccountMetricsParams) 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 +} diff --git a/rest_client_zrok/metrics/get_account_metrics_responses.go b/rest_client_zrok/metrics/get_account_metrics_responses.go new file mode 100644 index 00000000..4768551f --- /dev/null +++ b/rest_client_zrok/metrics/get_account_metrics_responses.go @@ -0,0 +1,98 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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/zrok/rest_model_zrok" +) + +// GetAccountMetricsReader is a Reader for the GetAccountMetrics structure. +type GetAccountMetricsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetAccountMetricsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetAccountMetricsOK() + 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()) + } +} + +// NewGetAccountMetricsOK creates a GetAccountMetricsOK with default headers values +func NewGetAccountMetricsOK() *GetAccountMetricsOK { + return &GetAccountMetricsOK{} +} + +/* +GetAccountMetricsOK describes a response with status code 200, with default header values. + +account metrics +*/ +type GetAccountMetricsOK struct { + Payload *rest_model_zrok.Metrics +} + +// IsSuccess returns true when this get account metrics o k response has a 2xx status code +func (o *GetAccountMetricsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get account metrics o k response has a 3xx status code +func (o *GetAccountMetricsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get account metrics o k response has a 4xx status code +func (o *GetAccountMetricsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get account metrics o k response has a 5xx status code +func (o *GetAccountMetricsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get account metrics o k response a status code equal to that given +func (o *GetAccountMetricsOK) IsCode(code int) bool { + return code == 200 +} + +func (o *GetAccountMetricsOK) Error() string { + return fmt.Sprintf("[GET /metrics/account][%d] getAccountMetricsOK %+v", 200, o.Payload) +} + +func (o *GetAccountMetricsOK) String() string { + return fmt.Sprintf("[GET /metrics/account][%d] getAccountMetricsOK %+v", 200, o.Payload) +} + +func (o *GetAccountMetricsOK) GetPayload() *rest_model_zrok.Metrics { + return o.Payload +} + +func (o *GetAccountMetricsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(rest_model_zrok.Metrics) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/rest_client_zrok/metrics/get_environment_metrics_parameters.go b/rest_client_zrok/metrics/get_environment_metrics_parameters.go new file mode 100644 index 00000000..538d0074 --- /dev/null +++ b/rest_client_zrok/metrics/get_environment_metrics_parameters.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" +) + +// NewGetEnvironmentMetricsParams creates a new GetEnvironmentMetricsParams 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 NewGetEnvironmentMetricsParams() *GetEnvironmentMetricsParams { + return &GetEnvironmentMetricsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetEnvironmentMetricsParamsWithTimeout creates a new GetEnvironmentMetricsParams object +// with the ability to set a timeout on a request. +func NewGetEnvironmentMetricsParamsWithTimeout(timeout time.Duration) *GetEnvironmentMetricsParams { + return &GetEnvironmentMetricsParams{ + timeout: timeout, + } +} + +// NewGetEnvironmentMetricsParamsWithContext creates a new GetEnvironmentMetricsParams object +// with the ability to set a context for a request. +func NewGetEnvironmentMetricsParamsWithContext(ctx context.Context) *GetEnvironmentMetricsParams { + return &GetEnvironmentMetricsParams{ + Context: ctx, + } +} + +// NewGetEnvironmentMetricsParamsWithHTTPClient creates a new GetEnvironmentMetricsParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetEnvironmentMetricsParamsWithHTTPClient(client *http.Client) *GetEnvironmentMetricsParams { + return &GetEnvironmentMetricsParams{ + HTTPClient: client, + } +} + +/* +GetEnvironmentMetricsParams contains all the parameters to send to the API endpoint + + for the get environment metrics operation. + + Typically these are written to a http.Request. +*/ +type GetEnvironmentMetricsParams struct { + + // EnvID. + EnvID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the get environment metrics params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetEnvironmentMetricsParams) WithDefaults() *GetEnvironmentMetricsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get environment metrics params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetEnvironmentMetricsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get environment metrics params +func (o *GetEnvironmentMetricsParams) WithTimeout(timeout time.Duration) *GetEnvironmentMetricsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get environment metrics params +func (o *GetEnvironmentMetricsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get environment metrics params +func (o *GetEnvironmentMetricsParams) WithContext(ctx context.Context) *GetEnvironmentMetricsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get environment metrics params +func (o *GetEnvironmentMetricsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get environment metrics params +func (o *GetEnvironmentMetricsParams) WithHTTPClient(client *http.Client) *GetEnvironmentMetricsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get environment metrics params +func (o *GetEnvironmentMetricsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEnvID adds the envID to the get environment metrics params +func (o *GetEnvironmentMetricsParams) WithEnvID(envID string) *GetEnvironmentMetricsParams { + o.SetEnvID(envID) + return o +} + +// SetEnvID adds the envId to the get environment metrics params +func (o *GetEnvironmentMetricsParams) SetEnvID(envID string) { + o.EnvID = envID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetEnvironmentMetricsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param envId + if err := r.SetPathParam("envId", o.EnvID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client_zrok/metrics/get_environment_metrics_responses.go b/rest_client_zrok/metrics/get_environment_metrics_responses.go new file mode 100644 index 00000000..9f555e8b --- /dev/null +++ b/rest_client_zrok/metrics/get_environment_metrics_responses.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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/zrok/rest_model_zrok" +) + +// GetEnvironmentMetricsReader is a Reader for the GetEnvironmentMetrics structure. +type GetEnvironmentMetricsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetEnvironmentMetricsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetEnvironmentMetricsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetEnvironmentMetricsUnauthorized() + 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()) + } +} + +// NewGetEnvironmentMetricsOK creates a GetEnvironmentMetricsOK with default headers values +func NewGetEnvironmentMetricsOK() *GetEnvironmentMetricsOK { + return &GetEnvironmentMetricsOK{} +} + +/* +GetEnvironmentMetricsOK describes a response with status code 200, with default header values. + +environment metrics +*/ +type GetEnvironmentMetricsOK struct { + Payload *rest_model_zrok.Metrics +} + +// IsSuccess returns true when this get environment metrics o k response has a 2xx status code +func (o *GetEnvironmentMetricsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get environment metrics o k response has a 3xx status code +func (o *GetEnvironmentMetricsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get environment metrics o k response has a 4xx status code +func (o *GetEnvironmentMetricsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get environment metrics o k response has a 5xx status code +func (o *GetEnvironmentMetricsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get environment metrics o k response a status code equal to that given +func (o *GetEnvironmentMetricsOK) IsCode(code int) bool { + return code == 200 +} + +func (o *GetEnvironmentMetricsOK) Error() string { + return fmt.Sprintf("[GET /metrics/environment/{envId}][%d] getEnvironmentMetricsOK %+v", 200, o.Payload) +} + +func (o *GetEnvironmentMetricsOK) String() string { + return fmt.Sprintf("[GET /metrics/environment/{envId}][%d] getEnvironmentMetricsOK %+v", 200, o.Payload) +} + +func (o *GetEnvironmentMetricsOK) GetPayload() *rest_model_zrok.Metrics { + return o.Payload +} + +func (o *GetEnvironmentMetricsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(rest_model_zrok.Metrics) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetEnvironmentMetricsUnauthorized creates a GetEnvironmentMetricsUnauthorized with default headers values +func NewGetEnvironmentMetricsUnauthorized() *GetEnvironmentMetricsUnauthorized { + return &GetEnvironmentMetricsUnauthorized{} +} + +/* +GetEnvironmentMetricsUnauthorized describes a response with status code 401, with default header values. + +unauthorized +*/ +type GetEnvironmentMetricsUnauthorized struct { +} + +// IsSuccess returns true when this get environment metrics unauthorized response has a 2xx status code +func (o *GetEnvironmentMetricsUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get environment metrics unauthorized response has a 3xx status code +func (o *GetEnvironmentMetricsUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get environment metrics unauthorized response has a 4xx status code +func (o *GetEnvironmentMetricsUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get environment metrics unauthorized response has a 5xx status code +func (o *GetEnvironmentMetricsUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get environment metrics unauthorized response a status code equal to that given +func (o *GetEnvironmentMetricsUnauthorized) IsCode(code int) bool { + return code == 401 +} + +func (o *GetEnvironmentMetricsUnauthorized) Error() string { + return fmt.Sprintf("[GET /metrics/environment/{envId}][%d] getEnvironmentMetricsUnauthorized ", 401) +} + +func (o *GetEnvironmentMetricsUnauthorized) String() string { + return fmt.Sprintf("[GET /metrics/environment/{envId}][%d] getEnvironmentMetricsUnauthorized ", 401) +} + +func (o *GetEnvironmentMetricsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} diff --git a/rest_client_zrok/metrics/get_share_metrics_parameters.go b/rest_client_zrok/metrics/get_share_metrics_parameters.go new file mode 100644 index 00000000..690b280f --- /dev/null +++ b/rest_client_zrok/metrics/get_share_metrics_parameters.go @@ -0,0 +1,148 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" +) + +// NewGetShareMetricsParams creates a new GetShareMetricsParams 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 NewGetShareMetricsParams() *GetShareMetricsParams { + return &GetShareMetricsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetShareMetricsParamsWithTimeout creates a new GetShareMetricsParams object +// with the ability to set a timeout on a request. +func NewGetShareMetricsParamsWithTimeout(timeout time.Duration) *GetShareMetricsParams { + return &GetShareMetricsParams{ + timeout: timeout, + } +} + +// NewGetShareMetricsParamsWithContext creates a new GetShareMetricsParams object +// with the ability to set a context for a request. +func NewGetShareMetricsParamsWithContext(ctx context.Context) *GetShareMetricsParams { + return &GetShareMetricsParams{ + Context: ctx, + } +} + +// NewGetShareMetricsParamsWithHTTPClient creates a new GetShareMetricsParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetShareMetricsParamsWithHTTPClient(client *http.Client) *GetShareMetricsParams { + return &GetShareMetricsParams{ + HTTPClient: client, + } +} + +/* +GetShareMetricsParams contains all the parameters to send to the API endpoint + + for the get share metrics operation. + + Typically these are written to a http.Request. +*/ +type GetShareMetricsParams struct { + + // ShrToken. + ShrToken string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the get share metrics params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetShareMetricsParams) WithDefaults() *GetShareMetricsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get share metrics params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetShareMetricsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get share metrics params +func (o *GetShareMetricsParams) WithTimeout(timeout time.Duration) *GetShareMetricsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get share metrics params +func (o *GetShareMetricsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get share metrics params +func (o *GetShareMetricsParams) WithContext(ctx context.Context) *GetShareMetricsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get share metrics params +func (o *GetShareMetricsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get share metrics params +func (o *GetShareMetricsParams) WithHTTPClient(client *http.Client) *GetShareMetricsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get share metrics params +func (o *GetShareMetricsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithShrToken adds the shrToken to the get share metrics params +func (o *GetShareMetricsParams) WithShrToken(shrToken string) *GetShareMetricsParams { + o.SetShrToken(shrToken) + return o +} + +// SetShrToken adds the shrToken to the get share metrics params +func (o *GetShareMetricsParams) SetShrToken(shrToken string) { + o.ShrToken = shrToken +} + +// WriteToRequest writes these params to a swagger request +func (o *GetShareMetricsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param shrToken + if err := r.SetPathParam("shrToken", o.ShrToken); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_client_zrok/metrics/get_share_metrics_responses.go b/rest_client_zrok/metrics/get_share_metrics_responses.go new file mode 100644 index 00000000..9f99df33 --- /dev/null +++ b/rest_client_zrok/metrics/get_share_metrics_responses.go @@ -0,0 +1,155 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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/zrok/rest_model_zrok" +) + +// GetShareMetricsReader is a Reader for the GetShareMetrics structure. +type GetShareMetricsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetShareMetricsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetShareMetricsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 401: + result := NewGetShareMetricsUnauthorized() + 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()) + } +} + +// NewGetShareMetricsOK creates a GetShareMetricsOK with default headers values +func NewGetShareMetricsOK() *GetShareMetricsOK { + return &GetShareMetricsOK{} +} + +/* +GetShareMetricsOK describes a response with status code 200, with default header values. + +share metrics +*/ +type GetShareMetricsOK struct { + Payload *rest_model_zrok.Metrics +} + +// IsSuccess returns true when this get share metrics o k response has a 2xx status code +func (o *GetShareMetricsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get share metrics o k response has a 3xx status code +func (o *GetShareMetricsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get share metrics o k response has a 4xx status code +func (o *GetShareMetricsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get share metrics o k response has a 5xx status code +func (o *GetShareMetricsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get share metrics o k response a status code equal to that given +func (o *GetShareMetricsOK) IsCode(code int) bool { + return code == 200 +} + +func (o *GetShareMetricsOK) Error() string { + return fmt.Sprintf("[GET /metrics/share/{shrToken}][%d] getShareMetricsOK %+v", 200, o.Payload) +} + +func (o *GetShareMetricsOK) String() string { + return fmt.Sprintf("[GET /metrics/share/{shrToken}][%d] getShareMetricsOK %+v", 200, o.Payload) +} + +func (o *GetShareMetricsOK) GetPayload() *rest_model_zrok.Metrics { + return o.Payload +} + +func (o *GetShareMetricsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(rest_model_zrok.Metrics) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetShareMetricsUnauthorized creates a GetShareMetricsUnauthorized with default headers values +func NewGetShareMetricsUnauthorized() *GetShareMetricsUnauthorized { + return &GetShareMetricsUnauthorized{} +} + +/* +GetShareMetricsUnauthorized describes a response with status code 401, with default header values. + +unauthorized +*/ +type GetShareMetricsUnauthorized struct { +} + +// IsSuccess returns true when this get share metrics unauthorized response has a 2xx status code +func (o *GetShareMetricsUnauthorized) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get share metrics unauthorized response has a 3xx status code +func (o *GetShareMetricsUnauthorized) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get share metrics unauthorized response has a 4xx status code +func (o *GetShareMetricsUnauthorized) IsClientError() bool { + return true +} + +// IsServerError returns true when this get share metrics unauthorized response has a 5xx status code +func (o *GetShareMetricsUnauthorized) IsServerError() bool { + return false +} + +// IsCode returns true when this get share metrics unauthorized response a status code equal to that given +func (o *GetShareMetricsUnauthorized) IsCode(code int) bool { + return code == 401 +} + +func (o *GetShareMetricsUnauthorized) Error() string { + return fmt.Sprintf("[GET /metrics/share/{shrToken}][%d] getShareMetricsUnauthorized ", 401) +} + +func (o *GetShareMetricsUnauthorized) String() string { + return fmt.Sprintf("[GET /metrics/share/{shrToken}][%d] getShareMetricsUnauthorized ", 401) +} + +func (o *GetShareMetricsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} diff --git a/rest_client_zrok/metrics/metrics_client.go b/rest_client_zrok/metrics/metrics_client.go new file mode 100644 index 00000000..b1f4ab1f --- /dev/null +++ b/rest_client_zrok/metrics/metrics_client.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" +) + +// New creates a new metrics API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { + return &Client{transport: transport, formats: formats} +} + +/* +Client for metrics API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +// ClientOption is the option for Client methods +type ClientOption func(*runtime.ClientOperation) + +// ClientService is the interface for Client methods +type ClientService interface { + GetAccountMetrics(params *GetAccountMetricsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAccountMetricsOK, error) + + GetEnvironmentMetrics(params *GetEnvironmentMetricsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEnvironmentMetricsOK, error) + + GetShareMetrics(params *GetShareMetricsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetShareMetricsOK, error) + + SetTransport(transport runtime.ClientTransport) +} + +/* +GetAccountMetrics get account metrics API +*/ +func (a *Client) GetAccountMetrics(params *GetAccountMetricsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAccountMetricsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetAccountMetricsParams() + } + op := &runtime.ClientOperation{ + ID: "getAccountMetrics", + Method: "GET", + PathPattern: "/metrics/account", + ProducesMediaTypes: []string{"application/zrok.v1+json"}, + ConsumesMediaTypes: []string{"application/zrok.v1+json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetAccountMetricsReader{formats: a.formats}, + AuthInfo: authInfo, + 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.(*GetAccountMetricsOK) + 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 getAccountMetrics: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +GetEnvironmentMetrics get environment metrics API +*/ +func (a *Client) GetEnvironmentMetrics(params *GetEnvironmentMetricsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEnvironmentMetricsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetEnvironmentMetricsParams() + } + op := &runtime.ClientOperation{ + ID: "getEnvironmentMetrics", + Method: "GET", + PathPattern: "/metrics/environment/{envId}", + ProducesMediaTypes: []string{"application/zrok.v1+json"}, + ConsumesMediaTypes: []string{"application/zrok.v1+json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetEnvironmentMetricsReader{formats: a.formats}, + AuthInfo: authInfo, + 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.(*GetEnvironmentMetricsOK) + 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 getEnvironmentMetrics: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + +/* +GetShareMetrics get share metrics API +*/ +func (a *Client) GetShareMetrics(params *GetShareMetricsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetShareMetricsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetShareMetricsParams() + } + op := &runtime.ClientOperation{ + ID: "getShareMetrics", + Method: "GET", + PathPattern: "/metrics/share/{shrToken}", + ProducesMediaTypes: []string{"application/zrok.v1+json"}, + ConsumesMediaTypes: []string{"application/zrok.v1+json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetShareMetricsReader{formats: a.formats}, + AuthInfo: authInfo, + 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.(*GetShareMetricsOK) + 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 getShareMetrics: 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 +} diff --git a/rest_client_zrok/zrok_client.go b/rest_client_zrok/zrok_client.go index a4200e67..c5f02b8c 100644 --- a/rest_client_zrok/zrok_client.go +++ b/rest_client_zrok/zrok_client.go @@ -14,6 +14,7 @@ import ( "github.com/openziti/zrok/rest_client_zrok/admin" "github.com/openziti/zrok/rest_client_zrok/environment" "github.com/openziti/zrok/rest_client_zrok/metadata" + "github.com/openziti/zrok/rest_client_zrok/metrics" "github.com/openziti/zrok/rest_client_zrok/share" ) @@ -63,6 +64,7 @@ func New(transport runtime.ClientTransport, formats strfmt.Registry) *Zrok { cli.Admin = admin.New(transport, formats) cli.Environment = environment.New(transport, formats) cli.Metadata = metadata.New(transport, formats) + cli.Metrics = metrics.New(transport, formats) cli.Share = share.New(transport, formats) return cli } @@ -116,6 +118,8 @@ type Zrok struct { Metadata metadata.ClientService + Metrics metrics.ClientService + Share share.ClientService Transport runtime.ClientTransport @@ -128,5 +132,6 @@ func (c *Zrok) SetTransport(transport runtime.ClientTransport) { c.Admin.SetTransport(transport) c.Environment.SetTransport(transport) c.Metadata.SetTransport(transport) + c.Metrics.SetTransport(transport) c.Share.SetTransport(transport) } diff --git a/rest_model_zrok/metrics.go b/rest_model_zrok/metrics.go new file mode 100644 index 00000000..dfb9bf08 --- /dev/null +++ b/rest_model_zrok/metrics.go @@ -0,0 +1,62 @@ +// 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" +) + +// Metrics metrics +// +// swagger:model metrics +type Metrics struct { + + // id + ID string `json:"id,omitempty"` + + // period + Period float64 `json:"period,omitempty"` + + // rx + Rx []float64 `json:"rx"` + + // scope + Scope string `json:"scope,omitempty"` + + // tx + Tx []float64 `json:"tx"` +} + +// Validate validates this metrics +func (m *Metrics) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this metrics based on context it is used +func (m *Metrics) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Metrics) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Metrics) UnmarshalBinary(b []byte) error { + var res Metrics + 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 5560d26d..59341826 100644 --- a/rest_server_zrok/embedded_spec.go +++ b/rest_server_zrok/embedded_spec.go @@ -520,6 +520,91 @@ func init() { } } }, + "/metrics/account": { + "get": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "metrics" + ], + "operationId": "getAccountMetrics", + "responses": { + "200": { + "description": "account metrics", + "schema": { + "$ref": "#/definitions/metrics" + } + } + } + } + }, + "/metrics/environment/{envId}": { + "get": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "metrics" + ], + "operationId": "getEnvironmentMetrics", + "parameters": [ + { + "type": "string", + "name": "envId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "environment metrics", + "schema": { + "$ref": "#/definitions/metrics" + } + }, + "401": { + "description": "unauthorized" + } + } + } + }, + "/metrics/share/{shrToken}": { + "get": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "metrics" + ], + "operationId": "getShareMetrics", + "parameters": [ + { + "type": "string", + "name": "shrToken", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "share metrics", + "schema": { + "$ref": "#/definitions/metrics" + } + }, + "401": { + "description": "unauthorized" + } + } + } + }, "/overview": { "get": { "security": [ @@ -1030,6 +1115,32 @@ func init() { "loginResponse": { "type": "string" }, + "metrics": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "period": { + "type": "number" + }, + "rx": { + "type": "array", + "items": { + "type": "number" + } + }, + "scope": { + "type": "string" + }, + "tx": { + "type": "array", + "items": { + "type": "number" + } + } + } + }, "principal": { "type": "object", "properties": { @@ -1802,6 +1913,91 @@ func init() { } } }, + "/metrics/account": { + "get": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "metrics" + ], + "operationId": "getAccountMetrics", + "responses": { + "200": { + "description": "account metrics", + "schema": { + "$ref": "#/definitions/metrics" + } + } + } + } + }, + "/metrics/environment/{envId}": { + "get": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "metrics" + ], + "operationId": "getEnvironmentMetrics", + "parameters": [ + { + "type": "string", + "name": "envId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "environment metrics", + "schema": { + "$ref": "#/definitions/metrics" + } + }, + "401": { + "description": "unauthorized" + } + } + } + }, + "/metrics/share/{shrToken}": { + "get": { + "security": [ + { + "key": [] + } + ], + "tags": [ + "metrics" + ], + "operationId": "getShareMetrics", + "parameters": [ + { + "type": "string", + "name": "shrToken", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "share metrics", + "schema": { + "$ref": "#/definitions/metrics" + } + }, + "401": { + "description": "unauthorized" + } + } + } + }, "/overview": { "get": { "security": [ @@ -2312,6 +2508,32 @@ func init() { "loginResponse": { "type": "string" }, + "metrics": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "period": { + "type": "number" + }, + "rx": { + "type": "array", + "items": { + "type": "number" + } + }, + "scope": { + "type": "string" + }, + "tx": { + "type": "array", + "items": { + "type": "number" + } + } + } + }, "principal": { "type": "object", "properties": { diff --git a/rest_server_zrok/operations/metrics/get_account_metrics.go b/rest_server_zrok/operations/metrics/get_account_metrics.go new file mode 100644 index 00000000..d3fcab7f --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_account_metrics.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" + + "github.com/openziti/zrok/rest_model_zrok" +) + +// GetAccountMetricsHandlerFunc turns a function with the right signature into a get account metrics handler +type GetAccountMetricsHandlerFunc func(GetAccountMetricsParams, *rest_model_zrok.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetAccountMetricsHandlerFunc) Handle(params GetAccountMetricsParams, principal *rest_model_zrok.Principal) middleware.Responder { + return fn(params, principal) +} + +// GetAccountMetricsHandler interface for that can handle valid get account metrics params +type GetAccountMetricsHandler interface { + Handle(GetAccountMetricsParams, *rest_model_zrok.Principal) middleware.Responder +} + +// NewGetAccountMetrics creates a new http.Handler for the get account metrics operation +func NewGetAccountMetrics(ctx *middleware.Context, handler GetAccountMetricsHandler) *GetAccountMetrics { + return &GetAccountMetrics{Context: ctx, Handler: handler} +} + +/* + GetAccountMetrics swagger:route GET /metrics/account metrics getAccountMetrics + +GetAccountMetrics get account metrics API +*/ +type GetAccountMetrics struct { + Context *middleware.Context + Handler GetAccountMetricsHandler +} + +func (o *GetAccountMetrics) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetAccountMetricsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal *rest_model_zrok.Principal + if uprinc != nil { + principal = uprinc.(*rest_model_zrok.Principal) // this is really a rest_model_zrok.Principal, I promise + } + + 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, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server_zrok/operations/metrics/get_account_metrics_parameters.go b/rest_server_zrok/operations/metrics/get_account_metrics_parameters.go new file mode 100644 index 00000000..98bb9b8c --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_account_metrics_parameters.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" +) + +// NewGetAccountMetricsParams creates a new GetAccountMetricsParams object +// +// There are no default values defined in the spec. +func NewGetAccountMetricsParams() GetAccountMetricsParams { + + return GetAccountMetricsParams{} +} + +// GetAccountMetricsParams contains all the bound params for the get account metrics operation +// typically these are obtained from a http.Request +// +// swagger:parameters getAccountMetrics +type GetAccountMetricsParams 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 NewGetAccountMetricsParams() beforehand. +func (o *GetAccountMetricsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/rest_server_zrok/operations/metrics/get_account_metrics_responses.go b/rest_server_zrok/operations/metrics/get_account_metrics_responses.go new file mode 100644 index 00000000..78480b51 --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_account_metrics_responses.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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/zrok/rest_model_zrok" +) + +// GetAccountMetricsOKCode is the HTTP code returned for type GetAccountMetricsOK +const GetAccountMetricsOKCode int = 200 + +/* +GetAccountMetricsOK account metrics + +swagger:response getAccountMetricsOK +*/ +type GetAccountMetricsOK struct { + + /* + In: Body + */ + Payload *rest_model_zrok.Metrics `json:"body,omitempty"` +} + +// NewGetAccountMetricsOK creates GetAccountMetricsOK with default headers values +func NewGetAccountMetricsOK() *GetAccountMetricsOK { + + return &GetAccountMetricsOK{} +} + +// WithPayload adds the payload to the get account metrics o k response +func (o *GetAccountMetricsOK) WithPayload(payload *rest_model_zrok.Metrics) *GetAccountMetricsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get account metrics o k response +func (o *GetAccountMetricsOK) SetPayload(payload *rest_model_zrok.Metrics) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetAccountMetricsOK) 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 + } + } +} diff --git a/rest_server_zrok/operations/metrics/get_account_metrics_urlbuilder.go b/rest_server_zrok/operations/metrics/get_account_metrics_urlbuilder.go new file mode 100644 index 00000000..16b79838 --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_account_metrics_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" +) + +// GetAccountMetricsURL generates an URL for the get account metrics operation +type GetAccountMetricsURL 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 *GetAccountMetricsURL) WithBasePath(bp string) *GetAccountMetricsURL { + 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 *GetAccountMetricsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetAccountMetricsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/metrics/account" + + _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 *GetAccountMetricsURL) 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 *GetAccountMetricsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetAccountMetricsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetAccountMetricsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetAccountMetricsURL") + } + + 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 *GetAccountMetricsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server_zrok/operations/metrics/get_environment_metrics.go b/rest_server_zrok/operations/metrics/get_environment_metrics.go new file mode 100644 index 00000000..b26b7535 --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_environment_metrics.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" + + "github.com/openziti/zrok/rest_model_zrok" +) + +// GetEnvironmentMetricsHandlerFunc turns a function with the right signature into a get environment metrics handler +type GetEnvironmentMetricsHandlerFunc func(GetEnvironmentMetricsParams, *rest_model_zrok.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetEnvironmentMetricsHandlerFunc) Handle(params GetEnvironmentMetricsParams, principal *rest_model_zrok.Principal) middleware.Responder { + return fn(params, principal) +} + +// GetEnvironmentMetricsHandler interface for that can handle valid get environment metrics params +type GetEnvironmentMetricsHandler interface { + Handle(GetEnvironmentMetricsParams, *rest_model_zrok.Principal) middleware.Responder +} + +// NewGetEnvironmentMetrics creates a new http.Handler for the get environment metrics operation +func NewGetEnvironmentMetrics(ctx *middleware.Context, handler GetEnvironmentMetricsHandler) *GetEnvironmentMetrics { + return &GetEnvironmentMetrics{Context: ctx, Handler: handler} +} + +/* + GetEnvironmentMetrics swagger:route GET /metrics/environment/{envId} metrics getEnvironmentMetrics + +GetEnvironmentMetrics get environment metrics API +*/ +type GetEnvironmentMetrics struct { + Context *middleware.Context + Handler GetEnvironmentMetricsHandler +} + +func (o *GetEnvironmentMetrics) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetEnvironmentMetricsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal *rest_model_zrok.Principal + if uprinc != nil { + principal = uprinc.(*rest_model_zrok.Principal) // this is really a rest_model_zrok.Principal, I promise + } + + 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, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server_zrok/operations/metrics/get_environment_metrics_parameters.go b/rest_server_zrok/operations/metrics/get_environment_metrics_parameters.go new file mode 100644 index 00000000..1f10409f --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_environment_metrics_parameters.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" + "github.com/go-openapi/strfmt" +) + +// NewGetEnvironmentMetricsParams creates a new GetEnvironmentMetricsParams object +// +// There are no default values defined in the spec. +func NewGetEnvironmentMetricsParams() GetEnvironmentMetricsParams { + + return GetEnvironmentMetricsParams{} +} + +// GetEnvironmentMetricsParams contains all the bound params for the get environment metrics operation +// typically these are obtained from a http.Request +// +// swagger:parameters getEnvironmentMetrics +type GetEnvironmentMetricsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + EnvID string +} + +// 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 NewGetEnvironmentMetricsParams() beforehand. +func (o *GetEnvironmentMetricsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rEnvID, rhkEnvID, _ := route.Params.GetOK("envId") + if err := o.bindEnvID(rEnvID, rhkEnvID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindEnvID binds and validates parameter EnvID from path. +func (o *GetEnvironmentMetricsParams) bindEnvID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.EnvID = raw + + return nil +} diff --git a/rest_server_zrok/operations/metrics/get_environment_metrics_responses.go b/rest_server_zrok/operations/metrics/get_environment_metrics_responses.go new file mode 100644 index 00000000..d5e9897c --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_environment_metrics_responses.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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/zrok/rest_model_zrok" +) + +// GetEnvironmentMetricsOKCode is the HTTP code returned for type GetEnvironmentMetricsOK +const GetEnvironmentMetricsOKCode int = 200 + +/* +GetEnvironmentMetricsOK environment metrics + +swagger:response getEnvironmentMetricsOK +*/ +type GetEnvironmentMetricsOK struct { + + /* + In: Body + */ + Payload *rest_model_zrok.Metrics `json:"body,omitempty"` +} + +// NewGetEnvironmentMetricsOK creates GetEnvironmentMetricsOK with default headers values +func NewGetEnvironmentMetricsOK() *GetEnvironmentMetricsOK { + + return &GetEnvironmentMetricsOK{} +} + +// WithPayload adds the payload to the get environment metrics o k response +func (o *GetEnvironmentMetricsOK) WithPayload(payload *rest_model_zrok.Metrics) *GetEnvironmentMetricsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get environment metrics o k response +func (o *GetEnvironmentMetricsOK) SetPayload(payload *rest_model_zrok.Metrics) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetEnvironmentMetricsOK) 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 + } + } +} + +// GetEnvironmentMetricsUnauthorizedCode is the HTTP code returned for type GetEnvironmentMetricsUnauthorized +const GetEnvironmentMetricsUnauthorizedCode int = 401 + +/* +GetEnvironmentMetricsUnauthorized unauthorized + +swagger:response getEnvironmentMetricsUnauthorized +*/ +type GetEnvironmentMetricsUnauthorized struct { +} + +// NewGetEnvironmentMetricsUnauthorized creates GetEnvironmentMetricsUnauthorized with default headers values +func NewGetEnvironmentMetricsUnauthorized() *GetEnvironmentMetricsUnauthorized { + + return &GetEnvironmentMetricsUnauthorized{} +} + +// WriteResponse to the client +func (o *GetEnvironmentMetricsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(401) +} diff --git a/rest_server_zrok/operations/metrics/get_environment_metrics_urlbuilder.go b/rest_server_zrok/operations/metrics/get_environment_metrics_urlbuilder.go new file mode 100644 index 00000000..a31dfd88 --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_environment_metrics_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" + "strings" +) + +// GetEnvironmentMetricsURL generates an URL for the get environment metrics operation +type GetEnvironmentMetricsURL struct { + EnvID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// 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 *GetEnvironmentMetricsURL) WithBasePath(bp string) *GetEnvironmentMetricsURL { + 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 *GetEnvironmentMetricsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetEnvironmentMetricsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/metrics/environment/{envId}" + + envID := o.EnvID + if envID != "" { + _path = strings.Replace(_path, "{envId}", envID, -1) + } else { + return nil, errors.New("envId is required on GetEnvironmentMetricsURL") + } + + _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 *GetEnvironmentMetricsURL) 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 *GetEnvironmentMetricsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetEnvironmentMetricsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetEnvironmentMetricsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetEnvironmentMetricsURL") + } + + 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 *GetEnvironmentMetricsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/rest_server_zrok/operations/metrics/get_share_metrics.go b/rest_server_zrok/operations/metrics/get_share_metrics.go new file mode 100644 index 00000000..67470dfa --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_share_metrics.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" + + "github.com/openziti/zrok/rest_model_zrok" +) + +// GetShareMetricsHandlerFunc turns a function with the right signature into a get share metrics handler +type GetShareMetricsHandlerFunc func(GetShareMetricsParams, *rest_model_zrok.Principal) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetShareMetricsHandlerFunc) Handle(params GetShareMetricsParams, principal *rest_model_zrok.Principal) middleware.Responder { + return fn(params, principal) +} + +// GetShareMetricsHandler interface for that can handle valid get share metrics params +type GetShareMetricsHandler interface { + Handle(GetShareMetricsParams, *rest_model_zrok.Principal) middleware.Responder +} + +// NewGetShareMetrics creates a new http.Handler for the get share metrics operation +func NewGetShareMetrics(ctx *middleware.Context, handler GetShareMetricsHandler) *GetShareMetrics { + return &GetShareMetrics{Context: ctx, Handler: handler} +} + +/* + GetShareMetrics swagger:route GET /metrics/share/{shrToken} metrics getShareMetrics + +GetShareMetrics get share metrics API +*/ +type GetShareMetrics struct { + Context *middleware.Context + Handler GetShareMetricsHandler +} + +func (o *GetShareMetrics) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetShareMetricsParams() + uprinc, aCtx, err := o.Context.Authorize(r, route) + if err != nil { + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + if aCtx != nil { + *r = *aCtx + } + var principal *rest_model_zrok.Principal + if uprinc != nil { + principal = uprinc.(*rest_model_zrok.Principal) // this is really a rest_model_zrok.Principal, I promise + } + + 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, principal) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/rest_server_zrok/operations/metrics/get_share_metrics_parameters.go b/rest_server_zrok/operations/metrics/get_share_metrics_parameters.go new file mode 100644 index 00000000..1013bb7a --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_share_metrics_parameters.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" + "github.com/go-openapi/strfmt" +) + +// NewGetShareMetricsParams creates a new GetShareMetricsParams object +// +// There are no default values defined in the spec. +func NewGetShareMetricsParams() GetShareMetricsParams { + + return GetShareMetricsParams{} +} + +// GetShareMetricsParams contains all the bound params for the get share metrics operation +// typically these are obtained from a http.Request +// +// swagger:parameters getShareMetrics +type GetShareMetricsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + ShrToken string +} + +// 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 NewGetShareMetricsParams() beforehand. +func (o *GetShareMetricsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rShrToken, rhkShrToken, _ := route.Params.GetOK("shrToken") + if err := o.bindShrToken(rShrToken, rhkShrToken, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindShrToken binds and validates parameter ShrToken from path. +func (o *GetShareMetricsParams) bindShrToken(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + o.ShrToken = raw + + return nil +} diff --git a/rest_server_zrok/operations/metrics/get_share_metrics_responses.go b/rest_server_zrok/operations/metrics/get_share_metrics_responses.go new file mode 100644 index 00000000..70e0c0e1 --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_share_metrics_responses.go @@ -0,0 +1,84 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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/zrok/rest_model_zrok" +) + +// GetShareMetricsOKCode is the HTTP code returned for type GetShareMetricsOK +const GetShareMetricsOKCode int = 200 + +/* +GetShareMetricsOK share metrics + +swagger:response getShareMetricsOK +*/ +type GetShareMetricsOK struct { + + /* + In: Body + */ + Payload *rest_model_zrok.Metrics `json:"body,omitempty"` +} + +// NewGetShareMetricsOK creates GetShareMetricsOK with default headers values +func NewGetShareMetricsOK() *GetShareMetricsOK { + + return &GetShareMetricsOK{} +} + +// WithPayload adds the payload to the get share metrics o k response +func (o *GetShareMetricsOK) WithPayload(payload *rest_model_zrok.Metrics) *GetShareMetricsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get share metrics o k response +func (o *GetShareMetricsOK) SetPayload(payload *rest_model_zrok.Metrics) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetShareMetricsOK) 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 + } + } +} + +// GetShareMetricsUnauthorizedCode is the HTTP code returned for type GetShareMetricsUnauthorized +const GetShareMetricsUnauthorizedCode int = 401 + +/* +GetShareMetricsUnauthorized unauthorized + +swagger:response getShareMetricsUnauthorized +*/ +type GetShareMetricsUnauthorized struct { +} + +// NewGetShareMetricsUnauthorized creates GetShareMetricsUnauthorized with default headers values +func NewGetShareMetricsUnauthorized() *GetShareMetricsUnauthorized { + + return &GetShareMetricsUnauthorized{} +} + +// WriteResponse to the client +func (o *GetShareMetricsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(401) +} diff --git a/rest_server_zrok/operations/metrics/get_share_metrics_urlbuilder.go b/rest_server_zrok/operations/metrics/get_share_metrics_urlbuilder.go new file mode 100644 index 00000000..deeb05e3 --- /dev/null +++ b/rest_server_zrok/operations/metrics/get_share_metrics_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metrics + +// 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" + "strings" +) + +// GetShareMetricsURL generates an URL for the get share metrics operation +type GetShareMetricsURL struct { + ShrToken string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// 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 *GetShareMetricsURL) WithBasePath(bp string) *GetShareMetricsURL { + 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 *GetShareMetricsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetShareMetricsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/metrics/share/{shrToken}" + + shrToken := o.ShrToken + if shrToken != "" { + _path = strings.Replace(_path, "{shrToken}", shrToken, -1) + } else { + return nil, errors.New("shrToken is required on GetShareMetricsURL") + } + + _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 *GetShareMetricsURL) 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 *GetShareMetricsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetShareMetricsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetShareMetricsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetShareMetricsURL") + } + + 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 *GetShareMetricsURL) 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 3424c976..19a12af8 100644 --- a/rest_server_zrok/operations/zrok_api.go +++ b/rest_server_zrok/operations/zrok_api.go @@ -24,6 +24,7 @@ import ( "github.com/openziti/zrok/rest_server_zrok/operations/admin" "github.com/openziti/zrok/rest_server_zrok/operations/environment" "github.com/openziti/zrok/rest_server_zrok/operations/metadata" + "github.com/openziti/zrok/rest_server_zrok/operations/metrics" "github.com/openziti/zrok/rest_server_zrok/operations/share" ) @@ -70,12 +71,21 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI { EnvironmentEnableHandler: environment.EnableHandlerFunc(func(params environment.EnableParams, principal *rest_model_zrok.Principal) middleware.Responder { return middleware.NotImplemented("operation environment.Enable has not yet been implemented") }), + MetricsGetAccountMetricsHandler: metrics.GetAccountMetricsHandlerFunc(func(params metrics.GetAccountMetricsParams, principal *rest_model_zrok.Principal) middleware.Responder { + return middleware.NotImplemented("operation metrics.GetAccountMetrics has not yet been implemented") + }), MetadataGetEnvironmentDetailHandler: metadata.GetEnvironmentDetailHandlerFunc(func(params metadata.GetEnvironmentDetailParams, principal *rest_model_zrok.Principal) middleware.Responder { return middleware.NotImplemented("operation metadata.GetEnvironmentDetail has not yet been implemented") }), + MetricsGetEnvironmentMetricsHandler: metrics.GetEnvironmentMetricsHandlerFunc(func(params metrics.GetEnvironmentMetricsParams, principal *rest_model_zrok.Principal) middleware.Responder { + return middleware.NotImplemented("operation metrics.GetEnvironmentMetrics has not yet been implemented") + }), MetadataGetShareDetailHandler: metadata.GetShareDetailHandlerFunc(func(params metadata.GetShareDetailParams, principal *rest_model_zrok.Principal) middleware.Responder { return middleware.NotImplemented("operation metadata.GetShareDetail has not yet been implemented") }), + MetricsGetShareMetricsHandler: metrics.GetShareMetricsHandlerFunc(func(params metrics.GetShareMetricsParams, principal *rest_model_zrok.Principal) middleware.Responder { + return middleware.NotImplemented("operation metrics.GetShareMetrics has not yet been implemented") + }), AccountInviteHandler: account.InviteHandlerFunc(func(params account.InviteParams) middleware.Responder { return middleware.NotImplemented("operation account.Invite has not yet been implemented") }), @@ -185,10 +195,16 @@ type ZrokAPI struct { EnvironmentDisableHandler environment.DisableHandler // EnvironmentEnableHandler sets the operation handler for the enable operation EnvironmentEnableHandler environment.EnableHandler + // MetricsGetAccountMetricsHandler sets the operation handler for the get account metrics operation + MetricsGetAccountMetricsHandler metrics.GetAccountMetricsHandler // MetadataGetEnvironmentDetailHandler sets the operation handler for the get environment detail operation MetadataGetEnvironmentDetailHandler metadata.GetEnvironmentDetailHandler + // MetricsGetEnvironmentMetricsHandler sets the operation handler for the get environment metrics operation + MetricsGetEnvironmentMetricsHandler metrics.GetEnvironmentMetricsHandler // MetadataGetShareDetailHandler sets the operation handler for the get share detail operation MetadataGetShareDetailHandler metadata.GetShareDetailHandler + // MetricsGetShareMetricsHandler sets the operation handler for the get share metrics operation + MetricsGetShareMetricsHandler metrics.GetShareMetricsHandler // AccountInviteHandler sets the operation handler for the invite operation AccountInviteHandler account.InviteHandler // AdminInviteTokenGenerateHandler sets the operation handler for the invite token generate operation @@ -321,12 +337,21 @@ func (o *ZrokAPI) Validate() error { if o.EnvironmentEnableHandler == nil { unregistered = append(unregistered, "environment.EnableHandler") } + if o.MetricsGetAccountMetricsHandler == nil { + unregistered = append(unregistered, "metrics.GetAccountMetricsHandler") + } if o.MetadataGetEnvironmentDetailHandler == nil { unregistered = append(unregistered, "metadata.GetEnvironmentDetailHandler") } + if o.MetricsGetEnvironmentMetricsHandler == nil { + unregistered = append(unregistered, "metrics.GetEnvironmentMetricsHandler") + } if o.MetadataGetShareDetailHandler == nil { unregistered = append(unregistered, "metadata.GetShareDetailHandler") } + if o.MetricsGetShareMetricsHandler == nil { + unregistered = append(unregistered, "metrics.GetShareMetricsHandler") + } if o.AccountInviteHandler == nil { unregistered = append(unregistered, "account.InviteHandler") } @@ -502,11 +527,23 @@ func (o *ZrokAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } + o.handlers["GET"]["/metrics/account"] = metrics.NewGetAccountMetrics(o.context, o.MetricsGetAccountMetricsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } o.handlers["GET"]["/detail/environment/{envZId}"] = metadata.NewGetEnvironmentDetail(o.context, o.MetadataGetEnvironmentDetailHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } + o.handlers["GET"]["/metrics/environment/{envId}"] = metrics.NewGetEnvironmentMetrics(o.context, o.MetricsGetEnvironmentMetricsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } o.handlers["GET"]["/detail/share/{shrToken}"] = metadata.NewGetShareDetail(o.context, o.MetadataGetShareDetailHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/metrics/share/{shrToken}"] = metrics.NewGetShareMetrics(o.context, o.MetricsGetShareMetricsHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } diff --git a/specs/zrok.yml b/specs/zrok.yml index 9064aa36..ffe081b8 100644 --- a/specs/zrok.yml +++ b/specs/zrok.yml @@ -404,6 +404,62 @@ paths: description: current server version schema: $ref: "#/definitions/version" + + # + # metrics + # + /metrics/account: + get: + tags: + - metrics + security: + - key: [] + operationId: getAccountMetrics + responses: + 200: + description: account metrics + schema: + $ref: "#/definitions/metrics" + + /metrics/environment/{envId}: + get: + tags: + - metrics + security: + - key: [] + operationId: getEnvironmentMetrics + parameters: + - name: envId + in: path + type: string + required: true + responses: + 200: + description: environment metrics + schema: + $ref: "#/definitions/metrics" + 401: + description: unauthorized + + /metrics/share/{shrToken}: + get: + tags: + - metrics + security: + - key: [] + operationId: getShareMetrics + parameters: + - name: shrToken + in: path + type: string + required: true + responses: + 200: + description: share metrics + schema: + $ref: "#/definitions/metrics" + 401: + description: unauthorized # # share # @@ -666,6 +722,24 @@ definitions: loginResponse: type: string + metrics: + type: object + properties: + scope: + type: string + id: + type: string + period: + type: number + rx: + type: array + items: + type: number + tx: + type: array + items: + type: number + principal: type: object properties: diff --git a/ui/src/api/metrics.js b/ui/src/api/metrics.js new file mode 100644 index 00000000..5c1111dd --- /dev/null +++ b/ui/src/api/metrics.js @@ -0,0 +1,65 @@ +/** @module metrics */ +// Auto-generated, edits will be overwritten +import * as gateway from './gateway' + +/** + */ +export function getAccountMetrics() { + return gateway.request(getAccountMetricsOperation) +} + +/** + * @param {string} envId + * @return {Promise} environment metrics + */ +export function getEnvironmentMetrics(envId) { + const parameters = { + path: { + envId + } + } + return gateway.request(getEnvironmentMetricsOperation, parameters) +} + +/** + * @param {string} shrToken + * @return {Promise} share metrics + */ +export function getShareMetrics(shrToken) { + const parameters = { + path: { + shrToken + } + } + return gateway.request(getShareMetricsOperation, parameters) +} + +const getAccountMetricsOperation = { + path: '/metrics/account', + method: 'get', + security: [ + { + id: 'key' + } + ] +} + +const getEnvironmentMetricsOperation = { + path: '/metrics/environment/{envId}', + method: 'get', + security: [ + { + id: 'key' + } + ] +} + +const getShareMetricsOperation = { + path: '/metrics/share/{shrToken}', + method: 'get', + security: [ + { + id: 'key' + } + ] +} diff --git a/ui/src/api/types.js b/ui/src/api/types.js index 6196d926..6f5a6317 100644 --- a/ui/src/api/types.js +++ b/ui/src/api/types.js @@ -123,6 +123,17 @@ * @property {string} password */ +/** + * @typedef metrics + * @memberof module:types + * + * @property {string} scope + * @property {string} id + * @property {number} period + * @property {number[]} rx + * @property {number[]} tx + */ + /** * @typedef principal * @memberof module:types