From 8688c7b9ad49e0ecad2319c38e147c26aeb6db92 Mon Sep 17 00:00:00 2001 From: Paul Gier Date: Tue, 12 Mar 2019 11:11:23 -0500 Subject: [PATCH] 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 --- Makefile | 15 +- .../v2}/client/alert/alert_client.go | 0 .../v2}/client/alert/get_alerts_parameters.go | 0 .../v2}/client/alert/get_alerts_responses.go | 2 +- .../client/alert/post_alerts_parameters.go | 2 +- .../v2}/client/alert/post_alerts_responses.go | 0 .../v2}/client/alertmanager_client.go | 8 +- .../v2}/client/general/general_client.go | 0 .../client/general/get_status_parameters.go | 0 .../client/general/get_status_responses.go | 2 +- .../receiver/get_receivers_parameters.go | 0 .../receiver/get_receivers_responses.go | 2 +- .../v2}/client/receiver/receiver_client.go | 0 .../silence/delete_silence_parameters.go | 0 .../silence/delete_silence_responses.go | 0 .../client/silence/get_silence_parameters.go | 0 .../client/silence/get_silence_responses.go | 2 +- .../client/silence/get_silences_parameters.go | 0 .../client/silence/get_silences_responses.go | 2 +- .../silence/post_silences_parameters.go | 2 +- .../client/silence/post_silences_responses.go | 0 .../v2}/client/silence/silence_client.go | 0 test/with_api_v2/acceptance.go | 8 +- test/with_api_v2/acceptance/api_test.go | 6 +- .../with_api_v2/api_v2_client/models/alert.go | 102 ------ .../api_v2_client/models/alert_status.go | 152 -------- .../models/alertmanager_config.go | 78 ----- .../models/alertmanager_status.go | 161 --------- .../api_v2_client/models/cluster_status.go | 155 --------- .../api_v2_client/models/gettable_alert.go | 327 ------------------ .../api_v2_client/models/gettable_alerts.go | 59 ---- .../api_v2_client/models/gettable_silence.go | 196 ----------- .../api_v2_client/models/gettable_silences.go | 59 ---- .../api_v2_client/models/label_set.go | 33 -- .../api_v2_client/models/matcher.go | 112 ------ .../api_v2_client/models/matchers.go | 66 ---- .../api_v2_client/models/peer_status.go | 95 ----- .../api_v2_client/models/postable_alert.go | 196 ----------- .../api_v2_client/models/postable_alerts.go | 59 ---- .../api_v2_client/models/postable_silence.go | 117 ------- .../api_v2_client/models/receiver.go | 78 ----- .../api_v2_client/models/silence.go | 163 --------- .../api_v2_client/models/silence_status.go | 118 ------- .../api_v2_client/models/version_info.go | 163 --------- test/with_api_v2/collector.go | 2 +- test/with_api_v2/mock.go | 2 +- vendor/modules.txt | 2 +- 47 files changed, 26 insertions(+), 2520 deletions(-) rename {test/with_api_v2/api_v2_client => api/v2}/client/alert/alert_client.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/alert/get_alerts_parameters.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/alert/get_alerts_responses.go (97%) rename {test/with_api_v2/api_v2_client => api/v2}/client/alert/post_alerts_parameters.go (98%) rename {test/with_api_v2/api_v2_client => api/v2}/client/alert/post_alerts_responses.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/alertmanager_client.go (92%) rename {test/with_api_v2/api_v2_client => api/v2}/client/general/general_client.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/general/get_status_parameters.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/general/get_status_responses.go (96%) rename {test/with_api_v2/api_v2_client => api/v2}/client/receiver/get_receivers_parameters.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/receiver/get_receivers_responses.go (96%) rename {test/with_api_v2/api_v2_client => api/v2}/client/receiver/receiver_client.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/silence/delete_silence_parameters.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/silence/delete_silence_responses.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/silence/get_silence_parameters.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/silence/get_silence_responses.go (97%) rename {test/with_api_v2/api_v2_client => api/v2}/client/silence/get_silences_parameters.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/silence/get_silences_responses.go (97%) rename {test/with_api_v2/api_v2_client => api/v2}/client/silence/post_silences_parameters.go (98%) rename {test/with_api_v2/api_v2_client => api/v2}/client/silence/post_silences_responses.go (100%) rename {test/with_api_v2/api_v2_client => api/v2}/client/silence/silence_client.go (100%) delete mode 100644 test/with_api_v2/api_v2_client/models/alert.go delete mode 100644 test/with_api_v2/api_v2_client/models/alert_status.go delete mode 100644 test/with_api_v2/api_v2_client/models/alertmanager_config.go delete mode 100644 test/with_api_v2/api_v2_client/models/alertmanager_status.go delete mode 100644 test/with_api_v2/api_v2_client/models/cluster_status.go delete mode 100644 test/with_api_v2/api_v2_client/models/gettable_alert.go delete mode 100644 test/with_api_v2/api_v2_client/models/gettable_alerts.go delete mode 100644 test/with_api_v2/api_v2_client/models/gettable_silence.go delete mode 100644 test/with_api_v2/api_v2_client/models/gettable_silences.go delete mode 100644 test/with_api_v2/api_v2_client/models/label_set.go delete mode 100644 test/with_api_v2/api_v2_client/models/matcher.go delete mode 100644 test/with_api_v2/api_v2_client/models/matchers.go delete mode 100644 test/with_api_v2/api_v2_client/models/peer_status.go delete mode 100644 test/with_api_v2/api_v2_client/models/postable_alert.go delete mode 100644 test/with_api_v2/api_v2_client/models/postable_alerts.go delete mode 100644 test/with_api_v2/api_v2_client/models/postable_silence.go delete mode 100644 test/with_api_v2/api_v2_client/models/receiver.go delete mode 100644 test/with_api_v2/api_v2_client/models/silence.go delete mode 100644 test/with_api_v2/api_v2_client/models/silence_status.go delete mode 100644 test/with_api_v2/api_v2_client/models/version_info.go diff --git a/Makefile b/Makefile index 049f65cc..cd7c7b01 100644 --- a/Makefile +++ b/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 diff --git a/test/with_api_v2/api_v2_client/client/alert/alert_client.go b/api/v2/client/alert/alert_client.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/alert/alert_client.go rename to api/v2/client/alert/alert_client.go diff --git a/test/with_api_v2/api_v2_client/client/alert/get_alerts_parameters.go b/api/v2/client/alert/get_alerts_parameters.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/alert/get_alerts_parameters.go rename to api/v2/client/alert/get_alerts_parameters.go diff --git a/test/with_api_v2/api_v2_client/client/alert/get_alerts_responses.go b/api/v2/client/alert/get_alerts_responses.go similarity index 97% rename from test/with_api_v2/api_v2_client/client/alert/get_alerts_responses.go rename to api/v2/client/alert/get_alerts_responses.go index 21d80454..ef6cedd5 100644 --- a/test/with_api_v2/api_v2_client/client/alert/get_alerts_responses.go +++ b/api/v2/client/alert/get_alerts_responses.go @@ -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. diff --git a/test/with_api_v2/api_v2_client/client/alert/post_alerts_parameters.go b/api/v2/client/alert/post_alerts_parameters.go similarity index 98% rename from test/with_api_v2/api_v2_client/client/alert/post_alerts_parameters.go rename to api/v2/client/alert/post_alerts_parameters.go index 816bdf60..de1b021a 100644 --- a/test/with_api_v2/api_v2_client/client/alert/post_alerts_parameters.go +++ b/api/v2/client/alert/post_alerts_parameters.go @@ -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 diff --git a/test/with_api_v2/api_v2_client/client/alert/post_alerts_responses.go b/api/v2/client/alert/post_alerts_responses.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/alert/post_alerts_responses.go rename to api/v2/client/alert/post_alerts_responses.go diff --git a/test/with_api_v2/api_v2_client/client/alertmanager_client.go b/api/v2/client/alertmanager_client.go similarity index 92% rename from test/with_api_v2/api_v2_client/client/alertmanager_client.go rename to api/v2/client/alertmanager_client.go index d9c926ca..dbdf7eeb 100644 --- a/test/with_api_v2/api_v2_client/client/alertmanager_client.go +++ b/api/v2/client/alertmanager_client.go @@ -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. diff --git a/test/with_api_v2/api_v2_client/client/general/general_client.go b/api/v2/client/general/general_client.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/general/general_client.go rename to api/v2/client/general/general_client.go diff --git a/test/with_api_v2/api_v2_client/client/general/get_status_parameters.go b/api/v2/client/general/get_status_parameters.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/general/get_status_parameters.go rename to api/v2/client/general/get_status_parameters.go diff --git a/test/with_api_v2/api_v2_client/client/general/get_status_responses.go b/api/v2/client/general/get_status_responses.go similarity index 96% rename from test/with_api_v2/api_v2_client/client/general/get_status_responses.go rename to api/v2/client/general/get_status_responses.go index cb7414a8..5a505733 100644 --- a/test/with_api_v2/api_v2_client/client/general/get_status_responses.go +++ b/api/v2/client/general/get_status_responses.go @@ -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. diff --git a/test/with_api_v2/api_v2_client/client/receiver/get_receivers_parameters.go b/api/v2/client/receiver/get_receivers_parameters.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/receiver/get_receivers_parameters.go rename to api/v2/client/receiver/get_receivers_parameters.go diff --git a/test/with_api_v2/api_v2_client/client/receiver/get_receivers_responses.go b/api/v2/client/receiver/get_receivers_responses.go similarity index 96% rename from test/with_api_v2/api_v2_client/client/receiver/get_receivers_responses.go rename to api/v2/client/receiver/get_receivers_responses.go index 2e9a943c..d9d586e5 100644 --- a/test/with_api_v2/api_v2_client/client/receiver/get_receivers_responses.go +++ b/api/v2/client/receiver/get_receivers_responses.go @@ -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. diff --git a/test/with_api_v2/api_v2_client/client/receiver/receiver_client.go b/api/v2/client/receiver/receiver_client.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/receiver/receiver_client.go rename to api/v2/client/receiver/receiver_client.go diff --git a/test/with_api_v2/api_v2_client/client/silence/delete_silence_parameters.go b/api/v2/client/silence/delete_silence_parameters.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/silence/delete_silence_parameters.go rename to api/v2/client/silence/delete_silence_parameters.go diff --git a/test/with_api_v2/api_v2_client/client/silence/delete_silence_responses.go b/api/v2/client/silence/delete_silence_responses.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/silence/delete_silence_responses.go rename to api/v2/client/silence/delete_silence_responses.go diff --git a/test/with_api_v2/api_v2_client/client/silence/get_silence_parameters.go b/api/v2/client/silence/get_silence_parameters.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/silence/get_silence_parameters.go rename to api/v2/client/silence/get_silence_parameters.go diff --git a/test/with_api_v2/api_v2_client/client/silence/get_silence_responses.go b/api/v2/client/silence/get_silence_responses.go similarity index 97% rename from test/with_api_v2/api_v2_client/client/silence/get_silence_responses.go rename to api/v2/client/silence/get_silence_responses.go index 1f48052c..45f29250 100644 --- a/test/with_api_v2/api_v2_client/client/silence/get_silence_responses.go +++ b/api/v2/client/silence/get_silence_responses.go @@ -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. diff --git a/test/with_api_v2/api_v2_client/client/silence/get_silences_parameters.go b/api/v2/client/silence/get_silences_parameters.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/silence/get_silences_parameters.go rename to api/v2/client/silence/get_silences_parameters.go diff --git a/test/with_api_v2/api_v2_client/client/silence/get_silences_responses.go b/api/v2/client/silence/get_silences_responses.go similarity index 97% rename from test/with_api_v2/api_v2_client/client/silence/get_silences_responses.go rename to api/v2/client/silence/get_silences_responses.go index a0add60a..cd81a20c 100644 --- a/test/with_api_v2/api_v2_client/client/silence/get_silences_responses.go +++ b/api/v2/client/silence/get_silences_responses.go @@ -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. diff --git a/test/with_api_v2/api_v2_client/client/silence/post_silences_parameters.go b/api/v2/client/silence/post_silences_parameters.go similarity index 98% rename from test/with_api_v2/api_v2_client/client/silence/post_silences_parameters.go rename to api/v2/client/silence/post_silences_parameters.go index b8c4c0a4..de117fd9 100644 --- a/test/with_api_v2/api_v2_client/client/silence/post_silences_parameters.go +++ b/api/v2/client/silence/post_silences_parameters.go @@ -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 diff --git a/test/with_api_v2/api_v2_client/client/silence/post_silences_responses.go b/api/v2/client/silence/post_silences_responses.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/silence/post_silences_responses.go rename to api/v2/client/silence/post_silences_responses.go diff --git a/test/with_api_v2/api_v2_client/client/silence/silence_client.go b/api/v2/client/silence/silence_client.go similarity index 100% rename from test/with_api_v2/api_v2_client/client/silence/silence_client.go rename to api/v2/client/silence/silence_client.go diff --git a/test/with_api_v2/acceptance.go b/test/with_api_v2/acceptance.go index 50e40290..88bfa267 100644 --- a/test/with_api_v2/acceptance.go +++ b/test/with_api_v2/acceptance.go @@ -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" diff --git a/test/with_api_v2/acceptance/api_test.go b/test/with_api_v2/acceptance/api_test.go index a7ec4b93..b59e3743 100644 --- a/test/with_api_v2/acceptance/api_test.go +++ b/test/with_api_v2/acceptance/api_test.go @@ -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" ) diff --git a/test/with_api_v2/api_v2_client/models/alert.go b/test/with_api_v2/api_v2_client/models/alert.go deleted file mode 100644 index 832df76e..00000000 --- a/test/with_api_v2/api_v2_client/models/alert.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/alert_status.go b/test/with_api_v2/api_v2_client/models/alert_status.go deleted file mode 100644 index cadbad36..00000000 --- a/test/with_api_v2/api_v2_client/models/alert_status.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/alertmanager_config.go b/test/with_api_v2/api_v2_client/models/alertmanager_config.go deleted file mode 100644 index a7ef560d..00000000 --- a/test/with_api_v2/api_v2_client/models/alertmanager_config.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/alertmanager_status.go b/test/with_api_v2/api_v2_client/models/alertmanager_status.go deleted file mode 100644 index 88afa7fe..00000000 --- a/test/with_api_v2/api_v2_client/models/alertmanager_status.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/cluster_status.go b/test/with_api_v2/api_v2_client/models/cluster_status.go deleted file mode 100644 index 9db4491d..00000000 --- a/test/with_api_v2/api_v2_client/models/cluster_status.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/gettable_alert.go b/test/with_api_v2/api_v2_client/models/gettable_alert.go deleted file mode 100644 index c0c98348..00000000 --- a/test/with_api_v2/api_v2_client/models/gettable_alert.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/gettable_alerts.go b/test/with_api_v2/api_v2_client/models/gettable_alerts.go deleted file mode 100644 index fe7f1def..00000000 --- a/test/with_api_v2/api_v2_client/models/gettable_alerts.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/gettable_silence.go b/test/with_api_v2/api_v2_client/models/gettable_silence.go deleted file mode 100644 index e2cad931..00000000 --- a/test/with_api_v2/api_v2_client/models/gettable_silence.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/gettable_silences.go b/test/with_api_v2/api_v2_client/models/gettable_silences.go deleted file mode 100644 index 8f1604e3..00000000 --- a/test/with_api_v2/api_v2_client/models/gettable_silences.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/label_set.go b/test/with_api_v2/api_v2_client/models/label_set.go deleted file mode 100644 index 0d1d3538..00000000 --- a/test/with_api_v2/api_v2_client/models/label_set.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/matcher.go b/test/with_api_v2/api_v2_client/models/matcher.go deleted file mode 100644 index eae3605a..00000000 --- a/test/with_api_v2/api_v2_client/models/matcher.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/matchers.go b/test/with_api_v2/api_v2_client/models/matchers.go deleted file mode 100644 index bd285489..00000000 --- a/test/with_api_v2/api_v2_client/models/matchers.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/peer_status.go b/test/with_api_v2/api_v2_client/models/peer_status.go deleted file mode 100644 index 29e10ece..00000000 --- a/test/with_api_v2/api_v2_client/models/peer_status.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/postable_alert.go b/test/with_api_v2/api_v2_client/models/postable_alert.go deleted file mode 100644 index afa91ca9..00000000 --- a/test/with_api_v2/api_v2_client/models/postable_alert.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/postable_alerts.go b/test/with_api_v2/api_v2_client/models/postable_alerts.go deleted file mode 100644 index 7097adca..00000000 --- a/test/with_api_v2/api_v2_client/models/postable_alerts.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/postable_silence.go b/test/with_api_v2/api_v2_client/models/postable_silence.go deleted file mode 100644 index 45efa4ff..00000000 --- a/test/with_api_v2/api_v2_client/models/postable_silence.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/receiver.go b/test/with_api_v2/api_v2_client/models/receiver.go deleted file mode 100644 index 3686e6d1..00000000 --- a/test/with_api_v2/api_v2_client/models/receiver.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/silence.go b/test/with_api_v2/api_v2_client/models/silence.go deleted file mode 100644 index 0a842a30..00000000 --- a/test/with_api_v2/api_v2_client/models/silence.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/silence_status.go b/test/with_api_v2/api_v2_client/models/silence_status.go deleted file mode 100644 index 669269e1..00000000 --- a/test/with_api_v2/api_v2_client/models/silence_status.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/api_v2_client/models/version_info.go b/test/with_api_v2/api_v2_client/models/version_info.go deleted file mode 100644 index 232d805d..00000000 --- a/test/with_api_v2/api_v2_client/models/version_info.go +++ /dev/null @@ -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 -} diff --git a/test/with_api_v2/collector.go b/test/with_api_v2/collector.go index cec9848d..4008c164 100644 --- a/test/with_api_v2/collector.go +++ b/test/with_api_v2/collector.go @@ -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 diff --git a/test/with_api_v2/mock.go b/test/with_api_v2/mock.go index 15c0fabb..3b48e52e 100644 --- a/test/with_api_v2/mock.go +++ b/test/with_api_v2/mock.go @@ -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" ) diff --git a/vendor/modules.txt b/vendor/modules.txt index 788aeb52..e22275bf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -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