account metrics endpoint (#319)

This commit is contained in:
Michael Quigley 2023-05-09 14:16:01 -04:00
parent 21fdaf8e3c
commit 6b078abcd7
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
27 changed files with 2498 additions and 145 deletions

View File

@ -47,6 +47,9 @@ func Run(inCfg *config.Config) error {
api.EnvironmentEnableHandler = newEnableHandler()
api.EnvironmentDisableHandler = newDisableHandler()
api.MetadataConfigurationHandler = newConfigurationHandler(cfg)
if cfg.Metrics != nil && cfg.Metrics.Influx != nil {
api.MetadataGetAccountMetricsHandler = newGetAccountMetricsHandler(cfg.Metrics.Influx)
}
api.MetadataGetEnvironmentDetailHandler = newEnvironmentDetailHandler()
api.MetadataGetShareDetailHandler = newShareDetailHandler()
api.MetadataOverviewHandler = metadata.OverviewHandlerFunc(overviewHandler)

84
controller/metrics.go Normal file
View File

@ -0,0 +1,84 @@
package controller
import (
"context"
"fmt"
"github.com/go-openapi/runtime/middleware"
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
"github.com/influxdata/influxdb-client-go/v2/api"
"github.com/openziti/zrok/controller/metrics"
"github.com/openziti/zrok/rest_model_zrok"
"github.com/openziti/zrok/rest_server_zrok/operations/metadata"
"github.com/sirupsen/logrus"
"time"
)
type getAccountMetricsHandler struct {
cfg *metrics.InfluxConfig
idb influxdb2.Client
queryApi api.QueryAPI
}
func newGetAccountMetricsHandler(cfg *metrics.InfluxConfig) *getAccountMetricsHandler {
idb := influxdb2.NewClient(cfg.Url, cfg.Token)
queryApi := idb.QueryAPI(cfg.Org)
return &getAccountMetricsHandler{
cfg: cfg,
idb: idb,
queryApi: queryApi,
}
}
func (h *getAccountMetricsHandler) Handle(params metadata.GetAccountMetricsParams, principal *rest_model_zrok.Principal) middleware.Responder {
duration := 30 * 24 * time.Hour
if params.Duration != nil {
v, err := time.ParseDuration(*params.Duration)
if err != nil {
logrus.Errorf("bad duration '%v' for '%v': %v", params.Duration, principal.Email, err)
return metadata.NewGetAccountMetricsBadRequest()
}
duration = v
}
slice := duration / 200
query := fmt.Sprintf("from(bucket: \"%v\")\n", h.cfg.Bucket) +
fmt.Sprintf("|> range(start -%v)\n", duration) +
"|> filter(fn: (r) => r[\"_measurement\"] == \"xfer\")\n" +
"|> filter(fn: (r) => r[\"_field\"] == \"rx\" or r[\"_field\"] == \"tx\")\n" +
"|> filter(fn: (r) => r[\"namespace\"] == \"backend\")\n" +
fmt.Sprintf("|> filter(fn: (r) => r[\"acctId\"] == \"%d\")\n", principal.ID) +
"|> drop(columns: [\"share\", \"envId\"])\n" +
fmt.Sprintf("|> aggregateWindow(every: %v, fn: sum, createEmpty: true)", slice)
rx, tx, err := runFluxForRxTxArray(query, h.queryApi)
if err != nil {
logrus.Errorf("error running account metrics query for '%v': %v", principal.Email, err)
return metadata.NewGetAccountMetricsInternalServerError()
}
response := &rest_model_zrok.Metrics{
ID: fmt.Sprintf("%d", principal.ID),
Period: duration.Seconds(),
Rx: rx,
Tx: tx,
}
return metadata.NewGetAccountMetricsOK().WithPayload(response)
}
func runFluxForRxTxArray(query string, queryApi api.QueryAPI) (rx, tx []float64, err error) {
result, err := queryApi.Query(context.Background(), query)
if err != nil {
return nil, nil, err
}
for result.Next() {
if v, ok := result.Record().Value().(int64); ok {
switch result.Record().Field() {
case "rx":
rx = append(rx, float64(v))
case "tx":
tx = append(tx, float64(v))
}
}
}
return rx, tx, nil
}

View File

@ -0,0 +1,160 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// 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 {
// Duration.
Duration *string
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
}
// WithDuration adds the duration to the get account metrics params
func (o *GetAccountMetricsParams) WithDuration(duration *string) *GetAccountMetricsParams {
o.SetDuration(duration)
return o
}
// SetDuration adds the duration to the get account metrics params
func (o *GetAccountMetricsParams) SetDuration(duration *string) {
o.Duration = duration
}
// 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 o.Duration != nil {
// query param duration
var qrDuration string
if o.Duration != nil {
qrDuration = *o.Duration
}
qDuration := qrDuration
if qDuration != "" {
if err := r.SetQueryParam("duration", qDuration); err != nil {
return err
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,212 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"github.com/openziti/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
case 400:
result := NewGetAccountMetricsBadRequest()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return nil, result
case 500:
result := NewGetAccountMetricsInternalServerError()
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())
}
}
// 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
}
// NewGetAccountMetricsBadRequest creates a GetAccountMetricsBadRequest with default headers values
func NewGetAccountMetricsBadRequest() *GetAccountMetricsBadRequest {
return &GetAccountMetricsBadRequest{}
}
/*
GetAccountMetricsBadRequest describes a response with status code 400, with default header values.
bad request
*/
type GetAccountMetricsBadRequest struct {
}
// IsSuccess returns true when this get account metrics bad request response has a 2xx status code
func (o *GetAccountMetricsBadRequest) IsSuccess() bool {
return false
}
// IsRedirect returns true when this get account metrics bad request response has a 3xx status code
func (o *GetAccountMetricsBadRequest) IsRedirect() bool {
return false
}
// IsClientError returns true when this get account metrics bad request response has a 4xx status code
func (o *GetAccountMetricsBadRequest) IsClientError() bool {
return true
}
// IsServerError returns true when this get account metrics bad request response has a 5xx status code
func (o *GetAccountMetricsBadRequest) IsServerError() bool {
return false
}
// IsCode returns true when this get account metrics bad request response a status code equal to that given
func (o *GetAccountMetricsBadRequest) IsCode(code int) bool {
return code == 400
}
func (o *GetAccountMetricsBadRequest) Error() string {
return fmt.Sprintf("[GET /metrics/account][%d] getAccountMetricsBadRequest ", 400)
}
func (o *GetAccountMetricsBadRequest) String() string {
return fmt.Sprintf("[GET /metrics/account][%d] getAccountMetricsBadRequest ", 400)
}
func (o *GetAccountMetricsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}
// NewGetAccountMetricsInternalServerError creates a GetAccountMetricsInternalServerError with default headers values
func NewGetAccountMetricsInternalServerError() *GetAccountMetricsInternalServerError {
return &GetAccountMetricsInternalServerError{}
}
/*
GetAccountMetricsInternalServerError describes a response with status code 500, with default header values.
internal server error
*/
type GetAccountMetricsInternalServerError struct {
}
// IsSuccess returns true when this get account metrics internal server error response has a 2xx status code
func (o *GetAccountMetricsInternalServerError) IsSuccess() bool {
return false
}
// IsRedirect returns true when this get account metrics internal server error response has a 3xx status code
func (o *GetAccountMetricsInternalServerError) IsRedirect() bool {
return false
}
// IsClientError returns true when this get account metrics internal server error response has a 4xx status code
func (o *GetAccountMetricsInternalServerError) IsClientError() bool {
return false
}
// IsServerError returns true when this get account metrics internal server error response has a 5xx status code
func (o *GetAccountMetricsInternalServerError) IsServerError() bool {
return true
}
// IsCode returns true when this get account metrics internal server error response a status code equal to that given
func (o *GetAccountMetricsInternalServerError) IsCode(code int) bool {
return code == 500
}
func (o *GetAccountMetricsInternalServerError) Error() string {
return fmt.Sprintf("[GET /metrics/account][%d] getAccountMetricsInternalServerError ", 500)
}
func (o *GetAccountMetricsInternalServerError) String() string {
return fmt.Sprintf("[GET /metrics/account][%d] getAccountMetricsInternalServerError ", 500)
}
func (o *GetAccountMetricsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
return nil
}

