duration parameter (#319)

This commit is contained in:
Michael Quigley 2023-05-09 11:36:53 -04:00
parent 58a225284d
commit 21fdaf8e3c
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
16 changed files with 331 additions and 10 deletions

View File

@ -14,6 +14,7 @@ import (
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewGetAccountMetricsParams creates a new GetAccountMetricsParams object,
@ -60,6 +61,10 @@ GetAccountMetricsParams contains all the parameters to send to the API endpoint
Typically these are written to a http.Request.
*/
type GetAccountMetricsParams struct {
// Duration.
Duration *float64
timeout time.Duration
Context context.Context
HTTPClient *http.Client
@ -113,6 +118,17 @@ 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 *float64) *GetAccountMetricsParams {
o.SetDuration(duration)
return o
}
// SetDuration adds the duration to the get account metrics params
func (o *GetAccountMetricsParams) SetDuration(duration *float64) {
o.Duration = duration
}
// WriteToRequest writes these params to a swagger request
func (o *GetAccountMetricsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
@ -121,6 +137,23 @@ func (o *GetAccountMetricsParams) WriteToRequest(r runtime.ClientRequest, reg st
}
var res []error
if o.Duration != nil {
// query param duration
var qrDuration float64
if o.Duration != nil {
qrDuration = *o.Duration
}
qDuration := swag.FormatFloat64(qrDuration)
if qDuration != "" {
if err := r.SetQueryParam("duration", qDuration); err != nil {
return err
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}

View File

@ -14,6 +14,7 @@ import (
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewGetEnvironmentMetricsParams creates a new GetEnvironmentMetricsParams object,
@ -61,6 +62,9 @@ GetEnvironmentMetricsParams contains all the parameters to send to the API endpo
*/
type GetEnvironmentMetricsParams struct {
// Duration.
Duration *float64
// EnvID.
EnvID string
@ -117,6 +121,17 @@ 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 *float64) *GetEnvironmentMetricsParams {
o.SetDuration(duration)
return o
}
// SetDuration adds the duration to the get environment metrics params
func (o *GetEnvironmentMetricsParams) SetDuration(duration *float64) {
o.Duration = duration
}
// WithEnvID adds the envID to the get environment metrics params
func (o *GetEnvironmentMetricsParams) WithEnvID(envID string) *GetEnvironmentMetricsParams {
o.SetEnvID(envID)
@ -136,6 +151,23 @@ func (o *GetEnvironmentMetricsParams) WriteToRequest(r runtime.ClientRequest, re
}
var res []error
if o.Duration != nil {
// query param duration
var qrDuration float64
if o.Duration != nil {
qrDuration = *o.Duration
}
qDuration := swag.FormatFloat64(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

View File

@ -14,6 +14,7 @@ import (
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewGetShareMetricsParams creates a new GetShareMetricsParams object,
@ -61,6 +62,9 @@ GetShareMetricsParams contains all the parameters to send to the API endpoint
*/
type GetShareMetricsParams struct {
// Duration.
Duration *float64
// ShrToken.
ShrToken string
@ -117,6 +121,17 @@ 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 *float64) *GetShareMetricsParams {
o.SetDuration(duration)
return o
}
// SetDuration adds the duration to the get share metrics params
func (o *GetShareMetricsParams) SetDuration(duration *float64) {
o.Duration = duration
}
// WithShrToken adds the shrToken to the get share metrics params
func (o *GetShareMetricsParams) WithShrToken(shrToken string) *GetShareMetricsParams {
o.SetShrToken(shrToken)
@ -136,6 +151,23 @@ func (o *GetShareMetricsParams) WriteToRequest(r runtime.ClientRequest, reg strf
}
var res []error
if o.Duration != nil {
// query param duration
var qrDuration float64
if o.Duration != nil {
qrDuration = *o.Duration
}
qDuration := swag.FormatFloat64(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

View File

@ -531,6 +531,13 @@ func init() {
"metrics"
],
"operationId": "getAccountMetrics",
"parameters": [
{
"type": "number",
"name": "duration",
"in": "query"
}
],
"responses": {
"200": {
"description": "account metrics",
@ -558,6 +565,11 @@ func init() {
"name": "envId",
"in": "path",
"required": true
},
{
"type": "number",
"name": "duration",
"in": "query"
}
],
"responses": {
@ -590,6 +602,11 @@ func init() {
"name": "shrToken",
"in": "path",
"required": true
},
{
"type": "number",
"name": "duration",
"in": "query"
}
],
"responses": {
@ -1924,6 +1941,13 @@ func init() {
"metrics"
],
"operationId": "getAccountMetrics",
"parameters": [
{
"type": "number",
"name": "duration",
"in": "query"
}
],
"responses": {
"200": {
"description": "account metrics",
@ -1951,6 +1975,11 @@ func init() {
"name": "envId",
"in": "path",
"required": true
},
{
"type": "number",
"name": "duration",
"in": "query"
}
],
"responses": {
@ -1983,6 +2012,11 @@ func init() {
"name": "shrToken",
"in": "path",
"required": true
},
{
"type": "number",
"name": "duration",
"in": "query"
}
],
"responses": {

View File

@ -9,7 +9,10 @@ import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewGetAccountMetricsParams creates a new GetAccountMetricsParams object
@ -28,6 +31,11 @@ type GetAccountMetricsParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: query
*/
Duration *float64
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
@ -39,8 +47,37 @@ func (o *GetAccountMetricsParams) BindRequest(r *http.Request, route *middleware
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
}
value, err := swag.ConvertFloat64(raw)
if err != nil {
return errors.InvalidType("duration", "query", "float64", raw)
}
o.Duration = &value
return nil
}

View File

@ -9,11 +9,17 @@ import (
"errors"
"net/url"
golangswaggerpaths "path"
"github.com/go-openapi/swag"
)
// GetAccountMetricsURL generates an URL for the get account metrics operation
type GetAccountMetricsURL struct {
Duration *float64
_basePath string
// avoid unkeyed usage
_ struct{}
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
@ -43,6 +49,18 @@ func (o *GetAccountMetricsURL) Build() (*url.URL, error) {
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
qs := make(url.Values)
var durationQ string
if o.Duration != nil {
durationQ = swag.FormatFloat64(*o.Duration)
}
if durationQ != "" {
qs.Set("duration", durationQ)
}
_result.RawQuery = qs.Encode()
return &_result, nil
}

View File

@ -9,8 +9,10 @@ import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewGetEnvironmentMetricsParams creates a new GetEnvironmentMetricsParams object
@ -30,6 +32,10 @@ type GetEnvironmentMetricsParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: query
*/
Duration *float64
/*
Required: true
In: path
@ -46,6 +52,13 @@ func (o *GetEnvironmentMetricsParams) BindRequest(r *http.Request, route *middle
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)
@ -56,6 +69,29 @@ func (o *GetEnvironmentMetricsParams) BindRequest(r *http.Request, route *middle
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
}
value, err := swag.ConvertFloat64(raw)
if err != nil {
return errors.InvalidType("duration", "query", "float64", raw)
}
o.Duration = &value
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

View File

@ -10,12 +10,16 @@ import (
"net/url"
golangswaggerpaths "path"
"strings"
"github.com/go-openapi/swag"
)
// GetEnvironmentMetricsURL generates an URL for the get environment metrics operation
type GetEnvironmentMetricsURL struct {
EnvID string
Duration *float64
_basePath string
// avoid unkeyed usage
_ struct{}
@ -55,6 +59,18 @@ func (o *GetEnvironmentMetricsURL) Build() (*url.URL, error) {
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
qs := make(url.Values)
var durationQ string
if o.Duration != nil {
durationQ = swag.FormatFloat64(*o.Duration)
}
if durationQ != "" {
qs.Set("duration", durationQ)
}
_result.RawQuery = qs.Encode()
return &_result, nil
}

View File

@ -9,8 +9,10 @@ import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// NewGetShareMetricsParams creates a new GetShareMetricsParams object
@ -30,6 +32,10 @@ type GetShareMetricsParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: query
*/
Duration *float64
/*
Required: true
In: path
@ -46,6 +52,13 @@ func (o *GetShareMetricsParams) BindRequest(r *http.Request, route *middleware.M
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)
@ -56,6 +69,29 @@ func (o *GetShareMetricsParams) BindRequest(r *http.Request, route *middleware.M
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
}
value, err := swag.ConvertFloat64(raw)
if err != nil {
return errors.InvalidType("duration", "query", "float64", raw)
}
o.Duration = &value
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

View File

@ -10,12 +10,16 @@ import (
"net/url"
golangswaggerpaths "path"
"strings"
"github.com/go-openapi/swag"
)
// GetShareMetricsURL generates an URL for the get share metrics operation
type GetShareMetricsURL struct {
ShrToken string
Duration *float64
_basePath string
// avoid unkeyed usage
_ struct{}
@ -55,6 +59,18 @@ func (o *GetShareMetricsURL) Build() (*url.URL, error) {
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
qs := make(url.Values)
var durationQ string
if o.Duration != nil {
durationQ = swag.FormatFloat64(*o.Duration)
}
if durationQ != "" {
qs.Set("duration", durationQ)
}
_result.RawQuery = qs.Encode()
return &_result, nil
}

View File

@ -415,6 +415,10 @@ paths:
security:
- key: []
operationId: getAccountMetrics
parameters:
- name: duration
in: query
type: number
responses:
200:
description: account metrics
@ -433,6 +437,9 @@ paths:
in: path
type: string
required: true
- name: duration
in: query
type: number
responses:
200:
description: environment metrics
@ -453,6 +460,9 @@ paths:
in: path
type: string
required: true
- name: duration
in: query
type: number
responses:
200:
description: share metrics

View File

@ -3,19 +3,34 @@
import * as gateway from './gateway'
/**
* @param {object} options Optional options
* @param {number} [options.duration]
* @return {Promise<module:types.metrics>} account metrics
*/
export function getAccountMetrics() {
return gateway.request(getAccountMetricsOperation)
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) {
export function getEnvironmentMetrics(envId, options) {
if (!options) options = {}
const parameters = {
path: {
envId
},
query: {
duration: options.duration
}
}
return gateway.request(getEnvironmentMetricsOperation, parameters)
@ -23,12 +38,18 @@ export function getEnvironmentMetrics(envId) {
/**
* @param {string} shrToken
* @param {object} options Optional options
* @param {number} [options.duration]
* @return {Promise<module:types.metrics>} share metrics
*/
export function getShareMetrics(shrToken) {
export function getShareMetrics(shrToken, options) {
if (!options) options = {}
const parameters = {
path: {
shrToken
},
query: {
duration: options.duration
}
}
return gateway.request(getShareMetricsOperation, parameters)

View File

@ -46,7 +46,7 @@ const SharesTab = (props) => {
cell: row => {
return <ResponsiveContainer width={"100%"} height={"100%"}>
<AreaChart data={row.metrics}>
<Area type="basis" dataKey={(v) => v} stroke={"#231069"} fillOpacity={1} fill={"#655796"} isAnimationActive={false} dot={false} />
<Area type="basis" dataKey={(v) => v} stroke={"#777"} fillOpacity={0.5} fill={"#04adef"} isAnimationActive={false} dot={false} />
</AreaChart>
</ResponsiveContainer>
}

View File

@ -42,7 +42,7 @@ const ShareDetail = (props) => {
metrics: row => (
<ResponsiveContainer width={"100%"} height={"100%"}>
<AreaChart data={row.value}>
<Area type="basis" dataKey={(v) => v} stroke={"#231069"} fillOpacity={1} fill={"#655796"} isAnimationActive={false} dot={false} />
<Area type="basis" dataKey={(v) => v} stroke={"#777"} fillOpacity={0.5} fill={"#04adef"} isAnimationActive={false} dot={false} />
</AreaChart>
</ResponsiveContainer>
),

View File

@ -21,8 +21,8 @@ const Network = (props) => {
}, []);
const paintNode = (node, ctx) => {
let nodeColor = node.selected ? "#04adef" : "#9BF316";
let textColor = node.selected ? "white" : "black";
let nodeColor = node.selected ? "#9BF316" : "#04adef";
let textColor = node.selected ? "black" : "white";
ctx.textBaseline = "middle";
ctx.textAlign = "center";

View File

@ -40,7 +40,7 @@ export const mergeGraph = (oldGraph, user, newOverview) => {
newGraph.links.push({
target: accountNode.id,
source: envNode.id,
color: "#9BF316"
color: "#04adef"
});
if(env.shares) {
env.shares.forEach(shr => {
@ -60,7 +60,7 @@ export const mergeGraph = (oldGraph, user, newOverview) => {
newGraph.links.push({
target: envNode.id,
source: shrNode.id,
color: "#9BF316"
color: "#04adef"
});
});
}