api/v2: move generated client code from test to api/v2 (#1792)
- Move the generated api/v2 client code out of the test directory and into the api/v2 directory with models and restapi. - Remove duplicate models directory - Update tests to use api/v2 package for models and client Signed-off-by: Paul Gier <pgier@redhat.com>
This commit is contained in:
parent
c637ca1a6e
commit
8688c7b9ad
15
Makefile
15
Makefile
|
@ -35,7 +35,7 @@ ui/app/script.js: $(shell find ui/app/src -iname *.elm) api/v2/openapi.yaml
|
|||
cd $(FRONTEND_DIR) && $(MAKE) script.js
|
||||
|
||||
.PHONY: apiv2
|
||||
apiv2: api/v2/models api/v2/restapi test/with_api_v2/api_v2_client/models test/with_api_v2/api_v2_client/client
|
||||
apiv2: api/v2/models api/v2/restapi api/v2/client
|
||||
|
||||
SWAGGER = docker run \
|
||||
--user=$(shell id -u $(USER)):$(shell id -g $(USER)) \
|
||||
|
@ -43,20 +43,15 @@ SWAGGER = docker run \
|
|||
-v $(shell pwd):/go/src/github.com/prometheus/alertmanager \
|
||||
-w /go/src/github.com/prometheus/alertmanager quay.io/goswagger/swagger:v0.18.0
|
||||
|
||||
api/v2/models api/v2/restapi: api/v2/openapi.yaml
|
||||
-rm -r api/v2/{models,restapi}
|
||||
api/v2/models api/v2/restapi api/v2/client: api/v2/openapi.yaml
|
||||
-rm -r api/v2/{client,models,restapi}
|
||||
$(SWAGGER) generate server -f api/v2/openapi.yaml --copyright-file=COPYRIGHT.txt --exclude-main -A alertmanager --target api/v2/
|
||||
|
||||
test/with_api_v2/api_v2_client/models test/with_api_v2/api_v2_client/client: api/v2/openapi.yaml
|
||||
-rm -r test/with_api_v1/api_v2_client; mkdir -p test/with_api_v2/api_v2_client
|
||||
$(SWAGGER) generate client -f api/v2/openapi.yaml --copyright-file=COPYRIGHT.txt --target test/with_api_v2/api_v2_client
|
||||
$(SWAGGER) generate client -f api/v2/openapi.yaml --copyright-file=COPYRIGHT.txt --skip-models --target api/v2
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
- @rm -rf asset/assets_vfsdata.go \
|
||||
api/v2/models api/v2/restapi \
|
||||
test/with_api_v2/api_v2_client/models \
|
||||
test/with_api_v2/api_v2_client/client
|
||||
api/v2/models api/v2/restapi api/v2/client
|
||||
- @cd $(FRONTEND_DIR) && $(MAKE) clean
|
||||
|
||||
.PHONY: test
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/models"
|
||||
models "github.com/prometheus/alertmanager/api/v2/models"
|
||||
)
|
||||
|
||||
// GetAlertsReader is a Reader for the GetAlerts structure.
|
|
@ -30,7 +30,7 @@ import (
|
|||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/models"
|
||||
models "github.com/prometheus/alertmanager/api/v2/models"
|
||||
)
|
||||
|
||||
// NewPostAlertsParams creates a new PostAlertsParams object
|
|
@ -25,10 +25,10 @@ import (
|
|||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/client/alert"
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/client/general"
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/client/receiver"
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/client/silence"
|
||||
"github.com/prometheus/alertmanager/api/v2/client/alert"
|
||||
"github.com/prometheus/alertmanager/api/v2/client/general"
|
||||
"github.com/prometheus/alertmanager/api/v2/client/receiver"
|
||||
"github.com/prometheus/alertmanager/api/v2/client/silence"
|
||||
)
|
||||
|
||||
// Default alertmanager HTTP client.
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/models"
|
||||
models "github.com/prometheus/alertmanager/api/v2/models"
|
||||
)
|
||||
|
||||
// GetStatusReader is a Reader for the GetStatus structure.
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/models"
|
||||
models "github.com/prometheus/alertmanager/api/v2/models"
|
||||
)
|
||||
|
||||
// GetReceiversReader is a Reader for the GetReceivers structure.
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/models"
|
||||
models "github.com/prometheus/alertmanager/api/v2/models"
|
||||
)
|
||||
|
||||
// GetSilenceReader is a Reader for the GetSilence structure.
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/models"
|
||||
models "github.com/prometheus/alertmanager/api/v2/models"
|
||||
)
|
||||
|
||||
// GetSilencesReader is a Reader for the GetSilences structure.
|
|
@ -30,7 +30,7 @@ import (
|
|||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
models "github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/models"
|
||||
models "github.com/prometheus/alertmanager/api/v2/models"
|
||||
)
|
||||
|
||||
// NewPostSilencesParams creates a new PostSilencesParams object
|
|
@ -29,10 +29,10 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
apiclient "github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/client"
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/client/alert"
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/client/general"
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/models"
|
||||
apiclient "github.com/prometheus/alertmanager/api/v2/client"
|
||||
"github.com/prometheus/alertmanager/api/v2/client/alert"
|
||||
"github.com/prometheus/alertmanager/api/v2/client/general"
|
||||
"github.com/prometheus/alertmanager/api/v2/models"
|
||||
|
||||
httptransport "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
|
|
@ -19,10 +19,10 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/prometheus/alertmanager/api/v2/client/alert"
|
||||
"github.com/prometheus/alertmanager/api/v2/client/silence"
|
||||
"github.com/prometheus/alertmanager/api/v2/models"
|
||||
a "github.com/prometheus/alertmanager/test/with_api_v2"
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/client/alert"
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/client/silence"
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/models"
|
||||
"github.com/prometheus/common/model"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// Alert alert
|
||||
// swagger:model alert
|
||||
type Alert struct {
|
||||
|
||||
// generator URL
|
||||
// Format: uri
|
||||
GeneratorURL strfmt.URI `json:"generatorURL,omitempty"`
|
||||
|
||||
// labels
|
||||
// Required: true
|
||||
Labels LabelSet `json:"labels"`
|
||||
}
|
||||
|
||||
// Validate validates this alert
|
||||
func (m *Alert) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateGeneratorURL(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateLabels(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Alert) validateGeneratorURL(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.GeneratorURL) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("generatorURL", "body", "uri", m.GeneratorURL.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Alert) validateLabels(formats strfmt.Registry) error {
|
||||
|
||||
if err := m.Labels.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("labels")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *Alert) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *Alert) UnmarshalBinary(b []byte) error {
|
||||
var res Alert
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
"encoding/json"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// AlertStatus alert status
|
||||
// swagger:model alertStatus
|
||||
type AlertStatus struct {
|
||||
|
||||
// inhibited by
|
||||
// Required: true
|
||||
InhibitedBy []string `json:"inhibitedBy"`
|
||||
|
||||
// silenced by
|
||||
// Required: true
|
||||
SilencedBy []string `json:"silencedBy"`
|
||||
|
||||
// state
|
||||
// Required: true
|
||||
// Enum: [unprocessed active suppressed]
|
||||
State *string `json:"state"`
|
||||
}
|
||||
|
||||
// Validate validates this alert status
|
||||
func (m *AlertStatus) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateInhibitedBy(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateSilencedBy(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateState(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AlertStatus) validateInhibitedBy(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("inhibitedBy", "body", m.InhibitedBy); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AlertStatus) validateSilencedBy(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("silencedBy", "body", m.SilencedBy); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var alertStatusTypeStatePropEnum []interface{}
|
||||
|
||||
func init() {
|
||||
var res []string
|
||||
if err := json.Unmarshal([]byte(`["unprocessed","active","suppressed"]`), &res); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, v := range res {
|
||||
alertStatusTypeStatePropEnum = append(alertStatusTypeStatePropEnum, v)
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
// AlertStatusStateUnprocessed captures enum value "unprocessed"
|
||||
AlertStatusStateUnprocessed string = "unprocessed"
|
||||
|
||||
// AlertStatusStateActive captures enum value "active"
|
||||
AlertStatusStateActive string = "active"
|
||||
|
||||
// AlertStatusStateSuppressed captures enum value "suppressed"
|
||||
AlertStatusStateSuppressed string = "suppressed"
|
||||
)
|
||||
|
||||
// prop value enum
|
||||
func (m *AlertStatus) validateStateEnum(path, location string, value string) error {
|
||||
if err := validate.Enum(path, location, value, alertStatusTypeStatePropEnum); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AlertStatus) validateState(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("state", "body", m.State); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// value enum
|
||||
if err := m.validateStateEnum("state", "body", *m.State); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *AlertStatus) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *AlertStatus) UnmarshalBinary(b []byte) error {
|
||||
var res AlertStatus
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// AlertmanagerConfig alertmanager config
|
||||
// swagger:model alertmanagerConfig
|
||||
type AlertmanagerConfig struct {
|
||||
|
||||
// original
|
||||
// Required: true
|
||||
Original *string `json:"original"`
|
||||
}
|
||||
|
||||
// Validate validates this alertmanager config
|
||||
func (m *AlertmanagerConfig) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateOriginal(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AlertmanagerConfig) validateOriginal(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("original", "body", m.Original); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *AlertmanagerConfig) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *AlertmanagerConfig) UnmarshalBinary(b []byte) error {
|
||||
var res AlertmanagerConfig
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// AlertmanagerStatus alertmanager status
|
||||
// swagger:model alertmanagerStatus
|
||||
type AlertmanagerStatus struct {
|
||||
|
||||
// cluster
|
||||
// Required: true
|
||||
Cluster *ClusterStatus `json:"cluster"`
|
||||
|
||||
// config
|
||||
// Required: true
|
||||
Config *AlertmanagerConfig `json:"config"`
|
||||
|
||||
// uptime
|
||||
// Required: true
|
||||
// Format: date-time
|
||||
Uptime *strfmt.DateTime `json:"uptime"`
|
||||
|
||||
// version info
|
||||
// Required: true
|
||||
VersionInfo *VersionInfo `json:"versionInfo"`
|
||||
}
|
||||
|
||||
// Validate validates this alertmanager status
|
||||
func (m *AlertmanagerStatus) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateCluster(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateConfig(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateUptime(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateVersionInfo(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AlertmanagerStatus) validateCluster(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("cluster", "body", m.Cluster); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if m.Cluster != nil {
|
||||
if err := m.Cluster.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("cluster")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AlertmanagerStatus) validateConfig(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("config", "body", m.Config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if m.Config != nil {
|
||||
if err := m.Config.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("config")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AlertmanagerStatus) validateUptime(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("uptime", "body", m.Uptime); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("uptime", "body", "date-time", m.Uptime.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *AlertmanagerStatus) validateVersionInfo(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("versionInfo", "body", m.VersionInfo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if m.VersionInfo != nil {
|
||||
if err := m.VersionInfo.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("versionInfo")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *AlertmanagerStatus) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *AlertmanagerStatus) UnmarshalBinary(b []byte) error {
|
||||
var res AlertmanagerStatus
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// ClusterStatus cluster status
|
||||
// swagger:model clusterStatus
|
||||
type ClusterStatus struct {
|
||||
|
||||
// name
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
// peers
|
||||
// Minimum: 0
|
||||
Peers []*PeerStatus `json:"peers"`
|
||||
|
||||
// status
|
||||
// Required: true
|
||||
// Enum: [ready settling disabled]
|
||||
Status *string `json:"status"`
|
||||
}
|
||||
|
||||
// Validate validates this cluster status
|
||||
func (m *ClusterStatus) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validatePeers(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateStatus(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ClusterStatus) validatePeers(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Peers) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Peers); i++ {
|
||||
if swag.IsZero(m.Peers[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Peers[i] != nil {
|
||||
if err := m.Peers[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("peers" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var clusterStatusTypeStatusPropEnum []interface{}
|
||||
|
||||
func init() {
|
||||
var res []string
|
||||
if err := json.Unmarshal([]byte(`["ready","settling","disabled"]`), &res); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, v := range res {
|
||||
clusterStatusTypeStatusPropEnum = append(clusterStatusTypeStatusPropEnum, v)
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
// ClusterStatusStatusReady captures enum value "ready"
|
||||
ClusterStatusStatusReady string = "ready"
|
||||
|
||||
// ClusterStatusStatusSettling captures enum value "settling"
|
||||
ClusterStatusStatusSettling string = "settling"
|
||||
|
||||
// ClusterStatusStatusDisabled captures enum value "disabled"
|
||||
ClusterStatusStatusDisabled string = "disabled"
|
||||
)
|
||||
|
||||
// prop value enum
|
||||
func (m *ClusterStatus) validateStatusEnum(path, location string, value string) error {
|
||||
if err := validate.Enum(path, location, value, clusterStatusTypeStatusPropEnum); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *ClusterStatus) validateStatus(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("status", "body", m.Status); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// value enum
|
||||
if err := m.validateStatusEnum("status", "body", *m.Status); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *ClusterStatus) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *ClusterStatus) UnmarshalBinary(b []byte) error {
|
||||
var res ClusterStatus
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,327 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// GettableAlert gettable alert
|
||||
// swagger:model gettableAlert
|
||||
type GettableAlert struct {
|
||||
|
||||
// annotations
|
||||
// Required: true
|
||||
Annotations LabelSet `json:"annotations"`
|
||||
|
||||
// ends at
|
||||
// Required: true
|
||||
// Format: date-time
|
||||
EndsAt *strfmt.DateTime `json:"endsAt"`
|
||||
|
||||
// fingerprint
|
||||
// Required: true
|
||||
Fingerprint *string `json:"fingerprint"`
|
||||
|
||||
// receivers
|
||||
// Required: true
|
||||
Receivers []*Receiver `json:"receivers"`
|
||||
|
||||
// starts at
|
||||
// Required: true
|
||||
// Format: date-time
|
||||
StartsAt *strfmt.DateTime `json:"startsAt"`
|
||||
|
||||
// status
|
||||
// Required: true
|
||||
Status *AlertStatus `json:"status"`
|
||||
|
||||
// updated at
|
||||
// Required: true
|
||||
// Format: date-time
|
||||
UpdatedAt *strfmt.DateTime `json:"updatedAt"`
|
||||
|
||||
Alert
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals this object from a JSON structure
|
||||
func (m *GettableAlert) UnmarshalJSON(raw []byte) error {
|
||||
// AO0
|
||||
var dataAO0 struct {
|
||||
Annotations LabelSet `json:"annotations"`
|
||||
|
||||
EndsAt *strfmt.DateTime `json:"endsAt"`
|
||||
|
||||
Fingerprint *string `json:"fingerprint"`
|
||||
|
||||
Receivers []*Receiver `json:"receivers"`
|
||||
|
||||
StartsAt *strfmt.DateTime `json:"startsAt"`
|
||||
|
||||
Status *AlertStatus `json:"status"`
|
||||
|
||||
UpdatedAt *strfmt.DateTime `json:"updatedAt"`
|
||||
}
|
||||
if err := swag.ReadJSON(raw, &dataAO0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m.Annotations = dataAO0.Annotations
|
||||
|
||||
m.EndsAt = dataAO0.EndsAt
|
||||
|
||||
m.Fingerprint = dataAO0.Fingerprint
|
||||
|
||||
m.Receivers = dataAO0.Receivers
|
||||
|
||||
m.StartsAt = dataAO0.StartsAt
|
||||
|
||||
m.Status = dataAO0.Status
|
||||
|
||||
m.UpdatedAt = dataAO0.UpdatedAt
|
||||
|
||||
// AO1
|
||||
var aO1 Alert
|
||||
if err := swag.ReadJSON(raw, &aO1); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Alert = aO1
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON marshals this object to a JSON structure
|
||||
func (m GettableAlert) MarshalJSON() ([]byte, error) {
|
||||
_parts := make([][]byte, 0, 2)
|
||||
|
||||
var dataAO0 struct {
|
||||
Annotations LabelSet `json:"annotations"`
|
||||
|
||||
EndsAt *strfmt.DateTime `json:"endsAt"`
|
||||
|
||||
Fingerprint *string `json:"fingerprint"`
|
||||
|
||||
Receivers []*Receiver `json:"receivers"`
|
||||
|
||||
StartsAt *strfmt.DateTime `json:"startsAt"`
|
||||
|
||||
Status *AlertStatus `json:"status"`
|
||||
|
||||
UpdatedAt *strfmt.DateTime `json:"updatedAt"`
|
||||
}
|
||||
|
||||
dataAO0.Annotations = m.Annotations
|
||||
|
||||
dataAO0.EndsAt = m.EndsAt
|
||||
|
||||
dataAO0.Fingerprint = m.Fingerprint
|
||||
|
||||
dataAO0.Receivers = m.Receivers
|
||||
|
||||
dataAO0.StartsAt = m.StartsAt
|
||||
|
||||
dataAO0.Status = m.Status
|
||||
|
||||
dataAO0.UpdatedAt = m.UpdatedAt
|
||||
|
||||
jsonDataAO0, errAO0 := swag.WriteJSON(dataAO0)
|
||||
if errAO0 != nil {
|
||||
return nil, errAO0
|
||||
}
|
||||
_parts = append(_parts, jsonDataAO0)
|
||||
|
||||
aO1, err := swag.WriteJSON(m.Alert)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_parts = append(_parts, aO1)
|
||||
|
||||
return swag.ConcatJSON(_parts...), nil
|
||||
}
|
||||
|
||||
// Validate validates this gettable alert
|
||||
func (m *GettableAlert) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateAnnotations(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateEndsAt(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateFingerprint(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateReceivers(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateStartsAt(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateStatus(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateUpdatedAt(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
// validation for a type composition with Alert
|
||||
if err := m.Alert.Validate(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GettableAlert) validateAnnotations(formats strfmt.Registry) error {
|
||||
|
||||
if err := m.Annotations.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("annotations")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GettableAlert) validateEndsAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("endsAt", "body", m.EndsAt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("endsAt", "body", "date-time", m.EndsAt.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GettableAlert) validateFingerprint(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("fingerprint", "body", m.Fingerprint); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GettableAlert) validateReceivers(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("receivers", "body", m.Receivers); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := 0; i < len(m.Receivers); i++ {
|
||||
if swag.IsZero(m.Receivers[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m.Receivers[i] != nil {
|
||||
if err := m.Receivers[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("receivers" + "." + strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GettableAlert) validateStartsAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("startsAt", "body", m.StartsAt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("startsAt", "body", "date-time", m.StartsAt.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GettableAlert) validateStatus(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("status", "body", m.Status); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if m.Status != nil {
|
||||
if err := m.Status.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("status")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GettableAlert) validateUpdatedAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("updatedAt", "body", m.UpdatedAt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("updatedAt", "body", "date-time", m.UpdatedAt.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *GettableAlert) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *GettableAlert) UnmarshalBinary(b []byte) error {
|
||||
var res GettableAlert
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// GettableAlerts gettable alerts
|
||||
// swagger:model gettableAlerts
|
||||
type GettableAlerts []*GettableAlert
|
||||
|
||||
// Validate validates this gettable alerts
|
||||
func (m GettableAlerts) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
for i := 0; i < len(m); i++ {
|
||||
if swag.IsZero(m[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m[i] != nil {
|
||||
if err := m[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName(strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// GettableSilence gettable silence
|
||||
// swagger:model gettableSilence
|
||||
type GettableSilence struct {
|
||||
|
||||
// id
|
||||
// Required: true
|
||||
ID *string `json:"id"`
|
||||
|
||||
// status
|
||||
// Required: true
|
||||
Status *SilenceStatus `json:"status"`
|
||||
|
||||
// updated at
|
||||
// Required: true
|
||||
// Format: date-time
|
||||
UpdatedAt *strfmt.DateTime `json:"updatedAt"`
|
||||
|
||||
Silence
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals this object from a JSON structure
|
||||
func (m *GettableSilence) UnmarshalJSON(raw []byte) error {
|
||||
// AO0
|
||||
var dataAO0 struct {
|
||||
ID *string `json:"id"`
|
||||
|
||||
Status *SilenceStatus `json:"status"`
|
||||
|
||||
UpdatedAt *strfmt.DateTime `json:"updatedAt"`
|
||||
}
|
||||
if err := swag.ReadJSON(raw, &dataAO0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m.ID = dataAO0.ID
|
||||
|
||||
m.Status = dataAO0.Status
|
||||
|
||||
m.UpdatedAt = dataAO0.UpdatedAt
|
||||
|
||||
// AO1
|
||||
var aO1 Silence
|
||||
if err := swag.ReadJSON(raw, &aO1); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Silence = aO1
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON marshals this object to a JSON structure
|
||||
func (m GettableSilence) MarshalJSON() ([]byte, error) {
|
||||
_parts := make([][]byte, 0, 2)
|
||||
|
||||
var dataAO0 struct {
|
||||
ID *string `json:"id"`
|
||||
|
||||
Status *SilenceStatus `json:"status"`
|
||||
|
||||
UpdatedAt *strfmt.DateTime `json:"updatedAt"`
|
||||
}
|
||||
|
||||
dataAO0.ID = m.ID
|
||||
|
||||
dataAO0.Status = m.Status
|
||||
|
||||
dataAO0.UpdatedAt = m.UpdatedAt
|
||||
|
||||
jsonDataAO0, errAO0 := swag.WriteJSON(dataAO0)
|
||||
if errAO0 != nil {
|
||||
return nil, errAO0
|
||||
}
|
||||
_parts = append(_parts, jsonDataAO0)
|
||||
|
||||
aO1, err := swag.WriteJSON(m.Silence)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_parts = append(_parts, aO1)
|
||||
|
||||
return swag.ConcatJSON(_parts...), nil
|
||||
}
|
||||
|
||||
// Validate validates this gettable silence
|
||||
func (m *GettableSilence) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateID(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateStatus(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateUpdatedAt(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
// validation for a type composition with Silence
|
||||
if err := m.Silence.Validate(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GettableSilence) validateID(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("id", "body", m.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GettableSilence) validateStatus(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("status", "body", m.Status); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if m.Status != nil {
|
||||
if err := m.Status.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("status")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GettableSilence) validateUpdatedAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("updatedAt", "body", m.UpdatedAt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("updatedAt", "body", "date-time", m.UpdatedAt.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *GettableSilence) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *GettableSilence) UnmarshalBinary(b []byte) error {
|
||||
var res GettableSilence
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// GettableSilences gettable silences
|
||||
// swagger:model gettableSilences
|
||||
type GettableSilences []*GettableSilence
|
||||
|
||||
// Validate validates this gettable silences
|
||||
func (m GettableSilences) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
for i := 0; i < len(m); i++ {
|
||||
if swag.IsZero(m[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m[i] != nil {
|
||||
if err := m[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName(strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// LabelSet label set
|
||||
// swagger:model labelSet
|
||||
type LabelSet map[string]string
|
||||
|
||||
// Validate validates this label set
|
||||
func (m LabelSet) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// Matcher matcher
|
||||
// swagger:model matcher
|
||||
type Matcher struct {
|
||||
|
||||
// is regex
|
||||
// Required: true
|
||||
IsRegex *bool `json:"isRegex"`
|
||||
|
||||
// name
|
||||
// Required: true
|
||||
Name *string `json:"name"`
|
||||
|
||||
// value
|
||||
// Required: true
|
||||
Value *string `json:"value"`
|
||||
}
|
||||
|
||||
// Validate validates this matcher
|
||||
func (m *Matcher) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateIsRegex(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateName(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateValue(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Matcher) validateIsRegex(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("isRegex", "body", m.IsRegex); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Matcher) validateName(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("name", "body", m.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Matcher) validateValue(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("value", "body", m.Value); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *Matcher) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *Matcher) UnmarshalBinary(b []byte) error {
|
||||
var res Matcher
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// Matchers matchers
|
||||
// swagger:model matchers
|
||||
type Matchers []*Matcher
|
||||
|
||||
// Validate validates this matchers
|
||||
func (m Matchers) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
iMatchersSize := int64(len(m))
|
||||
|
||||
if err := validate.MinItems("", "body", iMatchersSize, 1); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := 0; i < len(m); i++ {
|
||||
if swag.IsZero(m[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m[i] != nil {
|
||||
if err := m[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName(strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// PeerStatus peer status
|
||||
// swagger:model peerStatus
|
||||
type PeerStatus struct {
|
||||
|
||||
// address
|
||||
// Required: true
|
||||
Address *string `json:"address"`
|
||||
|
||||
// name
|
||||
// Required: true
|
||||
Name *string `json:"name"`
|
||||
}
|
||||
|
||||
// Validate validates this peer status
|
||||
func (m *PeerStatus) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateAddress(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateName(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PeerStatus) validateAddress(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("address", "body", m.Address); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PeerStatus) validateName(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("name", "body", m.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *PeerStatus) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *PeerStatus) UnmarshalBinary(b []byte) error {
|
||||
var res PeerStatus
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,196 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// PostableAlert postable alert
|
||||
// swagger:model postableAlert
|
||||
type PostableAlert struct {
|
||||
|
||||
// annotations
|
||||
Annotations LabelSet `json:"annotations,omitempty"`
|
||||
|
||||
// ends at
|
||||
// Format: date-time
|
||||
EndsAt strfmt.DateTime `json:"endsAt,omitempty"`
|
||||
|
||||
// starts at
|
||||
// Format: date-time
|
||||
StartsAt strfmt.DateTime `json:"startsAt,omitempty"`
|
||||
|
||||
Alert
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals this object from a JSON structure
|
||||
func (m *PostableAlert) UnmarshalJSON(raw []byte) error {
|
||||
// AO0
|
||||
var dataAO0 struct {
|
||||
Annotations LabelSet `json:"annotations,omitempty"`
|
||||
|
||||
EndsAt strfmt.DateTime `json:"endsAt,omitempty"`
|
||||
|
||||
StartsAt strfmt.DateTime `json:"startsAt,omitempty"`
|
||||
}
|
||||
if err := swag.ReadJSON(raw, &dataAO0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m.Annotations = dataAO0.Annotations
|
||||
|
||||
m.EndsAt = dataAO0.EndsAt
|
||||
|
||||
m.StartsAt = dataAO0.StartsAt
|
||||
|
||||
// AO1
|
||||
var aO1 Alert
|
||||
if err := swag.ReadJSON(raw, &aO1); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Alert = aO1
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON marshals this object to a JSON structure
|
||||
func (m PostableAlert) MarshalJSON() ([]byte, error) {
|
||||
_parts := make([][]byte, 0, 2)
|
||||
|
||||
var dataAO0 struct {
|
||||
Annotations LabelSet `json:"annotations,omitempty"`
|
||||
|
||||
EndsAt strfmt.DateTime `json:"endsAt,omitempty"`
|
||||
|
||||
StartsAt strfmt.DateTime `json:"startsAt,omitempty"`
|
||||
}
|
||||
|
||||
dataAO0.Annotations = m.Annotations
|
||||
|
||||
dataAO0.EndsAt = m.EndsAt
|
||||
|
||||
dataAO0.StartsAt = m.StartsAt
|
||||
|
||||
jsonDataAO0, errAO0 := swag.WriteJSON(dataAO0)
|
||||
if errAO0 != nil {
|
||||
return nil, errAO0
|
||||
}
|
||||
_parts = append(_parts, jsonDataAO0)
|
||||
|
||||
aO1, err := swag.WriteJSON(m.Alert)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_parts = append(_parts, aO1)
|
||||
|
||||
return swag.ConcatJSON(_parts...), nil
|
||||
}
|
||||
|
||||
// Validate validates this postable alert
|
||||
func (m *PostableAlert) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateAnnotations(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateEndsAt(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateStartsAt(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
// validation for a type composition with Alert
|
||||
if err := m.Alert.Validate(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostableAlert) validateAnnotations(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.Annotations) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := m.Annotations.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("annotations")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostableAlert) validateEndsAt(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.EndsAt) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("endsAt", "body", "date-time", m.EndsAt.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PostableAlert) validateStartsAt(formats strfmt.Registry) error {
|
||||
|
||||
if swag.IsZero(m.StartsAt) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("startsAt", "body", "date-time", m.StartsAt.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *PostableAlert) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *PostableAlert) UnmarshalBinary(b []byte) error {
|
||||
var res PostableAlert
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
"strconv"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// PostableAlerts postable alerts
|
||||
// swagger:model postableAlerts
|
||||
type PostableAlerts []*PostableAlert
|
||||
|
||||
// Validate validates this postable alerts
|
||||
func (m PostableAlerts) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
for i := 0; i < len(m); i++ {
|
||||
if swag.IsZero(m[i]) { // not required
|
||||
continue
|
||||
}
|
||||
|
||||
if m[i] != nil {
|
||||
if err := m[i].Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName(strconv.Itoa(i))
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// PostableSilence postable silence
|
||||
// swagger:model postableSilence
|
||||
type PostableSilence struct {
|
||||
|
||||
// id
|
||||
ID string `json:"id,omitempty"`
|
||||
|
||||
Silence
|
||||
}
|
||||
|
||||
// UnmarshalJSON unmarshals this object from a JSON structure
|
||||
func (m *PostableSilence) UnmarshalJSON(raw []byte) error {
|
||||
// AO0
|
||||
var dataAO0 struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
}
|
||||
if err := swag.ReadJSON(raw, &dataAO0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m.ID = dataAO0.ID
|
||||
|
||||
// AO1
|
||||
var aO1 Silence
|
||||
if err := swag.ReadJSON(raw, &aO1); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Silence = aO1
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON marshals this object to a JSON structure
|
||||
func (m PostableSilence) MarshalJSON() ([]byte, error) {
|
||||
_parts := make([][]byte, 0, 2)
|
||||
|
||||
var dataAO0 struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
}
|
||||
|
||||
dataAO0.ID = m.ID
|
||||
|
||||
jsonDataAO0, errAO0 := swag.WriteJSON(dataAO0)
|
||||
if errAO0 != nil {
|
||||
return nil, errAO0
|
||||
}
|
||||
_parts = append(_parts, jsonDataAO0)
|
||||
|
||||
aO1, err := swag.WriteJSON(m.Silence)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_parts = append(_parts, aO1)
|
||||
|
||||
return swag.ConcatJSON(_parts...), nil
|
||||
}
|
||||
|
||||
// Validate validates this postable silence
|
||||
func (m *PostableSilence) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
// validation for a type composition with Silence
|
||||
if err := m.Silence.Validate(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *PostableSilence) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *PostableSilence) UnmarshalBinary(b []byte) error {
|
||||
var res PostableSilence
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// Receiver receiver
|
||||
// swagger:model receiver
|
||||
type Receiver struct {
|
||||
|
||||
// name
|
||||
// Required: true
|
||||
Name *string `json:"name"`
|
||||
}
|
||||
|
||||
// Validate validates this receiver
|
||||
func (m *Receiver) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateName(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Receiver) validateName(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("name", "body", m.Name); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *Receiver) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *Receiver) UnmarshalBinary(b []byte) error {
|
||||
var res Receiver
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// Silence silence
|
||||
// swagger:model silence
|
||||
type Silence struct {
|
||||
|
||||
// comment
|
||||
// Required: true
|
||||
Comment *string `json:"comment"`
|
||||
|
||||
// created by
|
||||
// Required: true
|
||||
CreatedBy *string `json:"createdBy"`
|
||||
|
||||
// ends at
|
||||
// Required: true
|
||||
// Format: date-time
|
||||
EndsAt *strfmt.DateTime `json:"endsAt"`
|
||||
|
||||
// matchers
|
||||
// Required: true
|
||||
Matchers Matchers `json:"matchers"`
|
||||
|
||||
// starts at
|
||||
// Required: true
|
||||
// Format: date-time
|
||||
StartsAt *strfmt.DateTime `json:"startsAt"`
|
||||
}
|
||||
|
||||
// Validate validates this silence
|
||||
func (m *Silence) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateComment(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateCreatedBy(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateEndsAt(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateMatchers(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateStartsAt(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Silence) validateComment(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("comment", "body", m.Comment); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Silence) validateCreatedBy(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("createdBy", "body", m.CreatedBy); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Silence) validateEndsAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("endsAt", "body", m.EndsAt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("endsAt", "body", "date-time", m.EndsAt.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Silence) validateMatchers(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("matchers", "body", m.Matchers); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := m.Matchers.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("matchers")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Silence) validateStartsAt(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("startsAt", "body", m.StartsAt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validate.FormatOf("startsAt", "body", "date-time", m.StartsAt.String(), formats); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *Silence) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *Silence) UnmarshalBinary(b []byte) error {
|
||||
var res Silence
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
"encoding/json"
|
||||
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// SilenceStatus silence status
|
||||
// swagger:model silenceStatus
|
||||
type SilenceStatus struct {
|
||||
|
||||
// state
|
||||
// Required: true
|
||||
// Enum: [expired active pending]
|
||||
State *string `json:"state"`
|
||||
}
|
||||
|
||||
// Validate validates this silence status
|
||||
func (m *SilenceStatus) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateState(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var silenceStatusTypeStatePropEnum []interface{}
|
||||
|
||||
func init() {
|
||||
var res []string
|
||||
if err := json.Unmarshal([]byte(`["expired","active","pending"]`), &res); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, v := range res {
|
||||
silenceStatusTypeStatePropEnum = append(silenceStatusTypeStatePropEnum, v)
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
// SilenceStatusStateExpired captures enum value "expired"
|
||||
SilenceStatusStateExpired string = "expired"
|
||||
|
||||
// SilenceStatusStateActive captures enum value "active"
|
||||
SilenceStatusStateActive string = "active"
|
||||
|
||||
// SilenceStatusStatePending captures enum value "pending"
|
||||
SilenceStatusStatePending string = "pending"
|
||||
)
|
||||
|
||||
// prop value enum
|
||||
func (m *SilenceStatus) validateStateEnum(path, location string, value string) error {
|
||||
if err := validate.Enum(path, location, value, silenceStatusTypeStatePropEnum); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SilenceStatus) validateState(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("state", "body", m.State); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// value enum
|
||||
if err := m.validateStateEnum("state", "body", *m.State); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *SilenceStatus) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *SilenceStatus) UnmarshalBinary(b []byte) error {
|
||||
var res SilenceStatus
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// Copyright Prometheus Team
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
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 (
|
||||
strfmt "github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/swag"
|
||||
"github.com/go-openapi/validate"
|
||||
)
|
||||
|
||||
// VersionInfo version info
|
||||
// swagger:model versionInfo
|
||||
type VersionInfo struct {
|
||||
|
||||
// branch
|
||||
// Required: true
|
||||
Branch *string `json:"branch"`
|
||||
|
||||
// build date
|
||||
// Required: true
|
||||
BuildDate *string `json:"buildDate"`
|
||||
|
||||
// build user
|
||||
// Required: true
|
||||
BuildUser *string `json:"buildUser"`
|
||||
|
||||
// go version
|
||||
// Required: true
|
||||
GoVersion *string `json:"goVersion"`
|
||||
|
||||
// revision
|
||||
// Required: true
|
||||
Revision *string `json:"revision"`
|
||||
|
||||
// version
|
||||
// Required: true
|
||||
Version *string `json:"version"`
|
||||
}
|
||||
|
||||
// Validate validates this version info
|
||||
func (m *VersionInfo) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateBranch(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateBuildDate(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateBuildUser(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateGoVersion(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateRevision(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateVersion(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *VersionInfo) validateBranch(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("branch", "body", m.Branch); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *VersionInfo) validateBuildDate(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("buildDate", "body", m.BuildDate); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *VersionInfo) validateBuildUser(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("buildUser", "body", m.BuildUser); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *VersionInfo) validateGoVersion(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("goVersion", "body", m.GoVersion); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *VersionInfo) validateRevision(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("revision", "body", m.Revision); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *VersionInfo) validateVersion(formats strfmt.Registry) error {
|
||||
|
||||
if err := validate.Required("version", "body", m.Version); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *VersionInfo) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *VersionInfo) UnmarshalBinary(b []byte) error {
|
||||
var res VersionInfo
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
|
@ -20,7 +20,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/models"
|
||||
"github.com/prometheus/alertmanager/api/v2/models"
|
||||
)
|
||||
|
||||
// Collector gathers alerts received by a notification receiver
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
"github.com/prometheus/alertmanager/notify"
|
||||
|
||||
"github.com/prometheus/alertmanager/test/with_api_v2/api_v2_client/models"
|
||||
"github.com/prometheus/alertmanager/api/v2/models"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
|
|
@ -43,9 +43,9 @@ github.com/go-openapi/loads
|
|||
# github.com/go-openapi/runtime v0.18.0
|
||||
github.com/go-openapi/runtime/middleware
|
||||
github.com/go-openapi/runtime
|
||||
github.com/go-openapi/runtime/client
|
||||
github.com/go-openapi/runtime/flagext
|
||||
github.com/go-openapi/runtime/security
|
||||
github.com/go-openapi/runtime/client
|
||||
github.com/go-openapi/runtime/logger
|
||||
github.com/go-openapi/runtime/middleware/denco
|
||||
github.com/go-openapi/runtime/middleware/header
|
||||
|
|
Loading…
Reference in New Issue