View File

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// 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 {
// Duration.
Duration *string
// 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
}
// WithDuration adds the duration to the get environment metrics params
func (o *GetEnvironmentMetricsParams) WithDuration(duration *string) *GetEnvironmentMetricsParams {
o.SetDuration(duration)
return o
}
// SetDuration adds the duration to the get environment metrics params
func (o *GetEnvironmentMetricsParams) SetDuration(duration *string) {
o.Duration = duration
}
// 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
if o.Duration != nil {
// query param duration
var qrDuration string
if o.Duration != nil {
qrDuration = *o.Duration
}
qDuration := qrDuration
if qDuration != "" {
if err := r.SetQueryParam("duration", qDuration); err != nil {
return err
}
}
}
// path param envId
if err := r.SetPathParam("envId", o.EnvID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,155 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"github.com/openziti/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
}

View File

@ -0,0 +1,179 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
)
// 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 {
// Duration.
Duration *string
// 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
}
// WithDuration adds the duration to the get share metrics params
func (o *GetShareMetricsParams) WithDuration(duration *string) *GetShareMetricsParams {
o.SetDuration(duration)
return o
}
// SetDuration adds the duration to the get share metrics params
func (o *GetShareMetricsParams) SetDuration(duration *string) {
o.Duration = duration
}
// 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
if o.Duration != nil {
// query param duration
var qrDuration string
if o.Duration != nil {
qrDuration = *o.Duration
}
qDuration := qrDuration
if qDuration != "" {
if err := r.SetQueryParam("duration", qDuration); err != nil {
return err
}
}
}
// path param shrToken
if err := r.SetPathParam("shrToken", o.ShrToken); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,155 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
"github.com/go-openapi/strfmt"
"github.com/openziti/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
}

