diff --git a/api/models/metrics_config.go b/api/models/metrics_config.go new file mode 100644 index 000000000..af18c66f5 --- /dev/null +++ b/api/models/metrics_config.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// MetricsConfig metrics config +// +// swagger:model MetricsConfig +type MetricsConfig struct { + + // value for prometheus enable or not + // Required: true + Prometheus *bool `json:"prometheus"` +} + +// Validate validates this metrics config +func (m *MetricsConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePrometheus(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *MetricsConfig) validatePrometheus(formats strfmt.Registry) error { + + if err := validate.Required("prometheus", "body", m.Prometheus); err != nil { + return err + } + + return nil +} + +// ContextValidate validates this metrics config based on context it is used +func (m *MetricsConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *MetricsConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *MetricsConfig) UnmarshalBinary(b []byte) error { + var res MetricsConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/api/prometheus/prometheus.go b/api/prometheus/prometheus.go index 2e3d8e255..0c436f451 100644 --- a/api/prometheus/prometheus.go +++ b/api/prometheus/prometheus.go @@ -16,7 +16,11 @@ package prometheus import ( + "context" "fmt" + "github.com/go-openapi/errors" + "github.com/loxilb-io/loxilb/options" + "net/http" "strings" "sync" "time" @@ -46,6 +50,8 @@ var ( PromethusDefaultPeriod = 10 * time.Second PromethusPartialPeriod = (PromethusDefaultPeriod / 6) PromethusLongPeriod = (PromethusDefaultPeriod * 600) // To reset Period + prometheusCtx context.Context + prometheusCancel context.CancelFunc activeConntrackCount = promauto.NewGauge( prometheus.GaugeOpts{ Name: "active_conntrack_count", @@ -143,215 +149,288 @@ func PrometheusRegister(hook cmn.NetHookInterface) { } func Init() { + prometheusCtx, prometheusCancel = context.WithCancel(context.Background()) + // Make Conntrack Statistic map ConntrackStats = make(map[ConntrackKey]Stats) mutex = &sync.Mutex{} - go RunGetConntrack() - go RunGetEndpoint() - go RunActiveConntrackCount() - go RunHostCount() - go RunProcessedStatistic() - go RunNewFlowCount() - go RunResetCounts() - go RunGetLBRule() - go RunLcusCalculator() + go RunGetConntrack(prometheusCtx) + go RunGetEndpoint(prometheusCtx) + go RunActiveConntrackCount(prometheusCtx) + go RunHostCount(prometheusCtx) + go RunProcessedStatistic(prometheusCtx) + go RunNewFlowCount(prometheusCtx) + go RunResetCounts(prometheusCtx) + go RunGetLBRule(prometheusCtx) + go RunLcusCalculator(prometheusCtx) +} + +func Off() error { + if !options.Opts.Prometheus { + return errors.New(http.StatusBadRequest, "already prometheus turned off") + } + options.Opts.Prometheus = false + prometheusCancel() + return nil +} + +func TurnOn() error { + if options.Opts.Prometheus { + return errors.New(http.StatusBadRequest, "already prometheus turned on") + } + options.Opts.Prometheus = true + Init() + return nil } func MakeConntrackKey(c cmn.CtInfo) (key ConntrackKey) { return ConntrackKey(fmt.Sprintf("%s|%05d|%s|%05d|%v", c.Sip, c.Sport, c.Dip, c.Dport, c.Proto)) } -func RunResetCounts() { +func RunResetCounts(ctx context.Context) { for { // Statistic reset + select { + case <-ctx.Done(): + return + default: + mutex.Lock() + ConntrackStats = map[ConntrackKey]Stats{} + mutex.Unlock() + } time.Sleep(PromethusLongPeriod) - mutex.Lock() - ConntrackStats = map[ConntrackKey]Stats{} - mutex.Unlock() } } -func RunGetConntrack() { +func RunGetConntrack(ctx context.Context) { for { - mutex.Lock() - ConntrackInfo, err = hooks.NetCtInfoGet() - if err != nil { - tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) - } - - for _, ct := range ConntrackInfo { - k := MakeConntrackKey(ct) - var tmpStats Stats - _, ok := ConntrackStats[k] - if ok { - tmpStats = Stats{ - Bytes: ConntrackStats[k].Bytes + ct.Bytes, - Packets: ConntrackStats[k].Packets + ct.Pkts, - } - } else { - tmpStats = Stats{ - Bytes: ct.Bytes, - Packets: ct.Pkts, - } + select { + case <-ctx.Done(): + return + default: + mutex.Lock() + ConntrackInfo, err = hooks.NetCtInfoGet() + if err != nil { + tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) } - ConntrackStats[k] = tmpStats + for _, ct := range ConntrackInfo { + k := MakeConntrackKey(ct) + var tmpStats Stats + _, ok := ConntrackStats[k] + if ok { + tmpStats = Stats{ + Bytes: ConntrackStats[k].Bytes + ct.Bytes, + Packets: ConntrackStats[k].Packets + ct.Pkts, + } + } else { + tmpStats = Stats{ + Bytes: ct.Bytes, + Packets: ct.Pkts, + } + } + ConntrackStats[k] = tmpStats + } + mutex.Unlock() } - mutex.Unlock() + time.Sleep(PromethusDefaultPeriod) } } -func RunGetEndpoint() { +func RunGetEndpoint(ctx context.Context) { for { - mutex.Lock() - EndPointInfo, err = hooks.NetEpHostGet() - if err != nil { - tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) + select { + case <-ctx.Done(): + return + default: + mutex.Lock() + EndPointInfo, err = hooks.NetEpHostGet() + if err != nil { + tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) + } + mutex.Unlock() } - mutex.Unlock() + time.Sleep(PromethusDefaultPeriod) } } -func RunGetLBRule() { +func RunGetLBRule(ctx context.Context) { for { - mutex.Lock() - LBRuleInfo, err = hooks.NetLbRuleGet() - if err != nil { - tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) + select { + case <-ctx.Done(): + return + default: + mutex.Lock() + LBRuleInfo, err = hooks.NetLbRuleGet() + if err != nil { + tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) + } + ruleCount.Set(float64(len(LBRuleInfo))) + mutex.Unlock() } - ruleCount.Set(float64(len(LBRuleInfo))) - mutex.Unlock() time.Sleep(PromethusDefaultPeriod) } } -func RunActiveConntrackCount() { +func RunActiveConntrackCount(ctx context.Context) { for { - mutex.Lock() - // init Counts - activeFlowCountTcp.Set(0) - activeFlowCountUdp.Set(0) - activeFlowCountSctp.Set(0) - inActiveFlowCount.Set(0) + select { + case <-ctx.Done(): + return + default: + mutex.Lock() + // init Counts + activeFlowCountTcp.Set(0) + activeFlowCountUdp.Set(0) + activeFlowCountSctp.Set(0) + inActiveFlowCount.Set(0) - // Total flow count - activeConntrackCount.Set(float64(len(ConntrackInfo))) + // Total flow count + activeConntrackCount.Set(float64(len(ConntrackInfo))) - for _, ct := range ConntrackInfo { - // TCP flow count - if ct.Proto == "tcp" { - activeFlowCountTcp.Inc() - } - // UDP flow count - if ct.Proto == "udp" { - activeFlowCountUdp.Inc() - } - // SCTP flow count - if ct.Proto == "sctp" { - activeFlowCountSctp.Inc() - } - // Closed flow count - if ct.CState == "closed" { - inActiveFlowCount.Inc() + for _, ct := range ConntrackInfo { + // TCP flow count + if ct.Proto == "tcp" { + activeFlowCountTcp.Inc() + } + // UDP flow count + if ct.Proto == "udp" { + activeFlowCountUdp.Inc() + } + // SCTP flow count + if ct.Proto == "sctp" { + activeFlowCountSctp.Inc() + } + // Closed flow count + if ct.CState == "closed" { + inActiveFlowCount.Inc() + } } + mutex.Unlock() } - mutex.Unlock() + time.Sleep(PromethusDefaultPeriod) } } -func RunHostCount() { +func RunHostCount(ctx context.Context) { for { - mutex.Lock() - healthyHostCount.Set(0) - unHealthyHostCount.Set(0) - for _, ep := range EndPointInfo { - if ep.CurrState == "ok" { - healthyHostCount.Inc() - } - if ep.CurrState == "nok" { - unHealthyHostCount.Inc() + select { + case <-ctx.Done(): + return + default: + mutex.Lock() + healthyHostCount.Set(0) + unHealthyHostCount.Set(0) + for _, ep := range EndPointInfo { + if ep.CurrState == "ok" { + healthyHostCount.Inc() + } + if ep.CurrState == "nok" { + unHealthyHostCount.Inc() + } } + mutex.Unlock() } - mutex.Unlock() + time.Sleep(PromethusDefaultPeriod) } } -func RunProcessedStatistic() { +func RunProcessedStatistic(ctx context.Context) { for { - mutex.Lock() - // Init Stats - processedPackets.Set(0) - processedBytes.Set(0) - processedTCPBytes.Set(0) - processedUDPBytes.Set(0) - processedSCTPBytes.Set(0) - for k, ct := range ConntrackStats { - if strings.Contains(string(k), "tcp") { - processedTCPBytes.Add(float64(ct.Bytes)) - } - if strings.Contains(string(k), "udp") { - processedUDPBytes.Add(float64(ct.Bytes)) - } - if strings.Contains(string(k), "sctp") { - processedSCTPBytes.Add(float64(ct.Bytes)) + select { + case <-ctx.Done(): + return + default: + mutex.Lock() + // Init Stats + processedPackets.Set(0) + processedBytes.Set(0) + processedTCPBytes.Set(0) + processedUDPBytes.Set(0) + processedSCTPBytes.Set(0) + for k, ct := range ConntrackStats { + if strings.Contains(string(k), "tcp") { + processedTCPBytes.Add(float64(ct.Bytes)) + } + if strings.Contains(string(k), "udp") { + processedUDPBytes.Add(float64(ct.Bytes)) + } + if strings.Contains(string(k), "sctp") { + processedSCTPBytes.Add(float64(ct.Bytes)) + } + processedPackets.Add(float64(ct.Packets)) + processedBytes.Add(float64(ct.Bytes)) } - processedPackets.Add(float64(ct.Packets)) - processedBytes.Add(float64(ct.Bytes)) + mutex.Unlock() } - mutex.Unlock() + time.Sleep(PromethusDefaultPeriod) } } -func RunNewFlowCount() { +func RunNewFlowCount(ctx context.Context) { PreFlowCounts = 0 for { - mutex.Lock() - // Total new flow count - CurrentFlowCounts := len(ConntrackInfo) - diff := CurrentFlowCounts - PreFlowCounts - if diff > 0 { - newFlowCount.Set(float64(diff)) - } else { - newFlowCount.Set(0) + select { + case <-ctx.Done(): + return + default: + mutex.Lock() + // Total new flow count + CurrentFlowCounts := len(ConntrackInfo) + diff := CurrentFlowCounts - PreFlowCounts + if diff > 0 { + newFlowCount.Set(float64(diff)) + } else { + newFlowCount.Set(0) + } + PreFlowCounts = CurrentFlowCounts + mutex.Unlock() } - PreFlowCounts = CurrentFlowCounts - mutex.Unlock() + time.Sleep(PromethusDefaultPeriod) } } -func RunLcusCalculator() { +func RunLcusCalculator(ctx context.Context) { for { - time.Sleep(PromethusDefaultPeriod) - mutex.Lock() - var LCUNewFlowCount = &dto.Metric{} - var LCUActiveFlowCount = &dto.Metric{} - var LCURuleCount = &dto.Metric{} - var LCUProcessedBytes = &dto.Metric{} - if err := newFlowCount.Write(LCUNewFlowCount); err != nil { - tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) - } - if err := activeConntrackCount.Write(LCUActiveFlowCount); err != nil { - tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) - } - if err := ruleCount.Write(LCURuleCount); err != nil { - tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) - } - if err := processedBytes.Write(LCUProcessedBytes); err != nil { - tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) + select { + case <-ctx.Done(): + return + default: + mutex.Lock() + var LCUNewFlowCount = &dto.Metric{} + var LCUActiveFlowCount = &dto.Metric{} + var LCURuleCount = &dto.Metric{} + var LCUProcessedBytes = &dto.Metric{} + if err := newFlowCount.Write(LCUNewFlowCount); err != nil { + tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) + } + if err := activeConntrackCount.Write(LCUActiveFlowCount); err != nil { + tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) + } + if err := ruleCount.Write(LCURuleCount); err != nil { + tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) + } + if err := processedBytes.Write(LCUProcessedBytes); err != nil { + tk.LogIt(tk.LogDebug, "[Prometheus] Error occur : %v\n", err) + } + // LCU of accumulated Flow count = Flowcount / 2160000 + // LCU of Rule = ruleCount/1000 + // LCU of Byte = processedBytes(Gb)/1h + if LCURuleCount.Gauge.Value != nil && LCUProcessedBytes.Gauge.Value != nil { + consumedLcus.Set(float64(len(ConntrackStats))/2160000 + + *LCURuleCount.Gauge.Value/1000 + + (*LCUProcessedBytes.Gauge.Value*8)/360000000000) // (byte * 8)/ (60*60*1G)/10 + } + + mutex.Unlock() } - // LCU of accumulated Flow count = Flowcount / 2160000 - // LCU of Rule = ruleCount/1000 - // LCU of Byte = processedBytes(Gb)/1h - consumedLcus.Set(float64(len(ConntrackStats))/2160000 + - *LCURuleCount.Gauge.Value/1000 + - (*LCUProcessedBytes.Gauge.Value*8)/360000000000) // (byte * 8)/ (60*60*1G)/10 - mutex.Unlock() + time.Sleep(PromethusDefaultPeriod) } } diff --git a/api/restapi/configure_loxilb_rest_api.go b/api/restapi/configure_loxilb_rest_api.go index 8d2735c45..1db9e93e1 100644 --- a/api/restapi/configure_loxilb_rest_api.go +++ b/api/restapi/configure_loxilb_rest_api.go @@ -158,6 +158,9 @@ func configureAPI(api *operations.LoxilbRestAPIAPI) http.Handler { // Prometheus api.GetMetricsHandler = operations.GetMetricsHandlerFunc(handler.ConfigGetPrometheusCounter) + api.GetConfigMetricsHandler = operations.GetConfigMetricsHandlerFunc(handler.ConfigGetPrometheusOption) + api.PostConfigMetricsHandler = operations.PostConfigMetricsHandlerFunc(handler.ConfigPostPrometheus) + api.DeleteConfigMetricsHandler = operations.DeleteConfigMetricsHandlerFunc(handler.ConfigDeletePrometheus) // BGP Peer api.GetConfigBgpNeighAllHandler = operations.GetConfigBgpNeighAllHandlerFunc(handler.ConfigGetBGPNeigh) diff --git a/api/restapi/embedded_spec.go b/api/restapi/embedded_spec.go index 2ea838773..9b3523357 100644 --- a/api/restapi/embedded_spec.go +++ b/api/restapi/embedded_spec.go @@ -93,7 +93,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -133,7 +133,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -201,7 +201,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -265,7 +265,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -329,7 +329,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -396,7 +396,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -465,7 +465,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -529,7 +529,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -591,7 +591,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -662,7 +662,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -745,7 +745,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -812,7 +812,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -876,7 +876,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -916,7 +916,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -978,7 +978,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1042,7 +1042,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1082,7 +1082,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1122,7 +1122,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1186,7 +1186,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1226,7 +1226,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1306,7 +1306,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1370,7 +1370,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1410,7 +1410,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1479,7 +1479,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1543,7 +1543,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1650,7 +1650,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1690,7 +1690,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1754,7 +1754,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1794,7 +1794,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1870,7 +1870,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1937,7 +1937,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -1977,7 +1977,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2028,7 +2028,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2116,7 +2116,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2211,7 +2211,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2273,7 +2273,108 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/metrics": { + "get": { + "summary": "Get prometheus config value", + "responses": { + "200": { + "description": "prometheus config value", + "schema": { + "$ref": "#/definitions/MetricsConfig" + } + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintenance mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + }, + "post": { + "summary": "turn on prometheus option", + "responses": { + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintenance mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + }, + "delete": { + "summary": "turn off prometheus option", + "responses": { + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2337,7 +2438,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2377,7 +2478,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2439,7 +2540,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2503,7 +2604,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2543,7 +2644,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2612,7 +2713,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2671,7 +2772,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2733,7 +2834,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2797,7 +2898,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2837,7 +2938,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2899,7 +3000,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -2939,7 +3040,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3003,7 +3104,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3067,7 +3168,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3136,7 +3237,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3200,7 +3301,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3240,7 +3341,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3302,7 +3403,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3366,7 +3467,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3406,7 +3507,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3475,7 +3576,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3521,7 +3622,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3561,7 +3662,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3600,7 +3701,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3651,7 +3752,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3700,7 +3801,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3764,7 +3865,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3804,7 +3905,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3866,7 +3967,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -3938,7 +4039,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -4003,7 +4104,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -4048,7 +4149,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -4088,7 +4189,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -4128,7 +4229,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -5105,6 +5206,18 @@ func init() { } } }, + "MetricsConfig": { + "type": "object", + "required": [ + "prometheus" + ], + "properties": { + "prometheus": { + "description": "value for prometheus enable or not", + "type": "boolean" + } + } + }, "MirrorEntry": { "type": "object", "properties": { @@ -5804,7 +5917,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -5844,7 +5957,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -5912,7 +6025,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -5976,7 +6089,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6040,7 +6153,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6107,7 +6220,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6176,7 +6289,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6240,7 +6353,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6302,7 +6415,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6373,7 +6486,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6456,7 +6569,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6523,7 +6636,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6587,7 +6700,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6627,7 +6740,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6689,7 +6802,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6753,7 +6866,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6793,7 +6906,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6833,7 +6946,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6897,7 +7010,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -6937,7 +7050,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7017,7 +7130,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7081,7 +7194,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7121,7 +7234,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7190,7 +7303,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7254,7 +7367,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7361,7 +7474,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7401,7 +7514,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7465,7 +7578,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7505,7 +7618,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7581,7 +7694,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7648,7 +7761,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7688,7 +7801,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7739,7 +7852,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7827,7 +7940,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7922,7 +8035,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -7984,7 +8097,108 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/config/metrics": { + "get": { + "summary": "Get prometheus config value", + "responses": { + "200": { + "description": "prometheus config value", + "schema": { + "$ref": "#/definitions/MetricsConfig" + } + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintenance mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + }, + "post": { + "summary": "turn on prometheus option", + "responses": { + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintenance mode", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + }, + "delete": { + "summary": "turn off prometheus option", + "responses": { + "204": { + "description": "OK" + }, + "400": { + "description": "Malformed arguments for API call", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "401": { + "description": "Invalid authentication credentials", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "503": { + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8048,7 +8262,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8088,7 +8302,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8150,7 +8364,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8214,7 +8428,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8254,7 +8468,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8323,7 +8537,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8382,7 +8596,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8444,7 +8658,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8508,7 +8722,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8548,7 +8762,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8610,7 +8824,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8650,7 +8864,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8714,7 +8928,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8778,7 +8992,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8847,7 +9061,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8911,7 +9125,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -8951,7 +9165,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9013,7 +9227,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9077,7 +9291,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9117,7 +9331,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9186,7 +9400,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9232,7 +9446,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9272,7 +9486,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9311,7 +9525,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9362,7 +9576,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9411,7 +9625,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9475,7 +9689,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9515,7 +9729,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9577,7 +9791,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9649,7 +9863,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9714,7 +9928,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9759,7 +9973,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9799,7 +10013,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -9839,7 +10053,7 @@ func init() { } }, "503": { - "description": "Maintanence mode", + "description": "Maintenance mode", "schema": { "$ref": "#/definitions/Error" } @@ -11378,6 +11592,18 @@ func init() { } } }, + "MetricsConfig": { + "type": "object", + "required": [ + "prometheus" + ], + "properties": { + "prometheus": { + "description": "value for prometheus enable or not", + "type": "boolean" + } + } + }, "MirrorEntry": { "type": "object", "properties": { diff --git a/api/restapi/handler/prometheus.go b/api/restapi/handler/prometheus.go index 0e9585035..5d0788898 100644 --- a/api/restapi/handler/prometheus.go +++ b/api/restapi/handler/prometheus.go @@ -16,6 +16,8 @@ package handler import ( + "github.com/loxilb-io/loxilb/api/models" + "github.com/loxilb-io/loxilb/api/prometheus" "net/http" "github.com/go-openapi/runtime" @@ -35,3 +37,29 @@ func ConfigGetPrometheusCounter(params operations.GetMetricsParams) middleware.R promhttp.Handler().ServeHTTP(w, params.HTTPRequest) }) } + +func ConfigGetPrometheusOption(params operations.GetConfigMetricsParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] Prometheus %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + return operations.NewGetConfigMetricsOK().WithPayload(&models.MetricsConfig{Prometheus: &options.Opts.Prometheus}) +} + +func ConfigPostPrometheus(params operations.PostConfigMetricsParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] Prometheus %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + err := prometheus.TurnOn() + if err != nil { + tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + return &ResultResponse{Result: err.Error()} + } + return &ResultResponse{Result: "Success"} +} + +func ConfigDeletePrometheus(params operations.DeleteConfigMetricsParams) middleware.Responder { + tk.LogIt(tk.LogDebug, "[API] Prometheus %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + err := prometheus.Off() + if err != nil { + tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + return &ResultResponse{Result: err.Error()} + } + + return &ResultResponse{Result: "Success"} +} diff --git a/api/restapi/operations/delete_config_metrics.go b/api/restapi/operations/delete_config_metrics.go new file mode 100644 index 000000000..eaf768f17 --- /dev/null +++ b/api/restapi/operations/delete_config_metrics.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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" +) + +// DeleteConfigMetricsHandlerFunc turns a function with the right signature into a delete config metrics handler +type DeleteConfigMetricsHandlerFunc func(DeleteConfigMetricsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn DeleteConfigMetricsHandlerFunc) Handle(params DeleteConfigMetricsParams) middleware.Responder { + return fn(params) +} + +// DeleteConfigMetricsHandler interface for that can handle valid delete config metrics params +type DeleteConfigMetricsHandler interface { + Handle(DeleteConfigMetricsParams) middleware.Responder +} + +// NewDeleteConfigMetrics creates a new http.Handler for the delete config metrics operation +func NewDeleteConfigMetrics(ctx *middleware.Context, handler DeleteConfigMetricsHandler) *DeleteConfigMetrics { + return &DeleteConfigMetrics{Context: ctx, Handler: handler} +} + +/* + DeleteConfigMetrics swagger:route DELETE /config/metrics deleteConfigMetrics + +turn off prometheus option +*/ +type DeleteConfigMetrics struct { + Context *middleware.Context + Handler DeleteConfigMetricsHandler +} + +func (o *DeleteConfigMetrics) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewDeleteConfigMetricsParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/restapi/operations/delete_config_metrics_parameters.go b/api/restapi/operations/delete_config_metrics_parameters.go new file mode 100644 index 000000000..4059e268a --- /dev/null +++ b/api/restapi/operations/delete_config_metrics_parameters.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewDeleteConfigMetricsParams creates a new DeleteConfigMetricsParams object +// +// There are no default values defined in the spec. +func NewDeleteConfigMetricsParams() DeleteConfigMetricsParams { + + return DeleteConfigMetricsParams{} +} + +// DeleteConfigMetricsParams contains all the bound params for the delete config metrics operation +// typically these are obtained from a http.Request +// +// swagger:parameters DeleteConfigMetrics +type DeleteConfigMetricsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewDeleteConfigMetricsParams() beforehand. +func (o *DeleteConfigMetricsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/restapi/operations/delete_config_metrics_responses.go b/api/restapi/operations/delete_config_metrics_responses.go new file mode 100644 index 000000000..e04201a0c --- /dev/null +++ b/api/restapi/operations/delete_config_metrics_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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/loxilb-io/loxilb/api/models" +) + +// DeleteConfigMetricsNoContentCode is the HTTP code returned for type DeleteConfigMetricsNoContent +const DeleteConfigMetricsNoContentCode int = 204 + +/* +DeleteConfigMetricsNoContent OK + +swagger:response deleteConfigMetricsNoContent +*/ +type DeleteConfigMetricsNoContent struct { +} + +// NewDeleteConfigMetricsNoContent creates DeleteConfigMetricsNoContent with default headers values +func NewDeleteConfigMetricsNoContent() *DeleteConfigMetricsNoContent { + + return &DeleteConfigMetricsNoContent{} +} + +// WriteResponse to the client +func (o *DeleteConfigMetricsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// DeleteConfigMetricsBadRequestCode is the HTTP code returned for type DeleteConfigMetricsBadRequest +const DeleteConfigMetricsBadRequestCode int = 400 + +/* +DeleteConfigMetricsBadRequest Malformed arguments for API call + +swagger:response deleteConfigMetricsBadRequest +*/ +type DeleteConfigMetricsBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigMetricsBadRequest creates DeleteConfigMetricsBadRequest with default headers values +func NewDeleteConfigMetricsBadRequest() *DeleteConfigMetricsBadRequest { + + return &DeleteConfigMetricsBadRequest{} +} + +// WithPayload adds the payload to the delete config metrics bad request response +func (o *DeleteConfigMetricsBadRequest) WithPayload(payload *models.Error) *DeleteConfigMetricsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config metrics bad request response +func (o *DeleteConfigMetricsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigMetricsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigMetricsUnauthorizedCode is the HTTP code returned for type DeleteConfigMetricsUnauthorized +const DeleteConfigMetricsUnauthorizedCode int = 401 + +/* +DeleteConfigMetricsUnauthorized Invalid authentication credentials + +swagger:response deleteConfigMetricsUnauthorized +*/ +type DeleteConfigMetricsUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigMetricsUnauthorized creates DeleteConfigMetricsUnauthorized with default headers values +func NewDeleteConfigMetricsUnauthorized() *DeleteConfigMetricsUnauthorized { + + return &DeleteConfigMetricsUnauthorized{} +} + +// WithPayload adds the payload to the delete config metrics unauthorized response +func (o *DeleteConfigMetricsUnauthorized) WithPayload(payload *models.Error) *DeleteConfigMetricsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config metrics unauthorized response +func (o *DeleteConfigMetricsUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigMetricsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigMetricsInternalServerErrorCode is the HTTP code returned for type DeleteConfigMetricsInternalServerError +const DeleteConfigMetricsInternalServerErrorCode int = 500 + +/* +DeleteConfigMetricsInternalServerError Internal service error + +swagger:response deleteConfigMetricsInternalServerError +*/ +type DeleteConfigMetricsInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigMetricsInternalServerError creates DeleteConfigMetricsInternalServerError with default headers values +func NewDeleteConfigMetricsInternalServerError() *DeleteConfigMetricsInternalServerError { + + return &DeleteConfigMetricsInternalServerError{} +} + +// WithPayload adds the payload to the delete config metrics internal server error response +func (o *DeleteConfigMetricsInternalServerError) WithPayload(payload *models.Error) *DeleteConfigMetricsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config metrics internal server error response +func (o *DeleteConfigMetricsInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigMetricsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// DeleteConfigMetricsServiceUnavailableCode is the HTTP code returned for type DeleteConfigMetricsServiceUnavailable +const DeleteConfigMetricsServiceUnavailableCode int = 503 + +/* +DeleteConfigMetricsServiceUnavailable Maintenance mode + +swagger:response deleteConfigMetricsServiceUnavailable +*/ +type DeleteConfigMetricsServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewDeleteConfigMetricsServiceUnavailable creates DeleteConfigMetricsServiceUnavailable with default headers values +func NewDeleteConfigMetricsServiceUnavailable() *DeleteConfigMetricsServiceUnavailable { + + return &DeleteConfigMetricsServiceUnavailable{} +} + +// WithPayload adds the payload to the delete config metrics service unavailable response +func (o *DeleteConfigMetricsServiceUnavailable) WithPayload(payload *models.Error) *DeleteConfigMetricsServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the delete config metrics service unavailable response +func (o *DeleteConfigMetricsServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *DeleteConfigMetricsServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/delete_config_metrics_urlbuilder.go b/api/restapi/operations/delete_config_metrics_urlbuilder.go new file mode 100644 index 000000000..c42d430ba --- /dev/null +++ b/api/restapi/operations/delete_config_metrics_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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" +) + +// DeleteConfigMetricsURL generates an URL for the delete config metrics operation +type DeleteConfigMetricsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *DeleteConfigMetricsURL) WithBasePath(bp string) *DeleteConfigMetricsURL { + 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 *DeleteConfigMetricsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *DeleteConfigMetricsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/metrics" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *DeleteConfigMetricsURL) 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 *DeleteConfigMetricsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *DeleteConfigMetricsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on DeleteConfigMetricsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on DeleteConfigMetricsURL") + } + + 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 *DeleteConfigMetricsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/operations/get_config_metrics.go b/api/restapi/operations/get_config_metrics.go new file mode 100644 index 000000000..85bbc6c3e --- /dev/null +++ b/api/restapi/operations/get_config_metrics.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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" +) + +// GetConfigMetricsHandlerFunc turns a function with the right signature into a get config metrics handler +type GetConfigMetricsHandlerFunc func(GetConfigMetricsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetConfigMetricsHandlerFunc) Handle(params GetConfigMetricsParams) middleware.Responder { + return fn(params) +} + +// GetConfigMetricsHandler interface for that can handle valid get config metrics params +type GetConfigMetricsHandler interface { + Handle(GetConfigMetricsParams) middleware.Responder +} + +// NewGetConfigMetrics creates a new http.Handler for the get config metrics operation +func NewGetConfigMetrics(ctx *middleware.Context, handler GetConfigMetricsHandler) *GetConfigMetrics { + return &GetConfigMetrics{Context: ctx, Handler: handler} +} + +/* + GetConfigMetrics swagger:route GET /config/metrics getConfigMetrics + +Get prometheus config value +*/ +type GetConfigMetrics struct { + Context *middleware.Context + Handler GetConfigMetricsHandler +} + +func (o *GetConfigMetrics) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetConfigMetricsParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/restapi/operations/get_config_metrics_parameters.go b/api/restapi/operations/get_config_metrics_parameters.go new file mode 100644 index 000000000..56eb8e40f --- /dev/null +++ b/api/restapi/operations/get_config_metrics_parameters.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetConfigMetricsParams creates a new GetConfigMetricsParams object +// +// There are no default values defined in the spec. +func NewGetConfigMetricsParams() GetConfigMetricsParams { + + return GetConfigMetricsParams{} +} + +// GetConfigMetricsParams contains all the bound params for the get config metrics operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetConfigMetrics +type GetConfigMetricsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetConfigMetricsParams() beforehand. +func (o *GetConfigMetricsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/restapi/operations/get_config_metrics_responses.go b/api/restapi/operations/get_config_metrics_responses.go new file mode 100644 index 000000000..329a0dc3b --- /dev/null +++ b/api/restapi/operations/get_config_metrics_responses.go @@ -0,0 +1,239 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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/loxilb-io/loxilb/api/models" +) + +// GetConfigMetricsOKCode is the HTTP code returned for type GetConfigMetricsOK +const GetConfigMetricsOKCode int = 200 + +/* +GetConfigMetricsOK prometheus config value + +swagger:response getConfigMetricsOK +*/ +type GetConfigMetricsOK struct { + + /* + In: Body + */ + Payload *models.MetricsConfig `json:"body,omitempty"` +} + +// NewGetConfigMetricsOK creates GetConfigMetricsOK with default headers values +func NewGetConfigMetricsOK() *GetConfigMetricsOK { + + return &GetConfigMetricsOK{} +} + +// WithPayload adds the payload to the get config metrics o k response +func (o *GetConfigMetricsOK) WithPayload(payload *models.MetricsConfig) *GetConfigMetricsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config metrics o k response +func (o *GetConfigMetricsOK) SetPayload(payload *models.MetricsConfig) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigMetricsOK) 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 + } + } +} + +// GetConfigMetricsBadRequestCode is the HTTP code returned for type GetConfigMetricsBadRequest +const GetConfigMetricsBadRequestCode int = 400 + +/* +GetConfigMetricsBadRequest Malformed arguments for API call + +swagger:response getConfigMetricsBadRequest +*/ +type GetConfigMetricsBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigMetricsBadRequest creates GetConfigMetricsBadRequest with default headers values +func NewGetConfigMetricsBadRequest() *GetConfigMetricsBadRequest { + + return &GetConfigMetricsBadRequest{} +} + +// WithPayload adds the payload to the get config metrics bad request response +func (o *GetConfigMetricsBadRequest) WithPayload(payload *models.Error) *GetConfigMetricsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config metrics bad request response +func (o *GetConfigMetricsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigMetricsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigMetricsUnauthorizedCode is the HTTP code returned for type GetConfigMetricsUnauthorized +const GetConfigMetricsUnauthorizedCode int = 401 + +/* +GetConfigMetricsUnauthorized Invalid authentication credentials + +swagger:response getConfigMetricsUnauthorized +*/ +type GetConfigMetricsUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigMetricsUnauthorized creates GetConfigMetricsUnauthorized with default headers values +func NewGetConfigMetricsUnauthorized() *GetConfigMetricsUnauthorized { + + return &GetConfigMetricsUnauthorized{} +} + +// WithPayload adds the payload to the get config metrics unauthorized response +func (o *GetConfigMetricsUnauthorized) WithPayload(payload *models.Error) *GetConfigMetricsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config metrics unauthorized response +func (o *GetConfigMetricsUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigMetricsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigMetricsInternalServerErrorCode is the HTTP code returned for type GetConfigMetricsInternalServerError +const GetConfigMetricsInternalServerErrorCode int = 500 + +/* +GetConfigMetricsInternalServerError Internal service error + +swagger:response getConfigMetricsInternalServerError +*/ +type GetConfigMetricsInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigMetricsInternalServerError creates GetConfigMetricsInternalServerError with default headers values +func NewGetConfigMetricsInternalServerError() *GetConfigMetricsInternalServerError { + + return &GetConfigMetricsInternalServerError{} +} + +// WithPayload adds the payload to the get config metrics internal server error response +func (o *GetConfigMetricsInternalServerError) WithPayload(payload *models.Error) *GetConfigMetricsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config metrics internal server error response +func (o *GetConfigMetricsInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigMetricsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// GetConfigMetricsServiceUnavailableCode is the HTTP code returned for type GetConfigMetricsServiceUnavailable +const GetConfigMetricsServiceUnavailableCode int = 503 + +/* +GetConfigMetricsServiceUnavailable Maintenance mode + +swagger:response getConfigMetricsServiceUnavailable +*/ +type GetConfigMetricsServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewGetConfigMetricsServiceUnavailable creates GetConfigMetricsServiceUnavailable with default headers values +func NewGetConfigMetricsServiceUnavailable() *GetConfigMetricsServiceUnavailable { + + return &GetConfigMetricsServiceUnavailable{} +} + +// WithPayload adds the payload to the get config metrics service unavailable response +func (o *GetConfigMetricsServiceUnavailable) WithPayload(payload *models.Error) *GetConfigMetricsServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get config metrics service unavailable response +func (o *GetConfigMetricsServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetConfigMetricsServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/get_config_metrics_urlbuilder.go b/api/restapi/operations/get_config_metrics_urlbuilder.go new file mode 100644 index 000000000..4b11d06d0 --- /dev/null +++ b/api/restapi/operations/get_config_metrics_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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" +) + +// GetConfigMetricsURL generates an URL for the get config metrics operation +type GetConfigMetricsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetConfigMetricsURL) WithBasePath(bp string) *GetConfigMetricsURL { + 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 *GetConfigMetricsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetConfigMetricsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/metrics" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetConfigMetricsURL) 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 *GetConfigMetricsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetConfigMetricsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetConfigMetricsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetConfigMetricsURL") + } + + 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 *GetConfigMetricsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/restapi/operations/loxilb_rest_api_api.go b/api/restapi/operations/loxilb_rest_api_api.go index 4d0909b75..fa9d67095 100644 --- a/api/restapi/operations/loxilb_rest_api_api.go +++ b/api/restapi/operations/loxilb_rest_api_api.go @@ -81,6 +81,9 @@ func NewLoxilbRestAPIAPI(spec *loads.Document) *LoxilbRestAPIAPI { DeleteConfigLoadbalancerNameLbNameHandler: DeleteConfigLoadbalancerNameLbNameHandlerFunc(func(params DeleteConfigLoadbalancerNameLbNameParams) middleware.Responder { return middleware.NotImplemented("operation DeleteConfigLoadbalancerNameLbName has not yet been implemented") }), + DeleteConfigMetricsHandler: DeleteConfigMetricsHandlerFunc(func(params DeleteConfigMetricsParams) middleware.Responder { + return middleware.NotImplemented("operation DeleteConfigMetrics has not yet been implemented") + }), DeleteConfigMirrorIdentIdentHandler: DeleteConfigMirrorIdentIdentHandlerFunc(func(params DeleteConfigMirrorIdentIdentParams) middleware.Responder { return middleware.NotImplemented("operation DeleteConfigMirrorIdentIdent has not yet been implemented") }), @@ -144,6 +147,9 @@ func NewLoxilbRestAPIAPI(spec *loads.Document) *LoxilbRestAPIAPI { GetConfigLoadbalancerAllHandler: GetConfigLoadbalancerAllHandlerFunc(func(params GetConfigLoadbalancerAllParams) middleware.Responder { return middleware.NotImplemented("operation GetConfigLoadbalancerAll has not yet been implemented") }), + GetConfigMetricsHandler: GetConfigMetricsHandlerFunc(func(params GetConfigMetricsParams) middleware.Responder { + return middleware.NotImplemented("operation GetConfigMetrics has not yet been implemented") + }), GetConfigMirrorAllHandler: GetConfigMirrorAllHandlerFunc(func(params GetConfigMirrorAllParams) middleware.Responder { return middleware.NotImplemented("operation GetConfigMirrorAll has not yet been implemented") }), @@ -222,6 +228,9 @@ func NewLoxilbRestAPIAPI(spec *loads.Document) *LoxilbRestAPIAPI { PostConfigLoadbalancerHandler: PostConfigLoadbalancerHandlerFunc(func(params PostConfigLoadbalancerParams) middleware.Responder { return middleware.NotImplemented("operation PostConfigLoadbalancer has not yet been implemented") }), + PostConfigMetricsHandler: PostConfigMetricsHandlerFunc(func(params PostConfigMetricsParams) middleware.Responder { + return middleware.NotImplemented("operation PostConfigMetrics has not yet been implemented") + }), PostConfigMirrorHandler: PostConfigMirrorHandlerFunc(func(params PostConfigMirrorParams) middleware.Responder { return middleware.NotImplemented("operation PostConfigMirror has not yet been implemented") }), @@ -317,6 +326,8 @@ type LoxilbRestAPIAPI struct { DeleteConfigLoadbalancerHosturlHosturlExternalipaddressIPAddressPortPortProtocolProtoHandler DeleteConfigLoadbalancerHosturlHosturlExternalipaddressIPAddressPortPortProtocolProtoHandler // DeleteConfigLoadbalancerNameLbNameHandler sets the operation handler for the delete config loadbalancer name lb name operation DeleteConfigLoadbalancerNameLbNameHandler DeleteConfigLoadbalancerNameLbNameHandler + // DeleteConfigMetricsHandler sets the operation handler for the delete config metrics operation + DeleteConfigMetricsHandler DeleteConfigMetricsHandler // DeleteConfigMirrorIdentIdentHandler sets the operation handler for the delete config mirror ident ident operation DeleteConfigMirrorIdentIdentHandler DeleteConfigMirrorIdentIdentHandler // DeleteConfigNeighborIPAddressDevIfNameHandler sets the operation handler for the delete config neighbor IP address dev if name operation @@ -359,6 +370,8 @@ type LoxilbRestAPIAPI struct { GetConfigIpv4addressAllHandler GetConfigIpv4addressAllHandler // GetConfigLoadbalancerAllHandler sets the operation handler for the get config loadbalancer all operation GetConfigLoadbalancerAllHandler GetConfigLoadbalancerAllHandler + // GetConfigMetricsHandler sets the operation handler for the get config metrics operation + GetConfigMetricsHandler GetConfigMetricsHandler // GetConfigMirrorAllHandler sets the operation handler for the get config mirror all operation GetConfigMirrorAllHandler GetConfigMirrorAllHandler // GetConfigNeighborAllHandler sets the operation handler for the get config neighbor all operation @@ -411,6 +424,8 @@ type LoxilbRestAPIAPI struct { PostConfigIpv4addressHandler PostConfigIpv4addressHandler // PostConfigLoadbalancerHandler sets the operation handler for the post config loadbalancer operation PostConfigLoadbalancerHandler PostConfigLoadbalancerHandler + // PostConfigMetricsHandler sets the operation handler for the post config metrics operation + PostConfigMetricsHandler PostConfigMetricsHandler // PostConfigMirrorHandler sets the operation handler for the post config mirror operation PostConfigMirrorHandler PostConfigMirrorHandler // PostConfigNeighborHandler sets the operation handler for the post config neighbor operation @@ -549,6 +564,9 @@ func (o *LoxilbRestAPIAPI) Validate() error { if o.DeleteConfigLoadbalancerNameLbNameHandler == nil { unregistered = append(unregistered, "DeleteConfigLoadbalancerNameLbNameHandler") } + if o.DeleteConfigMetricsHandler == nil { + unregistered = append(unregistered, "DeleteConfigMetricsHandler") + } if o.DeleteConfigMirrorIdentIdentHandler == nil { unregistered = append(unregistered, "DeleteConfigMirrorIdentIdentHandler") } @@ -612,6 +630,9 @@ func (o *LoxilbRestAPIAPI) Validate() error { if o.GetConfigLoadbalancerAllHandler == nil { unregistered = append(unregistered, "GetConfigLoadbalancerAllHandler") } + if o.GetConfigMetricsHandler == nil { + unregistered = append(unregistered, "GetConfigMetricsHandler") + } if o.GetConfigMirrorAllHandler == nil { unregistered = append(unregistered, "GetConfigMirrorAllHandler") } @@ -690,6 +711,9 @@ func (o *LoxilbRestAPIAPI) Validate() error { if o.PostConfigLoadbalancerHandler == nil { unregistered = append(unregistered, "PostConfigLoadbalancerHandler") } + if o.PostConfigMetricsHandler == nil { + unregistered = append(unregistered, "PostConfigMetricsHandler") + } if o.PostConfigMirrorHandler == nil { unregistered = append(unregistered, "PostConfigMirrorHandler") } @@ -866,6 +890,10 @@ func (o *LoxilbRestAPIAPI) initHandlerCache() { if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) } + o.handlers["DELETE"]["/config/metrics"] = NewDeleteConfigMetrics(o.context, o.DeleteConfigMetricsHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } o.handlers["DELETE"]["/config/mirror/ident/{ident}"] = NewDeleteConfigMirrorIdentIdent(o.context, o.DeleteConfigMirrorIdentIdentHandler) if o.handlers["DELETE"] == nil { o.handlers["DELETE"] = make(map[string]http.Handler) @@ -950,6 +978,10 @@ func (o *LoxilbRestAPIAPI) initHandlerCache() { if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) } + o.handlers["GET"]["/config/metrics"] = NewGetConfigMetrics(o.context, o.GetConfigMetricsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } o.handlers["GET"]["/config/mirror/all"] = NewGetConfigMirrorAll(o.context, o.GetConfigMirrorAllHandler) if o.handlers["GET"] == nil { o.handlers["GET"] = make(map[string]http.Handler) @@ -1054,6 +1086,10 @@ func (o *LoxilbRestAPIAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } + o.handlers["POST"]["/config/metrics"] = NewPostConfigMetrics(o.context, o.PostConfigMetricsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } o.handlers["POST"]["/config/mirror"] = NewPostConfigMirror(o.context, o.PostConfigMirrorHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) @@ -1136,6 +1172,6 @@ func (o *LoxilbRestAPIAPI) AddMiddlewareFor(method, path string, builder middlew } o.Init() if h, ok := o.handlers[um][path]; ok { - o.handlers[method][path] = builder(h) + o.handlers[um][path] = builder(h) } } diff --git a/api/restapi/operations/post_config_metrics.go b/api/restapi/operations/post_config_metrics.go new file mode 100644 index 000000000..4a71789d6 --- /dev/null +++ b/api/restapi/operations/post_config_metrics.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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" +) + +// PostConfigMetricsHandlerFunc turns a function with the right signature into a post config metrics handler +type PostConfigMetricsHandlerFunc func(PostConfigMetricsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn PostConfigMetricsHandlerFunc) Handle(params PostConfigMetricsParams) middleware.Responder { + return fn(params) +} + +// PostConfigMetricsHandler interface for that can handle valid post config metrics params +type PostConfigMetricsHandler interface { + Handle(PostConfigMetricsParams) middleware.Responder +} + +// NewPostConfigMetrics creates a new http.Handler for the post config metrics operation +func NewPostConfigMetrics(ctx *middleware.Context, handler PostConfigMetricsHandler) *PostConfigMetrics { + return &PostConfigMetrics{Context: ctx, Handler: handler} +} + +/* + PostConfigMetrics swagger:route POST /config/metrics postConfigMetrics + +turn on prometheus option +*/ +type PostConfigMetrics struct { + Context *middleware.Context + Handler PostConfigMetricsHandler +} + +func (o *PostConfigMetrics) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewPostConfigMetricsParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/api/restapi/operations/post_config_metrics_parameters.go b/api/restapi/operations/post_config_metrics_parameters.go new file mode 100644 index 000000000..d36cedfb7 --- /dev/null +++ b/api/restapi/operations/post_config_metrics_parameters.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewPostConfigMetricsParams creates a new PostConfigMetricsParams object +// +// There are no default values defined in the spec. +func NewPostConfigMetricsParams() PostConfigMetricsParams { + + return PostConfigMetricsParams{} +} + +// PostConfigMetricsParams contains all the bound params for the post config metrics operation +// typically these are obtained from a http.Request +// +// swagger:parameters PostConfigMetrics +type PostConfigMetricsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewPostConfigMetricsParams() beforehand. +func (o *PostConfigMetricsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/api/restapi/operations/post_config_metrics_responses.go b/api/restapi/operations/post_config_metrics_responses.go new file mode 100644 index 000000000..74462966f --- /dev/null +++ b/api/restapi/operations/post_config_metrics_responses.go @@ -0,0 +1,219 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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/loxilb-io/loxilb/api/models" +) + +// PostConfigMetricsNoContentCode is the HTTP code returned for type PostConfigMetricsNoContent +const PostConfigMetricsNoContentCode int = 204 + +/* +PostConfigMetricsNoContent OK + +swagger:response postConfigMetricsNoContent +*/ +type PostConfigMetricsNoContent struct { +} + +// NewPostConfigMetricsNoContent creates PostConfigMetricsNoContent with default headers values +func NewPostConfigMetricsNoContent() *PostConfigMetricsNoContent { + + return &PostConfigMetricsNoContent{} +} + +// WriteResponse to the client +func (o *PostConfigMetricsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses + + rw.WriteHeader(204) +} + +// PostConfigMetricsBadRequestCode is the HTTP code returned for type PostConfigMetricsBadRequest +const PostConfigMetricsBadRequestCode int = 400 + +/* +PostConfigMetricsBadRequest Malformed arguments for API call + +swagger:response postConfigMetricsBadRequest +*/ +type PostConfigMetricsBadRequest struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigMetricsBadRequest creates PostConfigMetricsBadRequest with default headers values +func NewPostConfigMetricsBadRequest() *PostConfigMetricsBadRequest { + + return &PostConfigMetricsBadRequest{} +} + +// WithPayload adds the payload to the post config metrics bad request response +func (o *PostConfigMetricsBadRequest) WithPayload(payload *models.Error) *PostConfigMetricsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config metrics bad request response +func (o *PostConfigMetricsBadRequest) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigMetricsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigMetricsUnauthorizedCode is the HTTP code returned for type PostConfigMetricsUnauthorized +const PostConfigMetricsUnauthorizedCode int = 401 + +/* +PostConfigMetricsUnauthorized Invalid authentication credentials + +swagger:response postConfigMetricsUnauthorized +*/ +type PostConfigMetricsUnauthorized struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigMetricsUnauthorized creates PostConfigMetricsUnauthorized with default headers values +func NewPostConfigMetricsUnauthorized() *PostConfigMetricsUnauthorized { + + return &PostConfigMetricsUnauthorized{} +} + +// WithPayload adds the payload to the post config metrics unauthorized response +func (o *PostConfigMetricsUnauthorized) WithPayload(payload *models.Error) *PostConfigMetricsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config metrics unauthorized response +func (o *PostConfigMetricsUnauthorized) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigMetricsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigMetricsInternalServerErrorCode is the HTTP code returned for type PostConfigMetricsInternalServerError +const PostConfigMetricsInternalServerErrorCode int = 500 + +/* +PostConfigMetricsInternalServerError Internal service error + +swagger:response postConfigMetricsInternalServerError +*/ +type PostConfigMetricsInternalServerError struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigMetricsInternalServerError creates PostConfigMetricsInternalServerError with default headers values +func NewPostConfigMetricsInternalServerError() *PostConfigMetricsInternalServerError { + + return &PostConfigMetricsInternalServerError{} +} + +// WithPayload adds the payload to the post config metrics internal server error response +func (o *PostConfigMetricsInternalServerError) WithPayload(payload *models.Error) *PostConfigMetricsInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config metrics internal server error response +func (o *PostConfigMetricsInternalServerError) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigMetricsInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// PostConfigMetricsServiceUnavailableCode is the HTTP code returned for type PostConfigMetricsServiceUnavailable +const PostConfigMetricsServiceUnavailableCode int = 503 + +/* +PostConfigMetricsServiceUnavailable Maintenance mode + +swagger:response postConfigMetricsServiceUnavailable +*/ +type PostConfigMetricsServiceUnavailable struct { + + /* + In: Body + */ + Payload *models.Error `json:"body,omitempty"` +} + +// NewPostConfigMetricsServiceUnavailable creates PostConfigMetricsServiceUnavailable with default headers values +func NewPostConfigMetricsServiceUnavailable() *PostConfigMetricsServiceUnavailable { + + return &PostConfigMetricsServiceUnavailable{} +} + +// WithPayload adds the payload to the post config metrics service unavailable response +func (o *PostConfigMetricsServiceUnavailable) WithPayload(payload *models.Error) *PostConfigMetricsServiceUnavailable { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the post config metrics service unavailable response +func (o *PostConfigMetricsServiceUnavailable) SetPayload(payload *models.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *PostConfigMetricsServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(503) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/api/restapi/operations/post_config_metrics_urlbuilder.go b/api/restapi/operations/post_config_metrics_urlbuilder.go new file mode 100644 index 000000000..51660a76d --- /dev/null +++ b/api/restapi/operations/post_config_metrics_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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" +) + +// PostConfigMetricsURL generates an URL for the post config metrics operation +type PostConfigMetricsURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *PostConfigMetricsURL) WithBasePath(bp string) *PostConfigMetricsURL { + 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 *PostConfigMetricsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *PostConfigMetricsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/config/metrics" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/netlox/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *PostConfigMetricsURL) 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 *PostConfigMetricsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *PostConfigMetricsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on PostConfigMetricsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on PostConfigMetricsURL") + } + + 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 *PostConfigMetricsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/api/swagger.yml b/api/swagger.yml index 3fb8f9a84..66dd91717 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -2742,6 +2742,72 @@ paths: description: Metrics in prometheus text format schema: type: string + '/config/metrics': + get: + summary: Get prometheus config value + responses: + '200': + description: prometheus config value + schema: + $ref: '#/definitions/MetricsConfig' + '400': + description: Malformed arguments for API call + schema: + $ref: '#/definitions/Error' + '401': + description: Invalid authentication credentials + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintenance mode + schema: + $ref: '#/definitions/Error' + post: + summary: turn on prometheus option + responses: + '204': + description: OK + '400': + description: Malformed arguments for API call + schema: + $ref: '#/definitions/Error' + '401': + description: Invalid authentication credentials + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintenance mode + schema: + $ref: '#/definitions/Error' + delete: + summary: turn off prometheus option + responses: + '204': + description: OK + '400': + description: Malformed arguments for API call + schema: + $ref: '#/definitions/Error' + '401': + description: Invalid authentication credentials + schema: + $ref: '#/definitions/Error' + '500': + description: Internal service error + schema: + $ref: '#/definitions/Error' + '503': + description: Maintenance mode + schema: + $ref: '#/definitions/Error' #---------------------------------------------- # BFD @@ -4032,3 +4098,11 @@ definitions: type: integer format: uint8 description: Retry Count to detect failure + MetricsConfig: + type: object + required: + - prometheus + properties: + prometheus: + type: boolean + description: value for prometheus enable or not \ No newline at end of file