View File

@ -32,10 +32,16 @@ type ClientOption func(*runtime.ClientOperation)
type ClientService interface {
Configuration(params *ConfigurationParams, opts ...ClientOption) (*ConfigurationOK, error)
GetAccountMetrics(params *GetAccountMetricsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetAccountMetricsOK, error)
GetEnvironmentDetail(params *GetEnvironmentDetailParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEnvironmentDetailOK, error)
GetEnvironmentMetrics(params *GetEnvironmentMetricsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetEnvironmentMetricsOK, error)
GetShareDetail(params *GetShareDetailParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetShareDetailOK, error)
GetShareMetrics(params *GetShareMetricsParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetShareMetricsOK, error)
Overview(params *OverviewParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*OverviewOK, error)
Version(params *VersionParams, opts ...ClientOption) (*VersionOK, error)
@ -81,6 +87,45 @@ func (a *Client) Configuration(params *ConfigurationParams, opts ...ClientOption
panic(msg)
}
/*
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)
}
/*
GetEnvironmentDetail get environment detail API
*/
@ -120,6 +165,45 @@ func (a *Client) GetEnvironmentDetail(params *GetEnvironmentDetailParams, authIn
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)
}
/*
GetShareDetail get share detail API
*/
@ -159,6 +243,45 @@ func (a *Client) GetShareDetail(params *GetShareDetailParams, authInfo runtime.C
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)
}
/*
Overview overview API
*/

View File

@ -14,7 +14,6 @@ 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"
)
@ -64,7 +63,6 @@ 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
}
@ -118,8 +116,6 @@ type Zrok struct {
Metadata metadata.ClientService
Metrics metrics.ClientService
Share share.ClientService
Transport runtime.ClientTransport
@ -132,6 +128,5 @@ 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)
}

View File

@ -528,12 +528,12 @@ func init() {
}
],
"tags": [
"metrics"
"metadata"
],
"operationId": "getAccountMetrics",
"parameters": [
{
"type": "number",
"type": "string",
"name": "duration",
"in": "query"
}
@ -544,6 +544,12 @@ func init() {
"schema": {
"$ref": "#/definitions/metrics"
}
},
"400": {
"description": "bad request"
},
"500": {
"description": "internal server error"
}
}
}
@ -556,7 +562,7 @@ func init() {
}
],
"tags": [
"metrics"
"metadata"
],
"operationId": "getEnvironmentMetrics",
"parameters": [
@ -567,7 +573,7 @@ func init() {
"required": true
},
{
"type": "number",
"type": "string",
"name": "duration",
"in": "query"
}
@ -593,7 +599,7 @@ func init() {
}
],
"tags": [
"metrics"
"metadata"
],
"operationId": "getShareMetrics",
"parameters": [
@ -604,7 +610,7 @@ func init() {
"required": true
},
{
"type": "number",
"type": "string",
"name": "duration",
"in": "query"
}
@ -1938,12 +1944,12 @@ func init() {
}
],
"tags": [
"metrics"
"metadata"
],
"operationId": "getAccountMetrics",
"parameters": [
{
"type": "number",
"type": "string",
"name": "duration",
"in": "query"
}
@ -1954,6 +1960,12 @@ func init() {
"schema": {
"$ref": "#/definitions/metrics"
}
},
"400": {
"description": "bad request"
},
"500": {
"description": "internal server error"
}
}
}
@ -1966,7 +1978,7 @@ func init() {
}
],
"tags": [
"metrics"
"metadata"
],
"operationId": "getEnvironmentMetrics",
"parameters": [
@ -1977,7 +1989,7 @@ func init() {
"required": true
},
{
"type": "number",
"type": "string",
"name": "duration",
"in": "query"
}
@ -2003,7 +2015,7 @@ func init() {
}
],
"tags": [
"metrics"
"metadata"
],
"operationId": "getShareMetrics",
"parameters": [
@ -2014,7 +2026,7 @@ func init() {
"required": true
},
{
"type": "number",
"type": "string",
"name": "duration",
"in": "query"
}

View File

@ -0,0 +1,71 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"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 metadata 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)
}

View File

@ -0,0 +1,77 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
)
// 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:"-"`
/*
In: query
*/
Duration *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 NewGetAccountMetricsParams() beforehand.
func (o *GetAccountMetricsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
qs := runtime.Values(r.URL.Query())
qDuration, qhkDuration, _ := qs.GetOK("duration")
if err := o.bindDuration(qDuration, qhkDuration, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// bindDuration binds and validates parameter Duration from query.
func (o *GetAccountMetricsParams) bindDuration(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
o.Duration = &raw
return nil
}

View File

@ -0,0 +1,109 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"github.com/openziti/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
}
}
}
// GetAccountMetricsBadRequestCode is the HTTP code returned for type GetAccountMetricsBadRequest
const GetAccountMetricsBadRequestCode int = 400
/*
GetAccountMetricsBadRequest bad request
swagger:response getAccountMetricsBadRequest
*/
type GetAccountMetricsBadRequest struct {
}
// NewGetAccountMetricsBadRequest creates GetAccountMetricsBadRequest with default headers values
func NewGetAccountMetricsBadRequest() *GetAccountMetricsBadRequest {
return &GetAccountMetricsBadRequest{}
}
// WriteResponse to the client
func (o *GetAccountMetricsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(400)
}
// GetAccountMetricsInternalServerErrorCode is the HTTP code returned for type GetAccountMetricsInternalServerError
const GetAccountMetricsInternalServerErrorCode int = 500
/*
GetAccountMetricsInternalServerError internal server error
swagger:response getAccountMetricsInternalServerError
*/
type GetAccountMetricsInternalServerError struct {
}
// NewGetAccountMetricsInternalServerError creates GetAccountMetricsInternalServerError with default headers values
func NewGetAccountMetricsInternalServerError() *GetAccountMetricsInternalServerError {
return &GetAccountMetricsInternalServerError{}
}
// WriteResponse to the client
func (o *GetAccountMetricsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(500)
}

View File

@ -0,0 +1,103 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// GetAccountMetricsURL generates an URL for the get account metrics operation
type GetAccountMetricsURL struct {
Duration *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 *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)
qs := make(url.Values)
var durationQ string
if o.Duration != nil {
durationQ = *o.Duration
}
if durationQ != "" {
qs.Set("duration", durationQ)
}
_result.RawQuery = qs.Encode()
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()
}

View File

@ -0,0 +1,71 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"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} metadata 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)
}

View File

@ -0,0 +1,101 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/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:"-"`
/*
In: query
*/
Duration *string
/*
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
qs := runtime.Values(r.URL.Query())
qDuration, qhkDuration, _ := qs.GetOK("duration")
if err := o.bindDuration(qDuration, qhkDuration, route.Formats); err != nil {
res = append(res, err)
}
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
}
// bindDuration binds and validates parameter Duration from query.
func (o *GetEnvironmentMetricsParams) bindDuration(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
o.Duration = &raw
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
}

View File

@ -0,0 +1,84 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the 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)
}

View File

@ -0,0 +1,113 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
"strings"
)
// GetEnvironmentMetricsURL generates an URL for the get environment metrics operation
type GetEnvironmentMetricsURL struct {
EnvID string
Duration *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)
qs := make(url.Values)
var durationQ string
if o.Duration != nil {
durationQ = *o.Duration
}
if durationQ != "" {
qs.Set("duration", durationQ)
}
_result.RawQuery = qs.Encode()
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()
}

View File

@ -0,0 +1,71 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"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} metadata 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)
}

View File

@ -0,0 +1,101 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/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:"-"`
/*
In: query
*/
Duration *string
/*
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
qs := runtime.Values(r.URL.Query())
qDuration, qhkDuration, _ := qs.GetOK("duration")
if err := o.bindDuration(qDuration, qhkDuration, route.Formats); err != nil {
res = append(res, err)
}
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
}
// bindDuration binds and validates parameter Duration from query.
func (o *GetShareMetricsParams) bindDuration(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
o.Duration = &raw
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
}

View File

@ -0,0 +1,84 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the 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)
}

View File

@ -0,0 +1,113 @@
// Code generated by go-swagger; DO NOT EDIT.
package metadata
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
"strings"
)
// GetShareMetricsURL generates an URL for the get share metrics operation
type GetShareMetricsURL struct {
ShrToken string
Duration *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)
qs := make(url.Values)
var durationQ string
if o.Duration != nil {
durationQ = *o.Duration
}
if durationQ != "" {
qs.Set("duration", durationQ)
}
_result.RawQuery = qs.Encode()
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()
}

View File

@ -24,7 +24,6 @@ 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"
)
@ -71,20 +70,20 @@ 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")
MetadataGetAccountMetricsHandler: metadata.GetAccountMetricsHandlerFunc(func(params metadata.GetAccountMetricsParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation metadata.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")
MetadataGetEnvironmentMetricsHandler: metadata.GetEnvironmentMetricsHandlerFunc(func(params metadata.GetEnvironmentMetricsParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation metadata.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")
MetadataGetShareMetricsHandler: metadata.GetShareMetricsHandlerFunc(func(params metadata.GetShareMetricsParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation metadata.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")
@ -195,16 +194,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
// MetadataGetAccountMetricsHandler sets the operation handler for the get account metrics operation
MetadataGetAccountMetricsHandler metadata.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
// MetadataGetEnvironmentMetricsHandler sets the operation handler for the get environment metrics operation
MetadataGetEnvironmentMetricsHandler metadata.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
// MetadataGetShareMetricsHandler sets the operation handler for the get share metrics operation
MetadataGetShareMetricsHandler metadata.GetShareMetricsHandler
// AccountInviteHandler sets the operation handler for the invite operation
AccountInviteHandler account.InviteHandler
// AdminInviteTokenGenerateHandler sets the operation handler for the invite token generate operation
@ -337,20 +336,20 @@ 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.MetadataGetAccountMetricsHandler == nil {
unregistered = append(unregistered, "metadata.GetAccountMetricsHandler")
}
if o.MetadataGetEnvironmentDetailHandler == nil {
unregistered = append(unregistered, "metadata.GetEnvironmentDetailHandler")
}
if o.MetricsGetEnvironmentMetricsHandler == nil {
unregistered = append(unregistered, "metrics.GetEnvironmentMetricsHandler")
if o.MetadataGetEnvironmentMetricsHandler == nil {
unregistered = append(unregistered, "metadata.GetEnvironmentMetricsHandler")
}
if o.MetadataGetShareDetailHandler == nil {
unregistered = append(unregistered, "metadata.GetShareDetailHandler")
}
if o.MetricsGetShareMetricsHandler == nil {
unregistered = append(unregistered, "metrics.GetShareMetricsHandler")
if o.MetadataGetShareMetricsHandler == nil {
unregistered = append(unregistered, "metadata.GetShareMetricsHandler")
}
if o.AccountInviteHandler == nil {
unregistered = append(unregistered, "account.InviteHandler")
@ -527,7 +526,7 @@ 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)
o.handlers["GET"]["/metrics/account"] = metadata.NewGetAccountMetrics(o.context, o.MetadataGetAccountMetricsHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
@ -535,7 +534,7 @@ func (o *ZrokAPI) initHandlerCache() {
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)
o.handlers["GET"]["/metrics/environment/{envId}"] = metadata.NewGetEnvironmentMetrics(o.context, o.MetadataGetEnvironmentMetricsHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
@ -543,7 +542,7 @@ func (o *ZrokAPI) initHandlerCache() {
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)
o.handlers["GET"]["/metrics/share/{shrToken}"] = metadata.NewGetShareMetrics(o.context, o.MetadataGetShareMetricsHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}

View File

@ -394,41 +394,31 @@ paths:
schema:
$ref: "#/definitions/errorMessage"
/version:
get:
tags:
- metadata
operationId: version
responses:
200:
description: current server version
schema:
$ref: "#/definitions/version"
#
# metrics
#
/metrics/account:
get:
tags:
- metrics
- metadata
security:
- key: []
operationId: getAccountMetrics
parameters:
- name: duration
in: query
type: number
type: string
responses:
200:
description: account metrics
schema:
$ref: "#/definitions/metrics"
400:
description: bad request
500:
description: internal server error
/metrics/environment/{envId}:
get:
tags:
- metrics
- metadata
security:
- key: []
operationId: getEnvironmentMetrics
@ -439,7 +429,7 @@ paths:
required: true
- name: duration
in: query
type: number
type: string
responses:
200:
description: environment metrics
@ -451,7 +441,7 @@ paths:
/metrics/share/{shrToken}:
get:
tags:
- metrics
- metadata
security:
- key: []
operationId: getShareMetrics
@ -462,7 +452,7 @@ paths:
required: true
- name: duration
in: query
type: number
type: string
responses:
200:
description: share metrics
@ -470,6 +460,18 @@ paths:
$ref: "#/definitions/metrics"
401:
description: unauthorized
/version:
get:
tags:
- metadata
operationId: version
responses:
200:
description: current server version
schema:
$ref: "#/definitions/version"
#
# share
#

View File

@ -40,6 +40,59 @@ export function overview() {
return gateway.request(overviewOperation)
}
/**
* @param {object} options Optional options
* @param {string} [options.duration]
* @return {Promise<module:types.metrics>} account metrics
*/
export function getAccountMetrics(options) {
if (!options) options = {}
const parameters = {
query: {
duration: options.duration
}
}
return gateway.request(getAccountMetricsOperation, parameters)
}
/**
* @param {string} envId
* @param {object} options Optional options
* @param {string} [options.duration]
* @return {Promise<module:types.metrics>} environment metrics
*/
export function getEnvironmentMetrics(envId, options) {
if (!options) options = {}
const parameters = {
path: {
envId
},
query: {
duration: options.duration
}
}
return gateway.request(getEnvironmentMetricsOperation, parameters)
}
/**
* @param {string} shrToken
* @param {object} options Optional options
* @param {string} [options.duration]
* @return {Promise<module:types.metrics>} share metrics
*/
export function getShareMetrics(shrToken, options) {
if (!options) options = {}
const parameters = {
path: {
shrToken
},
query: {
duration: options.duration
}
}
return gateway.request(getShareMetricsOperation, parameters)
}
/**
*/
export function version() {
@ -81,6 +134,36 @@ const overviewOperation = {
]
}
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'
}
]
}
const versionOperation = {
path: '/version',
method: 'get'

View File

@ -1,86 +0,0 @@
/** @module metrics */
// Auto-generated, edits will be overwritten
import * as gateway from './gateway'
/**
* @param {object} options Optional options
* @param {number} [options.duration]
* @return {Promise<module:types.metrics>} account metrics
*/
export function getAccountMetrics(options) {
if (!options) options = {}
const parameters = {
query: {
duration: options.duration
}
}
return gateway.request(getAccountMetricsOperation, parameters)
}
/**
* @param {string} envId
* @param {object} options Optional options
* @param {number} [options.duration]
* @return {Promise<module:types.metrics>} environment metrics
*/
export function getEnvironmentMetrics(envId, options) {
if (!options) options = {}
const parameters = {
path: {
envId
},
query: {
duration: options.duration
}
}
return gateway.request(getEnvironmentMetricsOperation, parameters)
}
/**
* @param {string} shrToken
* @param {object} options Optional options
* @param {number} [options.duration]
* @return {Promise<module:types.metrics>} share metrics
*/
export function getShareMetrics(shrToken, options) {
if (!options) options = {}
const parameters = {
path: {
shrToken
},
query: {
duration: options.duration
}
}
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'
}
]
}