diff --git a/pkg/gen/models/ack.go b/pkg/gen/models/ack.go new file mode 100644 index 00000000000..e14f6cd1f33 --- /dev/null +++ b/pkg/gen/models/ack.go @@ -0,0 +1,11 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// Ack ack +// +// swagger:model Ack +type Ack interface{} diff --git a/pkg/gen/models/alert.go b/pkg/gen/models/alert.go new file mode 100644 index 00000000000..2549569d016 --- /dev/null +++ b/pkg/gen/models/alert.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Alert Alert has info for an alert. +// +// swagger:model Alert +type Alert struct { + + // active at + // Format: date-time + ActiveAt strfmt.DateTime `json:"activeAt,omitempty"` + + // state + State string `json:"state,omitempty"` + + // value + Value string `json:"value,omitempty"` + + // annotations + Annotations Labels `json:"annotations,omitempty"` + + // labels + Labels Labels `json:"labels,omitempty"` +} + +// Validate validates this alert +func (m *Alert) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateActiveAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAnnotations(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) validateActiveAt(formats strfmt.Registry) error { + + if swag.IsZero(m.ActiveAt) { // not required + return nil + } + + if err := validate.FormatOf("activeAt", "body", "date-time", m.ActiveAt.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *Alert) 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 *Alert) validateLabels(formats strfmt.Registry) error { + + if swag.IsZero(m.Labels) { // not required + return nil + } + + 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/pkg/gen/models/alert_discovery.go b/pkg/gen/models/alert_discovery.go new file mode 100644 index 00000000000..755b0fddb3e --- /dev/null +++ b/pkg/gen/models/alert_discovery.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AlertDiscovery AlertDiscovery has info for all active alerts. +// +// swagger:model AlertDiscovery +type AlertDiscovery struct { + + // alerts + Alerts []*Alert `json:"alerts"` +} + +// Validate validates this alert discovery +func (m *AlertDiscovery) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAlerts(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AlertDiscovery) validateAlerts(formats strfmt.Registry) error { + + if swag.IsZero(m.Alerts) { // not required + return nil + } + + for i := 0; i < len(m.Alerts); i++ { + if swag.IsZero(m.Alerts[i]) { // not required + continue + } + + if m.Alerts[i] != nil { + if err := m.Alerts[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("alerts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AlertDiscovery) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AlertDiscovery) UnmarshalBinary(b []byte) error { + var res AlertDiscovery + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/alert_group.go b/pkg/gen/models/alert_group.go new file mode 100644 index 00000000000..c4738eedd96 --- /dev/null +++ b/pkg/gen/models/alert_group.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// AlertGroup AlertGroup alert group +// +// swagger:model AlertGroup +type AlertGroup struct { + + // alerts + // Required: true + Alerts []*GettableAlert `json:"alerts"` + + // labels + // Required: true + Labels LabelSet `json:"labels"` + + // receiver + // Required: true + Receiver *Receiver `json:"receiver"` +} + +// Validate validates this alert group +func (m *AlertGroup) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAlerts(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLabels(formats); err != nil { + res = append(res, err) + } + + if err := m.validateReceiver(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AlertGroup) validateAlerts(formats strfmt.Registry) error { + + if err := validate.Required("alerts", "body", m.Alerts); err != nil { + return err + } + + for i := 0; i < len(m.Alerts); i++ { + if swag.IsZero(m.Alerts[i]) { // not required + continue + } + + if m.Alerts[i] != nil { + if err := m.Alerts[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("alerts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertGroup) 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 +} + +func (m *AlertGroup) validateReceiver(formats strfmt.Registry) error { + + if err := validate.Required("receiver", "body", m.Receiver); err != nil { + return err + } + + if m.Receiver != nil { + if err := m.Receiver.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("receiver") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AlertGroup) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AlertGroup) UnmarshalBinary(b []byte) error { + var res AlertGroup + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/alert_groups.go b/pkg/gen/models/alert_groups.go new file mode 100644 index 00000000000..f38e2319593 --- /dev/null +++ b/pkg/gen/models/alert_groups.go @@ -0,0 +1,11 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// AlertGroups alert groups +// +// swagger:model AlertGroups +type AlertGroups = AlertGroups diff --git a/pkg/gen/models/alert_instances_response.go b/pkg/gen/models/alert_instances_response.go new file mode 100644 index 00000000000..a54ab0b8d59 --- /dev/null +++ b/pkg/gen/models/alert_instances_response.go @@ -0,0 +1,44 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AlertInstancesResponse alert instances response +// +// swagger:model AlertInstancesResponse +type AlertInstancesResponse struct { + + // Instances is an array of arrow encoded dataframes + // each frame has a single row, and a column for each instance (alert identified by unique labels) with a boolean value (firing/not firing) + Instances [][]uint8 `json:"instances"` +} + +// Validate validates this alert instances response +func (m *AlertInstancesResponse) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *AlertInstancesResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AlertInstancesResponse) UnmarshalBinary(b []byte) error { + var res AlertInstancesResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/alert_notification.go b/pkg/gen/models/alert_notification.go new file mode 100644 index 00000000000..87b828068e1 --- /dev/null +++ b/pkg/gen/models/alert_notification.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// AlertNotification alert notification +// +// swagger:model AlertNotification +type AlertNotification struct { + + // created + // Format: date-time + Created strfmt.DateTime `json:"created,omitempty"` + + // disable resolve message + DisableResolveMessage bool `json:"disableResolveMessage,omitempty"` + + // Id + ID int64 `json:"id,omitempty"` + + // is default + IsDefault bool `json:"isDefault,omitempty"` + + // name + Name string `json:"name,omitempty"` + + // send reminder + SendReminder bool `json:"sendReminder,omitempty"` + + // type + Type string `json:"type,omitempty"` + + // updated + // Format: date-time + Updated strfmt.DateTime `json:"updated,omitempty"` + + // frequency + Frequency Duration `json:"frequency,omitempty"` + + // secure settings + SecureSettings SecureJSONData `json:"secureSettings,omitempty"` + + // settings + Settings JSON `json:"settings,omitempty"` +} + +// Validate validates this alert notification +func (m *AlertNotification) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateCreated(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdated(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSecureSettings(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AlertNotification) validateCreated(formats strfmt.Registry) error { + + if swag.IsZero(m.Created) { // not required + return nil + } + + if err := validate.FormatOf("created", "body", "date-time", m.Created.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *AlertNotification) validateUpdated(formats strfmt.Registry) error { + + if swag.IsZero(m.Updated) { // not required + return nil + } + + if err := validate.FormatOf("updated", "body", "date-time", m.Updated.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *AlertNotification) validateSecureSettings(formats strfmt.Registry) error { + + if swag.IsZero(m.SecureSettings) { // not required + return nil + } + + if err := m.SecureSettings.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("secureSettings") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AlertNotification) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AlertNotification) UnmarshalBinary(b []byte) error { + var res AlertNotification + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/alert_query.go b/pkg/gen/models/alert_query.go new file mode 100644 index 00000000000..3757f3620c4 --- /dev/null +++ b/pkg/gen/models/alert_query.go @@ -0,0 +1,81 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AlertQuery AlertQuery represents a single query associated with an alert definition. +// +// swagger:model AlertQuery +type AlertQuery struct { + + // JSON is the raw JSON query and includes the above properties as well as custom properties. + Model interface{} `json:"model,omitempty"` + + // QueryType is an optional identifier for the type of query. + // It can be used to distinguish different types of queries. + QueryType string `json:"queryType,omitempty"` + + // RefID is the unique identifier of the query, set by the frontend call. + RefID string `json:"refId,omitempty"` + + // relative time range + RelativeTimeRange *RelativeTimeRange `json:"relativeTimeRange,omitempty"` +} + +// Validate validates this alert query +func (m *AlertQuery) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRelativeTimeRange(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AlertQuery) validateRelativeTimeRange(formats strfmt.Registry) error { + + if swag.IsZero(m.RelativeTimeRange) { // not required + return nil + } + + if m.RelativeTimeRange != nil { + if err := m.RelativeTimeRange.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("relativeTimeRange") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AlertQuery) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AlertQuery) UnmarshalBinary(b []byte) error { + var res AlertQuery + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/alert_response.go b/pkg/gen/models/alert_response.go new file mode 100644 index 00000000000..47c52c1111a --- /dev/null +++ b/pkg/gen/models/alert_response.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AlertResponse alert response +// +// swagger:model AlertResponse +type AlertResponse struct { + + // body + Body *AlertResponseBody `json:"Body,omitempty"` +} + +// Validate validates this alert response +func (m *AlertResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBody(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AlertResponse) validateBody(formats strfmt.Registry) error { + + if swag.IsZero(m.Body) { // not required + return nil + } + + if m.Body != nil { + if err := m.Body.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("Body") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AlertResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AlertResponse) UnmarshalBinary(b []byte) error { + var res AlertResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/alert_response_body.go b/pkg/gen/models/alert_response_body.go new file mode 100644 index 00000000000..500079c2148 --- /dev/null +++ b/pkg/gen/models/alert_response_body.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AlertResponseBody in: body +// +// swagger:model alertResponseBody +type AlertResponseBody struct { + + // error + Error string `json:"error,omitempty"` + + // status + Status string `json:"status,omitempty"` + + // data + Data *AlertDiscovery `json:"data,omitempty"` + + // error type + ErrorType ErrorType `json:"errorType,omitempty"` +} + +// Validate validates this alert response body +func (m *AlertResponseBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateErrorType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AlertResponseBody) validateData(formats strfmt.Registry) error { + + if swag.IsZero(m.Data) { // not required + return nil + } + + if m.Data != nil { + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *AlertResponseBody) validateErrorType(formats strfmt.Registry) error { + + if swag.IsZero(m.ErrorType) { // not required + return nil + } + + if err := m.ErrorType.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("errorType") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AlertResponseBody) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AlertResponseBody) UnmarshalBinary(b []byte) error { + var res AlertResponseBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/alert_status.go b/pkg/gen/models/alert_status.go new file mode 100644 index 00000000000..0286a76c34c --- /dev/null +++ b/pkg/gen/models/alert_status.go @@ -0,0 +1,132 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// AlertStatus 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 ( + + // AlertStatusStateUnprocessedActiveSuppressed captures enum value "[unprocessed active suppressed]" + AlertStatusStateUnprocessedActiveSuppressed string = "[unprocessed active suppressed]" +) + +// prop value enum +func (m *AlertStatus) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, alertStatusTypeStatePropEnum, true); 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/pkg/gen/models/alerting_config_response.go b/pkg/gen/models/alerting_config_response.go new file mode 100644 index 00000000000..e4ee15ffa77 --- /dev/null +++ b/pkg/gen/models/alerting_config_response.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AlertingConfigResponse alerting config response +// +// swagger:model AlertingConfigResponse +type AlertingConfigResponse struct { + + // body + Body *UserConfig `json:"Body,omitempty"` +} + +// Validate validates this alerting config response +func (m *AlertingConfigResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBody(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AlertingConfigResponse) validateBody(formats strfmt.Registry) error { + + if swag.IsZero(m.Body) { // not required + return nil + } + + if m.Body != nil { + if err := m.Body.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("Body") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AlertingConfigResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AlertingConfigResponse) UnmarshalBinary(b []byte) error { + var res AlertingConfigResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/alerting_rule.go b/pkg/gen/models/alerting_rule.go new file mode 100644 index 00000000000..c2a4aa1b848 --- /dev/null +++ b/pkg/gen/models/alerting_rule.go @@ -0,0 +1,192 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// AlertingRule adapted from cortex +// +// swagger:model AlertingRule +type AlertingRule struct { + + // alerts + Alerts []*Alert `json:"alerts"` + + // duration + Duration float64 `json:"duration,omitempty"` + + // evaluation time + EvaluationTime float64 `json:"evaluationTime,omitempty"` + + // health + Health string `json:"health,omitempty"` + + // last error + LastError string `json:"lastError,omitempty"` + + // last evaluation + // Format: date-time + LastEvaluation strfmt.DateTime `json:"lastEvaluation,omitempty"` + + // name + Name string `json:"name,omitempty"` + + // query + Query string `json:"query,omitempty"` + + // State can be "pending", "firing", "inactive". + State string `json:"state,omitempty"` + + // annotations + Annotations Labels `json:"annotations,omitempty"` + + // labels + Labels Labels `json:"labels,omitempty"` + + // type + Type RuleType `json:"type,omitempty"` +} + +// Validate validates this alerting rule +func (m *AlertingRule) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAlerts(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLastEvaluation(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAnnotations(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLabels(formats); err != nil { + res = append(res, err) + } + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AlertingRule) validateAlerts(formats strfmt.Registry) error { + + if swag.IsZero(m.Alerts) { // not required + return nil + } + + for i := 0; i < len(m.Alerts); i++ { + if swag.IsZero(m.Alerts[i]) { // not required + continue + } + + if m.Alerts[i] != nil { + if err := m.Alerts[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("alerts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertingRule) validateLastEvaluation(formats strfmt.Registry) error { + + if swag.IsZero(m.LastEvaluation) { // not required + return nil + } + + if err := validate.FormatOf("lastEvaluation", "body", "date-time", m.LastEvaluation.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *AlertingRule) 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 *AlertingRule) validateLabels(formats strfmt.Registry) error { + + if swag.IsZero(m.Labels) { // not required + return nil + } + + if err := m.Labels.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("labels") + } + return err + } + + return nil +} + +func (m *AlertingRule) validateType(formats strfmt.Registry) error { + + if swag.IsZero(m.Type) { // not required + return nil + } + + if err := m.Type.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("type") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AlertingRule) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AlertingRule) UnmarshalBinary(b []byte) error { + var res AlertingRule + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/alertmanager_config.go b/pkg/gen/models/alertmanager_config.go new file mode 100644 index 00000000000..029c2adf050 --- /dev/null +++ b/pkg/gen/models/alertmanager_config.go @@ -0,0 +1,64 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// AlertmanagerConfig 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/pkg/gen/models/api_alerting_config.go b/pkg/gen/models/api_alerting_config.go new file mode 100644 index 00000000000..2bab2aaf6c3 --- /dev/null +++ b/pkg/gen/models/api_alerting_config.go @@ -0,0 +1,165 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// APIAlertingConfig Api alerting config +// +// swagger:model ApiAlertingConfig +type APIAlertingConfig struct { + + // inhibit rules + InhibitRules []*InhibitRule `json:"inhibit_rules"` + + // Override with our superset receiver type + Receivers []*APIReceiver `json:"receivers"` + + // templates + Templates []string `json:"templates"` + + // global + Global *GlobalConfig `json:"global,omitempty"` + + // route + Route *Route `json:"route,omitempty"` +} + +// Validate validates this Api alerting config +func (m *APIAlertingConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateInhibitRules(formats); err != nil { + res = append(res, err) + } + + if err := m.validateReceivers(formats); err != nil { + res = append(res, err) + } + + if err := m.validateGlobal(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRoute(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIAlertingConfig) validateInhibitRules(formats strfmt.Registry) error { + + if swag.IsZero(m.InhibitRules) { // not required + return nil + } + + for i := 0; i < len(m.InhibitRules); i++ { + if swag.IsZero(m.InhibitRules[i]) { // not required + continue + } + + if m.InhibitRules[i] != nil { + if err := m.InhibitRules[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("inhibit_rules" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIAlertingConfig) validateReceivers(formats strfmt.Registry) error { + + if swag.IsZero(m.Receivers) { // not required + return nil + } + + 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 *APIAlertingConfig) validateGlobal(formats strfmt.Registry) error { + + if swag.IsZero(m.Global) { // not required + return nil + } + + if m.Global != nil { + if err := m.Global.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("global") + } + return err + } + } + + return nil +} + +func (m *APIAlertingConfig) validateRoute(formats strfmt.Registry) error { + + if swag.IsZero(m.Route) { // not required + return nil + } + + if m.Route != nil { + if err := m.Route.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("route") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *APIAlertingConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIAlertingConfig) UnmarshalBinary(b []byte) error { + var res APIAlertingConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/api_receiver.go b/pkg/gen/models/api_receiver.go new file mode 100644 index 00000000000..18081dfc40b --- /dev/null +++ b/pkg/gen/models/api_receiver.go @@ -0,0 +1,334 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// APIReceiver Api receiver +// +// swagger:model ApiReceiver +type APIReceiver struct { + + // email configs + EmailConfigs []*EmailConfig `json:"email_configs"` + + // grafana managed receivers + GrafanaManagedReceivers []GrafanaReceiver `json:"grafana_managed_receiver_configs"` + + // A unique identifier for this receiver. + Name string `json:"name,omitempty"` + + // ops genie configs + OpsGenieConfigs []*OpsGenieConfig `json:"opsgenie_configs"` + + // pagerduty configs + PagerdutyConfigs []*PagerdutyConfig `json:"pagerduty_configs"` + + // pushover configs + PushoverConfigs []*PushoverConfig `json:"pushover_configs"` + + // slack configs + SlackConfigs []*SlackConfig `json:"slack_configs"` + + // victor ops configs + VictorOpsConfigs []*VictorOpsConfig `json:"victorops_configs"` + + // webhook configs + WebhookConfigs []*WebhookConfig `json:"webhook_configs"` + + // wechat configs + WechatConfigs []*WechatConfig `json:"wechat_configs"` +} + +// Validate validates this Api receiver +func (m *APIReceiver) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEmailConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateGrafanaManagedReceivers(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOpsGenieConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePagerdutyConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePushoverConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSlackConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVictorOpsConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateWebhookConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateWechatConfigs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIReceiver) validateEmailConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.EmailConfigs) { // not required + return nil + } + + for i := 0; i < len(m.EmailConfigs); i++ { + if swag.IsZero(m.EmailConfigs[i]) { // not required + continue + } + + if m.EmailConfigs[i] != nil { + if err := m.EmailConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("email_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIReceiver) validateGrafanaManagedReceivers(formats strfmt.Registry) error { + + if swag.IsZero(m.GrafanaManagedReceivers) { // not required + return nil + } + + for i := 0; i < len(m.GrafanaManagedReceivers); i++ { + + if err := m.GrafanaManagedReceivers[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("grafana_managed_receiver_configs" + "." + strconv.Itoa(i)) + } + return err + } + + } + + return nil +} + +func (m *APIReceiver) validateOpsGenieConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.OpsGenieConfigs) { // not required + return nil + } + + for i := 0; i < len(m.OpsGenieConfigs); i++ { + if swag.IsZero(m.OpsGenieConfigs[i]) { // not required + continue + } + + if m.OpsGenieConfigs[i] != nil { + if err := m.OpsGenieConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("opsgenie_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIReceiver) validatePagerdutyConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.PagerdutyConfigs) { // not required + return nil + } + + for i := 0; i < len(m.PagerdutyConfigs); i++ { + if swag.IsZero(m.PagerdutyConfigs[i]) { // not required + continue + } + + if m.PagerdutyConfigs[i] != nil { + if err := m.PagerdutyConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pagerduty_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIReceiver) validatePushoverConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.PushoverConfigs) { // not required + return nil + } + + for i := 0; i < len(m.PushoverConfigs); i++ { + if swag.IsZero(m.PushoverConfigs[i]) { // not required + continue + } + + if m.PushoverConfigs[i] != nil { + if err := m.PushoverConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pushover_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIReceiver) validateSlackConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.SlackConfigs) { // not required + return nil + } + + for i := 0; i < len(m.SlackConfigs); i++ { + if swag.IsZero(m.SlackConfigs[i]) { // not required + continue + } + + if m.SlackConfigs[i] != nil { + if err := m.SlackConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("slack_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIReceiver) validateVictorOpsConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.VictorOpsConfigs) { // not required + return nil + } + + for i := 0; i < len(m.VictorOpsConfigs); i++ { + if swag.IsZero(m.VictorOpsConfigs[i]) { // not required + continue + } + + if m.VictorOpsConfigs[i] != nil { + if err := m.VictorOpsConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("victorops_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIReceiver) validateWebhookConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.WebhookConfigs) { // not required + return nil + } + + for i := 0; i < len(m.WebhookConfigs); i++ { + if swag.IsZero(m.WebhookConfigs[i]) { // not required + continue + } + + if m.WebhookConfigs[i] != nil { + if err := m.WebhookConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("webhook_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIReceiver) validateWechatConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.WechatConfigs) { // not required + return nil + } + + for i := 0; i < len(m.WechatConfigs); i++ { + if swag.IsZero(m.WechatConfigs[i]) { // not required + continue + } + + if m.WechatConfigs[i] != nil { + if err := m.WechatConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("wechat_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *APIReceiver) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIReceiver) UnmarshalBinary(b []byte) error { + var res APIReceiver + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/basic_auth.go b/pkg/gen/models/basic_auth.go new file mode 100644 index 00000000000..4d17c398e53 --- /dev/null +++ b/pkg/gen/models/basic_auth.go @@ -0,0 +1,75 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// BasicAuth BasicAuth contains basic HTTP authentication credentials. +// +// swagger:model BasicAuth +type BasicAuth struct { + + // password + Password Secret `json:"Password,omitempty"` + + // password file + PasswordFile string `json:"PasswordFile,omitempty"` + + // username + Username string `json:"Username,omitempty"` +} + +// Validate validates this basic auth +func (m *BasicAuth) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePassword(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *BasicAuth) validatePassword(formats strfmt.Registry) error { + + if swag.IsZero(m.Password) { // not required + return nil + } + + if err := m.Password.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("Password") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BasicAuth) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BasicAuth) UnmarshalBinary(b []byte) error { + var res BasicAuth + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/cluster_status.go b/pkg/gen/models/cluster_status.go new file mode 100644 index 00000000000..6f779030ceb --- /dev/null +++ b/pkg/gen/models/cluster_status.go @@ -0,0 +1,134 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ClusterStatus ClusterStatus cluster status +// +// swagger:model ClusterStatus +type ClusterStatus struct { + + // name + Name string `json:"name,omitempty"` + + // peers + 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 ( + + // ClusterStatusStatusReadySettlingDisabled captures enum value "[ready settling disabled]" + ClusterStatusStatusReadySettlingDisabled string = "[ready settling disabled]" +) + +// prop value enum +func (m *ClusterStatus) validateStatusEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, clusterStatusTypeStatusPropEnum, true); 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/pkg/gen/models/create_alert_notification_command.go b/pkg/gen/models/create_alert_notification_command.go new file mode 100644 index 00000000000..5bb4ef8767e --- /dev/null +++ b/pkg/gen/models/create_alert_notification_command.go @@ -0,0 +1,98 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// CreateAlertNotificationCommand create alert notification command +// +// swagger:model CreateAlertNotificationCommand +type CreateAlertNotificationCommand struct { + + // disable resolve message + DisableResolveMessage bool `json:"disableResolveMessage,omitempty"` + + // frequency + Frequency string `json:"frequency,omitempty"` + + // is default + IsDefault bool `json:"isDefault,omitempty"` + + // name + Name string `json:"name,omitempty"` + + // result + Result *AlertNotification `json:"Result,omitempty"` + + // secure settings + SecureSettings map[string]string `json:"secureSettings,omitempty"` + + // send reminder + SendReminder bool `json:"sendReminder,omitempty"` + + // type + Type string `json:"type,omitempty"` + + // Uid + UID string `json:"uid,omitempty"` + + // settings + Settings JSON `json:"settings,omitempty"` +} + +// Validate validates this create alert notification command +func (m *CreateAlertNotificationCommand) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateResult(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *CreateAlertNotificationCommand) validateResult(formats strfmt.Registry) error { + + if swag.IsZero(m.Result) { // not required + return nil + } + + if m.Result != nil { + if err := m.Result.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("Result") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CreateAlertNotificationCommand) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CreateAlertNotificationCommand) UnmarshalBinary(b []byte) error { + var res CreateAlertNotificationCommand + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/dashboard_acl_update_item.go b/pkg/gen/models/dashboard_acl_update_item.go new file mode 100644 index 00000000000..e1a0a04ee13 --- /dev/null +++ b/pkg/gen/models/dashboard_acl_update_item.go @@ -0,0 +1,98 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// DashboardACLUpdateItem dashboard Acl update item +// +// swagger:model DashboardAclUpdateItem +type DashboardACLUpdateItem struct { + + // team ID + TeamID int64 `json:"teamId,omitempty"` + + // user ID + UserID int64 `json:"userId,omitempty"` + + // permission + Permission PermissionType `json:"permission,omitempty"` + + // role + Role RoleType `json:"role,omitempty"` +} + +// Validate validates this dashboard Acl update item +func (m *DashboardACLUpdateItem) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validatePermission(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRole(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DashboardACLUpdateItem) validatePermission(formats strfmt.Registry) error { + + if swag.IsZero(m.Permission) { // not required + return nil + } + + if err := m.Permission.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("permission") + } + return err + } + + return nil +} + +func (m *DashboardACLUpdateItem) validateRole(formats strfmt.Registry) error { + + if swag.IsZero(m.Role) { // not required + return nil + } + + if err := m.Role.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("role") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *DashboardACLUpdateItem) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DashboardACLUpdateItem) UnmarshalBinary(b []byte) error { + var res DashboardACLUpdateItem + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/duration.go b/pkg/gen/models/duration.go new file mode 100644 index 00000000000..038ddcede16 --- /dev/null +++ b/pkg/gen/models/duration.go @@ -0,0 +1,11 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// Duration duration +// +// swagger:model Duration +type Duration = Duration diff --git a/pkg/gen/models/email_config.go b/pkg/gen/models/email_config.go new file mode 100644 index 00000000000..18ec840f58e --- /dev/null +++ b/pkg/gen/models/email_config.go @@ -0,0 +1,172 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// EmailConfig EmailConfig configures notifications via mail. +// +// swagger:model EmailConfig +type EmailConfig struct { + + // auth identity + AuthIdentity string `json:"auth_identity,omitempty"` + + // auth username + AuthUsername string `json:"auth_username,omitempty"` + + // from + From string `json:"from,omitempty"` + + // HTML + HTML string `json:"html,omitempty"` + + // headers + Headers map[string]string `json:"headers,omitempty"` + + // hello + Hello string `json:"hello,omitempty"` + + // require TLS + RequireTLS bool `json:"require_tls,omitempty"` + + // text + Text string `json:"text,omitempty"` + + // Email address to notify. + To string `json:"to,omitempty"` + + // v send resolved + VSendResolved bool `json:"send_resolved,omitempty"` + + // auth password + AuthPassword Secret `json:"auth_password,omitempty"` + + // auth secret + AuthSecret Secret `json:"auth_secret,omitempty"` + + // smarthost + Smarthost *HostPort `json:"smarthost,omitempty"` + + // tls config + TLSConfig *TLSConfig `json:"tls_config,omitempty"` +} + +// Validate validates this email config +func (m *EmailConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAuthPassword(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAuthSecret(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSmarthost(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTLSConfig(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *EmailConfig) validateAuthPassword(formats strfmt.Registry) error { + + if swag.IsZero(m.AuthPassword) { // not required + return nil + } + + if err := m.AuthPassword.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("auth_password") + } + return err + } + + return nil +} + +func (m *EmailConfig) validateAuthSecret(formats strfmt.Registry) error { + + if swag.IsZero(m.AuthSecret) { // not required + return nil + } + + if err := m.AuthSecret.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("auth_secret") + } + return err + } + + return nil +} + +func (m *EmailConfig) validateSmarthost(formats strfmt.Registry) error { + + if swag.IsZero(m.Smarthost) { // not required + return nil + } + + if m.Smarthost != nil { + if err := m.Smarthost.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("smarthost") + } + return err + } + } + + return nil +} + +func (m *EmailConfig) validateTLSConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.TLSConfig) { // not required + return nil + } + + if m.TLSConfig != nil { + if err := m.TLSConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tls_config") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *EmailConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *EmailConfig) UnmarshalBinary(b []byte) error { + var res EmailConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/error_type.go b/pkg/gen/models/error_type.go new file mode 100644 index 00000000000..d7acf607db0 --- /dev/null +++ b/pkg/gen/models/error_type.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// ErrorType ErrorType models the different API error types. +// +// swagger:model ErrorType +type ErrorType string + +// Validate validates this error type +func (m ErrorType) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/eval_alert_condition_command.go b/pkg/gen/models/eval_alert_condition_command.go new file mode 100644 index 00000000000..113cd3b6737 --- /dev/null +++ b/pkg/gen/models/eval_alert_condition_command.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// EvalAlertConditionCommand eval alert condition command +// +// swagger:model EvalAlertConditionCommand +type EvalAlertConditionCommand struct { + + // condition + Condition string `json:"condition,omitempty"` + + // data + Data []*AlertQuery `json:"data"` + + // now + // Format: date-time + Now strfmt.DateTime `json:"now,omitempty"` +} + +// Validate validates this eval alert condition command +func (m *EvalAlertConditionCommand) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNow(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *EvalAlertConditionCommand) validateData(formats strfmt.Registry) error { + + if swag.IsZero(m.Data) { // not required + return nil + } + + for i := 0; i < len(m.Data); i++ { + if swag.IsZero(m.Data[i]) { // not required + continue + } + + if m.Data[i] != nil { + if err := m.Data[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *EvalAlertConditionCommand) validateNow(formats strfmt.Registry) error { + + if swag.IsZero(m.Now) { // not required + return nil + } + + if err := validate.FormatOf("now", "body", "date-time", m.Now.String(), formats); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *EvalAlertConditionCommand) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *EvalAlertConditionCommand) UnmarshalBinary(b []byte) error { + var res EvalAlertConditionCommand + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/extended_receiver.go b/pkg/gen/models/extended_receiver.go new file mode 100644 index 00000000000..c131bb87a62 --- /dev/null +++ b/pkg/gen/models/extended_receiver.go @@ -0,0 +1,269 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ExtendedReceiver extended receiver +// +// swagger:model ExtendedReceiver +type ExtendedReceiver struct { + + // email configs + EmailConfigs *EmailConfig `json:"email_configs,omitempty"` + + // grafana managed receiver + GrafanaManagedReceiver GrafanaReceiver `json:"grafana_managed_receiver,omitempty"` + + // opsgenie configs + OpsgenieConfigs *OpsGenieConfig `json:"opsgenie_configs,omitempty"` + + // pagerduty configs + PagerdutyConfigs *PagerdutyConfig `json:"pagerduty_configs,omitempty"` + + // pushover configs + PushoverConfigs *PushoverConfig `json:"pushover_configs,omitempty"` + + // slack configs + SlackConfigs *SlackConfig `json:"slack_configs,omitempty"` + + // victorops configs + VictoropsConfigs *VictorOpsConfig `json:"victorops_configs,omitempty"` + + // webhook configs + WebhookConfigs *WebhookConfig `json:"webhook_configs,omitempty"` + + // wechat configs + WechatConfigs *WechatConfig `json:"wechat_configs,omitempty"` +} + +// Validate validates this extended receiver +func (m *ExtendedReceiver) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEmailConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateGrafanaManagedReceiver(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOpsgenieConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePagerdutyConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePushoverConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSlackConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVictoropsConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateWebhookConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateWechatConfigs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExtendedReceiver) validateEmailConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.EmailConfigs) { // not required + return nil + } + + if m.EmailConfigs != nil { + if err := m.EmailConfigs.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("email_configs") + } + return err + } + } + + return nil +} + +func (m *ExtendedReceiver) validateGrafanaManagedReceiver(formats strfmt.Registry) error { + + if swag.IsZero(m.GrafanaManagedReceiver) { // not required + return nil + } + + if err := m.GrafanaManagedReceiver.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("grafana_managed_receiver") + } + return err + } + + return nil +} + +func (m *ExtendedReceiver) validateOpsgenieConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.OpsgenieConfigs) { // not required + return nil + } + + if m.OpsgenieConfigs != nil { + if err := m.OpsgenieConfigs.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("opsgenie_configs") + } + return err + } + } + + return nil +} + +func (m *ExtendedReceiver) validatePagerdutyConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.PagerdutyConfigs) { // not required + return nil + } + + if m.PagerdutyConfigs != nil { + if err := m.PagerdutyConfigs.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pagerduty_configs") + } + return err + } + } + + return nil +} + +func (m *ExtendedReceiver) validatePushoverConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.PushoverConfigs) { // not required + return nil + } + + if m.PushoverConfigs != nil { + if err := m.PushoverConfigs.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pushover_configs") + } + return err + } + } + + return nil +} + +func (m *ExtendedReceiver) validateSlackConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.SlackConfigs) { // not required + return nil + } + + if m.SlackConfigs != nil { + if err := m.SlackConfigs.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("slack_configs") + } + return err + } + } + + return nil +} + +func (m *ExtendedReceiver) validateVictoropsConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.VictoropsConfigs) { // not required + return nil + } + + if m.VictoropsConfigs != nil { + if err := m.VictoropsConfigs.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("victorops_configs") + } + return err + } + } + + return nil +} + +func (m *ExtendedReceiver) validateWebhookConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.WebhookConfigs) { // not required + return nil + } + + if m.WebhookConfigs != nil { + if err := m.WebhookConfigs.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("webhook_configs") + } + return err + } + } + + return nil +} + +func (m *ExtendedReceiver) validateWechatConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.WechatConfigs) { // not required + return nil + } + + if m.WechatConfigs != nil { + if err := m.WechatConfigs.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("wechat_configs") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ExtendedReceiver) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ExtendedReceiver) UnmarshalBinary(b []byte) error { + var res ExtendedReceiver + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/extended_rule_node.go b/pkg/gen/models/extended_rule_node.go new file mode 100644 index 00000000000..7ddcaf7cff5 --- /dev/null +++ b/pkg/gen/models/extended_rule_node.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ExtendedRuleNode extended rule node +// +// swagger:model ExtendedRuleNode +type ExtendedRuleNode struct { + + // alert + Alert string `json:"alert,omitempty"` + + // annotations + Annotations map[string]string `json:"annotations,omitempty"` + + // expr + Expr string `json:"expr,omitempty"` + + // labels + Labels map[string]string `json:"labels,omitempty"` + + // record + Record string `json:"record,omitempty"` + + // for + For Duration `json:"for,omitempty"` + + // grafana alert + GrafanaAlert *ExtendedUpsertAlertDefinitionCommand `json:"grafana_alert,omitempty"` +} + +// Validate validates this extended rule node +func (m *ExtendedRuleNode) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateGrafanaAlert(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExtendedRuleNode) validateGrafanaAlert(formats strfmt.Registry) error { + + if swag.IsZero(m.GrafanaAlert) { // not required + return nil + } + + if m.GrafanaAlert != nil { + if err := m.GrafanaAlert.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("grafana_alert") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ExtendedRuleNode) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ExtendedRuleNode) UnmarshalBinary(b []byte) error { + var res ExtendedRuleNode + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/extended_upsert_alert_definition_command.go b/pkg/gen/models/extended_upsert_alert_definition_command.go new file mode 100644 index 00000000000..f658aab4dba --- /dev/null +++ b/pkg/gen/models/extended_upsert_alert_definition_command.go @@ -0,0 +1,206 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ExtendedUpsertAlertDefinitionCommand ExtendedUpsertAlertDefinitionCommand extends UpsertAlertDefinitionCommand +// with properties of grafana dashboard alerts +// +// swagger:model ExtendedUpsertAlertDefinitionCommand +type ExtendedUpsertAlertDefinitionCommand struct { + + // Condition is the refID of the query or expression to be evaluated + Condition string `json:"condition,omitempty"` + + // Data is an array of the queries and expressions + Data []*AlertQuery `json:"data"` + + // execution error state + // Enum: [Alerting KeepLastState] + ExecutionErrorState string `json:"exec_err_state,omitempty"` + + // no data state + // Enum: [Alerting NoData KeepLastState OK] + NoDataState string `json:"no_data_state,omitempty"` + + // Receivers are optional and used for migrating notification channels of existing alerts + Receivers []string `json:"receivers"` + + // settings + Settings map[string]interface{} `json:"settings,omitempty"` + + // title + Title string `json:"title,omitempty"` + + // UID is set only for existing definitions + UID string `json:"uid,omitempty"` +} + +// Validate validates this extended upsert alert definition command +func (m *ExtendedUpsertAlertDefinitionCommand) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateExecutionErrorState(formats); err != nil { + res = append(res, err) + } + + if err := m.validateNoDataState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ExtendedUpsertAlertDefinitionCommand) validateData(formats strfmt.Registry) error { + + if swag.IsZero(m.Data) { // not required + return nil + } + + for i := 0; i < len(m.Data); i++ { + if swag.IsZero(m.Data[i]) { // not required + continue + } + + if m.Data[i] != nil { + if err := m.Data[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +var extendedUpsertAlertDefinitionCommandTypeExecutionErrorStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["Alerting","KeepLastState"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + extendedUpsertAlertDefinitionCommandTypeExecutionErrorStatePropEnum = append(extendedUpsertAlertDefinitionCommandTypeExecutionErrorStatePropEnum, v) + } +} + +const ( + + // ExtendedUpsertAlertDefinitionCommandExecutionErrorStateAlerting captures enum value "Alerting" + ExtendedUpsertAlertDefinitionCommandExecutionErrorStateAlerting string = "Alerting" + + // ExtendedUpsertAlertDefinitionCommandExecutionErrorStateKeepLastState captures enum value "KeepLastState" + ExtendedUpsertAlertDefinitionCommandExecutionErrorStateKeepLastState string = "KeepLastState" +) + +// prop value enum +func (m *ExtendedUpsertAlertDefinitionCommand) validateExecutionErrorStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, extendedUpsertAlertDefinitionCommandTypeExecutionErrorStatePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *ExtendedUpsertAlertDefinitionCommand) validateExecutionErrorState(formats strfmt.Registry) error { + + if swag.IsZero(m.ExecutionErrorState) { // not required + return nil + } + + // value enum + if err := m.validateExecutionErrorStateEnum("exec_err_state", "body", m.ExecutionErrorState); err != nil { + return err + } + + return nil +} + +var extendedUpsertAlertDefinitionCommandTypeNoDataStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["Alerting","NoData","KeepLastState","OK"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + extendedUpsertAlertDefinitionCommandTypeNoDataStatePropEnum = append(extendedUpsertAlertDefinitionCommandTypeNoDataStatePropEnum, v) + } +} + +const ( + + // ExtendedUpsertAlertDefinitionCommandNoDataStateAlerting captures enum value "Alerting" + ExtendedUpsertAlertDefinitionCommandNoDataStateAlerting string = "Alerting" + + // ExtendedUpsertAlertDefinitionCommandNoDataStateNoData captures enum value "NoData" + ExtendedUpsertAlertDefinitionCommandNoDataStateNoData string = "NoData" + + // ExtendedUpsertAlertDefinitionCommandNoDataStateKeepLastState captures enum value "KeepLastState" + ExtendedUpsertAlertDefinitionCommandNoDataStateKeepLastState string = "KeepLastState" + + // ExtendedUpsertAlertDefinitionCommandNoDataStateOK captures enum value "OK" + ExtendedUpsertAlertDefinitionCommandNoDataStateOK string = "OK" +) + +// prop value enum +func (m *ExtendedUpsertAlertDefinitionCommand) validateNoDataStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, extendedUpsertAlertDefinitionCommandTypeNoDataStatePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *ExtendedUpsertAlertDefinitionCommand) validateNoDataState(formats strfmt.Registry) error { + + if swag.IsZero(m.NoDataState) { // not required + return nil + } + + // value enum + if err := m.validateNoDataStateEnum("no_data_state", "body", m.NoDataState); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ExtendedUpsertAlertDefinitionCommand) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ExtendedUpsertAlertDefinitionCommand) UnmarshalBinary(b []byte) error { + var res ExtendedUpsertAlertDefinitionCommand + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/failure.go b/pkg/gen/models/failure.go new file mode 100644 index 00000000000..774d9df05ec --- /dev/null +++ b/pkg/gen/models/failure.go @@ -0,0 +1,47 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Failure failure +// +// swagger:model Failure +type Failure struct { + ResponseDetails +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *Failure) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 ResponseDetails + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.ResponseDetails = aO0 + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m Failure) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 1) + + aO0, err := swag.WriteJSON(m.ResponseDetails) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this failure +func (m *Failure) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/gettable_alert.go b/pkg/gen/models/gettable_alert.go new file mode 100644 index 00000000000..f8ce4f08af6 --- /dev/null +++ b/pkg/gen/models/gettable_alert.go @@ -0,0 +1,253 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// GettableAlert GettableAlert gettable alert +// +// swagger:model GettableAlert +type GettableAlert struct { + + // ends at + // Required: true + // Format: date-time + EndsAt *strfmt.DateTime `json:"endsAt"` + + // fingerprint + // Required: true + Fingerprint *string `json:"fingerprint"` + + // generator URL + // Format: uri + // Format: uri + GeneratorURL strfmt.URI `json:"generatorURL,omitempty"` + + // receivers + // Required: true + Receivers []*Receiver `json:"receivers"` + + // starts at + // Required: true + // Format: date-time + StartsAt *strfmt.DateTime `json:"startsAt"` + + // updated at + // Required: true + // Format: date-time + UpdatedAt *strfmt.DateTime `json:"updatedAt"` + + // annotations + // Required: true + Annotations LabelSet `json:"annotations"` + + // labels + // Required: true + Labels LabelSet `json:"labels"` + + // status + // Required: true + Status *AlertStatus `json:"status"` +} + +// Validate validates this gettable alert +func (m *GettableAlert) Validate(formats strfmt.Registry) error { + var res []error + + 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.validateGeneratorURL(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.validateUpdatedAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAnnotations(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLabels(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 *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) 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 *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) 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 +} + +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) 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 +} + +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 +} + +// 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/pkg/gen/models/gettable_alerts.go b/pkg/gen/models/gettable_alerts.go new file mode 100644 index 00000000000..5a8d178c3d7 --- /dev/null +++ b/pkg/gen/models/gettable_alerts.go @@ -0,0 +1,11 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// GettableAlerts gettable alerts +// +// swagger:model GettableAlerts +type GettableAlerts = GettableAlerts diff --git a/pkg/gen/models/gettable_silence.go b/pkg/gen/models/gettable_silence.go new file mode 100644 index 00000000000..81ea24cb6b5 --- /dev/null +++ b/pkg/gen/models/gettable_silence.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// GettableSilence GettableSilence gettable silence +// +// swagger:model GettableSilence +type GettableSilence 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"` + + // id + // Required: true + ID *string `json:"id"` + + // starts at + // Required: true + // Format: date-time + StartsAt *strfmt.DateTime `json:"startsAt"` + + // updated at + // Required: true + // Format: date-time + UpdatedAt *strfmt.DateTime `json:"updatedAt"` + + // matchers + // Required: true + Matchers Matchers `json:"matchers"` + + // status + // Required: true + Status *SilenceStatus `json:"status"` +} + +// Validate validates this gettable silence +func (m *GettableSilence) 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.validateID(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartsAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUpdatedAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchers(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 *GettableSilence) validateComment(formats strfmt.Registry) error { + + if err := validate.Required("comment", "body", m.Comment); err != nil { + return err + } + + return nil +} + +func (m *GettableSilence) validateCreatedBy(formats strfmt.Registry) error { + + if err := validate.Required("createdBy", "body", m.CreatedBy); err != nil { + return err + } + + return nil +} + +func (m *GettableSilence) 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 *GettableSilence) validateID(formats strfmt.Registry) error { + + if err := validate.Required("id", "body", m.ID); err != nil { + return err + } + + return nil +} + +func (m *GettableSilence) 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 *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 +} + +func (m *GettableSilence) 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 *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 +} + +// 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/pkg/gen/models/gettable_silences.go b/pkg/gen/models/gettable_silences.go new file mode 100644 index 00000000000..90008b2f6f4 --- /dev/null +++ b/pkg/gen/models/gettable_silences.go @@ -0,0 +1,45 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// GettableSilences 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/pkg/gen/models/global_config.go b/pkg/gen/models/global_config.go new file mode 100644 index 00000000000..3b95de3362d --- /dev/null +++ b/pkg/gen/models/global_config.go @@ -0,0 +1,376 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// GlobalConfig GlobalConfig defines configuration parameters that are valid globally +// unless overwritten. +// +// swagger:model GlobalConfig +type GlobalConfig struct { + + // SMTP auth identity + SMTPAuthIdentity string `json:"smtp_auth_identity,omitempty"` + + // SMTP auth username + SMTPAuthUsername string `json:"smtp_auth_username,omitempty"` + + // SMTP from + SMTPFrom string `json:"smtp_from,omitempty"` + + // SMTP hello + SMTPHello string `json:"smtp_hello,omitempty"` + + // SMTP require TLS + SMTPRequireTLS bool `json:"smtp_require_tls,omitempty"` + + // we chat API corp ID + WeChatAPICorpID string `json:"wechat_api_corp_id,omitempty"` + + // http config + HTTPConfig *HTTPClientConfig `json:"http_config,omitempty"` + + // opsgenie api key + OpsgenieAPIKey Secret `json:"opsgenie_api_key,omitempty"` + + // opsgenie api url + OpsgenieAPIURL *URL `json:"opsgenie_api_url,omitempty"` + + // pagerduty url + PagerdutyURL *URL `json:"pagerduty_url,omitempty"` + + // resolve timeout + ResolveTimeout Duration `json:"resolve_timeout,omitempty"` + + // slack api url + SlackAPIURL SecretURL `json:"slack_api_url,omitempty"` + + // smtp auth password + SMTPAuthPassword Secret `json:"smtp_auth_password,omitempty"` + + // smtp auth secret + SMTPAuthSecret Secret `json:"smtp_auth_secret,omitempty"` + + // smtp smarthost + SMTPSmarthost *HostPort `json:"smtp_smarthost,omitempty"` + + // victorops api key + VictoropsAPIKey Secret `json:"victorops_api_key,omitempty"` + + // victorops api url + VictoropsAPIURL *URL `json:"victorops_api_url,omitempty"` + + // wechat api secret + WechatAPISecret Secret `json:"wechat_api_secret,omitempty"` + + // wechat api url + WechatAPIURL *URL `json:"wechat_api_url,omitempty"` +} + +// Validate validates this global config +func (m *GlobalConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHTTPConfig(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOpsgenieAPIKey(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOpsgenieAPIURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePagerdutyURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validateResolveTimeout(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSlackAPIURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSMTPAuthPassword(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSMTPAuthSecret(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSMTPSmarthost(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVictoropsAPIKey(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVictoropsAPIURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validateWechatAPISecret(formats); err != nil { + res = append(res, err) + } + + if err := m.validateWechatAPIURL(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *GlobalConfig) validateHTTPConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPConfig) { // not required + return nil + } + + if m.HTTPConfig != nil { + if err := m.HTTPConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_config") + } + return err + } + } + + return nil +} + +func (m *GlobalConfig) validateOpsgenieAPIKey(formats strfmt.Registry) error { + + if swag.IsZero(m.OpsgenieAPIKey) { // not required + return nil + } + + if err := m.OpsgenieAPIKey.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("opsgenie_api_key") + } + return err + } + + return nil +} + +func (m *GlobalConfig) validateOpsgenieAPIURL(formats strfmt.Registry) error { + + if swag.IsZero(m.OpsgenieAPIURL) { // not required + return nil + } + + if m.OpsgenieAPIURL != nil { + if err := m.OpsgenieAPIURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("opsgenie_api_url") + } + return err + } + } + + return nil +} + +func (m *GlobalConfig) validatePagerdutyURL(formats strfmt.Registry) error { + + if swag.IsZero(m.PagerdutyURL) { // not required + return nil + } + + if m.PagerdutyURL != nil { + if err := m.PagerdutyURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pagerduty_url") + } + return err + } + } + + return nil +} + +func (m *GlobalConfig) validateResolveTimeout(formats strfmt.Registry) error { + + if swag.IsZero(m.ResolveTimeout) { // not required + return nil + } + + if err := m.ResolveTimeout.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resolve_timeout") + } + return err + } + + return nil +} + +func (m *GlobalConfig) validateSlackAPIURL(formats strfmt.Registry) error { + + if swag.IsZero(m.SlackAPIURL) { // not required + return nil + } + + if err := m.SlackAPIURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("slack_api_url") + } + return err + } + + return nil +} + +func (m *GlobalConfig) validateSMTPAuthPassword(formats strfmt.Registry) error { + + if swag.IsZero(m.SMTPAuthPassword) { // not required + return nil + } + + if err := m.SMTPAuthPassword.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("smtp_auth_password") + } + return err + } + + return nil +} + +func (m *GlobalConfig) validateSMTPAuthSecret(formats strfmt.Registry) error { + + if swag.IsZero(m.SMTPAuthSecret) { // not required + return nil + } + + if err := m.SMTPAuthSecret.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("smtp_auth_secret") + } + return err + } + + return nil +} + +func (m *GlobalConfig) validateSMTPSmarthost(formats strfmt.Registry) error { + + if swag.IsZero(m.SMTPSmarthost) { // not required + return nil + } + + if m.SMTPSmarthost != nil { + if err := m.SMTPSmarthost.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("smtp_smarthost") + } + return err + } + } + + return nil +} + +func (m *GlobalConfig) validateVictoropsAPIKey(formats strfmt.Registry) error { + + if swag.IsZero(m.VictoropsAPIKey) { // not required + return nil + } + + if err := m.VictoropsAPIKey.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("victorops_api_key") + } + return err + } + + return nil +} + +func (m *GlobalConfig) validateVictoropsAPIURL(formats strfmt.Registry) error { + + if swag.IsZero(m.VictoropsAPIURL) { // not required + return nil + } + + if m.VictoropsAPIURL != nil { + if err := m.VictoropsAPIURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("victorops_api_url") + } + return err + } + } + + return nil +} + +func (m *GlobalConfig) validateWechatAPISecret(formats strfmt.Registry) error { + + if swag.IsZero(m.WechatAPISecret) { // not required + return nil + } + + if err := m.WechatAPISecret.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("wechat_api_secret") + } + return err + } + + return nil +} + +func (m *GlobalConfig) validateWechatAPIURL(formats strfmt.Registry) error { + + if swag.IsZero(m.WechatAPIURL) { // not required + return nil + } + + if m.WechatAPIURL != nil { + if err := m.WechatAPIURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("wechat_api_url") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *GlobalConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *GlobalConfig) UnmarshalBinary(b []byte) error { + var res GlobalConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/grafana_receiver.go b/pkg/gen/models/grafana_receiver.go new file mode 100644 index 00000000000..db449ddbf47 --- /dev/null +++ b/pkg/gen/models/grafana_receiver.go @@ -0,0 +1,47 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// GrafanaReceiver grafana receiver +// +// swagger:model GrafanaReceiver +type GrafanaReceiver struct { + CreateAlertNotificationCommand +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *GrafanaReceiver) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 CreateAlertNotificationCommand + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.CreateAlertNotificationCommand = aO0 + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m GrafanaReceiver) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 1) + + aO0, err := swag.WriteJSON(m.CreateAlertNotificationCommand) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this grafana receiver +func (m *GrafanaReceiver) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/host_port.go b/pkg/gen/models/host_port.go new file mode 100644 index 00000000000..6c046c3e39c --- /dev/null +++ b/pkg/gen/models/host_port.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// HostPort HostPort represents a "host:port" network address. +// +// swagger:model HostPort +type HostPort struct { + + // host + Host string `json:"Host,omitempty"` + + // port + Port string `json:"Port,omitempty"` +} + +// Validate validates this host port +func (m *HostPort) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *HostPort) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *HostPort) UnmarshalBinary(b []byte) error { + var res HostPort + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/http_client_config.go b/pkg/gen/models/http_client_config.go new file mode 100644 index 00000000000..88f80ace76b --- /dev/null +++ b/pkg/gen/models/http_client_config.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// HTTPClientConfig HTTPClientConfig configures an HTTP client. +// +// swagger:model HTTPClientConfig +type HTTPClientConfig struct { + + // basic auth + BasicAuth *BasicAuth `json:"BasicAuth,omitempty"` + + // bearer token + BearerToken Secret `json:"BearerToken,omitempty"` + + // The bearer token file for the targets. + BearerTokenFile string `json:"BearerTokenFile,omitempty"` + + // proxy URL + ProxyURL *URL `json:"ProxyURL,omitempty"` + + // TLS config + TLSConfig *TLSConfig `json:"TLSConfig,omitempty"` +} + +// Validate validates this HTTP client config +func (m *HTTPClientConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBasicAuth(formats); err != nil { + res = append(res, err) + } + + if err := m.validateBearerToken(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProxyURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTLSConfig(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *HTTPClientConfig) validateBasicAuth(formats strfmt.Registry) error { + + if swag.IsZero(m.BasicAuth) { // not required + return nil + } + + if m.BasicAuth != nil { + if err := m.BasicAuth.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("BasicAuth") + } + return err + } + } + + return nil +} + +func (m *HTTPClientConfig) validateBearerToken(formats strfmt.Registry) error { + + if swag.IsZero(m.BearerToken) { // not required + return nil + } + + if err := m.BearerToken.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("BearerToken") + } + return err + } + + return nil +} + +func (m *HTTPClientConfig) validateProxyURL(formats strfmt.Registry) error { + + if swag.IsZero(m.ProxyURL) { // not required + return nil + } + + if m.ProxyURL != nil { + if err := m.ProxyURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("ProxyURL") + } + return err + } + } + + return nil +} + +func (m *HTTPClientConfig) validateTLSConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.TLSConfig) { // not required + return nil + } + + if m.TLSConfig != nil { + if err := m.TLSConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("TLSConfig") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *HTTPClientConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *HTTPClientConfig) UnmarshalBinary(b []byte) error { + var res HTTPClientConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/inhibit_rule.go b/pkg/gen/models/inhibit_rule.go new file mode 100644 index 00000000000..9768c415437 --- /dev/null +++ b/pkg/gen/models/inhibit_rule.go @@ -0,0 +1,171 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// InhibitRule InhibitRule defines an inhibition rule that mutes alerts that match the +// target labels if an alert matching the source labels exists. +// Both alerts have to have a set of labels being equal. +// +// swagger:model InhibitRule +type InhibitRule struct { + + // SourceMatch defines a set of labels that have to equal the given + // value for source alerts. Deprecated. Remove before v1.0 release. + SourceMatch map[string]string `json:"source_match,omitempty"` + + // TargetMatch defines a set of labels that have to equal the given + // value for target alerts. Deprecated. Remove before v1.0 release. + TargetMatch map[string]string `json:"target_match,omitempty"` + + // equal + Equal LabelNames `json:"equal,omitempty"` + + // source match re + SourceMatchRe MatchRegexps `json:"source_match_re,omitempty"` + + // source matchers + SourceMatchers Matchers `json:"source_matchers,omitempty"` + + // target match re + TargetMatchRe MatchRegexps `json:"target_match_re,omitempty"` + + // target matchers + TargetMatchers Matchers `json:"target_matchers,omitempty"` +} + +// Validate validates this inhibit rule +func (m *InhibitRule) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEqual(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSourceMatchRe(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSourceMatchers(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTargetMatchRe(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTargetMatchers(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *InhibitRule) validateEqual(formats strfmt.Registry) error { + + if swag.IsZero(m.Equal) { // not required + return nil + } + + if err := m.Equal.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("equal") + } + return err + } + + return nil +} + +func (m *InhibitRule) validateSourceMatchRe(formats strfmt.Registry) error { + + if swag.IsZero(m.SourceMatchRe) { // not required + return nil + } + + if err := m.SourceMatchRe.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("source_match_re") + } + return err + } + + return nil +} + +func (m *InhibitRule) validateSourceMatchers(formats strfmt.Registry) error { + + if swag.IsZero(m.SourceMatchers) { // not required + return nil + } + + if err := m.SourceMatchers.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("source_matchers") + } + return err + } + + return nil +} + +func (m *InhibitRule) validateTargetMatchRe(formats strfmt.Registry) error { + + if swag.IsZero(m.TargetMatchRe) { // not required + return nil + } + + if err := m.TargetMatchRe.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("target_match_re") + } + return err + } + + return nil +} + +func (m *InhibitRule) validateTargetMatchers(formats strfmt.Registry) error { + + if swag.IsZero(m.TargetMatchers) { // not required + return nil + } + + if err := m.TargetMatchers.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("target_matchers") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *InhibitRule) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *InhibitRule) UnmarshalBinary(b []byte) error { + var res InhibitRule + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/json.go b/pkg/gen/models/json.go new file mode 100644 index 00000000000..3ac07c860ad --- /dev/null +++ b/pkg/gen/models/json.go @@ -0,0 +1,11 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// JSON Json +// +// swagger:model Json +type JSON interface{} diff --git a/pkg/gen/models/label.go b/pkg/gen/models/label.go new file mode 100644 index 00000000000..624f613117e --- /dev/null +++ b/pkg/gen/models/label.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Label Label is a key/value pair of strings. +// +// swagger:model Label +type Label struct { + + // value + Value string `json:"Name,omitempty"` +} + +// Validate validates this label +func (m *Label) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Label) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Label) UnmarshalBinary(b []byte) error { + var res Label + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/label_name.go b/pkg/gen/models/label_name.go new file mode 100644 index 00000000000..cfb031f339f --- /dev/null +++ b/pkg/gen/models/label_name.go @@ -0,0 +1,21 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// LabelName A LabelName is a key for a LabelSet or Metric. It has a value associated +// therewith. +// +// swagger:model LabelName +type LabelName string + +// Validate validates this label name +func (m LabelName) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/label_names.go b/pkg/gen/models/label_names.go new file mode 100644 index 00000000000..886da093d36 --- /dev/null +++ b/pkg/gen/models/label_names.go @@ -0,0 +1,39 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" +) + +// LabelNames LabelNames is a sortable LabelName slice. In implements sort.Interface. +// +// swagger:model LabelNames +type LabelNames []LabelName + +// Validate validates this label names +func (m LabelNames) Validate(formats strfmt.Registry) error { + var res []error + + for i := 0; i < len(m); i++ { + + 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/pkg/gen/models/label_set.go b/pkg/gen/models/label_set.go new file mode 100644 index 00000000000..7e76e3fd901 --- /dev/null +++ b/pkg/gen/models/label_set.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// LabelSet 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/pkg/gen/models/labels.go b/pkg/gen/models/labels.go new file mode 100644 index 00000000000..42d0e2cec1f --- /dev/null +++ b/pkg/gen/models/labels.go @@ -0,0 +1,22 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// Labels override the labels type with a map for generation. +// +// The custom marshaling for labels.Labels ends up doing this anyways. +// +// swagger:model labels +type Labels map[string]string + +// Validate validates this labels +func (m Labels) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/lotex_query.go b/pkg/gen/models/lotex_query.go new file mode 100644 index 00000000000..a65c0902d83 --- /dev/null +++ b/pkg/gen/models/lotex_query.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// LotexQuery lotex query +// +// swagger:model LotexQuery +type LotexQuery struct { + + // DatasourceUID is required if the query will be sent to grafana to be executed + DatasourceUID string `json:"datasourceUid,omitempty"` + + // expr + Expr string `json:"Expr,omitempty"` +} + +// Validate validates this lotex query +func (m *LotexQuery) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *LotexQuery) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *LotexQuery) UnmarshalBinary(b []byte) error { + var res LotexQuery + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/match_regexps.go b/pkg/gen/models/match_regexps.go new file mode 100644 index 00000000000..53f6cab35b3 --- /dev/null +++ b/pkg/gen/models/match_regexps.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// MatchRegexps MatchRegexps represents a map of Regexp. +// +// swagger:model MatchRegexps +type MatchRegexps map[string]Regexp + +// Validate validates this match regexps +func (m MatchRegexps) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/match_type.go b/pkg/gen/models/match_type.go new file mode 100644 index 00000000000..30a4703d75e --- /dev/null +++ b/pkg/gen/models/match_type.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// MatchType MatchType is an enum for label matching types. +// +// swagger:model MatchType +type MatchType int64 + +// Validate validates this match type +func (m MatchType) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/matcher.go b/pkg/gen/models/matcher.go new file mode 100644 index 00000000000..83846e1faf6 --- /dev/null +++ b/pkg/gen/models/matcher.go @@ -0,0 +1,98 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Matcher 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/pkg/gen/models/matchers.go b/pkg/gen/models/matchers.go new file mode 100644 index 00000000000..f018a300109 --- /dev/null +++ b/pkg/gen/models/matchers.go @@ -0,0 +1,45 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Matchers Matchers matchers +// +// swagger:model Matchers +type Matchers []*Matcher + +// Validate validates this matchers +func (m Matchers) 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/pkg/gen/models/namespace_config_response.go b/pkg/gen/models/namespace_config_response.go new file mode 100644 index 00000000000..181e0cd1477 --- /dev/null +++ b/pkg/gen/models/namespace_config_response.go @@ -0,0 +1,40 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NamespaceConfigResponse namespace config response +// +// swagger:model NamespaceConfigResponse +type NamespaceConfigResponse map[string]RuleGroupConfig + +// Validate validates this namespace config response +func (m NamespaceConfigResponse) Validate(formats strfmt.Registry) error { + var res []error + + for k := range m { + + if err := validate.Required(k, "body", m[k]); err != nil { + return err + } + if val, ok := m[k]; ok { + if err := val.Validate(formats); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/gen/models/ops_genie_config.go b/pkg/gen/models/ops_genie_config.go new file mode 100644 index 00000000000..c73f09768c6 --- /dev/null +++ b/pkg/gen/models/ops_genie_config.go @@ -0,0 +1,177 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// OpsGenieConfig OpsGenieConfig configures notifications via OpsGenie. +// +// swagger:model OpsGenieConfig +type OpsGenieConfig struct { + + // description + Description string `json:"description,omitempty"` + + // details + Details map[string]string `json:"details,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // note + Note string `json:"note,omitempty"` + + // priority + Priority string `json:"priority,omitempty"` + + // responders + Responders []*OpsGenieConfigResponder `json:"responders"` + + // source + Source string `json:"source,omitempty"` + + // tags + Tags string `json:"tags,omitempty"` + + // v send resolved + VSendResolved bool `json:"send_resolved,omitempty"` + + // api key + APIKey Secret `json:"api_key,omitempty"` + + // api url + APIURL *URL `json:"api_url,omitempty"` + + // http config + HTTPConfig *HTTPClientConfig `json:"http_config,omitempty"` +} + +// Validate validates this ops genie config +func (m *OpsGenieConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateResponders(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAPIKey(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAPIURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPConfig(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *OpsGenieConfig) validateResponders(formats strfmt.Registry) error { + + if swag.IsZero(m.Responders) { // not required + return nil + } + + for i := 0; i < len(m.Responders); i++ { + if swag.IsZero(m.Responders[i]) { // not required + continue + } + + if m.Responders[i] != nil { + if err := m.Responders[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("responders" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *OpsGenieConfig) validateAPIKey(formats strfmt.Registry) error { + + if swag.IsZero(m.APIKey) { // not required + return nil + } + + if err := m.APIKey.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("api_key") + } + return err + } + + return nil +} + +func (m *OpsGenieConfig) validateAPIURL(formats strfmt.Registry) error { + + if swag.IsZero(m.APIURL) { // not required + return nil + } + + if m.APIURL != nil { + if err := m.APIURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("api_url") + } + return err + } + } + + return nil +} + +func (m *OpsGenieConfig) validateHTTPConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPConfig) { // not required + return nil + } + + if m.HTTPConfig != nil { + if err := m.HTTPConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_config") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *OpsGenieConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OpsGenieConfig) UnmarshalBinary(b []byte) error { + var res OpsGenieConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/ops_genie_config_responder.go b/pkg/gen/models/ops_genie_config_responder.go new file mode 100644 index 00000000000..84f71de0f7e --- /dev/null +++ b/pkg/gen/models/ops_genie_config_responder.go @@ -0,0 +1,52 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// OpsGenieConfigResponder ops genie config responder +// +// swagger:model OpsGenieConfigResponder +type OpsGenieConfigResponder struct { + + // One of those 3 should be filled. + ID string `json:"id,omitempty"` + + // name + Name string `json:"name,omitempty"` + + // team, user, escalation, schedule etc. + Type string `json:"type,omitempty"` + + // username + Username string `json:"username,omitempty"` +} + +// Validate validates this ops genie config responder +func (m *OpsGenieConfigResponder) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *OpsGenieConfigResponder) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *OpsGenieConfigResponder) UnmarshalBinary(b []byte) error { + var res OpsGenieConfigResponder + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/pagerduty_config.go b/pkg/gen/models/pagerduty_config.go new file mode 100644 index 00000000000..b20525ed744 --- /dev/null +++ b/pkg/gen/models/pagerduty_config.go @@ -0,0 +1,235 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PagerdutyConfig PagerdutyConfig configures notifications via PagerDuty. +// +// swagger:model PagerdutyConfig +type PagerdutyConfig struct { + + // class + Class string `json:"class,omitempty"` + + // client + Client string `json:"client,omitempty"` + + // client URL + ClientURL string `json:"client_url,omitempty"` + + // component + Component string `json:"component,omitempty"` + + // description + Description string `json:"description,omitempty"` + + // details + Details map[string]string `json:"details,omitempty"` + + // group + Group string `json:"group,omitempty"` + + // images + Images []*PagerdutyImage `json:"images"` + + // links + Links []*PagerdutyLink `json:"links"` + + // severity + Severity string `json:"severity,omitempty"` + + // v send resolved + VSendResolved bool `json:"send_resolved,omitempty"` + + // http config + HTTPConfig *HTTPClientConfig `json:"http_config,omitempty"` + + // routing key + RoutingKey Secret `json:"routing_key,omitempty"` + + // service key + ServiceKey Secret `json:"service_key,omitempty"` + + // url + URL *URL `json:"url,omitempty"` +} + +// Validate validates this pagerduty config +func (m *PagerdutyConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateImages(formats); err != nil { + res = append(res, err) + } + + if err := m.validateLinks(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPConfig(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRoutingKey(formats); err != nil { + res = append(res, err) + } + + if err := m.validateServiceKey(formats); err != nil { + res = append(res, err) + } + + if err := m.validateURL(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PagerdutyConfig) validateImages(formats strfmt.Registry) error { + + if swag.IsZero(m.Images) { // not required + return nil + } + + for i := 0; i < len(m.Images); i++ { + if swag.IsZero(m.Images[i]) { // not required + continue + } + + if m.Images[i] != nil { + if err := m.Images[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("images" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PagerdutyConfig) validateLinks(formats strfmt.Registry) error { + + if swag.IsZero(m.Links) { // not required + return nil + } + + for i := 0; i < len(m.Links); i++ { + if swag.IsZero(m.Links[i]) { // not required + continue + } + + if m.Links[i] != nil { + if err := m.Links[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("links" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *PagerdutyConfig) validateHTTPConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPConfig) { // not required + return nil + } + + if m.HTTPConfig != nil { + if err := m.HTTPConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_config") + } + return err + } + } + + return nil +} + +func (m *PagerdutyConfig) validateRoutingKey(formats strfmt.Registry) error { + + if swag.IsZero(m.RoutingKey) { // not required + return nil + } + + if err := m.RoutingKey.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("routing_key") + } + return err + } + + return nil +} + +func (m *PagerdutyConfig) validateServiceKey(formats strfmt.Registry) error { + + if swag.IsZero(m.ServiceKey) { // not required + return nil + } + + if err := m.ServiceKey.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("service_key") + } + return err + } + + return nil +} + +func (m *PagerdutyConfig) validateURL(formats strfmt.Registry) error { + + if swag.IsZero(m.URL) { // not required + return nil + } + + if m.URL != nil { + if err := m.URL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("url") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PagerdutyConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PagerdutyConfig) UnmarshalBinary(b []byte) error { + var res PagerdutyConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/pagerduty_image.go b/pkg/gen/models/pagerduty_image.go new file mode 100644 index 00000000000..cfac19facbb --- /dev/null +++ b/pkg/gen/models/pagerduty_image.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PagerdutyImage PagerdutyImage is an image +// +// swagger:model PagerdutyImage +type PagerdutyImage struct { + + // alt + Alt string `json:"alt,omitempty"` + + // href + Href string `json:"href,omitempty"` + + // src + Src string `json:"src,omitempty"` +} + +// Validate validates this pagerduty image +func (m *PagerdutyImage) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PagerdutyImage) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PagerdutyImage) UnmarshalBinary(b []byte) error { + var res PagerdutyImage + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/pagerduty_link.go b/pkg/gen/models/pagerduty_link.go new file mode 100644 index 00000000000..78aff523836 --- /dev/null +++ b/pkg/gen/models/pagerduty_link.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PagerdutyLink PagerdutyLink is a link +// +// swagger:model PagerdutyLink +type PagerdutyLink struct { + + // href + Href string `json:"href,omitempty"` + + // text + Text string `json:"text,omitempty"` +} + +// Validate validates this pagerduty link +func (m *PagerdutyLink) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PagerdutyLink) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PagerdutyLink) UnmarshalBinary(b []byte) error { + var res PagerdutyLink + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/peer_status.go b/pkg/gen/models/peer_status.go new file mode 100644 index 00000000000..21985775a99 --- /dev/null +++ b/pkg/gen/models/peer_status.go @@ -0,0 +1,81 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PeerStatus 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/pkg/gen/models/permission_type.go b/pkg/gen/models/permission_type.go new file mode 100644 index 00000000000..f21bdbbc4d7 --- /dev/null +++ b/pkg/gen/models/permission_type.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// PermissionType permission type +// +// swagger:model PermissionType +type PermissionType int64 + +// Validate validates this permission type +func (m PermissionType) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/permissions.go b/pkg/gen/models/permissions.go new file mode 100644 index 00000000000..5ea018783ea --- /dev/null +++ b/pkg/gen/models/permissions.go @@ -0,0 +1,45 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Permissions permissions +// +// swagger:model Permissions +type Permissions []*UpdateDashboardACLCommand + +// Validate validates this permissions +func (m Permissions) 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/pkg/gen/models/postable_alert.go b/pkg/gen/models/postable_alert.go new file mode 100644 index 00000000000..a63b6621a98 --- /dev/null +++ b/pkg/gen/models/postable_alert.go @@ -0,0 +1,156 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// PostableAlert PostableAlert postable alert +// +// swagger:model PostableAlert +type PostableAlert struct { + + // ends at + // Format: date-time + // Format: date-time + EndsAt strfmt.DateTime `json:"endsAt,omitempty"` + + // generator URL + // Format: uri + // Format: uri + GeneratorURL strfmt.URI `json:"generatorURL,omitempty"` + + // starts at + // Format: date-time + // Format: date-time + StartsAt strfmt.DateTime `json:"startsAt,omitempty"` + + // annotations + Annotations LabelSet `json:"annotations,omitempty"` + + // labels + // Required: true + Labels LabelSet `json:"labels"` +} + +// Validate validates this postable alert +func (m *PostableAlert) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEndsAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateGeneratorURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validateStartsAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAnnotations(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 *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) 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 *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 +} + +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) 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 *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/pkg/gen/models/pushover_config.go b/pkg/gen/models/pushover_config.go new file mode 100644 index 00000000000..e1e05a09a1d --- /dev/null +++ b/pkg/gen/models/pushover_config.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// PushoverConfig pushover config +// +// swagger:model PushoverConfig +type PushoverConfig struct { + + // HTML + HTML bool `json:"html,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // priority + Priority string `json:"priority,omitempty"` + + // sound + Sound string `json:"sound,omitempty"` + + // title + Title string `json:"title,omitempty"` + + // URL + URL string `json:"url,omitempty"` + + // URL title + URLTitle string `json:"url_title,omitempty"` + + // v send resolved + VSendResolved bool `json:"send_resolved,omitempty"` + + // expire + Expire Duration `json:"expire,omitempty"` + + // http config + HTTPConfig *HTTPClientConfig `json:"http_config,omitempty"` + + // retry + Retry Duration `json:"retry,omitempty"` + + // token + Token Secret `json:"token,omitempty"` + + // user key + UserKey Secret `json:"user_key,omitempty"` +} + +// Validate validates this pushover config +func (m *PushoverConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHTTPConfig(formats); err != nil { + res = append(res, err) + } + + if err := m.validateToken(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUserKey(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *PushoverConfig) validateHTTPConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPConfig) { // not required + return nil + } + + if m.HTTPConfig != nil { + if err := m.HTTPConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_config") + } + return err + } + } + + return nil +} + +func (m *PushoverConfig) validateToken(formats strfmt.Registry) error { + + if swag.IsZero(m.Token) { // not required + return nil + } + + if err := m.Token.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("token") + } + return err + } + + return nil +} + +func (m *PushoverConfig) validateUserKey(formats strfmt.Registry) error { + + if swag.IsZero(m.UserKey) { // not required + return nil + } + + if err := m.UserKey.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("user_key") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *PushoverConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PushoverConfig) UnmarshalBinary(b []byte) error { + var res PushoverConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/receiver.go b/pkg/gen/models/receiver.go new file mode 100644 index 00000000000..c430ea75adb --- /dev/null +++ b/pkg/gen/models/receiver.go @@ -0,0 +1,307 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Receiver Receiver configuration provides configuration on how to contact a receiver. +// +// swagger:model Receiver +type Receiver struct { + + // email configs + EmailConfigs []*EmailConfig `json:"email_configs"` + + // A unique identifier for this receiver. + Name string `json:"name,omitempty"` + + // ops genie configs + OpsGenieConfigs []*OpsGenieConfig `json:"opsgenie_configs"` + + // pagerduty configs + PagerdutyConfigs []*PagerdutyConfig `json:"pagerduty_configs"` + + // pushover configs + PushoverConfigs []*PushoverConfig `json:"pushover_configs"` + + // slack configs + SlackConfigs []*SlackConfig `json:"slack_configs"` + + // victor ops configs + VictorOpsConfigs []*VictorOpsConfig `json:"victorops_configs"` + + // webhook configs + WebhookConfigs []*WebhookConfig `json:"webhook_configs"` + + // wechat configs + WechatConfigs []*WechatConfig `json:"wechat_configs"` +} + +// Validate validates this receiver +func (m *Receiver) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateEmailConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateOpsGenieConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePagerdutyConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validatePushoverConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSlackConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateVictorOpsConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateWebhookConfigs(formats); err != nil { + res = append(res, err) + } + + if err := m.validateWechatConfigs(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Receiver) validateEmailConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.EmailConfigs) { // not required + return nil + } + + for i := 0; i < len(m.EmailConfigs); i++ { + if swag.IsZero(m.EmailConfigs[i]) { // not required + continue + } + + if m.EmailConfigs[i] != nil { + if err := m.EmailConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("email_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Receiver) validateOpsGenieConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.OpsGenieConfigs) { // not required + return nil + } + + for i := 0; i < len(m.OpsGenieConfigs); i++ { + if swag.IsZero(m.OpsGenieConfigs[i]) { // not required + continue + } + + if m.OpsGenieConfigs[i] != nil { + if err := m.OpsGenieConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("opsgenie_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Receiver) validatePagerdutyConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.PagerdutyConfigs) { // not required + return nil + } + + for i := 0; i < len(m.PagerdutyConfigs); i++ { + if swag.IsZero(m.PagerdutyConfigs[i]) { // not required + continue + } + + if m.PagerdutyConfigs[i] != nil { + if err := m.PagerdutyConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pagerduty_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Receiver) validatePushoverConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.PushoverConfigs) { // not required + return nil + } + + for i := 0; i < len(m.PushoverConfigs); i++ { + if swag.IsZero(m.PushoverConfigs[i]) { // not required + continue + } + + if m.PushoverConfigs[i] != nil { + if err := m.PushoverConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("pushover_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Receiver) validateSlackConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.SlackConfigs) { // not required + return nil + } + + for i := 0; i < len(m.SlackConfigs); i++ { + if swag.IsZero(m.SlackConfigs[i]) { // not required + continue + } + + if m.SlackConfigs[i] != nil { + if err := m.SlackConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("slack_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Receiver) validateVictorOpsConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.VictorOpsConfigs) { // not required + return nil + } + + for i := 0; i < len(m.VictorOpsConfigs); i++ { + if swag.IsZero(m.VictorOpsConfigs[i]) { // not required + continue + } + + if m.VictorOpsConfigs[i] != nil { + if err := m.VictorOpsConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("victorops_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Receiver) validateWebhookConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.WebhookConfigs) { // not required + return nil + } + + for i := 0; i < len(m.WebhookConfigs); i++ { + if swag.IsZero(m.WebhookConfigs[i]) { // not required + continue + } + + if m.WebhookConfigs[i] != nil { + if err := m.WebhookConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("webhook_configs" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Receiver) validateWechatConfigs(formats strfmt.Registry) error { + + if swag.IsZero(m.WechatConfigs) { // not required + return nil + } + + for i := 0; i < len(m.WechatConfigs); i++ { + if swag.IsZero(m.WechatConfigs[i]) { // not required + continue + } + + if m.WechatConfigs[i] != nil { + if err := m.WechatConfigs[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("wechat_configs" + "." + strconv.Itoa(i)) + } + 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/pkg/gen/models/regexp.go b/pkg/gen/models/regexp.go new file mode 100644 index 00000000000..cdafb8949ca --- /dev/null +++ b/pkg/gen/models/regexp.go @@ -0,0 +1,14 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// Regexp Regexp is the representation of a compiled regular expression. +// +// A Regexp is safe for concurrent use by multiple goroutines, +// except for configuration methods, such as Longest. +// +// swagger:model Regexp +type Regexp interface{} diff --git a/pkg/gen/models/relative_time_range.go b/pkg/gen/models/relative_time_range.go new file mode 100644 index 00000000000..762313c313e --- /dev/null +++ b/pkg/gen/models/relative_time_range.go @@ -0,0 +1,47 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RelativeTimeRange RelativeTimeRange is the per query start and end time +// for requests. +// +// swagger:model RelativeTimeRange +type RelativeTimeRange struct { + + // from + From Duration `json:"from,omitempty"` + + // to + To Duration `json:"to,omitempty"` +} + +// Validate validates this relative time range +func (m *RelativeTimeRange) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *RelativeTimeRange) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RelativeTimeRange) UnmarshalBinary(b []byte) error { + var res RelativeTimeRange + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/response_details.go b/pkg/gen/models/response_details.go new file mode 100644 index 00000000000..a36613e801a --- /dev/null +++ b/pkg/gen/models/response_details.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ResponseDetails response details +// +// swagger:model ResponseDetails +type ResponseDetails struct { + + // msg + Msg string `json:"msg,omitempty"` +} + +// Validate validates this response details +func (m *ResponseDetails) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ResponseDetails) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ResponseDetails) UnmarshalBinary(b []byte) error { + var res ResponseDetails + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/role_type.go b/pkg/gen/models/role_type.go new file mode 100644 index 00000000000..f855e77403e --- /dev/null +++ b/pkg/gen/models/role_type.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// RoleType role type +// +// swagger:model RoleType +type RoleType string + +// Validate validates this role type +func (m RoleType) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/route.go b/pkg/gen/models/route.go new file mode 100644 index 00000000000..14502d1d467 --- /dev/null +++ b/pkg/gen/models/route.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Route A Route is a node that contains definitions of how to handle alerts. +// +// swagger:model Route +type Route struct { + + // continue + Continue bool `json:"continue,omitempty"` + + // group by str + GroupByStr []string `json:"group_by"` + + // Deprecated. Remove before v1.0 release. + Match map[string]string `json:"match,omitempty"` + + // receiver + Receiver string `json:"receiver,omitempty"` + + // routes + Routes []*Route `json:"routes"` + + // group interval + GroupInterval Duration `json:"group_interval,omitempty"` + + // group wait + GroupWait Duration `json:"group_wait,omitempty"` + + // match re + MatchRe MatchRegexps `json:"match_re,omitempty"` + + // matchers + Matchers Matchers `json:"matchers,omitempty"` + + // repeat interval + RepeatInterval Duration `json:"repeat_interval,omitempty"` +} + +// Validate validates this route +func (m *Route) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRoutes(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchRe(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchers(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Route) validateRoutes(formats strfmt.Registry) error { + + if swag.IsZero(m.Routes) { // not required + return nil + } + + for i := 0; i < len(m.Routes); i++ { + if swag.IsZero(m.Routes[i]) { // not required + continue + } + + if m.Routes[i] != nil { + if err := m.Routes[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("routes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *Route) validateMatchRe(formats strfmt.Registry) error { + + if swag.IsZero(m.MatchRe) { // not required + return nil + } + + if err := m.MatchRe.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("match_re") + } + return err + } + + return nil +} + +func (m *Route) validateMatchers(formats strfmt.Registry) error { + + if swag.IsZero(m.Matchers) { // not required + return nil + } + + if err := m.Matchers.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("matchers") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Route) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Route) UnmarshalBinary(b []byte) error { + var res Route + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/rule_discovery.go b/pkg/gen/models/rule_discovery.go new file mode 100644 index 00000000000..310a26e341e --- /dev/null +++ b/pkg/gen/models/rule_discovery.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RuleDiscovery rule discovery +// +// swagger:model RuleDiscovery +type RuleDiscovery struct { + + // rule groups + RuleGroups []*RuleGroup `json:"groups"` +} + +// Validate validates this rule discovery +func (m *RuleDiscovery) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRuleGroups(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RuleDiscovery) validateRuleGroups(formats strfmt.Registry) error { + + if swag.IsZero(m.RuleGroups) { // not required + return nil + } + + for i := 0; i < len(m.RuleGroups); i++ { + if swag.IsZero(m.RuleGroups[i]) { // not required + continue + } + + if m.RuleGroups[i] != nil { + if err := m.RuleGroups[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("groups" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RuleDiscovery) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RuleDiscovery) UnmarshalBinary(b []byte) error { + var res RuleDiscovery + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/rule_group.go b/pkg/gen/models/rule_group.go new file mode 100644 index 00000000000..e862b636097 --- /dev/null +++ b/pkg/gen/models/rule_group.go @@ -0,0 +1,116 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// RuleGroup rule group +// +// swagger:model RuleGroup +type RuleGroup struct { + + // evaluation time + EvaluationTime float64 `json:"evaluationTime,omitempty"` + + // file + File string `json:"file,omitempty"` + + // interval + Interval float64 `json:"interval,omitempty"` + + // last evaluation + // Format: date-time + LastEvaluation strfmt.DateTime `json:"lastEvaluation,omitempty"` + + // name + Name string `json:"name,omitempty"` + + // In order to preserve rule ordering, while exposing type (alerting or recording) + // specific properties, both alerting and recording rules are exposed in the + // same array. + Rules []*AlertingRule `json:"rules"` +} + +// Validate validates this rule group +func (m *RuleGroup) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateLastEvaluation(formats); err != nil { + res = append(res, err) + } + + if err := m.validateRules(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RuleGroup) validateLastEvaluation(formats strfmt.Registry) error { + + if swag.IsZero(m.LastEvaluation) { // not required + return nil + } + + if err := validate.FormatOf("lastEvaluation", "body", "date-time", m.LastEvaluation.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *RuleGroup) validateRules(formats strfmt.Registry) error { + + if swag.IsZero(m.Rules) { // not required + return nil + } + + for i := 0; i < len(m.Rules); i++ { + if swag.IsZero(m.Rules[i]) { // not required + continue + } + + if m.Rules[i] != nil { + if err := m.Rules[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RuleGroup) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RuleGroup) UnmarshalBinary(b []byte) error { + var res RuleGroup + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/rule_group_config.go b/pkg/gen/models/rule_group_config.go new file mode 100644 index 00000000000..baba9d384f0 --- /dev/null +++ b/pkg/gen/models/rule_group_config.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RuleGroupConfig rule group config +// +// swagger:model RuleGroupConfig +type RuleGroupConfig struct { + + // name + Name string `json:"name,omitempty"` + + // rules + Rules []*ExtendedRuleNode `json:"rules"` + + // interval + Interval Duration `json:"interval,omitempty"` +} + +// Validate validates this rule group config +func (m *RuleGroupConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRules(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RuleGroupConfig) validateRules(formats strfmt.Registry) error { + + if swag.IsZero(m.Rules) { // not required + return nil + } + + for i := 0; i < len(m.Rules); i++ { + if swag.IsZero(m.Rules[i]) { // not required + continue + } + + if m.Rules[i] != nil { + if err := m.Rules[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RuleGroupConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RuleGroupConfig) UnmarshalBinary(b []byte) error { + var res RuleGroupConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/rule_group_config_response.go b/pkg/gen/models/rule_group_config_response.go new file mode 100644 index 00000000000..975f582bed9 --- /dev/null +++ b/pkg/gen/models/rule_group_config_response.go @@ -0,0 +1,86 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RuleGroupConfigResponse rule group config response +// +// swagger:model RuleGroupConfigResponse +type RuleGroupConfigResponse struct { + + // name + Name string `json:"name,omitempty"` + + // rules + Rules []*ExtendedRuleNode `json:"rules"` + + // interval + Interval Duration `json:"interval,omitempty"` +} + +// Validate validates this rule group config response +func (m *RuleGroupConfigResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRules(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RuleGroupConfigResponse) validateRules(formats strfmt.Registry) error { + + if swag.IsZero(m.Rules) { // not required + return nil + } + + for i := 0; i < len(m.Rules); i++ { + if swag.IsZero(m.Rules[i]) { // not required + continue + } + + if m.Rules[i] != nil { + if err := m.Rules[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RuleGroupConfigResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RuleGroupConfigResponse) UnmarshalBinary(b []byte) error { + var res RuleGroupConfigResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/rule_response.go b/pkg/gen/models/rule_response.go new file mode 100644 index 00000000000..d99e939343c --- /dev/null +++ b/pkg/gen/models/rule_response.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RuleResponse rule response +// +// swagger:model RuleResponse +type RuleResponse struct { + + // body + Body *RuleResponseBody `json:"Body,omitempty"` +} + +// Validate validates this rule response +func (m *RuleResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateBody(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RuleResponse) validateBody(formats strfmt.Registry) error { + + if swag.IsZero(m.Body) { // not required + return nil + } + + if m.Body != nil { + if err := m.Body.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("Body") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RuleResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RuleResponse) UnmarshalBinary(b []byte) error { + var res RuleResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/rule_response_body.go b/pkg/gen/models/rule_response_body.go new file mode 100644 index 00000000000..833ba55d6c1 --- /dev/null +++ b/pkg/gen/models/rule_response_body.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// RuleResponseBody in: body +// +// swagger:model ruleResponseBody +type RuleResponseBody struct { + + // error + Error string `json:"error,omitempty"` + + // status + Status string `json:"status,omitempty"` + + // data + Data *RuleDiscovery `json:"data,omitempty"` + + // error type + ErrorType ErrorType `json:"errorType,omitempty"` +} + +// Validate validates this rule response body +func (m *RuleResponseBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateData(formats); err != nil { + res = append(res, err) + } + + if err := m.validateErrorType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *RuleResponseBody) validateData(formats strfmt.Registry) error { + + if swag.IsZero(m.Data) { // not required + return nil + } + + if m.Data != nil { + if err := m.Data.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("data") + } + return err + } + } + + return nil +} + +func (m *RuleResponseBody) validateErrorType(formats strfmt.Registry) error { + + if swag.IsZero(m.ErrorType) { // not required + return nil + } + + if err := m.ErrorType.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("errorType") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *RuleResponseBody) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *RuleResponseBody) UnmarshalBinary(b []byte) error { + var res RuleResponseBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/rule_type.go b/pkg/gen/models/rule_type.go new file mode 100644 index 00000000000..d7483e431b5 --- /dev/null +++ b/pkg/gen/models/rule_type.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// RuleType RuleType models the type of a rule. +// +// swagger:model RuleType +type RuleType string + +// Validate validates this rule type +func (m RuleType) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/sample.go b/pkg/gen/models/sample.go new file mode 100644 index 00000000000..d6e2a6c0c77 --- /dev/null +++ b/pkg/gen/models/sample.go @@ -0,0 +1,75 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Sample Sample is a single sample belonging to a metric. +// +// swagger:model Sample +type Sample struct { + + // metric + Metric Labels `json:"Metric,omitempty"` + + // t + T int64 `json:"T,omitempty"` + + // v + V float64 `json:"V,omitempty"` +} + +// Validate validates this sample +func (m *Sample) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateMetric(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Sample) validateMetric(formats strfmt.Registry) error { + + if swag.IsZero(m.Metric) { // not required + return nil + } + + if err := m.Metric.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("Metric") + } + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Sample) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Sample) UnmarshalBinary(b []byte) error { + var res Sample + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/secret.go b/pkg/gen/models/secret.go new file mode 100644 index 00000000000..ea6dc56875b --- /dev/null +++ b/pkg/gen/models/secret.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// Secret Secret special type for storing secrets. +// +// swagger:model Secret +type Secret string + +// Validate validates this secret +func (m Secret) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/secret_url.go b/pkg/gen/models/secret_url.go new file mode 100644 index 00000000000..ebb61eda721 --- /dev/null +++ b/pkg/gen/models/secret_url.go @@ -0,0 +1,47 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SecretURL SecretURL is a URL that must not be revealed on marshaling. +// +// swagger:model SecretURL +type SecretURL struct { + URL +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *SecretURL) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 URL + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.URL = aO0 + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m SecretURL) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 1) + + aO0, err := swag.WriteJSON(m.URL) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this secret URL +func (m *SecretURL) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/secure_json_data.go b/pkg/gen/models/secure_json_data.go new file mode 100644 index 00000000000..f886e68c64d --- /dev/null +++ b/pkg/gen/models/secure_json_data.go @@ -0,0 +1,21 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" +) + +// SecureJSONData SecureJsonData is used to store encrypted data (for example in data_source table). Only values are separately +// encrypted. +// +// swagger:model SecureJsonData +type SecureJSONData map[string][]uint8 + +// Validate validates this secure Json data +func (m SecureJSONData) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/silence.go b/pkg/gen/models/silence.go new file mode 100644 index 00000000000..b1c9ebfb5c9 --- /dev/null +++ b/pkg/gen/models/silence.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Silence 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"` + + // starts at + // Required: true + // Format: date-time + StartsAt *strfmt.DateTime `json:"startsAt"` + + // matchers + // Required: true + Matchers Matchers `json:"matchers"` +} + +// 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.validateStartsAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchers(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) 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 *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 +} + +// 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/pkg/gen/models/silence_body.go b/pkg/gen/models/silence_body.go new file mode 100644 index 00000000000..8d52fa62f74 --- /dev/null +++ b/pkg/gen/models/silence_body.go @@ -0,0 +1,152 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SilenceBody silence body +// +// swagger:model SilenceBody +type SilenceBody 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"` + + // Id + ID string `json:"id,omitempty"` + + // starts at + // Required: true + // Format: date-time + StartsAt *strfmt.DateTime `json:"startsAt"` + + // matchers + // Required: true + Matchers Matchers `json:"matchers"` +} + +// Validate validates this silence body +func (m *SilenceBody) 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.validateStartsAt(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMatchers(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SilenceBody) validateComment(formats strfmt.Registry) error { + + if err := validate.Required("comment", "body", m.Comment); err != nil { + return err + } + + return nil +} + +func (m *SilenceBody) validateCreatedBy(formats strfmt.Registry) error { + + if err := validate.Required("createdBy", "body", m.CreatedBy); err != nil { + return err + } + + return nil +} + +func (m *SilenceBody) 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 *SilenceBody) 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 *SilenceBody) 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 +} + +// MarshalBinary interface implementation +func (m *SilenceBody) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SilenceBody) UnmarshalBinary(b []byte) error { + var res SilenceBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/silence_status.go b/pkg/gen/models/silence_status.go new file mode 100644 index 00000000000..e6427fb5879 --- /dev/null +++ b/pkg/gen/models/silence_status.go @@ -0,0 +1,98 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SilenceStatus 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 ( + + // SilenceStatusStateExpiredActivePending captures enum value "[expired active pending]" + SilenceStatusStateExpiredActivePending string = "[expired active pending]" +) + +// prop value enum +func (m *SilenceStatus) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, silenceStatusTypeStatePropEnum, true); 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/pkg/gen/models/slack_action.go b/pkg/gen/models/slack_action.go new file mode 100644 index 00000000000..211a1e5ef15 --- /dev/null +++ b/pkg/gen/models/slack_action.go @@ -0,0 +1,92 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SlackAction SlackAction configures a single Slack action that is sent with each notification. +// +// See https://api.slack.com/docs/message-attachments#action_fields and https://api.slack.com/docs/message-buttons +// for more information. +// +// swagger:model SlackAction +type SlackAction struct { + + // name + Name string `json:"name,omitempty"` + + // style + Style string `json:"style,omitempty"` + + // text + Text string `json:"text,omitempty"` + + // type + Type string `json:"type,omitempty"` + + // URL + URL string `json:"url,omitempty"` + + // value + Value string `json:"value,omitempty"` + + // confirm + Confirm *SlackConfirmationField `json:"confirm,omitempty"` +} + +// Validate validates this slack action +func (m *SlackAction) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateConfirm(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SlackAction) validateConfirm(formats strfmt.Registry) error { + + if swag.IsZero(m.Confirm) { // not required + return nil + } + + if m.Confirm != nil { + if err := m.Confirm.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("confirm") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SlackAction) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SlackAction) UnmarshalBinary(b []byte) error { + var res SlackAction + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/slack_config.go b/pkg/gen/models/slack_config.go new file mode 100644 index 00000000000..31517d37ffd --- /dev/null +++ b/pkg/gen/models/slack_config.go @@ -0,0 +1,214 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SlackConfig SlackConfig configures notifications via Slack. +// +// swagger:model SlackConfig +type SlackConfig struct { + + // actions + Actions []*SlackAction `json:"actions"` + + // callback ID + CallbackID string `json:"callback_id,omitempty"` + + // Slack channel override, (like #other-channel or @username). + Channel string `json:"channel,omitempty"` + + // color + Color string `json:"color,omitempty"` + + // fallback + Fallback string `json:"fallback,omitempty"` + + // fields + Fields []*SlackField `json:"fields"` + + // footer + Footer string `json:"footer,omitempty"` + + // icon emoji + IconEmoji string `json:"icon_emoji,omitempty"` + + // icon URL + IconURL string `json:"icon_url,omitempty"` + + // image URL + ImageURL string `json:"image_url,omitempty"` + + // link names + LinkNames bool `json:"link_names,omitempty"` + + // mrkdwn in + MrkdwnIn []string `json:"mrkdwn_in"` + + // pretext + Pretext string `json:"pretext,omitempty"` + + // short fields + ShortFields bool `json:"short_fields,omitempty"` + + // text + Text string `json:"text,omitempty"` + + // thumb URL + ThumbURL string `json:"thumb_url,omitempty"` + + // title + Title string `json:"title,omitempty"` + + // title link + TitleLink string `json:"title_link,omitempty"` + + // username + Username string `json:"username,omitempty"` + + // v send resolved + VSendResolved bool `json:"send_resolved,omitempty"` + + // api url + APIURL SecretURL `json:"api_url,omitempty"` + + // http config + HTTPConfig *HTTPClientConfig `json:"http_config,omitempty"` +} + +// Validate validates this slack config +func (m *SlackConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateActions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateFields(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAPIURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPConfig(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SlackConfig) validateActions(formats strfmt.Registry) error { + + if swag.IsZero(m.Actions) { // not required + return nil + } + + for i := 0; i < len(m.Actions); i++ { + if swag.IsZero(m.Actions[i]) { // not required + continue + } + + if m.Actions[i] != nil { + if err := m.Actions[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("actions" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *SlackConfig) validateFields(formats strfmt.Registry) error { + + if swag.IsZero(m.Fields) { // not required + return nil + } + + for i := 0; i < len(m.Fields); i++ { + if swag.IsZero(m.Fields[i]) { // not required + continue + } + + if m.Fields[i] != nil { + if err := m.Fields[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("fields" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *SlackConfig) validateAPIURL(formats strfmt.Registry) error { + + if swag.IsZero(m.APIURL) { // not required + return nil + } + + if err := m.APIURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("api_url") + } + return err + } + + return nil +} + +func (m *SlackConfig) validateHTTPConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPConfig) { // not required + return nil + } + + if m.HTTPConfig != nil { + if err := m.HTTPConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_config") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SlackConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SlackConfig) UnmarshalBinary(b []byte) error { + var res SlackConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/slack_confirmation_field.go b/pkg/gen/models/slack_confirmation_field.go new file mode 100644 index 00000000000..bbba898a181 --- /dev/null +++ b/pkg/gen/models/slack_confirmation_field.go @@ -0,0 +1,54 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SlackConfirmationField SlackConfirmationField protect users from destructive actions or particularly distinguished decisions +// by asking them to confirm their button click one more time. +// See https://api.slack.com/docs/interactive-message-field-guide#confirmation_fields for more information. +// +// swagger:model SlackConfirmationField +type SlackConfirmationField struct { + + // dismiss text + DismissText string `json:"dismiss_text,omitempty"` + + // ok text + OkText string `json:"ok_text,omitempty"` + + // text + Text string `json:"text,omitempty"` + + // title + Title string `json:"title,omitempty"` +} + +// Validate validates this slack confirmation field +func (m *SlackConfirmationField) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SlackConfirmationField) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SlackConfirmationField) UnmarshalBinary(b []byte) error { + var res SlackConfirmationField + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/slack_field.go b/pkg/gen/models/slack_field.go new file mode 100644 index 00000000000..b2e282e8e60 --- /dev/null +++ b/pkg/gen/models/slack_field.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SlackField SlackField configures a single Slack field that is sent with each notification. +// +// Each field must contain a title, value, and optionally, a boolean value to indicate if the field +// is short enough to be displayed next to other fields designated as short. +// See https://api.slack.com/docs/message-attachments#fields for more information. +// +// swagger:model SlackField +type SlackField struct { + + // short + Short bool `json:"short,omitempty"` + + // title + Title string `json:"title,omitempty"` + + // value + Value string `json:"value,omitempty"` +} + +// Validate validates this slack field +func (m *SlackField) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SlackField) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SlackField) UnmarshalBinary(b []byte) error { + var res SlackField + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/smtp_not_enabled.go b/pkg/gen/models/smtp_not_enabled.go new file mode 100644 index 00000000000..b4f600b6d1a --- /dev/null +++ b/pkg/gen/models/smtp_not_enabled.go @@ -0,0 +1,47 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SMTPNotEnabled Smtp not enabled +// +// swagger:model SmtpNotEnabled +type SMTPNotEnabled struct { + ResponseDetails +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *SMTPNotEnabled) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 ResponseDetails + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.ResponseDetails = aO0 + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m SMTPNotEnabled) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 1) + + aO0, err := swag.WriteJSON(m.ResponseDetails) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this Smtp not enabled +func (m *SMTPNotEnabled) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/success.go b/pkg/gen/models/success.go new file mode 100644 index 00000000000..5b6ed698fd2 --- /dev/null +++ b/pkg/gen/models/success.go @@ -0,0 +1,47 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Success success +// +// swagger:model Success +type Success struct { + ResponseDetails +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *Success) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 ResponseDetails + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.ResponseDetails = aO0 + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m Success) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 1) + + aO0, err := swag.WriteJSON(m.ResponseDetails) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this success +func (m *Success) Validate(formats strfmt.Registry) error { + return nil +} diff --git a/pkg/gen/models/test_rule_payload.go b/pkg/gen/models/test_rule_payload.go new file mode 100644 index 00000000000..e6861c5df5b --- /dev/null +++ b/pkg/gen/models/test_rule_payload.go @@ -0,0 +1,96 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// TestRulePayload test rule payload +// +// swagger:model TestRulePayload +type TestRulePayload struct { + + // expr + Expr *LotexQuery `json:"expr,omitempty"` + + // grafana condition + GrafanaCondition *EvalAlertConditionCommand `json:"grafana_condition,omitempty"` +} + +// Validate validates this test rule payload +func (m *TestRulePayload) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateExpr(formats); err != nil { + res = append(res, err) + } + + if err := m.validateGrafanaCondition(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TestRulePayload) validateExpr(formats strfmt.Registry) error { + + if swag.IsZero(m.Expr) { // not required + return nil + } + + if m.Expr != nil { + if err := m.Expr.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("expr") + } + return err + } + } + + return nil +} + +func (m *TestRulePayload) validateGrafanaCondition(formats strfmt.Registry) error { + + if swag.IsZero(m.GrafanaCondition) { // not required + return nil + } + + if m.GrafanaCondition != nil { + if err := m.GrafanaCondition.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("grafana_condition") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *TestRulePayload) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TestRulePayload) UnmarshalBinary(b []byte) error { + var res TestRulePayload + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/test_rule_response.go b/pkg/gen/models/test_rule_response.go new file mode 100644 index 00000000000..50fa42937cc --- /dev/null +++ b/pkg/gen/models/test_rule_response.go @@ -0,0 +1,94 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// TestRuleResponse test rule response +// +// swagger:model TestRuleResponse +type TestRuleResponse struct { + + // alerts + Alerts Vector `json:"alerts,omitempty"` + + // grafana alert instances + GrafanaAlertInstances *AlertInstancesResponse `json:"grafana_alert_instances,omitempty"` +} + +// Validate validates this test rule response +func (m *TestRuleResponse) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAlerts(formats); err != nil { + res = append(res, err) + } + + if err := m.validateGrafanaAlertInstances(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *TestRuleResponse) validateAlerts(formats strfmt.Registry) error { + + if swag.IsZero(m.Alerts) { // not required + return nil + } + + if err := m.Alerts.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("alerts") + } + return err + } + + return nil +} + +func (m *TestRuleResponse) validateGrafanaAlertInstances(formats strfmt.Registry) error { + + if swag.IsZero(m.GrafanaAlertInstances) { // not required + return nil + } + + if m.GrafanaAlertInstances != nil { + if err := m.GrafanaAlertInstances.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("grafana_alert_instances") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *TestRuleResponse) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TestRuleResponse) UnmarshalBinary(b []byte) error { + var res TestRuleResponse + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/tls_config.go b/pkg/gen/models/tls_config.go new file mode 100644 index 00000000000..f3c6b097a1b --- /dev/null +++ b/pkg/gen/models/tls_config.go @@ -0,0 +1,55 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// TLSConfig TLSConfig configures the options for TLS connections. +// +// swagger:model TLSConfig +type TLSConfig struct { + + // The CA cert to use for the targets. + CAFile string `json:"CAFile,omitempty"` + + // The client cert file for the targets. + CertFile string `json:"CertFile,omitempty"` + + // Disable target certificate validation. + InsecureSkipVerify bool `json:"InsecureSkipVerify,omitempty"` + + // The client key file for the targets. + KeyFile string `json:"KeyFile,omitempty"` + + // Used to verify the hostname for the targets. + ServerName string `json:"ServerName,omitempty"` +} + +// Validate validates this TLS config +func (m *TLSConfig) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *TLSConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *TLSConfig) UnmarshalBinary(b []byte) error { + var res TLSConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/update_dashboard_acl_command.go b/pkg/gen/models/update_dashboard_acl_command.go new file mode 100644 index 00000000000..01fc1e8872c --- /dev/null +++ b/pkg/gen/models/update_dashboard_acl_command.go @@ -0,0 +1,80 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UpdateDashboardACLCommand update dashboard Acl command +// +// swagger:model UpdateDashboardAclCommand +type UpdateDashboardACLCommand struct { + + // items + Items []*DashboardACLUpdateItem `json:"items"` +} + +// Validate validates this update dashboard Acl command +func (m *UpdateDashboardACLCommand) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateItems(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UpdateDashboardACLCommand) validateItems(formats strfmt.Registry) error { + + if swag.IsZero(m.Items) { // not required + return nil + } + + for i := 0; i < len(m.Items); i++ { + if swag.IsZero(m.Items[i]) { // not required + continue + } + + if m.Items[i] != nil { + if err := m.Items[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("items" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *UpdateDashboardACLCommand) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UpdateDashboardACLCommand) UnmarshalBinary(b []byte) error { + var res UpdateDashboardACLCommand + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/url.go b/pkg/gen/models/url.go new file mode 100644 index 00000000000..4c7e885e546 --- /dev/null +++ b/pkg/gen/models/url.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// URL A URL represents a parsed URL (technically, a URI reference). +// +// The general form represented is: +// +// [scheme:][//[userinfo@]host][/]path[?query][#fragment] +// +// URLs that do not start with a slash after the scheme are interpreted as: +// +// scheme:opaque[?query][#fragment] +// +// Note that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/. +// A consequence is that it is impossible to tell which slashes in the Path were +// slashes in the raw URL and which were %2f. This distinction is rarely important, +// but when it is, the code should use RawPath, an optional field which only gets +// set if the default encoding is different from Path. +// +// URL's String method uses the EscapedPath method to obtain the path. See the +// EscapedPath method for more details. +// +// swagger:model URL +type URL struct { + + // force query + ForceQuery bool `json:"ForceQuery,omitempty"` + + // fragment + Fragment string `json:"Fragment,omitempty"` + + // host + Host string `json:"Host,omitempty"` + + // opaque + Opaque string `json:"Opaque,omitempty"` + + // path + Path string `json:"Path,omitempty"` + + // raw fragment + RawFragment string `json:"RawFragment,omitempty"` + + // raw path + RawPath string `json:"RawPath,omitempty"` + + // raw query + RawQuery string `json:"RawQuery,omitempty"` + + // scheme + Scheme string `json:"Scheme,omitempty"` + + // user + User Userinfo `json:"User,omitempty"` +} + +// Validate validates this URL +func (m *URL) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *URL) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *URL) UnmarshalBinary(b []byte) error { + var res URL + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/user_config.go b/pkg/gen/models/user_config.go new file mode 100644 index 00000000000..a75db5cf7d3 --- /dev/null +++ b/pkg/gen/models/user_config.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// UserConfig user config +// +// swagger:model UserConfig +type UserConfig struct { + + // template files + TemplateFiles map[string]string `json:"template_files,omitempty"` + + // alertmanager config + AlertmanagerConfig *APIAlertingConfig `json:"alertmanager_config,omitempty"` +} + +// Validate validates this user config +func (m *UserConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAlertmanagerConfig(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UserConfig) validateAlertmanagerConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.AlertmanagerConfig) { // not required + return nil + } + + if m.AlertmanagerConfig != nil { + if err := m.AlertmanagerConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("alertmanager_config") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *UserConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UserConfig) UnmarshalBinary(b []byte) error { + var res UserConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/userinfo.go b/pkg/gen/models/userinfo.go new file mode 100644 index 00000000000..452565c295d --- /dev/null +++ b/pkg/gen/models/userinfo.go @@ -0,0 +1,14 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// Userinfo The Userinfo type is an immutable encapsulation of username and +// password details for a URL. An existing Userinfo value is guaranteed +// to have a username set (potentially empty, as allowed by RFC 2396), +// and optionally a password. +// +// swagger:model Userinfo +type Userinfo interface{} diff --git a/pkg/gen/models/validation_error.go b/pkg/gen/models/validation_error.go new file mode 100644 index 00000000000..573470e29c2 --- /dev/null +++ b/pkg/gen/models/validation_error.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// ValidationError validation error +// +// swagger:model ValidationError +type ValidationError struct { + + // msg + Msg string `json:"msg,omitempty"` +} + +// Validate validates this validation error +func (m *ValidationError) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ValidationError) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ValidationError) UnmarshalBinary(b []byte) error { + var res ValidationError + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/vector.go b/pkg/gen/models/vector.go new file mode 100644 index 00000000000..9fac1772dca --- /dev/null +++ b/pkg/gen/models/vector.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// Vector Vector is basically only an alias for model.Samples, but the +// contract is that in a Vector, all Samples have the same timestamp. +// +// swagger:model Vector +type Vector []*Sample + +// Validate validates this vector +func (m Vector) 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/pkg/gen/models/version_info.go b/pkg/gen/models/version_info.go new file mode 100644 index 00000000000..5314fab7631 --- /dev/null +++ b/pkg/gen/models/version_info.go @@ -0,0 +1,149 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// VersionInfo 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/pkg/gen/models/victor_ops_config.go b/pkg/gen/models/victor_ops_config.go new file mode 100644 index 00000000000..80b3b6d2292 --- /dev/null +++ b/pkg/gen/models/victor_ops_config.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// VictorOpsConfig VictorOpsConfig configures notifications via VictorOps. +// +// swagger:model VictorOpsConfig +type VictorOpsConfig struct { + + // custom fields + CustomFields map[string]string `json:"custom_fields,omitempty"` + + // entity display name + EntityDisplayName string `json:"entity_display_name,omitempty"` + + // message type + MessageType string `json:"message_type,omitempty"` + + // monitoring tool + MonitoringTool string `json:"monitoring_tool,omitempty"` + + // routing key + RoutingKey string `json:"routing_key,omitempty"` + + // state message + StateMessage string `json:"state_message,omitempty"` + + // v send resolved + VSendResolved bool `json:"send_resolved,omitempty"` + + // api key + APIKey Secret `json:"api_key,omitempty"` + + // api url + APIURL *URL `json:"api_url,omitempty"` + + // http config + HTTPConfig *HTTPClientConfig `json:"http_config,omitempty"` +} + +// Validate validates this victor ops config +func (m *VictorOpsConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAPIKey(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAPIURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPConfig(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *VictorOpsConfig) validateAPIKey(formats strfmt.Registry) error { + + if swag.IsZero(m.APIKey) { // not required + return nil + } + + if err := m.APIKey.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("api_key") + } + return err + } + + return nil +} + +func (m *VictorOpsConfig) validateAPIURL(formats strfmt.Registry) error { + + if swag.IsZero(m.APIURL) { // not required + return nil + } + + if m.APIURL != nil { + if err := m.APIURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("api_url") + } + return err + } + } + + return nil +} + +func (m *VictorOpsConfig) validateHTTPConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPConfig) { // not required + return nil + } + + if m.HTTPConfig != nil { + if err := m.HTTPConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_config") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *VictorOpsConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *VictorOpsConfig) UnmarshalBinary(b []byte) error { + var res VictorOpsConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/webhook_config.go b/pkg/gen/models/webhook_config.go new file mode 100644 index 00000000000..97a14ac9f62 --- /dev/null +++ b/pkg/gen/models/webhook_config.go @@ -0,0 +1,104 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// WebhookConfig WebhookConfig configures notifications via a generic webhook. +// +// swagger:model WebhookConfig +type WebhookConfig struct { + + // MaxAlerts is the maximum number of alerts to be sent per webhook message. + // Alerts exceeding this threshold will be truncated. Setting this to 0 + // allows an unlimited number of alerts. + MaxAlerts uint64 `json:"max_alerts,omitempty"` + + // v send resolved + VSendResolved bool `json:"send_resolved,omitempty"` + + // http config + HTTPConfig *HTTPClientConfig `json:"http_config,omitempty"` + + // url + URL *URL `json:"url,omitempty"` +} + +// Validate validates this webhook config +func (m *WebhookConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateHTTPConfig(formats); err != nil { + res = append(res, err) + } + + if err := m.validateURL(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *WebhookConfig) validateHTTPConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPConfig) { // not required + return nil + } + + if m.HTTPConfig != nil { + if err := m.HTTPConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_config") + } + return err + } + } + + return nil +} + +func (m *WebhookConfig) validateURL(formats strfmt.Registry) error { + + if swag.IsZero(m.URL) { // not required + return nil + } + + if m.URL != nil { + if err := m.URL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("url") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *WebhookConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *WebhookConfig) UnmarshalBinary(b []byte) error { + var res WebhookConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/models/wechat_config.go b/pkg/gen/models/wechat_config.go new file mode 100644 index 00000000000..67e1ffe2ccf --- /dev/null +++ b/pkg/gen/models/wechat_config.go @@ -0,0 +1,143 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// WechatConfig WechatConfig configures notifications via Wechat. +// +// swagger:model WechatConfig +type WechatConfig struct { + + // agent ID + AgentID string `json:"agent_id,omitempty"` + + // corp ID + CorpID string `json:"corp_id,omitempty"` + + // message + Message string `json:"message,omitempty"` + + // message type + MessageType string `json:"message_type,omitempty"` + + // to party + ToParty string `json:"to_party,omitempty"` + + // to tag + ToTag string `json:"to_tag,omitempty"` + + // to user + ToUser string `json:"to_user,omitempty"` + + // v send resolved + VSendResolved bool `json:"send_resolved,omitempty"` + + // api secret + APISecret Secret `json:"api_secret,omitempty"` + + // api url + APIURL *URL `json:"api_url,omitempty"` + + // http config + HTTPConfig *HTTPClientConfig `json:"http_config,omitempty"` +} + +// Validate validates this wechat config +func (m *WechatConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAPISecret(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAPIURL(formats); err != nil { + res = append(res, err) + } + + if err := m.validateHTTPConfig(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *WechatConfig) validateAPISecret(formats strfmt.Registry) error { + + if swag.IsZero(m.APISecret) { // not required + return nil + } + + if err := m.APISecret.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("api_secret") + } + return err + } + + return nil +} + +func (m *WechatConfig) validateAPIURL(formats strfmt.Registry) error { + + if swag.IsZero(m.APIURL) { // not required + return nil + } + + if m.APIURL != nil { + if err := m.APIURL.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("api_url") + } + return err + } + } + + return nil +} + +func (m *WechatConfig) validateHTTPConfig(formats strfmt.Registry) error { + + if swag.IsZero(m.HTTPConfig) { // not required + return nil + } + + if m.HTTPConfig != nil { + if err := m.HTTPConfig.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("http_config") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *WechatConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *WechatConfig) UnmarshalBinary(b []byte) error { + var res WechatConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/gen/restapi/configure_documentation_of_the_api.go b/pkg/gen/restapi/configure_documentation_of_the_api.go new file mode 100644 index 00000000000..f149f128554 --- /dev/null +++ b/pkg/gen/restapi/configure_documentation_of_the_api.go @@ -0,0 +1,186 @@ +// This file is safe to edit. Once it exists it will not be overwritten + +package restapi + +import ( + "crypto/tls" + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + + "github.com/grafana/alerting-api/pkg/gen/restapi/operations" + "github.com/grafana/alerting-api/pkg/gen/restapi/operations/alertmanager" + "github.com/grafana/alerting-api/pkg/gen/restapi/operations/permissions" + "github.com/grafana/alerting-api/pkg/gen/restapi/operations/prometheus" + "github.com/grafana/alerting-api/pkg/gen/restapi/operations/ruler" + "github.com/grafana/alerting-api/pkg/gen/restapi/operations/testing" +) + +//go:generate swagger generate server --target ../../gen --name DocumentationOfTheAPI --spec ../../../post.json --principal interface{} --exclude-main + +func configureFlags(api *operations.DocumentationOfTheAPIAPI) { + // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } +} + +func configureAPI(api *operations.DocumentationOfTheAPIAPI) http.Handler { + // configure the api here + api.ServeError = errors.ServeError + + // Set your custom logger if needed. Default one is log.Printf + // Expected interface func(string, ...interface{}) + // + // Example: + // api.Logger = log.Printf + + api.UseSwaggerUI() + // To continue using redoc as your UI, uncomment the following line + // api.UseRedoc() + + api.JSONConsumer = runtime.JSONConsumer() + api.YamlConsumer = yamlpc.YAMLConsumer() + + api.JSONProducer = runtime.JSONProducer() + + if api.AlertmanagerRouteCreateSilenceHandler == nil { + api.AlertmanagerRouteCreateSilenceHandler = alertmanager.RouteCreateSilenceHandlerFunc(func(params alertmanager.RouteCreateSilenceParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteCreateSilence has not yet been implemented") + }) + } + if api.AlertmanagerRouteDeleteAlertingConfigHandler == nil { + api.AlertmanagerRouteDeleteAlertingConfigHandler = alertmanager.RouteDeleteAlertingConfigHandlerFunc(func(params alertmanager.RouteDeleteAlertingConfigParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteDeleteAlertingConfig has not yet been implemented") + }) + } + if api.RulerRouteDeleteNamespaceRulesConfigHandler == nil { + api.RulerRouteDeleteNamespaceRulesConfigHandler = ruler.RouteDeleteNamespaceRulesConfigHandlerFunc(func(params ruler.RouteDeleteNamespaceRulesConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RouteDeleteNamespaceRulesConfig has not yet been implemented") + }) + } + if api.RulerRouteDeleteRuleGroupConfigHandler == nil { + api.RulerRouteDeleteRuleGroupConfigHandler = ruler.RouteDeleteRuleGroupConfigHandlerFunc(func(params ruler.RouteDeleteRuleGroupConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RouteDeleteRuleGroupConfig has not yet been implemented") + }) + } + if api.AlertmanagerRouteDeleteSilenceHandler == nil { + api.AlertmanagerRouteDeleteSilenceHandler = alertmanager.RouteDeleteSilenceHandlerFunc(func(params alertmanager.RouteDeleteSilenceParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteDeleteSilence has not yet been implemented") + }) + } + if api.PrometheusRouteGetAlertStatusesHandler == nil { + api.PrometheusRouteGetAlertStatusesHandler = prometheus.RouteGetAlertStatusesHandlerFunc(func(params prometheus.RouteGetAlertStatusesParams) middleware.Responder { + return middleware.NotImplemented("operation prometheus.RouteGetAlertStatuses has not yet been implemented") + }) + } + if api.AlertmanagerRouteGetAlertingConfigHandler == nil { + api.AlertmanagerRouteGetAlertingConfigHandler = alertmanager.RouteGetAlertingConfigHandlerFunc(func(params alertmanager.RouteGetAlertingConfigParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteGetAlertingConfig has not yet been implemented") + }) + } + if api.AlertmanagerRouteGetAmAlertGroupsHandler == nil { + api.AlertmanagerRouteGetAmAlertGroupsHandler = alertmanager.RouteGetAmAlertGroupsHandlerFunc(func(params alertmanager.RouteGetAmAlertGroupsParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteGetAmAlertGroups has not yet been implemented") + }) + } + if api.AlertmanagerRouteGetAmAlertsHandler == nil { + api.AlertmanagerRouteGetAmAlertsHandler = alertmanager.RouteGetAmAlertsHandlerFunc(func(params alertmanager.RouteGetAmAlertsParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteGetAmAlerts has not yet been implemented") + }) + } + if api.PermissionsRouteGetNamespacePermissionsHandler == nil { + api.PermissionsRouteGetNamespacePermissionsHandler = permissions.RouteGetNamespacePermissionsHandlerFunc(func(params permissions.RouteGetNamespacePermissionsParams) middleware.Responder { + return middleware.NotImplemented("operation permissions.RouteGetNamespacePermissions has not yet been implemented") + }) + } + if api.RulerRouteGetNamespaceRulesConfigHandler == nil { + api.RulerRouteGetNamespaceRulesConfigHandler = ruler.RouteGetNamespaceRulesConfigHandlerFunc(func(params ruler.RouteGetNamespaceRulesConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RouteGetNamespaceRulesConfig has not yet been implemented") + }) + } + if api.PrometheusRouteGetRuleStatusesHandler == nil { + api.PrometheusRouteGetRuleStatusesHandler = prometheus.RouteGetRuleStatusesHandlerFunc(func(params prometheus.RouteGetRuleStatusesParams) middleware.Responder { + return middleware.NotImplemented("operation prometheus.RouteGetRuleStatuses has not yet been implemented") + }) + } + if api.RulerRouteGetRulegGroupConfigHandler == nil { + api.RulerRouteGetRulegGroupConfigHandler = ruler.RouteGetRulegGroupConfigHandlerFunc(func(params ruler.RouteGetRulegGroupConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RouteGetRulegGroupConfig has not yet been implemented") + }) + } + if api.RulerRouteGetRulesConfigHandler == nil { + api.RulerRouteGetRulesConfigHandler = ruler.RouteGetRulesConfigHandlerFunc(func(params ruler.RouteGetRulesConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RouteGetRulesConfig has not yet been implemented") + }) + } + if api.AlertmanagerRouteGetSilenceHandler == nil { + api.AlertmanagerRouteGetSilenceHandler = alertmanager.RouteGetSilenceHandlerFunc(func(params alertmanager.RouteGetSilenceParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteGetSilence has not yet been implemented") + }) + } + if api.AlertmanagerRouteGetSilencesHandler == nil { + api.AlertmanagerRouteGetSilencesHandler = alertmanager.RouteGetSilencesHandlerFunc(func(params alertmanager.RouteGetSilencesParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteGetSilences has not yet been implemented") + }) + } + if api.AlertmanagerRoutePostAlertingConfigHandler == nil { + api.AlertmanagerRoutePostAlertingConfigHandler = alertmanager.RoutePostAlertingConfigHandlerFunc(func(params alertmanager.RoutePostAlertingConfigParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RoutePostAlertingConfig has not yet been implemented") + }) + } + if api.AlertmanagerRoutePostAmAlertsHandler == nil { + api.AlertmanagerRoutePostAmAlertsHandler = alertmanager.RoutePostAmAlertsHandlerFunc(func(params alertmanager.RoutePostAmAlertsParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RoutePostAmAlerts has not yet been implemented") + }) + } + if api.RulerRoutePostNameRulesConfigHandler == nil { + api.RulerRoutePostNameRulesConfigHandler = ruler.RoutePostNameRulesConfigHandlerFunc(func(params ruler.RoutePostNameRulesConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RoutePostNameRulesConfig has not yet been implemented") + }) + } + if api.PermissionsRouteSetNamespacePermissionsHandler == nil { + api.PermissionsRouteSetNamespacePermissionsHandler = permissions.RouteSetNamespacePermissionsHandlerFunc(func(params permissions.RouteSetNamespacePermissionsParams) middleware.Responder { + return middleware.NotImplemented("operation permissions.RouteSetNamespacePermissions has not yet been implemented") + }) + } + if api.TestingRouteTestReceiverConfigHandler == nil { + api.TestingRouteTestReceiverConfigHandler = testing.RouteTestReceiverConfigHandlerFunc(func(params testing.RouteTestReceiverConfigParams) middleware.Responder { + return middleware.NotImplemented("operation testing.RouteTestReceiverConfig has not yet been implemented") + }) + } + if api.TestingRouteTestRuleConfigHandler == nil { + api.TestingRouteTestRuleConfigHandler = testing.RouteTestRuleConfigHandlerFunc(func(params testing.RouteTestRuleConfigParams) middleware.Responder { + return middleware.NotImplemented("operation testing.RouteTestRuleConfig has not yet been implemented") + }) + } + + api.PreServerShutdown = func() {} + + api.ServerShutdown = func() {} + + return setupGlobalMiddleware(api.Serve(setupMiddlewares)) +} + +// The TLS configuration before HTTPS server starts. +func configureTLS(tlsConfig *tls.Config) { + // Make all necessary changes to the TLS configuration here. +} + +// As soon as server is initialized but not run yet, this function will be called. +// If you need to modify a config, store server instance to stop it individually later, this is the place. +// This function can be called multiple times, depending on the number of serving schemes. +// scheme value will be set accordingly: "http", "https" or "unix" +func configureServer(s *http.Server, scheme, addr string) { +} + +// The middleware configuration is for the handler executors. These do not apply to the swagger.json document. +// The middleware executes after routing but before authentication, binding and validation +func setupMiddlewares(handler http.Handler) http.Handler { + return handler +} + +// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document. +// So this is a good place to plug in a panic handling middleware, logging and metrics +func setupGlobalMiddleware(handler http.Handler) http.Handler { + return handler +} diff --git a/pkg/gen/restapi/doc.go b/pkg/gen/restapi/doc.go new file mode 100644 index 00000000000..b2465d765df --- /dev/null +++ b/pkg/gen/restapi/doc.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +// Package restapi Documentation of the API. +// +// Schemes: +// http +// https +// Host: localhost +// BasePath: /api/v1 +// Version: 1.0.0 +// +// Consumes: +// - application/json +// - application/yaml +// +// Produces: +// - application/json +// +// swagger:meta +package restapi diff --git a/pkg/gen/restapi/embedded_spec.go b/pkg/gen/restapi/embedded_spec.go new file mode 100644 index 00000000000..7f59195775d --- /dev/null +++ b/pkg/gen/restapi/embedded_spec.go @@ -0,0 +1,6952 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package restapi + +// 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" +) + +var ( + // SwaggerJSON embedded version of the swagger document used at generation time + SwaggerJSON json.RawMessage + // FlatSwaggerJSON embedded flattened version of the swagger document used at generation time + FlatSwaggerJSON json.RawMessage +) + +func init() { + SwaggerJSON = json.RawMessage([]byte(`{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "schemes": [ + "http", + "https" + ], + "swagger": "2.0", + "info": { + "title": "Documentation of the API.", + "version": "1.0.0" + }, + "basePath": "/api/v1", + "paths": { + "/alertmanager/{DatasourceId}/api/v2/alerts": { + "get": { + "description": "get alertmanager alerts", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetAmAlerts", + "parameters": [ + { + "type": "boolean", + "x-go-name": "Active", + "description": "Show active alerts", + "name": "active", + "in": "query" + }, + { + "type": "boolean", + "x-go-name": "Silenced", + "description": "Show silenced alerts", + "name": "silenced", + "in": "query" + }, + { + "type": "boolean", + "x-go-name": "Inhibited", + "description": "Show inhibited alerts", + "name": "inhibited", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Matchers", + "description": "A list of matchers to filter alerts by", + "name": "matchers", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Receivers", + "description": "A list of receivers to filter alerts by", + "name": "receivers", + "in": "query" + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "GettableAlerts", + "schema": { + "$ref": "#/definitions/GettableAlerts" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "post": { + "description": "create alertmanager alerts", + "tags": [ + "alertmanager" + ], + "operationId": "RoutePostAmAlerts", + "parameters": [ + { + "name": "PostableAlerts", + "in": "body", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/postableAlert" + } + } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/alertmanager/{DatasourceId}/api/v2/alerts/groups": { + "get": { + "description": "get alertmanager alerts", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetAmAlertGroups", + "parameters": [ + { + "type": "boolean", + "x-go-name": "Active", + "description": "Show active alerts", + "name": "active", + "in": "query" + }, + { + "type": "boolean", + "x-go-name": "Silenced", + "description": "Show silenced alerts", + "name": "silenced", + "in": "query" + }, + { + "type": "boolean", + "x-go-name": "Inhibited", + "description": "Show inhibited alerts", + "name": "inhibited", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Matchers", + "description": "A list of matchers to filter alerts by", + "name": "matchers", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Receivers", + "description": "A list of receivers to filter alerts by", + "name": "receivers", + "in": "query" + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "AlertGroups", + "schema": { + "$ref": "#/definitions/AlertGroups" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/alertmanager/{DatasourceId}/api/v2/silence/{SilenceId}": { + "get": { + "description": "get silence", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetSilence", + "parameters": [ + { + "type": "string", + "name": "SilenceId", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "GettableSilence", + "schema": { + "$ref": "#/definitions/GettableSilence" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "delete": { + "description": "delete silence", + "tags": [ + "alertmanager" + ], + "operationId": "RouteDeleteSilence", + "parameters": [ + { + "type": "string", + "name": "SilenceId", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/alertmanager/{DatasourceId}/api/v2/silences": { + "get": { + "description": "get silences", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetSilences", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "GettableSilences", + "schema": { + "$ref": "#/definitions/GettableSilences" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "post": { + "description": "create silence", + "tags": [ + "alertmanager" + ], + "operationId": "RouteCreateSilence", + "parameters": [ + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/SilenceBody" + } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "GettableSilence", + "schema": { + "$ref": "#/definitions/GettableSilence" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/alertmanager/{DatasourceId}/config/api/v1/alerts": { + "get": { + "description": "gets an Alerting config", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetAlertingConfig", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "AlertingConfigResponse", + "schema": { + "$ref": "#/definitions/AlertingConfigResponse" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "post": { + "description": "sets an Alerting config", + "tags": [ + "alertmanager" + ], + "operationId": "RoutePostAlertingConfig", + "parameters": [ + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/UserConfig" + } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "delete": { + "description": "deletes the Alerting config for a tenant", + "tags": [ + "alertmanager" + ], + "operationId": "RouteDeleteAlertingConfig", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/api/v1/namespace/{Namespace}/permissions": { + "get": { + "description": "sets an Alerting config", + "tags": [ + "permissions" + ], + "operationId": "RouteGetNamespacePermissions", + "parameters": [ + { + "type": "string", + "description": "Namespace name", + "name": "Namespace", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Permissions", + "schema": { + "$ref": "#/definitions/Permissions" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "post": { + "description": "gets an Alerting config", + "tags": [ + "permissions" + ], + "operationId": "RouteSetNamespacePermissions", + "parameters": [ + { + "type": "string", + "description": "Namespace name to apply perms to", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "description": "New namespace permissions", + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/Permissions" + } + } + ], + "responses": { + "201": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/api/v1/receiver/test": { + "get": { + "description": "Test receiver", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "testing" + ], + "operationId": "RouteTestReceiverConfig", + "parameters": [ + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/ExtendedReceiver" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Success" + } + }, + "412": { + "description": "SmtpNotEnabled", + "schema": { + "$ref": "#/definitions/SmtpNotEnabled" + } + }, + "500": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/Failure" + } + } + } + } + }, + "/api/v1/rule/test": { + "get": { + "description": "Test rule", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "testing" + ], + "operationId": "RouteTestRuleConfig", + "parameters": [ + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/TestRulePayload" + } + } + ], + "responses": { + "200": { + "description": "TestRuleResponse", + "schema": { + "$ref": "#/definitions/TestRuleResponse" + } + } + } + } + }, + "/prometheus/{DatasourceId}/api/v1/alerts": { + "get": { + "description": "gets the current alerts", + "tags": [ + "prometheus" + ], + "operationId": "RouteGetAlertStatuses", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "AlertResponse", + "schema": { + "$ref": "#/definitions/AlertResponse" + } + } + } + } + }, + "/prometheus/{DatasourceId}/api/v1/rules": { + "get": { + "description": "gets the evaluation statuses of all rules", + "tags": [ + "prometheus" + ], + "operationId": "RouteGetRuleStatuses", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "RuleResponse", + "schema": { + "$ref": "#/definitions/RuleResponse" + } + } + } + } + }, + "/ruler/{DatasourceId}/api/v1/rules": { + "get": { + "description": "List rule groups", + "produces": [ + "application/json" + ], + "tags": [ + "ruler" + ], + "operationId": "RouteGetRulesConfig", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "NamespaceConfigResponse", + "schema": { + "$ref": "#/definitions/NamespaceConfigResponse" + } + } + } + } + }, + "/ruler/{DatasourceId}/api/v1/rules/{Namespace}": { + "get": { + "description": "Get rule groups by namespace", + "produces": [ + "application/json" + ], + "tags": [ + "ruler" + ], + "operationId": "RouteGetNamespaceRulesConfig", + "parameters": [ + { + "type": "string", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "NamespaceConfigResponse", + "schema": { + "$ref": "#/definitions/NamespaceConfigResponse" + } + } + } + }, + "post": { + "description": "Creates or updates a rule group", + "consumes": [ + "application/json", + "application/yaml" + ], + "tags": [ + "ruler" + ], + "operationId": "RoutePostNameRulesConfig", + "parameters": [ + { + "type": "string", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/RuleGroupConfig" + } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + } + } + }, + "delete": { + "description": "Delete namespace", + "tags": [ + "ruler" + ], + "operationId": "RouteDeleteNamespaceRulesConfig", + "parameters": [ + { + "type": "string", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + } + } + } + }, + "/ruler/{DatasourceId}/api/v1/rules/{Namespace}/{Groupname}": { + "get": { + "description": "Get rule group", + "produces": [ + "application/json" + ], + "tags": [ + "ruler" + ], + "operationId": "RouteGetRulegGroupConfig", + "parameters": [ + { + "type": "string", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "Groupname", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "RuleGroupConfigResponse", + "schema": { + "$ref": "#/definitions/RuleGroupConfigResponse" + } + } + } + }, + "delete": { + "description": "Delete rule group", + "tags": [ + "ruler" + ], + "operationId": "RouteDeleteRuleGroupConfig", + "parameters": [ + { + "type": "string", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "Groupname", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + } + } + } + } + }, + "definitions": { + "Ack": { + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Alert": { + "type": "object", + "title": "Alert has info for an alert.", + "properties": { + "activeAt": { + "type": "string", + "format": "date-time", + "x-go-name": "ActiveAt" + }, + "annotations": { + "$ref": "#/definitions/labels" + }, + "labels": { + "$ref": "#/definitions/labels" + }, + "state": { + "type": "string", + "x-go-name": "State" + }, + "value": { + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertDiscovery": { + "type": "object", + "title": "AlertDiscovery has info for all active alerts.", + "properties": { + "alerts": { + "type": "array", + "items": { + "$ref": "#/definitions/Alert" + }, + "x-go-name": "Alerts" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertGroups": { + "$ref": "#/definitions/alertGroups" + }, + "AlertInstancesResponse": { + "type": "object", + "properties": { + "instances": { + "description": "Instances is an array of arrow encoded dataframes\neach frame has a single row, and a column for each instance (alert identified by unique labels) with a boolean value (firing/not firing)", + "type": "array", + "items": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + } + }, + "x-go-name": "Instances" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertNotification": { + "type": "object", + "properties": { + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "disableResolveMessage": { + "type": "boolean", + "x-go-name": "DisableResolveMessage" + }, + "frequency": { + "$ref": "#/definitions/Duration" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "Id" + }, + "isDefault": { + "type": "boolean", + "x-go-name": "IsDefault" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "secureSettings": { + "$ref": "#/definitions/SecureJsonData" + }, + "sendReminder": { + "type": "boolean", + "x-go-name": "SendReminder" + }, + "settings": { + "$ref": "#/definitions/Json" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "updated": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "AlertQuery": { + "type": "object", + "title": "AlertQuery represents a single query associated with an alert definition.", + "properties": { + "model": { + "description": "JSON is the raw JSON query and includes the above properties as well as custom properties.", + "type": "object", + "x-go-name": "Model" + }, + "queryType": { + "description": "QueryType is an optional identifier for the type of query.\nIt can be used to distinguish different types of queries.", + "type": "string", + "x-go-name": "QueryType" + }, + "refId": { + "description": "RefID is the unique identifier of the query, set by the frontend call.", + "type": "string", + "x-go-name": "RefID" + }, + "relativeTimeRange": { + "$ref": "#/definitions/RelativeTimeRange" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/eval" + }, + "AlertResponse": { + "type": "object", + "properties": { + "Body": { + "description": "in: body", + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/AlertDiscovery" + }, + "error": { + "type": "string", + "x-go-name": "Error" + }, + "errorType": { + "$ref": "#/definitions/ErrorType" + }, + "status": { + "type": "string", + "x-go-name": "Status" + } + } + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertingConfigResponse": { + "type": "object", + "properties": { + "Body": { + "$ref": "#/definitions/UserConfig" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertingRule": { + "description": "adapted from cortex", + "type": "object", + "properties": { + "alerts": { + "type": "array", + "items": { + "$ref": "#/definitions/Alert" + }, + "x-go-name": "Alerts" + }, + "annotations": { + "$ref": "#/definitions/labels" + }, + "duration": { + "type": "number", + "format": "double", + "x-go-name": "Duration" + }, + "evaluationTime": { + "type": "number", + "format": "double", + "x-go-name": "EvaluationTime" + }, + "health": { + "type": "string", + "x-go-name": "Health" + }, + "labels": { + "$ref": "#/definitions/labels" + }, + "lastError": { + "type": "string", + "x-go-name": "LastError" + }, + "lastEvaluation": { + "type": "string", + "format": "date-time", + "x-go-name": "LastEvaluation" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "query": { + "type": "string", + "x-go-name": "Query" + }, + "state": { + "description": "State can be \"pending\", \"firing\", \"inactive\".", + "type": "string", + "x-go-name": "State" + }, + "type": { + "$ref": "#/definitions/RuleType" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ApiAlertingConfig": { + "type": "object", + "properties": { + "global": { + "$ref": "#/definitions/GlobalConfig" + }, + "inhibit_rules": { + "type": "array", + "items": { + "$ref": "#/definitions/InhibitRule" + }, + "x-go-name": "InhibitRules" + }, + "receivers": { + "description": "Override with our superset receiver type", + "type": "array", + "items": { + "$ref": "#/definitions/ApiReceiver" + }, + "x-go-name": "Receivers" + }, + "route": { + "$ref": "#/definitions/Route" + }, + "templates": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Templates" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ApiReceiver": { + "type": "object", + "properties": { + "email_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/EmailConfig" + }, + "x-go-name": "EmailConfigs" + }, + "grafana_managed_receiver_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/GrafanaReceiver" + }, + "x-go-name": "GrafanaManagedReceivers" + }, + "name": { + "description": "A unique identifier for this receiver.", + "type": "string", + "x-go-name": "Name" + }, + "opsgenie_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/OpsGenieConfig" + }, + "x-go-name": "OpsGenieConfigs" + }, + "pagerduty_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/PagerdutyConfig" + }, + "x-go-name": "PagerdutyConfigs" + }, + "pushover_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/PushoverConfig" + }, + "x-go-name": "PushoverConfigs" + }, + "slack_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/SlackConfig" + }, + "x-go-name": "SlackConfigs" + }, + "victorops_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/VictorOpsConfig" + }, + "x-go-name": "VictorOpsConfigs" + }, + "webhook_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookConfig" + }, + "x-go-name": "WebhookConfigs" + }, + "wechat_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/WechatConfig" + }, + "x-go-name": "WechatConfigs" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ApiRuleNode": { + "type": "object", + "properties": { + "alert": { + "type": "string", + "x-go-name": "Alert" + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Annotations" + }, + "expr": { + "type": "string", + "x-go-name": "Expr" + }, + "for": { + "$ref": "#/definitions/Duration" + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Labels" + }, + "record": { + "type": "string", + "x-go-name": "Record" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "BasicAuth": { + "type": "object", + "title": "BasicAuth contains basic HTTP authentication credentials.", + "properties": { + "Password": { + "$ref": "#/definitions/Secret" + }, + "PasswordFile": { + "type": "string" + }, + "Username": { + "type": "string" + } + }, + "x-go-package": "github.com/prometheus/common/config" + }, + "BodyAlertingConfig": { + "type": "object", + "properties": { + "Body": { + "$ref": "#/definitions/UserConfig" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Config": { + "type": "object", + "title": "Config is the top-level configuration for Alertmanager's config files.", + "properties": { + "global": { + "$ref": "#/definitions/GlobalConfig" + }, + "inhibit_rules": { + "type": "array", + "items": { + "$ref": "#/definitions/InhibitRule" + }, + "x-go-name": "InhibitRules" + }, + "receivers": { + "type": "array", + "items": { + "$ref": "#/definitions/Receiver" + }, + "x-go-name": "Receivers" + }, + "route": { + "$ref": "#/definitions/Route" + }, + "templates": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Templates" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "CreateAlertNotificationCommand": { + "type": "object", + "properties": { + "Result": { + "$ref": "#/definitions/AlertNotification" + }, + "disableResolveMessage": { + "type": "boolean", + "x-go-name": "DisableResolveMessage" + }, + "frequency": { + "type": "string", + "x-go-name": "Frequency" + }, + "isDefault": { + "type": "boolean", + "x-go-name": "IsDefault" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "secureSettings": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "SecureSettings" + }, + "sendReminder": { + "type": "boolean", + "x-go-name": "SendReminder" + }, + "settings": { + "$ref": "#/definitions/Json" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "uid": { + "type": "string", + "x-go-name": "Uid" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "DashboardAclUpdateItem": { + "type": "object", + "properties": { + "permission": { + "$ref": "#/definitions/PermissionType" + }, + "role": { + "$ref": "#/definitions/RoleType" + }, + "teamId": { + "type": "integer", + "format": "int64", + "x-go-name": "TeamID" + }, + "userId": { + "type": "integer", + "format": "int64", + "x-go-name": "UserID" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/api/dtos" + }, + "DateTime": { + "description": "DateTime is a time but it serializes to ISO8601 format with millis\nIt knows how to read 3 different variations of a RFC3339 date time.\nMost APIs we encounter want either millisecond or second precision times.\nThis just tries to make it worry-free.", + "type": "string", + "format": "date-time", + "x-go-package": "github.com/go-openapi/strfmt" + }, + "Duration": { + "type": "integer", + "format": "int64", + "title": "Duration is a type used for marshalling durations." + }, + "EmailConfig": { + "type": "object", + "title": "EmailConfig configures notifications via mail.", + "properties": { + "auth_identity": { + "type": "string", + "x-go-name": "AuthIdentity" + }, + "auth_password": { + "$ref": "#/definitions/Secret" + }, + "auth_secret": { + "$ref": "#/definitions/Secret" + }, + "auth_username": { + "type": "string", + "x-go-name": "AuthUsername" + }, + "from": { + "type": "string", + "x-go-name": "From" + }, + "headers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Headers" + }, + "hello": { + "type": "string", + "x-go-name": "Hello" + }, + "html": { + "type": "string", + "x-go-name": "HTML" + }, + "require_tls": { + "type": "boolean", + "x-go-name": "RequireTLS" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "smarthost": { + "$ref": "#/definitions/HostPort" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "tls_config": { + "$ref": "#/definitions/TLSConfig" + }, + "to": { + "description": "Email address to notify.", + "type": "string", + "x-go-name": "To" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "ErrorType": { + "type": "string", + "title": "ErrorType models the different API error types.", + "x-go-package": "github.com/prometheus/client_golang/api/prometheus/v1" + }, + "EvalAlertConditionCommand": { + "type": "object", + "properties": { + "condition": { + "type": "string", + "x-go-name": "Condition" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/AlertQuery" + }, + "x-go-name": "Data" + }, + "now": { + "type": "string", + "format": "date-time", + "x-go-name": "Now" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ExtendedReceiver": { + "type": "object", + "properties": { + "email_configs": { + "$ref": "#/definitions/EmailConfig" + }, + "grafana_managed_receiver": { + "$ref": "#/definitions/GrafanaReceiver" + }, + "opsgenie_configs": { + "$ref": "#/definitions/OpsGenieConfig" + }, + "pagerduty_configs": { + "$ref": "#/definitions/PagerdutyConfig" + }, + "pushover_configs": { + "$ref": "#/definitions/PushoverConfig" + }, + "slack_configs": { + "$ref": "#/definitions/SlackConfig" + }, + "victorops_configs": { + "$ref": "#/definitions/VictorOpsConfig" + }, + "webhook_configs": { + "$ref": "#/definitions/WebhookConfig" + }, + "wechat_configs": { + "$ref": "#/definitions/WechatConfig" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ExtendedRuleNode": { + "type": "object", + "properties": { + "alert": { + "type": "string", + "x-go-name": "Alert" + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Annotations" + }, + "expr": { + "type": "string", + "x-go-name": "Expr" + }, + "for": { + "$ref": "#/definitions/Duration" + }, + "grafana_alert": { + "$ref": "#/definitions/ExtendedUpsertAlertDefinitionCommand" + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Labels" + }, + "record": { + "type": "string", + "x-go-name": "Record" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ExtendedUpsertAlertDefinitionCommand": { + "description": "ExtendedUpsertAlertDefinitionCommand extends UpsertAlertDefinitionCommand\nwith properties of grafana dashboard alerts", + "type": "object", + "properties": { + "condition": { + "description": "Condition is the refID of the query or expression to be evaluated", + "type": "string", + "x-go-name": "Condition" + }, + "data": { + "description": "Data is an array of the queries and expressions", + "type": "array", + "items": { + "$ref": "#/definitions/AlertQuery" + }, + "x-go-name": "Data" + }, + "exec_err_state": { + "type": "string", + "enum": [ + "Alerting", + "KeepLastState" + ], + "x-go-name": "ExecutionErrorState" + }, + "no_data_state": { + "type": "string", + "enum": [ + "Alerting", + "NoData", + "KeepLastState", + "OK" + ], + "x-go-name": "NoDataState" + }, + "receivers": { + "description": "Receivers are optional and used for migrating notification channels of existing alerts", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Receivers" + }, + "settings": { + "type": "object", + "additionalProperties": { + "type": "object" + }, + "x-go-name": "Settings" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "uid": { + "description": "UID is set only for existing definitions", + "type": "string", + "x-go-name": "UID" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Failure": { + "$ref": "#/definitions/ResponseDetails" + }, + "GettableAlerts": { + "$ref": "#/definitions/gettableAlerts" + }, + "GettableSilence": { + "$ref": "#/definitions/silence" + }, + "GettableSilences": { + "type": "array", + "items": { + "$ref": "#/definitions/gettableSilences" + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "GlobalConfig": { + "description": "GlobalConfig defines configuration parameters that are valid globally\nunless overwritten.", + "type": "object", + "properties": { + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "opsgenie_api_key": { + "$ref": "#/definitions/Secret" + }, + "opsgenie_api_url": { + "$ref": "#/definitions/URL" + }, + "pagerduty_url": { + "$ref": "#/definitions/URL" + }, + "resolve_timeout": { + "$ref": "#/definitions/Duration" + }, + "slack_api_url": { + "$ref": "#/definitions/SecretURL" + }, + "smtp_auth_identity": { + "type": "string", + "x-go-name": "SMTPAuthIdentity" + }, + "smtp_auth_password": { + "$ref": "#/definitions/Secret" + }, + "smtp_auth_secret": { + "$ref": "#/definitions/Secret" + }, + "smtp_auth_username": { + "type": "string", + "x-go-name": "SMTPAuthUsername" + }, + "smtp_from": { + "type": "string", + "x-go-name": "SMTPFrom" + }, + "smtp_hello": { + "type": "string", + "x-go-name": "SMTPHello" + }, + "smtp_require_tls": { + "type": "boolean", + "x-go-name": "SMTPRequireTLS" + }, + "smtp_smarthost": { + "$ref": "#/definitions/HostPort" + }, + "victorops_api_key": { + "$ref": "#/definitions/Secret" + }, + "victorops_api_url": { + "$ref": "#/definitions/URL" + }, + "wechat_api_corp_id": { + "type": "string", + "x-go-name": "WeChatAPICorpID" + }, + "wechat_api_secret": { + "$ref": "#/definitions/Secret" + }, + "wechat_api_url": { + "$ref": "#/definitions/URL" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "GrafanaReceiver": { + "$ref": "#/definitions/CreateAlertNotificationCommand" + }, + "GrafanaReceivers": { + "type": "object", + "properties": { + "grafana_managed_receiver_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/GrafanaReceiver" + }, + "x-go-name": "GrafanaManagedReceivers" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "HTTPClientConfig": { + "type": "object", + "title": "HTTPClientConfig configures an HTTP client.", + "properties": { + "BasicAuth": { + "$ref": "#/definitions/BasicAuth" + }, + "BearerToken": { + "$ref": "#/definitions/Secret" + }, + "BearerTokenFile": { + "description": "The bearer token file for the targets.", + "type": "string" + }, + "ProxyURL": { + "$ref": "#/definitions/URL" + }, + "TLSConfig": { + "$ref": "#/definitions/TLSConfig" + } + }, + "x-go-package": "github.com/prometheus/common/config" + }, + "HostPort": { + "type": "object", + "title": "HostPort represents a \"host:port\" network address.", + "properties": { + "Host": { + "type": "string" + }, + "Port": { + "type": "string" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "InhibitRule": { + "description": "InhibitRule defines an inhibition rule that mutes alerts that match the\ntarget labels if an alert matching the source labels exists.\nBoth alerts have to have a set of labels being equal.", + "type": "object", + "properties": { + "equal": { + "$ref": "#/definitions/LabelNames" + }, + "source_match": { + "description": "SourceMatch defines a set of labels that have to equal the given\nvalue for source alerts. Deprecated. Remove before v1.0 release.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "SourceMatch" + }, + "source_match_re": { + "$ref": "#/definitions/MatchRegexps" + }, + "source_matchers": { + "$ref": "#/definitions/Matchers" + }, + "target_match": { + "description": "TargetMatch defines a set of labels that have to equal the given\nvalue for target alerts. Deprecated. Remove before v1.0 release.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "TargetMatch" + }, + "target_match_re": { + "$ref": "#/definitions/MatchRegexps" + }, + "target_matchers": { + "$ref": "#/definitions/Matchers" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "Json": { + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/components/simplejson" + }, + "Label": { + "type": "object", + "title": "Label is a key/value pair of strings.", + "properties": { + "Name": { + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-package": "github.com/prometheus/prometheus/pkg/labels" + }, + "LabelName": { + "description": "A LabelName is a key for a LabelSet or Metric. It has a value associated\ntherewith.", + "type": "string", + "x-go-package": "github.com/prometheus/common/model" + }, + "LabelNames": { + "type": "array", + "title": "LabelNames is a sortable LabelName slice. In implements sort.Interface.", + "items": { + "$ref": "#/definitions/LabelName" + }, + "x-go-package": "github.com/prometheus/common/model" + }, + "Labels": { + "description": "Labels is a sorted set of labels. Order has to be guaranteed upon\ninstantiation.", + "type": "array", + "items": { + "$ref": "#/definitions/Label" + }, + "x-go-package": "github.com/prometheus/prometheus/pkg/labels" + }, + "LotexQuery": { + "type": "object", + "properties": { + "Expr": { + "type": "string", + "example": "(node_filesystem_avail_bytes{fstype!=\"\",job=\"integrations/node_exporter\"} node_filesystem_size_bytes{fstype!=\"\",job=\"integrations/node_exporter\"} * 100 \u003c 5 and node_filesystem_readonly{fstype!=\"\",job=\"integrations/node_exporter\"} == 0)" + }, + "datasourceUid": { + "description": "DatasourceUID is required if the query will be sent to grafana to be executed", + "type": "string", + "x-go-name": "DatasourceUID" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "MatchRegexps": { + "type": "object", + "title": "MatchRegexps represents a map of Regexp.", + "additionalProperties": { + "$ref": "#/definitions/Regexp" + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "MatchType": { + "type": "integer", + "format": "int64", + "title": "MatchType is an enum for label matching types.", + "x-go-package": "github.com/prometheus/alertmanager/pkg/labels" + }, + "Matcher": { + "type": "object", + "title": "Matcher models the matching of a label.", + "properties": { + "Name": { + "type": "string" + }, + "Type": { + "$ref": "#/definitions/MatchType" + }, + "Value": { + "type": "string" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/pkg/labels" + }, + "Matchers": { + "description": "Matchers is a slice of Matchers that is sortable, implements Stringer, and\nprovides a Matches method to match a LabelSet against all Matchers in the\nslice. Note that some users of Matchers might require it to be sorted.", + "type": "array", + "items": { + "$ref": "#/definitions/Matcher" + } + }, + "NamespaceConfigResponse": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/RuleGroupConfig" + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "NotifierConfig": { + "type": "object", + "title": "NotifierConfig contains base options common across all notifier configurations.", + "properties": { + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "OpsGenieConfig": { + "type": "object", + "title": "OpsGenieConfig configures notifications via OpsGenie.", + "properties": { + "api_key": { + "$ref": "#/definitions/Secret" + }, + "api_url": { + "$ref": "#/definitions/URL" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "details": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Details" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "note": { + "type": "string", + "x-go-name": "Note" + }, + "priority": { + "type": "string", + "x-go-name": "Priority" + }, + "responders": { + "type": "array", + "items": { + "$ref": "#/definitions/OpsGenieConfigResponder" + }, + "x-go-name": "Responders" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "source": { + "type": "string", + "x-go-name": "Source" + }, + "tags": { + "type": "string", + "x-go-name": "Tags" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "OpsGenieConfigResponder": { + "type": "object", + "properties": { + "id": { + "description": "One of those 3 should be filled.", + "type": "string", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "type": { + "description": "team, user, escalation, schedule etc.", + "type": "string", + "x-go-name": "Type" + }, + "username": { + "type": "string", + "x-go-name": "Username" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PagerdutyConfig": { + "type": "object", + "title": "PagerdutyConfig configures notifications via PagerDuty.", + "properties": { + "class": { + "type": "string", + "x-go-name": "Class" + }, + "client": { + "type": "string", + "x-go-name": "Client" + }, + "client_url": { + "type": "string", + "x-go-name": "ClientURL" + }, + "component": { + "type": "string", + "x-go-name": "Component" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "details": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Details" + }, + "group": { + "type": "string", + "x-go-name": "Group" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "images": { + "type": "array", + "items": { + "$ref": "#/definitions/PagerdutyImage" + }, + "x-go-name": "Images" + }, + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/PagerdutyLink" + }, + "x-go-name": "Links" + }, + "routing_key": { + "$ref": "#/definitions/Secret" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "service_key": { + "$ref": "#/definitions/Secret" + }, + "severity": { + "type": "string", + "x-go-name": "Severity" + }, + "url": { + "$ref": "#/definitions/URL" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PagerdutyImage": { + "description": "PagerdutyImage is an image", + "type": "object", + "properties": { + "alt": { + "type": "string", + "x-go-name": "Alt" + }, + "href": { + "type": "string", + "x-go-name": "Href" + }, + "src": { + "type": "string", + "x-go-name": "Src" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PagerdutyLink": { + "description": "PagerdutyLink is a link", + "type": "object", + "properties": { + "href": { + "type": "string", + "x-go-name": "Href" + }, + "text": { + "type": "string", + "x-go-name": "Text" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PermissionType": { + "type": "integer", + "format": "int64", + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "Permissions": { + "type": "array", + "items": { + "$ref": "#/definitions/UpdateDashboardAclCommand" + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Point": { + "type": "object", + "title": "Point represents a single data point for a given timestamp.", + "properties": { + "T": { + "type": "integer", + "format": "int64" + }, + "V": { + "type": "number", + "format": "double" + } + }, + "x-go-package": "github.com/prometheus/prometheus/promql" + }, + "PushoverConfig": { + "type": "object", + "properties": { + "expire": { + "$ref": "#/definitions/duration" + }, + "html": { + "type": "boolean", + "x-go-name": "HTML" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "priority": { + "type": "string", + "x-go-name": "Priority" + }, + "retry": { + "$ref": "#/definitions/duration" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "sound": { + "type": "string", + "x-go-name": "Sound" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "token": { + "$ref": "#/definitions/Secret" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "url_title": { + "type": "string", + "x-go-name": "URLTitle" + }, + "user_key": { + "$ref": "#/definitions/Secret" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "Receiver": { + "type": "object", + "title": "Receiver configuration provides configuration on how to contact a receiver.", + "properties": { + "email_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/EmailConfig" + }, + "x-go-name": "EmailConfigs" + }, + "name": { + "description": "A unique identifier for this receiver.", + "type": "string", + "x-go-name": "Name" + }, + "opsgenie_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/OpsGenieConfig" + }, + "x-go-name": "OpsGenieConfigs" + }, + "pagerduty_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/PagerdutyConfig" + }, + "x-go-name": "PagerdutyConfigs" + }, + "pushover_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/PushoverConfig" + }, + "x-go-name": "PushoverConfigs" + }, + "slack_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/SlackConfig" + }, + "x-go-name": "SlackConfigs" + }, + "victorops_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/VictorOpsConfig" + }, + "x-go-name": "VictorOpsConfigs" + }, + "webhook_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookConfig" + }, + "x-go-name": "WebhookConfigs" + }, + "wechat_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/WechatConfig" + }, + "x-go-name": "WechatConfigs" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "Regexp": { + "description": "A Regexp is safe for concurrent use by multiple goroutines,\nexcept for configuration methods, such as Longest.", + "type": "object", + "title": "Regexp is the representation of a compiled regular expression.", + "x-go-package": "regexp" + }, + "RelativeTimeRange": { + "description": "RelativeTimeRange is the per query start and end time\nfor requests.", + "type": "object", + "properties": { + "from": { + "$ref": "#/definitions/Duration" + }, + "to": { + "$ref": "#/definitions/Duration" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/eval" + }, + "ResponseDetails": { + "type": "object", + "properties": { + "msg": { + "type": "string", + "x-go-name": "Msg" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RoleType": { + "type": "string", + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "Route": { + "type": "object", + "title": "A Route is a node that contains definitions of how to handle alerts.", + "properties": { + "continue": { + "type": "boolean", + "x-go-name": "Continue" + }, + "group_by": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "GroupByStr" + }, + "group_interval": { + "$ref": "#/definitions/Duration" + }, + "group_wait": { + "$ref": "#/definitions/Duration" + }, + "match": { + "description": "Deprecated. Remove before v1.0 release.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Match" + }, + "match_re": { + "$ref": "#/definitions/MatchRegexps" + }, + "matchers": { + "$ref": "#/definitions/Matchers" + }, + "receiver": { + "type": "string", + "x-go-name": "Receiver" + }, + "repeat_interval": { + "$ref": "#/definitions/Duration" + }, + "routes": { + "type": "array", + "items": { + "$ref": "#/definitions/Route" + }, + "x-go-name": "Routes" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "Rule": { + "description": "adapted from cortex", + "type": "object", + "properties": { + "evaluationTime": { + "type": "number", + "format": "double", + "x-go-name": "EvaluationTime" + }, + "health": { + "type": "string", + "x-go-name": "Health" + }, + "labels": { + "$ref": "#/definitions/labels" + }, + "lastError": { + "type": "string", + "x-go-name": "LastError" + }, + "lastEvaluation": { + "type": "string", + "format": "date-time", + "x-go-name": "LastEvaluation" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "query": { + "type": "string", + "x-go-name": "Query" + }, + "type": { + "$ref": "#/definitions/RuleType" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleDiscovery": { + "type": "object", + "properties": { + "groups": { + "type": "array", + "items": { + "$ref": "#/definitions/RuleGroup" + }, + "x-go-name": "RuleGroups" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleGroup": { + "type": "object", + "properties": { + "evaluationTime": { + "type": "number", + "format": "double", + "x-go-name": "EvaluationTime" + }, + "file": { + "type": "string", + "x-go-name": "File" + }, + "interval": { + "type": "number", + "format": "double", + "x-go-name": "Interval" + }, + "lastEvaluation": { + "type": "string", + "format": "date-time", + "x-go-name": "LastEvaluation" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "rules": { + "description": "In order to preserve rule ordering, while exposing type (alerting or recording)\nspecific properties, both alerting and recording rules are exposed in the\nsame array.", + "type": "array", + "items": { + "$ref": "#/definitions/AlertingRule" + }, + "x-go-name": "Rules" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleGroupConfig": { + "type": "object", + "properties": { + "interval": { + "$ref": "#/definitions/Duration" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "rules": { + "type": "array", + "items": { + "$ref": "#/definitions/ExtendedRuleNode" + }, + "x-go-name": "Rules" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleGroupConfigResponse": { + "type": "object", + "properties": { + "interval": { + "$ref": "#/definitions/Duration" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "rules": { + "type": "array", + "items": { + "$ref": "#/definitions/ExtendedRuleNode" + }, + "x-go-name": "Rules" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleResponse": { + "type": "object", + "properties": { + "Body": { + "description": "in: body", + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/RuleDiscovery" + }, + "error": { + "type": "string", + "x-go-name": "Error" + }, + "errorType": { + "$ref": "#/definitions/ErrorType" + }, + "status": { + "type": "string", + "x-go-name": "Status" + } + } + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleType": { + "type": "string", + "title": "RuleType models the type of a rule.", + "x-go-package": "github.com/prometheus/client_golang/api/prometheus/v1" + }, + "Sample": { + "type": "object", + "title": "Sample is a single sample belonging to a metric.", + "properties": { + "Metric": { + "$ref": "#/definitions/Labels" + }, + "T": { + "type": "integer", + "format": "int64" + }, + "V": { + "type": "number", + "format": "double" + } + }, + "x-go-package": "github.com/prometheus/prometheus/promql" + }, + "Secret": { + "type": "string", + "title": "Secret special type for storing secrets.", + "x-go-package": "github.com/prometheus/common/config" + }, + "SecretURL": { + "title": "SecretURL is a URL that must not be revealed on marshaling.", + "$ref": "#/definitions/URL" + }, + "SecureJsonData": { + "description": "SecureJsonData is used to store encrypted data (for example in data_source table). Only values are separately\nencrypted.", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/components/securejsondata" + }, + "SilenceBody": { + "type": "object", + "required": [ + "comment", + "createdBy", + "endsAt", + "matchers", + "startsAt" + ], + "properties": { + "comment": { + "description": "comment", + "type": "string", + "x-go-name": "Comment" + }, + "createdBy": { + "description": "created by", + "type": "string", + "x-go-name": "CreatedBy" + }, + "endsAt": { + "description": "ends at", + "type": "string", + "format": "date-time", + "x-go-name": "EndsAt" + }, + "id": { + "type": "string", + "x-go-name": "Id" + }, + "matchers": { + "$ref": "#/definitions/matchers" + }, + "startsAt": { + "description": "starts at", + "type": "string", + "format": "date-time", + "x-go-name": "StartsAt" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/tst" + }, + "SlackAction": { + "description": "See https://api.slack.com/docs/message-attachments#action_fields and https://api.slack.com/docs/message-buttons\nfor more information.", + "type": "object", + "title": "SlackAction configures a single Slack action that is sent with each notification.", + "properties": { + "confirm": { + "$ref": "#/definitions/SlackConfirmationField" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "style": { + "type": "string", + "x-go-name": "Style" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "value": { + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SlackConfig": { + "type": "object", + "title": "SlackConfig configures notifications via Slack.", + "properties": { + "actions": { + "type": "array", + "items": { + "$ref": "#/definitions/SlackAction" + }, + "x-go-name": "Actions" + }, + "api_url": { + "$ref": "#/definitions/SecretURL" + }, + "callback_id": { + "type": "string", + "x-go-name": "CallbackID" + }, + "channel": { + "description": "Slack channel override, (like #other-channel or @username).", + "type": "string", + "x-go-name": "Channel" + }, + "color": { + "type": "string", + "x-go-name": "Color" + }, + "fallback": { + "type": "string", + "x-go-name": "Fallback" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/SlackField" + }, + "x-go-name": "Fields" + }, + "footer": { + "type": "string", + "x-go-name": "Footer" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "icon_emoji": { + "type": "string", + "x-go-name": "IconEmoji" + }, + "icon_url": { + "type": "string", + "x-go-name": "IconURL" + }, + "image_url": { + "type": "string", + "x-go-name": "ImageURL" + }, + "link_names": { + "type": "boolean", + "x-go-name": "LinkNames" + }, + "mrkdwn_in": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "MrkdwnIn" + }, + "pretext": { + "type": "string", + "x-go-name": "Pretext" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "short_fields": { + "type": "boolean", + "x-go-name": "ShortFields" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "thumb_url": { + "type": "string", + "x-go-name": "ThumbURL" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "title_link": { + "type": "string", + "x-go-name": "TitleLink" + }, + "username": { + "type": "string", + "x-go-name": "Username" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SlackConfirmationField": { + "description": "SlackConfirmationField protect users from destructive actions or particularly distinguished decisions\nby asking them to confirm their button click one more time.\nSee https://api.slack.com/docs/interactive-message-field-guide#confirmation_fields for more information.", + "type": "object", + "properties": { + "dismiss_text": { + "type": "string", + "x-go-name": "DismissText" + }, + "ok_text": { + "type": "string", + "x-go-name": "OkText" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SlackField": { + "description": "Each field must contain a title, value, and optionally, a boolean value to indicate if the field\nis short enough to be displayed next to other fields designated as short.\nSee https://api.slack.com/docs/message-attachments#fields for more information.", + "type": "object", + "title": "SlackField configures a single Slack field that is sent with each notification.", + "properties": { + "short": { + "type": "boolean", + "x-go-name": "Short" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "value": { + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SmtpNotEnabled": { + "$ref": "#/definitions/ResponseDetails" + }, + "Success": { + "$ref": "#/definitions/ResponseDetails" + }, + "TLSConfig": { + "type": "object", + "title": "TLSConfig configures the options for TLS connections.", + "properties": { + "CAFile": { + "description": "The CA cert to use for the targets.", + "type": "string" + }, + "CertFile": { + "description": "The client cert file for the targets.", + "type": "string" + }, + "InsecureSkipVerify": { + "description": "Disable target certificate validation.", + "type": "boolean" + }, + "KeyFile": { + "description": "The client key file for the targets.", + "type": "string" + }, + "ServerName": { + "description": "Used to verify the hostname for the targets.", + "type": "string" + } + }, + "x-go-package": "github.com/prometheus/common/config" + }, + "TestRulePayload": { + "type": "object", + "properties": { + "expr": { + "$ref": "#/definitions/LotexQuery" + }, + "grafana_condition": { + "$ref": "#/definitions/EvalAlertConditionCommand" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "TestRuleResponse": { + "type": "object", + "properties": { + "alerts": { + "$ref": "#/definitions/Vector" + }, + "grafana_alert_instances": { + "$ref": "#/definitions/AlertInstancesResponse" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "URL": { + "description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.", + "type": "object", + "title": "A URL represents a parsed URL (technically, a URI reference).", + "properties": { + "ForceQuery": { + "type": "boolean" + }, + "Fragment": { + "type": "string" + }, + "Host": { + "type": "string" + }, + "Opaque": { + "type": "string" + }, + "Path": { + "type": "string" + }, + "RawFragment": { + "type": "string" + }, + "RawPath": { + "type": "string" + }, + "RawQuery": { + "type": "string" + }, + "Scheme": { + "type": "string" + }, + "User": { + "$ref": "#/definitions/Userinfo" + } + }, + "x-go-package": "net/url" + }, + "UpdateDashboardAclCommand": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/DashboardAclUpdateItem" + }, + "x-go-name": "Items" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/api/dtos" + }, + "UpsertAlertDefinitionCommand": { + "description": "https://github.com/grafana/grafana/blob/debb82e12417e82a0e2bd09e1a450065f884c1bc/pkg/services/ngalert/models.go#L85", + "type": "object", + "title": "UpsertAlertDefinitionCommand is copy of the unexported struct:", + "properties": { + "condition": { + "description": "Condition is the refID of the query or expression to be evaluated", + "type": "string", + "x-go-name": "Condition" + }, + "data": { + "description": "Data is an array of the queries and expressions", + "type": "array", + "items": { + "$ref": "#/definitions/AlertQuery" + }, + "x-go-name": "Data" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "uid": { + "description": "UID is set only for existing definitions", + "type": "string", + "x-go-name": "UID" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "UserConfig": { + "type": "object", + "properties": { + "alertmanager_config": { + "$ref": "#/definitions/ApiAlertingConfig" + }, + "template_files": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "TemplateFiles" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/tst" + }, + "Userinfo": { + "description": "The Userinfo type is an immutable encapsulation of username and\npassword details for a URL. An existing Userinfo value is guaranteed\nto have a username set (potentially empty, as allowed by RFC 2396),\nand optionally a password.", + "type": "object", + "x-go-package": "net/url" + }, + "ValidationError": { + "type": "object", + "properties": { + "msg": { + "type": "string", + "x-go-name": "Msg" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Vector": { + "description": "Vector is basically only an alias for model.Samples, but the\ncontract is that in a Vector, all Samples have the same timestamp.", + "type": "array", + "items": { + "$ref": "#/definitions/Sample" + }, + "x-go-package": "github.com/prometheus/prometheus/promql" + }, + "VictorOpsConfig": { + "type": "object", + "title": "VictorOpsConfig configures notifications via VictorOps.", + "properties": { + "api_key": { + "$ref": "#/definitions/Secret" + }, + "api_url": { + "$ref": "#/definitions/URL" + }, + "custom_fields": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "CustomFields" + }, + "entity_display_name": { + "type": "string", + "x-go-name": "EntityDisplayName" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message_type": { + "type": "string", + "x-go-name": "MessageType" + }, + "monitoring_tool": { + "type": "string", + "x-go-name": "MonitoringTool" + }, + "routing_key": { + "type": "string", + "x-go-name": "RoutingKey" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "state_message": { + "type": "string", + "x-go-name": "StateMessage" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "WebhookConfig": { + "type": "object", + "title": "WebhookConfig configures notifications via a generic webhook.", + "properties": { + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "max_alerts": { + "description": "MaxAlerts is the maximum number of alerts to be sent per webhook message.\nAlerts exceeding this threshold will be truncated. Setting this to 0\nallows an unlimited number of alerts.", + "type": "integer", + "format": "uint64", + "x-go-name": "MaxAlerts" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "url": { + "$ref": "#/definitions/URL" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "WechatConfig": { + "type": "object", + "title": "WechatConfig configures notifications via Wechat.", + "properties": { + "agent_id": { + "type": "string", + "x-go-name": "AgentID" + }, + "api_secret": { + "$ref": "#/definitions/Secret" + }, + "api_url": { + "$ref": "#/definitions/URL" + }, + "corp_id": { + "type": "string", + "x-go-name": "CorpID" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "message_type": { + "type": "string", + "x-go-name": "MessageType" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "to_party": { + "type": "string", + "x-go-name": "ToParty" + }, + "to_tag": { + "type": "string", + "x-go-name": "ToTag" + }, + "to_user": { + "type": "string", + "x-go-name": "ToUser" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "alert": { + "description": "Alert alert", + "type": "object", + "required": [ + "labels" + ], + "properties": { + "generatorURL": { + "description": "generator URL\nFormat: uri", + "type": "string", + "format": "uri", + "x-go-name": "GeneratorURL" + }, + "labels": { + "$ref": "#/definitions/labelSet" + } + }, + "x-go-name": "Alert", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertGroup": { + "description": "AlertGroup alert group", + "type": "object", + "required": [ + "alerts", + "labels", + "receiver" + ], + "properties": { + "alerts": { + "description": "alerts", + "type": "array", + "items": { + "$ref": "#/definitions/gettableAlert" + }, + "x-go-name": "Alerts" + }, + "labels": { + "$ref": "#/definitions/labelSet" + }, + "receiver": { + "$ref": "#/definitions/receiver" + } + }, + "x-go-name": "AlertGroup", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertGroups": { + "description": "AlertGroups alert groups", + "type": "array", + "items": { + "$ref": "#/definitions/alertGroup" + }, + "x-go-name": "AlertGroups", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertStatus": { + "description": "AlertStatus alert status", + "type": "object", + "required": [ + "inhibitedBy", + "silencedBy", + "state" + ], + "properties": { + "inhibitedBy": { + "description": "inhibited by", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "InhibitedBy" + }, + "silencedBy": { + "description": "silenced by", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "SilencedBy" + }, + "state": { + "description": "state", + "type": "string", + "enum": [ + "[unprocessed active suppressed]" + ], + "x-go-name": "State" + } + }, + "x-go-name": "AlertStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertmanagerConfig": { + "description": "AlertmanagerConfig alertmanager config", + "type": "object", + "required": [ + "original" + ], + "properties": { + "original": { + "description": "original", + "type": "string", + "x-go-name": "Original" + } + }, + "x-go-name": "AlertmanagerConfig", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertmanagerStatus": { + "description": "AlertmanagerStatus alertmanager status", + "type": "object", + "required": [ + "cluster", + "config", + "uptime", + "versionInfo" + ], + "properties": { + "cluster": { + "$ref": "#/definitions/clusterStatus" + }, + "config": { + "$ref": "#/definitions/alertmanagerConfig" + }, + "uptime": { + "description": "uptime", + "type": "string", + "format": "date-time", + "x-go-name": "Uptime" + }, + "versionInfo": { + "$ref": "#/definitions/versionInfo" + } + }, + "x-go-name": "AlertmanagerStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "clusterStatus": { + "description": "ClusterStatus cluster status", + "type": "object", + "required": [ + "status" + ], + "properties": { + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + }, + "peers": { + "description": "peers", + "type": "array", + "items": { + "$ref": "#/definitions/peerStatus" + }, + "x-go-name": "Peers" + }, + "status": { + "description": "status", + "type": "string", + "enum": [ + "[ready settling disabled]" + ], + "x-go-name": "Status" + } + }, + "x-go-name": "ClusterStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "discoveryBase": { + "type": "object", + "properties": { + "error": { + "type": "string", + "x-go-name": "Error" + }, + "errorType": { + "$ref": "#/definitions/ErrorType" + }, + "status": { + "type": "string", + "x-go-name": "Status" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "duration": { + "$ref": "#/definitions/Duration" + }, + "gettableAlert": { + "description": "GettableAlert gettable alert", + "type": "object", + "required": [ + "labels", + "annotations", + "endsAt", + "fingerprint", + "receivers", + "startsAt", + "status", + "updatedAt" + ], + "properties": { + "annotations": { + "$ref": "#/definitions/labelSet" + }, + "endsAt": { + "description": "ends at", + "type": "string", + "format": "date-time", + "x-go-name": "EndsAt" + }, + "fingerprint": { + "description": "fingerprint", + "type": "string", + "x-go-name": "Fingerprint" + }, + "generatorURL": { + "description": "generator URL\nFormat: uri", + "type": "string", + "format": "uri", + "x-go-name": "GeneratorURL" + }, + "labels": { + "$ref": "#/definitions/labelSet" + }, + "receivers": { + "description": "receivers", + "type": "array", + "items": { + "$ref": "#/definitions/receiver" + }, + "x-go-name": "Receivers" + }, + "startsAt": { + "description": "starts at", + "type": "string", + "format": "date-time", + "x-go-name": "StartsAt" + }, + "status": { + "$ref": "#/definitions/alertStatus" + }, + "updatedAt": { + "description": "updated at", + "type": "string", + "format": "date-time", + "x-go-name": "UpdatedAt" + } + }, + "x-go-name": "GettableAlert", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "gettableAlerts": { + "description": "GettableAlerts gettable alerts", + "type": "array", + "items": { + "$ref": "#/definitions/gettableAlert" + }, + "x-go-name": "GettableAlerts", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "gettableSilence": { + "description": "GettableSilence gettable silence", + "type": "object", + "required": [ + "comment", + "createdBy", + "endsAt", + "matchers", + "startsAt", + "id", + "status", + "updatedAt" + ], + "properties": { + "comment": { + "description": "comment", + "type": "string", + "x-go-name": "Comment" + }, + "createdBy": { + "description": "created by", + "type": "string", + "x-go-name": "CreatedBy" + }, + "endsAt": { + "description": "ends at", + "type": "string", + "format": "date-time", + "x-go-name": "EndsAt" + }, + "id": { + "description": "id", + "type": "string", + "x-go-name": "ID" + }, + "matchers": { + "$ref": "#/definitions/matchers" + }, + "startsAt": { + "description": "starts at", + "type": "string", + "format": "date-time", + "x-go-name": "StartsAt" + }, + "status": { + "$ref": "#/definitions/silenceStatus" + }, + "updatedAt": { + "description": "updated at", + "type": "string", + "format": "date-time", + "x-go-name": "UpdatedAt" + } + }, + "x-go-name": "GettableSilence", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "gettableSilences": { + "description": "GettableSilences gettable silences", + "type": "array", + "items": { + "$ref": "#/definitions/gettableSilence" + }, + "x-go-name": "GettableSilences", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "labelSet": { + "description": "LabelSet label set", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "LabelSet", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "labels": { + "description": "The custom marshaling for labels.Labels ends up doing this anyways.", + "type": "object", + "title": "override the labels type with a map for generation.", + "additionalProperties": { + "type": "string" + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "matcher": { + "description": "Matcher matcher", + "type": "object", + "required": [ + "isRegex", + "name", + "value" + ], + "properties": { + "isRegex": { + "description": "is regex", + "type": "boolean", + "x-go-name": "IsRegex" + }, + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + }, + "value": { + "description": "value", + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-name": "Matcher", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "matchers": { + "description": "Matchers matchers", + "type": "array", + "items": { + "$ref": "#/definitions/matcher" + }, + "x-go-name": "Matchers", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "peerStatus": { + "description": "PeerStatus peer status", + "type": "object", + "required": [ + "address", + "name" + ], + "properties": { + "address": { + "description": "address", + "type": "string", + "x-go-name": "Address" + }, + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-name": "PeerStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "postableAlert": { + "description": "PostableAlert postable alert", + "type": "object", + "required": [ + "labels" + ], + "properties": { + "annotations": { + "$ref": "#/definitions/labelSet" + }, + "endsAt": { + "description": "ends at\nFormat: date-time", + "type": "string", + "format": "date-time", + "x-go-name": "EndsAt" + }, + "generatorURL": { + "description": "generator URL\nFormat: uri", + "type": "string", + "format": "uri", + "x-go-name": "GeneratorURL" + }, + "labels": { + "$ref": "#/definitions/labelSet" + }, + "startsAt": { + "description": "starts at\nFormat: date-time", + "type": "string", + "format": "date-time", + "x-go-name": "StartsAt" + } + }, + "x-go-name": "PostableAlert", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "postableAlerts": { + "description": "PostableAlerts postable alerts", + "type": "array", + "items": { + "$ref": "#/definitions/postableAlert" + }, + "x-go-name": "PostableAlerts", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "postableSilence": { + "description": "PostableSilence postable silence", + "type": "object", + "required": [ + "comment", + "createdBy", + "endsAt", + "matchers", + "startsAt" + ], + "properties": { + "comment": { + "description": "comment", + "type": "string", + "x-go-name": "Comment" + }, + "createdBy": { + "description": "created by", + "type": "string", + "x-go-name": "CreatedBy" + }, + "endsAt": { + "description": "ends at", + "type": "string", + "format": "date-time", + "x-go-name": "EndsAt" + }, + "id": { + "description": "id", + "type": "string", + "x-go-name": "ID" + }, + "matchers": { + "$ref": "#/definitions/matchers" + }, + "startsAt": { + "description": "starts at", + "type": "string", + "format": "date-time", + "x-go-name": "StartsAt" + } + }, + "x-go-name": "PostableSilence", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "receiver": { + "description": "Receiver receiver", + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-name": "Receiver", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "silence": { + "description": "Silence silence", + "type": "object", + "required": [ + "comment", + "createdBy", + "endsAt", + "matchers", + "startsAt" + ], + "properties": { + "comment": { + "description": "comment", + "type": "string", + "x-go-name": "Comment" + }, + "createdBy": { + "description": "created by", + "type": "string", + "x-go-name": "CreatedBy" + }, + "endsAt": { + "description": "ends at", + "type": "string", + "format": "date-time", + "x-go-name": "EndsAt" + }, + "matchers": { + "$ref": "#/definitions/matchers" + }, + "startsAt": { + "description": "starts at", + "type": "string", + "format": "date-time", + "x-go-name": "StartsAt" + } + }, + "x-go-name": "Silence", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "silenceStatus": { + "description": "SilenceStatus silence status", + "type": "object", + "required": [ + "state" + ], + "properties": { + "state": { + "description": "state", + "type": "string", + "enum": [ + "[expired active pending]" + ], + "x-go-name": "State" + } + }, + "x-go-name": "SilenceStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "versionInfo": { + "description": "VersionInfo version info", + "type": "object", + "required": [ + "branch", + "buildDate", + "buildUser", + "goVersion", + "revision", + "version" + ], + "properties": { + "branch": { + "description": "branch", + "type": "string", + "x-go-name": "Branch" + }, + "buildDate": { + "description": "build date", + "type": "string", + "x-go-name": "BuildDate" + }, + "buildUser": { + "description": "build user", + "type": "string", + "x-go-name": "BuildUser" + }, + "goVersion": { + "description": "go version", + "type": "string", + "x-go-name": "GoVersion" + }, + "revision": { + "description": "revision", + "type": "string", + "x-go-name": "Revision" + }, + "version": { + "description": "version", + "type": "string", + "x-go-name": "Version" + } + }, + "x-go-name": "VersionInfo", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + } + }, + "securityDefinitions": { + "basic": { + "type": "basic" + } + } +}`)) + FlatSwaggerJSON = json.RawMessage([]byte(`{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "schemes": [ + "http", + "https" + ], + "swagger": "2.0", + "info": { + "title": "Documentation of the API.", + "version": "1.0.0" + }, + "basePath": "/api/v1", + "paths": { + "/alertmanager/{DatasourceId}/api/v2/alerts": { + "get": { + "description": "get alertmanager alerts", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetAmAlerts", + "parameters": [ + { + "type": "boolean", + "x-go-name": "Active", + "description": "Show active alerts", + "name": "active", + "in": "query" + }, + { + "type": "boolean", + "x-go-name": "Silenced", + "description": "Show silenced alerts", + "name": "silenced", + "in": "query" + }, + { + "type": "boolean", + "x-go-name": "Inhibited", + "description": "Show inhibited alerts", + "name": "inhibited", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Matchers", + "description": "A list of matchers to filter alerts by", + "name": "matchers", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Receivers", + "description": "A list of receivers to filter alerts by", + "name": "receivers", + "in": "query" + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "GettableAlerts", + "schema": { + "$ref": "#/definitions/GettableAlerts" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "post": { + "description": "create alertmanager alerts", + "tags": [ + "alertmanager" + ], + "operationId": "RoutePostAmAlerts", + "parameters": [ + { + "name": "PostableAlerts", + "in": "body", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/postableAlert" + } + } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/alertmanager/{DatasourceId}/api/v2/alerts/groups": { + "get": { + "description": "get alertmanager alerts", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetAmAlertGroups", + "parameters": [ + { + "type": "boolean", + "x-go-name": "Active", + "description": "Show active alerts", + "name": "active", + "in": "query" + }, + { + "type": "boolean", + "x-go-name": "Silenced", + "description": "Show silenced alerts", + "name": "silenced", + "in": "query" + }, + { + "type": "boolean", + "x-go-name": "Inhibited", + "description": "Show inhibited alerts", + "name": "inhibited", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Matchers", + "description": "A list of matchers to filter alerts by", + "name": "matchers", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Receivers", + "description": "A list of receivers to filter alerts by", + "name": "receivers", + "in": "query" + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "AlertGroups", + "schema": { + "$ref": "#/definitions/AlertGroups" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/alertmanager/{DatasourceId}/api/v2/silence/{SilenceId}": { + "get": { + "description": "get silence", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetSilence", + "parameters": [ + { + "type": "string", + "name": "SilenceId", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "GettableSilence", + "schema": { + "$ref": "#/definitions/GettableSilence" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "delete": { + "description": "delete silence", + "tags": [ + "alertmanager" + ], + "operationId": "RouteDeleteSilence", + "parameters": [ + { + "type": "string", + "name": "SilenceId", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/alertmanager/{DatasourceId}/api/v2/silences": { + "get": { + "description": "get silences", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetSilences", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "GettableSilences", + "schema": { + "$ref": "#/definitions/GettableSilences" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "post": { + "description": "create silence", + "tags": [ + "alertmanager" + ], + "operationId": "RouteCreateSilence", + "parameters": [ + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/SilenceBody" + } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "GettableSilence", + "schema": { + "$ref": "#/definitions/GettableSilence" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/alertmanager/{DatasourceId}/config/api/v1/alerts": { + "get": { + "description": "gets an Alerting config", + "tags": [ + "alertmanager" + ], + "operationId": "RouteGetAlertingConfig", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "AlertingConfigResponse", + "schema": { + "$ref": "#/definitions/AlertingConfigResponse" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "post": { + "description": "sets an Alerting config", + "tags": [ + "alertmanager" + ], + "operationId": "RoutePostAlertingConfig", + "parameters": [ + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/UserConfig" + } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "delete": { + "description": "deletes the Alerting config for a tenant", + "tags": [ + "alertmanager" + ], + "operationId": "RouteDeleteAlertingConfig", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/api/v1/namespace/{Namespace}/permissions": { + "get": { + "description": "sets an Alerting config", + "tags": [ + "permissions" + ], + "operationId": "RouteGetNamespacePermissions", + "parameters": [ + { + "type": "string", + "description": "Namespace name", + "name": "Namespace", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Permissions", + "schema": { + "$ref": "#/definitions/Permissions" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + }, + "post": { + "description": "gets an Alerting config", + "tags": [ + "permissions" + ], + "operationId": "RouteSetNamespacePermissions", + "parameters": [ + { + "type": "string", + "description": "Namespace name to apply perms to", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "description": "New namespace permissions", + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/Permissions" + } + } + ], + "responses": { + "201": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + } + } + }, + "/api/v1/receiver/test": { + "get": { + "description": "Test receiver", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "testing" + ], + "operationId": "RouteTestReceiverConfig", + "parameters": [ + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/ExtendedReceiver" + } + } + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Success" + } + }, + "412": { + "description": "SmtpNotEnabled", + "schema": { + "$ref": "#/definitions/SmtpNotEnabled" + } + }, + "500": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/Failure" + } + } + } + } + }, + "/api/v1/rule/test": { + "get": { + "description": "Test rule", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "testing" + ], + "operationId": "RouteTestRuleConfig", + "parameters": [ + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/TestRulePayload" + } + } + ], + "responses": { + "200": { + "description": "TestRuleResponse", + "schema": { + "$ref": "#/definitions/TestRuleResponse" + } + } + } + } + }, + "/prometheus/{DatasourceId}/api/v1/alerts": { + "get": { + "description": "gets the current alerts", + "tags": [ + "prometheus" + ], + "operationId": "RouteGetAlertStatuses", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "AlertResponse", + "schema": { + "$ref": "#/definitions/AlertResponse" + } + } + } + } + }, + "/prometheus/{DatasourceId}/api/v1/rules": { + "get": { + "description": "gets the evaluation statuses of all rules", + "tags": [ + "prometheus" + ], + "operationId": "RouteGetRuleStatuses", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "RuleResponse", + "schema": { + "$ref": "#/definitions/RuleResponse" + } + } + } + } + }, + "/ruler/{DatasourceId}/api/v1/rules": { + "get": { + "description": "List rule groups", + "produces": [ + "application/json" + ], + "tags": [ + "ruler" + ], + "operationId": "RouteGetRulesConfig", + "parameters": [ + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "NamespaceConfigResponse", + "schema": { + "$ref": "#/definitions/NamespaceConfigResponse" + } + } + } + } + }, + "/ruler/{DatasourceId}/api/v1/rules/{Namespace}": { + "get": { + "description": "Get rule groups by namespace", + "produces": [ + "application/json" + ], + "tags": [ + "ruler" + ], + "operationId": "RouteGetNamespaceRulesConfig", + "parameters": [ + { + "type": "string", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "NamespaceConfigResponse", + "schema": { + "$ref": "#/definitions/NamespaceConfigResponse" + } + } + } + }, + "post": { + "description": "Creates or updates a rule group", + "consumes": [ + "application/json", + "application/yaml" + ], + "tags": [ + "ruler" + ], + "operationId": "RoutePostNameRulesConfig", + "parameters": [ + { + "type": "string", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "name": "Body", + "in": "body", + "schema": { + "$ref": "#/definitions/RuleGroupConfig" + } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + } + } + }, + "delete": { + "description": "Delete namespace", + "tags": [ + "ruler" + ], + "operationId": "RouteDeleteNamespaceRulesConfig", + "parameters": [ + { + "type": "string", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + } + } + } + }, + "/ruler/{DatasourceId}/api/v1/rules/{Namespace}/{Groupname}": { + "get": { + "description": "Get rule group", + "produces": [ + "application/json" + ], + "tags": [ + "ruler" + ], + "operationId": "RouteGetRulegGroupConfig", + "parameters": [ + { + "type": "string", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "Groupname", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "RuleGroupConfigResponse", + "schema": { + "$ref": "#/definitions/RuleGroupConfigResponse" + } + } + } + }, + "delete": { + "description": "Delete rule group", + "tags": [ + "ruler" + ], + "operationId": "RouteDeleteRuleGroupConfig", + "parameters": [ + { + "type": "string", + "name": "Namespace", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "Groupname", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true + } + ], + "responses": { + "202": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + } + } + } + } + }, + "definitions": { + "Ack": { + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Alert": { + "type": "object", + "title": "Alert has info for an alert.", + "properties": { + "activeAt": { + "type": "string", + "format": "date-time", + "x-go-name": "ActiveAt" + }, + "annotations": { + "$ref": "#/definitions/labels" + }, + "labels": { + "$ref": "#/definitions/labels" + }, + "state": { + "type": "string", + "x-go-name": "State" + }, + "value": { + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertDiscovery": { + "type": "object", + "title": "AlertDiscovery has info for all active alerts.", + "properties": { + "alerts": { + "type": "array", + "items": { + "$ref": "#/definitions/Alert" + }, + "x-go-name": "Alerts" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertGroups": {}, + "AlertInstancesResponse": { + "type": "object", + "properties": { + "instances": { + "description": "Instances is an array of arrow encoded dataframes\neach frame has a single row, and a column for each instance (alert identified by unique labels) with a boolean value (firing/not firing)", + "type": "array", + "items": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + } + }, + "x-go-name": "Instances" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertNotification": { + "type": "object", + "properties": { + "created": { + "type": "string", + "format": "date-time", + "x-go-name": "Created" + }, + "disableResolveMessage": { + "type": "boolean", + "x-go-name": "DisableResolveMessage" + }, + "frequency": { + "$ref": "#/definitions/Duration" + }, + "id": { + "type": "integer", + "format": "int64", + "x-go-name": "Id" + }, + "isDefault": { + "type": "boolean", + "x-go-name": "IsDefault" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "secureSettings": { + "$ref": "#/definitions/SecureJsonData" + }, + "sendReminder": { + "type": "boolean", + "x-go-name": "SendReminder" + }, + "settings": { + "$ref": "#/definitions/Json" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "updated": { + "type": "string", + "format": "date-time", + "x-go-name": "Updated" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "AlertQuery": { + "type": "object", + "title": "AlertQuery represents a single query associated with an alert definition.", + "properties": { + "model": { + "description": "JSON is the raw JSON query and includes the above properties as well as custom properties.", + "type": "object", + "x-go-name": "Model" + }, + "queryType": { + "description": "QueryType is an optional identifier for the type of query.\nIt can be used to distinguish different types of queries.", + "type": "string", + "x-go-name": "QueryType" + }, + "refId": { + "description": "RefID is the unique identifier of the query, set by the frontend call.", + "type": "string", + "x-go-name": "RefID" + }, + "relativeTimeRange": { + "$ref": "#/definitions/RelativeTimeRange" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/eval" + }, + "AlertResponse": { + "type": "object", + "properties": { + "Body": { + "$ref": "#/definitions/alertResponseBody" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertingConfigResponse": { + "type": "object", + "properties": { + "Body": { + "$ref": "#/definitions/UserConfig" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertingRule": { + "description": "adapted from cortex", + "type": "object", + "properties": { + "alerts": { + "type": "array", + "items": { + "$ref": "#/definitions/Alert" + }, + "x-go-name": "Alerts" + }, + "annotations": { + "$ref": "#/definitions/labels" + }, + "duration": { + "type": "number", + "format": "double", + "x-go-name": "Duration" + }, + "evaluationTime": { + "type": "number", + "format": "double", + "x-go-name": "EvaluationTime" + }, + "health": { + "type": "string", + "x-go-name": "Health" + }, + "labels": { + "$ref": "#/definitions/labels" + }, + "lastError": { + "type": "string", + "x-go-name": "LastError" + }, + "lastEvaluation": { + "type": "string", + "format": "date-time", + "x-go-name": "LastEvaluation" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "query": { + "type": "string", + "x-go-name": "Query" + }, + "state": { + "description": "State can be \"pending\", \"firing\", \"inactive\".", + "type": "string", + "x-go-name": "State" + }, + "type": { + "$ref": "#/definitions/RuleType" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ApiAlertingConfig": { + "type": "object", + "properties": { + "global": { + "$ref": "#/definitions/GlobalConfig" + }, + "inhibit_rules": { + "type": "array", + "items": { + "$ref": "#/definitions/InhibitRule" + }, + "x-go-name": "InhibitRules" + }, + "receivers": { + "description": "Override with our superset receiver type", + "type": "array", + "items": { + "$ref": "#/definitions/ApiReceiver" + }, + "x-go-name": "Receivers" + }, + "route": { + "$ref": "#/definitions/Route" + }, + "templates": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Templates" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ApiReceiver": { + "type": "object", + "properties": { + "email_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/EmailConfig" + }, + "x-go-name": "EmailConfigs" + }, + "grafana_managed_receiver_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/GrafanaReceiver" + }, + "x-go-name": "GrafanaManagedReceivers" + }, + "name": { + "description": "A unique identifier for this receiver.", + "type": "string", + "x-go-name": "Name" + }, + "opsgenie_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/OpsGenieConfig" + }, + "x-go-name": "OpsGenieConfigs" + }, + "pagerduty_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/PagerdutyConfig" + }, + "x-go-name": "PagerdutyConfigs" + }, + "pushover_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/PushoverConfig" + }, + "x-go-name": "PushoverConfigs" + }, + "slack_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/SlackConfig" + }, + "x-go-name": "SlackConfigs" + }, + "victorops_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/VictorOpsConfig" + }, + "x-go-name": "VictorOpsConfigs" + }, + "webhook_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookConfig" + }, + "x-go-name": "WebhookConfigs" + }, + "wechat_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/WechatConfig" + }, + "x-go-name": "WechatConfigs" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "BasicAuth": { + "type": "object", + "title": "BasicAuth contains basic HTTP authentication credentials.", + "properties": { + "Password": { + "$ref": "#/definitions/Secret" + }, + "PasswordFile": { + "type": "string" + }, + "Username": { + "type": "string" + } + }, + "x-go-package": "github.com/prometheus/common/config" + }, + "CreateAlertNotificationCommand": { + "type": "object", + "properties": { + "Result": { + "$ref": "#/definitions/AlertNotification" + }, + "disableResolveMessage": { + "type": "boolean", + "x-go-name": "DisableResolveMessage" + }, + "frequency": { + "type": "string", + "x-go-name": "Frequency" + }, + "isDefault": { + "type": "boolean", + "x-go-name": "IsDefault" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "secureSettings": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "SecureSettings" + }, + "sendReminder": { + "type": "boolean", + "x-go-name": "SendReminder" + }, + "settings": { + "$ref": "#/definitions/Json" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "uid": { + "type": "string", + "x-go-name": "Uid" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "DashboardAclUpdateItem": { + "type": "object", + "properties": { + "permission": { + "$ref": "#/definitions/PermissionType" + }, + "role": { + "$ref": "#/definitions/RoleType" + }, + "teamId": { + "type": "integer", + "format": "int64", + "x-go-name": "TeamID" + }, + "userId": { + "type": "integer", + "format": "int64", + "x-go-name": "UserID" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/api/dtos" + }, + "Duration": {}, + "EmailConfig": { + "type": "object", + "title": "EmailConfig configures notifications via mail.", + "properties": { + "auth_identity": { + "type": "string", + "x-go-name": "AuthIdentity" + }, + "auth_password": { + "$ref": "#/definitions/Secret" + }, + "auth_secret": { + "$ref": "#/definitions/Secret" + }, + "auth_username": { + "type": "string", + "x-go-name": "AuthUsername" + }, + "from": { + "type": "string", + "x-go-name": "From" + }, + "headers": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Headers" + }, + "hello": { + "type": "string", + "x-go-name": "Hello" + }, + "html": { + "type": "string", + "x-go-name": "HTML" + }, + "require_tls": { + "type": "boolean", + "x-go-name": "RequireTLS" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "smarthost": { + "$ref": "#/definitions/HostPort" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "tls_config": { + "$ref": "#/definitions/TLSConfig" + }, + "to": { + "description": "Email address to notify.", + "type": "string", + "x-go-name": "To" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "ErrorType": { + "type": "string", + "title": "ErrorType models the different API error types.", + "x-go-package": "github.com/prometheus/client_golang/api/prometheus/v1" + }, + "EvalAlertConditionCommand": { + "type": "object", + "properties": { + "condition": { + "type": "string", + "x-go-name": "Condition" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/AlertQuery" + }, + "x-go-name": "Data" + }, + "now": { + "type": "string", + "format": "date-time", + "x-go-name": "Now" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ExtendedReceiver": { + "type": "object", + "properties": { + "email_configs": { + "$ref": "#/definitions/EmailConfig" + }, + "grafana_managed_receiver": { + "$ref": "#/definitions/GrafanaReceiver" + }, + "opsgenie_configs": { + "$ref": "#/definitions/OpsGenieConfig" + }, + "pagerduty_configs": { + "$ref": "#/definitions/PagerdutyConfig" + }, + "pushover_configs": { + "$ref": "#/definitions/PushoverConfig" + }, + "slack_configs": { + "$ref": "#/definitions/SlackConfig" + }, + "victorops_configs": { + "$ref": "#/definitions/VictorOpsConfig" + }, + "webhook_configs": { + "$ref": "#/definitions/WebhookConfig" + }, + "wechat_configs": { + "$ref": "#/definitions/WechatConfig" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ExtendedRuleNode": { + "type": "object", + "properties": { + "alert": { + "type": "string", + "x-go-name": "Alert" + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Annotations" + }, + "expr": { + "type": "string", + "x-go-name": "Expr" + }, + "for": { + "$ref": "#/definitions/Duration" + }, + "grafana_alert": { + "$ref": "#/definitions/ExtendedUpsertAlertDefinitionCommand" + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Labels" + }, + "record": { + "type": "string", + "x-go-name": "Record" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ExtendedUpsertAlertDefinitionCommand": { + "description": "ExtendedUpsertAlertDefinitionCommand extends UpsertAlertDefinitionCommand\nwith properties of grafana dashboard alerts", + "type": "object", + "properties": { + "condition": { + "description": "Condition is the refID of the query or expression to be evaluated", + "type": "string", + "x-go-name": "Condition" + }, + "data": { + "description": "Data is an array of the queries and expressions", + "type": "array", + "items": { + "$ref": "#/definitions/AlertQuery" + }, + "x-go-name": "Data" + }, + "exec_err_state": { + "type": "string", + "enum": [ + "Alerting", + "KeepLastState" + ], + "x-go-name": "ExecutionErrorState" + }, + "no_data_state": { + "type": "string", + "enum": [ + "Alerting", + "NoData", + "KeepLastState", + "OK" + ], + "x-go-name": "NoDataState" + }, + "receivers": { + "description": "Receivers are optional and used for migrating notification channels of existing alerts", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "Receivers" + }, + "settings": { + "type": "object", + "additionalProperties": { + "type": "object" + }, + "x-go-name": "Settings" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "uid": { + "description": "UID is set only for existing definitions", + "type": "string", + "x-go-name": "UID" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Failure": { + "$ref": "#/definitions/ResponseDetails" + }, + "GettableAlerts": {}, + "GettableSilence": { + "$ref": "#/definitions/silence" + }, + "GettableSilences": { + "type": "array", + "items": { + "$ref": "#/definitions/gettableSilences" + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "GlobalConfig": { + "description": "GlobalConfig defines configuration parameters that are valid globally\nunless overwritten.", + "type": "object", + "properties": { + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "opsgenie_api_key": { + "$ref": "#/definitions/Secret" + }, + "opsgenie_api_url": { + "$ref": "#/definitions/URL" + }, + "pagerduty_url": { + "$ref": "#/definitions/URL" + }, + "resolve_timeout": { + "$ref": "#/definitions/Duration" + }, + "slack_api_url": { + "$ref": "#/definitions/SecretURL" + }, + "smtp_auth_identity": { + "type": "string", + "x-go-name": "SMTPAuthIdentity" + }, + "smtp_auth_password": { + "$ref": "#/definitions/Secret" + }, + "smtp_auth_secret": { + "$ref": "#/definitions/Secret" + }, + "smtp_auth_username": { + "type": "string", + "x-go-name": "SMTPAuthUsername" + }, + "smtp_from": { + "type": "string", + "x-go-name": "SMTPFrom" + }, + "smtp_hello": { + "type": "string", + "x-go-name": "SMTPHello" + }, + "smtp_require_tls": { + "type": "boolean", + "x-go-name": "SMTPRequireTLS" + }, + "smtp_smarthost": { + "$ref": "#/definitions/HostPort" + }, + "victorops_api_key": { + "$ref": "#/definitions/Secret" + }, + "victorops_api_url": { + "$ref": "#/definitions/URL" + }, + "wechat_api_corp_id": { + "type": "string", + "x-go-name": "WeChatAPICorpID" + }, + "wechat_api_secret": { + "$ref": "#/definitions/Secret" + }, + "wechat_api_url": { + "$ref": "#/definitions/URL" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "GrafanaReceiver": { + "$ref": "#/definitions/CreateAlertNotificationCommand" + }, + "HTTPClientConfig": { + "type": "object", + "title": "HTTPClientConfig configures an HTTP client.", + "properties": { + "BasicAuth": { + "$ref": "#/definitions/BasicAuth" + }, + "BearerToken": { + "$ref": "#/definitions/Secret" + }, + "BearerTokenFile": { + "description": "The bearer token file for the targets.", + "type": "string" + }, + "ProxyURL": { + "$ref": "#/definitions/URL" + }, + "TLSConfig": { + "$ref": "#/definitions/TLSConfig" + } + }, + "x-go-package": "github.com/prometheus/common/config" + }, + "HostPort": { + "type": "object", + "title": "HostPort represents a \"host:port\" network address.", + "properties": { + "Host": { + "type": "string" + }, + "Port": { + "type": "string" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "InhibitRule": { + "description": "InhibitRule defines an inhibition rule that mutes alerts that match the\ntarget labels if an alert matching the source labels exists.\nBoth alerts have to have a set of labels being equal.", + "type": "object", + "properties": { + "equal": { + "$ref": "#/definitions/LabelNames" + }, + "source_match": { + "description": "SourceMatch defines a set of labels that have to equal the given\nvalue for source alerts. Deprecated. Remove before v1.0 release.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "SourceMatch" + }, + "source_match_re": { + "$ref": "#/definitions/MatchRegexps" + }, + "source_matchers": { + "$ref": "#/definitions/Matchers" + }, + "target_match": { + "description": "TargetMatch defines a set of labels that have to equal the given\nvalue for target alerts. Deprecated. Remove before v1.0 release.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "TargetMatch" + }, + "target_match_re": { + "$ref": "#/definitions/MatchRegexps" + }, + "target_matchers": { + "$ref": "#/definitions/Matchers" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "Json": { + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/components/simplejson" + }, + "Label": { + "type": "object", + "title": "Label is a key/value pair of strings.", + "properties": { + "Name": { + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-package": "github.com/prometheus/prometheus/pkg/labels" + }, + "LabelName": { + "description": "A LabelName is a key for a LabelSet or Metric. It has a value associated\ntherewith.", + "type": "string", + "x-go-package": "github.com/prometheus/common/model" + }, + "LabelNames": { + "type": "array", + "title": "LabelNames is a sortable LabelName slice. In implements sort.Interface.", + "items": { + "$ref": "#/definitions/LabelName" + }, + "x-go-package": "github.com/prometheus/common/model" + }, + "Labels": { + "description": "Labels is a sorted set of labels. Order has to be guaranteed upon\ninstantiation.", + "type": "array", + "items": { + "$ref": "#/definitions/Label" + }, + "x-go-package": "github.com/prometheus/prometheus/pkg/labels" + }, + "LotexQuery": { + "type": "object", + "properties": { + "Expr": { + "type": "string", + "example": "(node_filesystem_avail_bytes{fstype!=\"\",job=\"integrations/node_exporter\"} node_filesystem_size_bytes{fstype!=\"\",job=\"integrations/node_exporter\"} * 100 \u003c 5 and node_filesystem_readonly{fstype!=\"\",job=\"integrations/node_exporter\"} == 0)" + }, + "datasourceUid": { + "description": "DatasourceUID is required if the query will be sent to grafana to be executed", + "type": "string", + "x-go-name": "DatasourceUID" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "MatchRegexps": { + "type": "object", + "title": "MatchRegexps represents a map of Regexp.", + "additionalProperties": { + "$ref": "#/definitions/Regexp" + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "MatchType": { + "type": "integer", + "format": "int64", + "title": "MatchType is an enum for label matching types.", + "x-go-package": "github.com/prometheus/alertmanager/pkg/labels" + }, + "Matcher": { + "type": "object", + "title": "Matcher models the matching of a label.", + "properties": { + "Name": { + "type": "string" + }, + "Type": { + "$ref": "#/definitions/MatchType" + }, + "Value": { + "type": "string" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/pkg/labels" + }, + "Matchers": { + "description": "Matchers is a slice of Matchers that is sortable, implements Stringer, and\nprovides a Matches method to match a LabelSet against all Matchers in the\nslice. Note that some users of Matchers might require it to be sorted.", + "type": "array", + "items": { + "$ref": "#/definitions/Matcher" + } + }, + "NamespaceConfigResponse": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/RuleGroupConfig" + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "OpsGenieConfig": { + "type": "object", + "title": "OpsGenieConfig configures notifications via OpsGenie.", + "properties": { + "api_key": { + "$ref": "#/definitions/Secret" + }, + "api_url": { + "$ref": "#/definitions/URL" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "details": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Details" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "note": { + "type": "string", + "x-go-name": "Note" + }, + "priority": { + "type": "string", + "x-go-name": "Priority" + }, + "responders": { + "type": "array", + "items": { + "$ref": "#/definitions/OpsGenieConfigResponder" + }, + "x-go-name": "Responders" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "source": { + "type": "string", + "x-go-name": "Source" + }, + "tags": { + "type": "string", + "x-go-name": "Tags" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "OpsGenieConfigResponder": { + "type": "object", + "properties": { + "id": { + "description": "One of those 3 should be filled.", + "type": "string", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "type": { + "description": "team, user, escalation, schedule etc.", + "type": "string", + "x-go-name": "Type" + }, + "username": { + "type": "string", + "x-go-name": "Username" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PagerdutyConfig": { + "type": "object", + "title": "PagerdutyConfig configures notifications via PagerDuty.", + "properties": { + "class": { + "type": "string", + "x-go-name": "Class" + }, + "client": { + "type": "string", + "x-go-name": "Client" + }, + "client_url": { + "type": "string", + "x-go-name": "ClientURL" + }, + "component": { + "type": "string", + "x-go-name": "Component" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "details": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Details" + }, + "group": { + "type": "string", + "x-go-name": "Group" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "images": { + "type": "array", + "items": { + "$ref": "#/definitions/PagerdutyImage" + }, + "x-go-name": "Images" + }, + "links": { + "type": "array", + "items": { + "$ref": "#/definitions/PagerdutyLink" + }, + "x-go-name": "Links" + }, + "routing_key": { + "$ref": "#/definitions/Secret" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "service_key": { + "$ref": "#/definitions/Secret" + }, + "severity": { + "type": "string", + "x-go-name": "Severity" + }, + "url": { + "$ref": "#/definitions/URL" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PagerdutyImage": { + "description": "PagerdutyImage is an image", + "type": "object", + "properties": { + "alt": { + "type": "string", + "x-go-name": "Alt" + }, + "href": { + "type": "string", + "x-go-name": "Href" + }, + "src": { + "type": "string", + "x-go-name": "Src" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PagerdutyLink": { + "description": "PagerdutyLink is a link", + "type": "object", + "properties": { + "href": { + "type": "string", + "x-go-name": "Href" + }, + "text": { + "type": "string", + "x-go-name": "Text" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PermissionType": { + "type": "integer", + "format": "int64", + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "Permissions": { + "type": "array", + "items": { + "$ref": "#/definitions/UpdateDashboardAclCommand" + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "PushoverConfig": { + "type": "object", + "properties": { + "expire": { + "$ref": "#/definitions/duration" + }, + "html": { + "type": "boolean", + "x-go-name": "HTML" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "priority": { + "type": "string", + "x-go-name": "Priority" + }, + "retry": { + "$ref": "#/definitions/duration" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "sound": { + "type": "string", + "x-go-name": "Sound" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "token": { + "$ref": "#/definitions/Secret" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "url_title": { + "type": "string", + "x-go-name": "URLTitle" + }, + "user_key": { + "$ref": "#/definitions/Secret" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "Receiver": { + "type": "object", + "title": "Receiver configuration provides configuration on how to contact a receiver.", + "properties": { + "email_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/EmailConfig" + }, + "x-go-name": "EmailConfigs" + }, + "name": { + "description": "A unique identifier for this receiver.", + "type": "string", + "x-go-name": "Name" + }, + "opsgenie_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/OpsGenieConfig" + }, + "x-go-name": "OpsGenieConfigs" + }, + "pagerduty_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/PagerdutyConfig" + }, + "x-go-name": "PagerdutyConfigs" + }, + "pushover_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/PushoverConfig" + }, + "x-go-name": "PushoverConfigs" + }, + "slack_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/SlackConfig" + }, + "x-go-name": "SlackConfigs" + }, + "victorops_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/VictorOpsConfig" + }, + "x-go-name": "VictorOpsConfigs" + }, + "webhook_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/WebhookConfig" + }, + "x-go-name": "WebhookConfigs" + }, + "wechat_configs": { + "type": "array", + "items": { + "$ref": "#/definitions/WechatConfig" + }, + "x-go-name": "WechatConfigs" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "Regexp": { + "description": "A Regexp is safe for concurrent use by multiple goroutines,\nexcept for configuration methods, such as Longest.", + "type": "object", + "title": "Regexp is the representation of a compiled regular expression.", + "x-go-package": "regexp" + }, + "RelativeTimeRange": { + "description": "RelativeTimeRange is the per query start and end time\nfor requests.", + "type": "object", + "properties": { + "from": { + "$ref": "#/definitions/Duration" + }, + "to": { + "$ref": "#/definitions/Duration" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/eval" + }, + "ResponseDetails": { + "type": "object", + "properties": { + "msg": { + "type": "string", + "x-go-name": "Msg" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RoleType": { + "type": "string", + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "Route": { + "type": "object", + "title": "A Route is a node that contains definitions of how to handle alerts.", + "properties": { + "continue": { + "type": "boolean", + "x-go-name": "Continue" + }, + "group_by": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "GroupByStr" + }, + "group_interval": { + "$ref": "#/definitions/Duration" + }, + "group_wait": { + "$ref": "#/definitions/Duration" + }, + "match": { + "description": "Deprecated. Remove before v1.0 release.", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "Match" + }, + "match_re": { + "$ref": "#/definitions/MatchRegexps" + }, + "matchers": { + "$ref": "#/definitions/Matchers" + }, + "receiver": { + "type": "string", + "x-go-name": "Receiver" + }, + "repeat_interval": { + "$ref": "#/definitions/Duration" + }, + "routes": { + "type": "array", + "items": { + "$ref": "#/definitions/Route" + }, + "x-go-name": "Routes" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "RuleDiscovery": { + "type": "object", + "properties": { + "groups": { + "type": "array", + "items": { + "$ref": "#/definitions/RuleGroup" + }, + "x-go-name": "RuleGroups" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleGroup": { + "type": "object", + "properties": { + "evaluationTime": { + "type": "number", + "format": "double", + "x-go-name": "EvaluationTime" + }, + "file": { + "type": "string", + "x-go-name": "File" + }, + "interval": { + "type": "number", + "format": "double", + "x-go-name": "Interval" + }, + "lastEvaluation": { + "type": "string", + "format": "date-time", + "x-go-name": "LastEvaluation" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "rules": { + "description": "In order to preserve rule ordering, while exposing type (alerting or recording)\nspecific properties, both alerting and recording rules are exposed in the\nsame array.", + "type": "array", + "items": { + "$ref": "#/definitions/AlertingRule" + }, + "x-go-name": "Rules" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleGroupConfig": { + "type": "object", + "properties": { + "interval": { + "$ref": "#/definitions/Duration" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "rules": { + "type": "array", + "items": { + "$ref": "#/definitions/ExtendedRuleNode" + }, + "x-go-name": "Rules" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleGroupConfigResponse": { + "type": "object", + "properties": { + "interval": { + "$ref": "#/definitions/Duration" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "rules": { + "type": "array", + "items": { + "$ref": "#/definitions/ExtendedRuleNode" + }, + "x-go-name": "Rules" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleResponse": { + "type": "object", + "properties": { + "Body": { + "$ref": "#/definitions/ruleResponseBody" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleType": { + "type": "string", + "title": "RuleType models the type of a rule.", + "x-go-package": "github.com/prometheus/client_golang/api/prometheus/v1" + }, + "Sample": { + "type": "object", + "title": "Sample is a single sample belonging to a metric.", + "properties": { + "Metric": { + "$ref": "#/definitions/Labels" + }, + "T": { + "type": "integer", + "format": "int64" + }, + "V": { + "type": "number", + "format": "double" + } + }, + "x-go-package": "github.com/prometheus/prometheus/promql" + }, + "Secret": { + "type": "string", + "title": "Secret special type for storing secrets.", + "x-go-package": "github.com/prometheus/common/config" + }, + "SecretURL": { + "title": "SecretURL is a URL that must not be revealed on marshaling.", + "$ref": "#/definitions/URL" + }, + "SecureJsonData": { + "description": "SecureJsonData is used to store encrypted data (for example in data_source table). Only values are separately\nencrypted.", + "type": "object", + "additionalProperties": { + "type": "array", + "items": { + "type": "integer", + "format": "uint8" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/components/securejsondata" + }, + "SilenceBody": { + "type": "object", + "required": [ + "comment", + "createdBy", + "endsAt", + "matchers", + "startsAt" + ], + "properties": { + "comment": { + "description": "comment", + "type": "string", + "x-go-name": "Comment" + }, + "createdBy": { + "description": "created by", + "type": "string", + "x-go-name": "CreatedBy" + }, + "endsAt": { + "description": "ends at", + "type": "string", + "format": "date-time", + "x-go-name": "EndsAt" + }, + "id": { + "type": "string", + "x-go-name": "Id" + }, + "matchers": { + "$ref": "#/definitions/matchers" + }, + "startsAt": { + "description": "starts at", + "type": "string", + "format": "date-time", + "x-go-name": "StartsAt" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/tst" + }, + "SlackAction": { + "description": "See https://api.slack.com/docs/message-attachments#action_fields and https://api.slack.com/docs/message-buttons\nfor more information.", + "type": "object", + "title": "SlackAction configures a single Slack action that is sent with each notification.", + "properties": { + "confirm": { + "$ref": "#/definitions/SlackConfirmationField" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "style": { + "type": "string", + "x-go-name": "Style" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "value": { + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SlackConfig": { + "type": "object", + "title": "SlackConfig configures notifications via Slack.", + "properties": { + "actions": { + "type": "array", + "items": { + "$ref": "#/definitions/SlackAction" + }, + "x-go-name": "Actions" + }, + "api_url": { + "$ref": "#/definitions/SecretURL" + }, + "callback_id": { + "type": "string", + "x-go-name": "CallbackID" + }, + "channel": { + "description": "Slack channel override, (like #other-channel or @username).", + "type": "string", + "x-go-name": "Channel" + }, + "color": { + "type": "string", + "x-go-name": "Color" + }, + "fallback": { + "type": "string", + "x-go-name": "Fallback" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/definitions/SlackField" + }, + "x-go-name": "Fields" + }, + "footer": { + "type": "string", + "x-go-name": "Footer" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "icon_emoji": { + "type": "string", + "x-go-name": "IconEmoji" + }, + "icon_url": { + "type": "string", + "x-go-name": "IconURL" + }, + "image_url": { + "type": "string", + "x-go-name": "ImageURL" + }, + "link_names": { + "type": "boolean", + "x-go-name": "LinkNames" + }, + "mrkdwn_in": { + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "MrkdwnIn" + }, + "pretext": { + "type": "string", + "x-go-name": "Pretext" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "short_fields": { + "type": "boolean", + "x-go-name": "ShortFields" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "thumb_url": { + "type": "string", + "x-go-name": "ThumbURL" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "title_link": { + "type": "string", + "x-go-name": "TitleLink" + }, + "username": { + "type": "string", + "x-go-name": "Username" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SlackConfirmationField": { + "description": "SlackConfirmationField protect users from destructive actions or particularly distinguished decisions\nby asking them to confirm their button click one more time.\nSee https://api.slack.com/docs/interactive-message-field-guide#confirmation_fields for more information.", + "type": "object", + "properties": { + "dismiss_text": { + "type": "string", + "x-go-name": "DismissText" + }, + "ok_text": { + "type": "string", + "x-go-name": "OkText" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SlackField": { + "description": "Each field must contain a title, value, and optionally, a boolean value to indicate if the field\nis short enough to be displayed next to other fields designated as short.\nSee https://api.slack.com/docs/message-attachments#fields for more information.", + "type": "object", + "title": "SlackField configures a single Slack field that is sent with each notification.", + "properties": { + "short": { + "type": "boolean", + "x-go-name": "Short" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "value": { + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SmtpNotEnabled": { + "$ref": "#/definitions/ResponseDetails" + }, + "Success": { + "$ref": "#/definitions/ResponseDetails" + }, + "TLSConfig": { + "type": "object", + "title": "TLSConfig configures the options for TLS connections.", + "properties": { + "CAFile": { + "description": "The CA cert to use for the targets.", + "type": "string" + }, + "CertFile": { + "description": "The client cert file for the targets.", + "type": "string" + }, + "InsecureSkipVerify": { + "description": "Disable target certificate validation.", + "type": "boolean" + }, + "KeyFile": { + "description": "The client key file for the targets.", + "type": "string" + }, + "ServerName": { + "description": "Used to verify the hostname for the targets.", + "type": "string" + } + }, + "x-go-package": "github.com/prometheus/common/config" + }, + "TestRulePayload": { + "type": "object", + "properties": { + "expr": { + "$ref": "#/definitions/LotexQuery" + }, + "grafana_condition": { + "$ref": "#/definitions/EvalAlertConditionCommand" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "TestRuleResponse": { + "type": "object", + "properties": { + "alerts": { + "$ref": "#/definitions/Vector" + }, + "grafana_alert_instances": { + "$ref": "#/definitions/AlertInstancesResponse" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "URL": { + "description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.", + "type": "object", + "title": "A URL represents a parsed URL (technically, a URI reference).", + "properties": { + "ForceQuery": { + "type": "boolean" + }, + "Fragment": { + "type": "string" + }, + "Host": { + "type": "string" + }, + "Opaque": { + "type": "string" + }, + "Path": { + "type": "string" + }, + "RawFragment": { + "type": "string" + }, + "RawPath": { + "type": "string" + }, + "RawQuery": { + "type": "string" + }, + "Scheme": { + "type": "string" + }, + "User": { + "$ref": "#/definitions/Userinfo" + } + }, + "x-go-package": "net/url" + }, + "UpdateDashboardAclCommand": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/DashboardAclUpdateItem" + }, + "x-go-name": "Items" + } + }, + "x-go-package": "github.com/grafana/grafana/pkg/api/dtos" + }, + "UserConfig": { + "type": "object", + "properties": { + "alertmanager_config": { + "$ref": "#/definitions/ApiAlertingConfig" + }, + "template_files": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "TemplateFiles" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/tst" + }, + "Userinfo": { + "description": "The Userinfo type is an immutable encapsulation of username and\npassword details for a URL. An existing Userinfo value is guaranteed\nto have a username set (potentially empty, as allowed by RFC 2396),\nand optionally a password.", + "type": "object", + "x-go-package": "net/url" + }, + "ValidationError": { + "type": "object", + "properties": { + "msg": { + "type": "string", + "x-go-name": "Msg" + } + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Vector": { + "description": "Vector is basically only an alias for model.Samples, but the\ncontract is that in a Vector, all Samples have the same timestamp.", + "type": "array", + "items": { + "$ref": "#/definitions/Sample" + }, + "x-go-package": "github.com/prometheus/prometheus/promql" + }, + "VictorOpsConfig": { + "type": "object", + "title": "VictorOpsConfig configures notifications via VictorOps.", + "properties": { + "api_key": { + "$ref": "#/definitions/Secret" + }, + "api_url": { + "$ref": "#/definitions/URL" + }, + "custom_fields": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "CustomFields" + }, + "entity_display_name": { + "type": "string", + "x-go-name": "EntityDisplayName" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message_type": { + "type": "string", + "x-go-name": "MessageType" + }, + "monitoring_tool": { + "type": "string", + "x-go-name": "MonitoringTool" + }, + "routing_key": { + "type": "string", + "x-go-name": "RoutingKey" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "state_message": { + "type": "string", + "x-go-name": "StateMessage" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "WebhookConfig": { + "type": "object", + "title": "WebhookConfig configures notifications via a generic webhook.", + "properties": { + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "max_alerts": { + "description": "MaxAlerts is the maximum number of alerts to be sent per webhook message.\nAlerts exceeding this threshold will be truncated. Setting this to 0\nallows an unlimited number of alerts.", + "type": "integer", + "format": "uint64", + "x-go-name": "MaxAlerts" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "url": { + "$ref": "#/definitions/URL" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "WechatConfig": { + "type": "object", + "title": "WechatConfig configures notifications via Wechat.", + "properties": { + "agent_id": { + "type": "string", + "x-go-name": "AgentID" + }, + "api_secret": { + "$ref": "#/definitions/Secret" + }, + "api_url": { + "$ref": "#/definitions/URL" + }, + "corp_id": { + "type": "string", + "x-go-name": "CorpID" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "message_type": { + "type": "string", + "x-go-name": "MessageType" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "to_party": { + "type": "string", + "x-go-name": "ToParty" + }, + "to_tag": { + "type": "string", + "x-go-name": "ToTag" + }, + "to_user": { + "type": "string", + "x-go-name": "ToUser" + } + }, + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "alertGroup": { + "description": "AlertGroup alert group", + "type": "object", + "required": [ + "alerts", + "labels", + "receiver" + ], + "properties": { + "alerts": { + "description": "alerts", + "type": "array", + "items": { + "$ref": "#/definitions/gettableAlert" + }, + "x-go-name": "Alerts" + }, + "labels": { + "$ref": "#/definitions/labelSet" + }, + "receiver": { + "$ref": "#/definitions/receiver" + } + }, + "x-go-name": "AlertGroup", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertGroups": { + "description": "AlertGroups alert groups", + "type": "array", + "items": { + "$ref": "#/definitions/alertGroup" + }, + "x-go-name": "AlertGroups", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertResponseBody": { + "description": "in: body", + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/AlertDiscovery" + }, + "error": { + "type": "string", + "x-go-name": "Error" + }, + "errorType": { + "$ref": "#/definitions/ErrorType" + }, + "status": { + "type": "string", + "x-go-name": "Status" + } + }, + "x-go-gen-location": "models" + }, + "alertStatus": { + "description": "AlertStatus alert status", + "type": "object", + "required": [ + "inhibitedBy", + "silencedBy", + "state" + ], + "properties": { + "inhibitedBy": { + "description": "inhibited by", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "InhibitedBy" + }, + "silencedBy": { + "description": "silenced by", + "type": "array", + "items": { + "type": "string" + }, + "x-go-name": "SilencedBy" + }, + "state": { + "description": "state", + "type": "string", + "enum": [ + "[unprocessed active suppressed]" + ], + "x-go-name": "State" + } + }, + "x-go-name": "AlertStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertmanagerConfig": { + "description": "AlertmanagerConfig alertmanager config", + "type": "object", + "required": [ + "original" + ], + "properties": { + "original": { + "description": "original", + "type": "string", + "x-go-name": "Original" + } + }, + "x-go-name": "AlertmanagerConfig", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "clusterStatus": { + "description": "ClusterStatus cluster status", + "type": "object", + "required": [ + "status" + ], + "properties": { + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + }, + "peers": { + "description": "peers", + "type": "array", + "items": { + "$ref": "#/definitions/peerStatus" + }, + "x-go-name": "Peers" + }, + "status": { + "description": "status", + "type": "string", + "enum": [ + "[ready settling disabled]" + ], + "x-go-name": "Status" + } + }, + "x-go-name": "ClusterStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "duration": { + "$ref": "#/definitions/Duration" + }, + "gettableAlert": { + "description": "GettableAlert gettable alert", + "type": "object", + "required": [ + "labels", + "annotations", + "endsAt", + "fingerprint", + "receivers", + "startsAt", + "status", + "updatedAt" + ], + "properties": { + "annotations": { + "$ref": "#/definitions/labelSet" + }, + "endsAt": { + "description": "ends at", + "type": "string", + "format": "date-time", + "x-go-name": "EndsAt" + }, + "fingerprint": { + "description": "fingerprint", + "type": "string", + "x-go-name": "Fingerprint" + }, + "generatorURL": { + "description": "generator URL\nFormat: uri", + "type": "string", + "format": "uri", + "x-go-name": "GeneratorURL" + }, + "labels": { + "$ref": "#/definitions/labelSet" + }, + "receivers": { + "description": "receivers", + "type": "array", + "items": { + "$ref": "#/definitions/receiver" + }, + "x-go-name": "Receivers" + }, + "startsAt": { + "description": "starts at", + "type": "string", + "format": "date-time", + "x-go-name": "StartsAt" + }, + "status": { + "$ref": "#/definitions/alertStatus" + }, + "updatedAt": { + "description": "updated at", + "type": "string", + "format": "date-time", + "x-go-name": "UpdatedAt" + } + }, + "x-go-name": "GettableAlert", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "gettableAlerts": { + "description": "GettableAlerts gettable alerts", + "type": "array", + "items": { + "$ref": "#/definitions/gettableAlert" + }, + "x-go-name": "GettableAlerts", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "gettableSilence": { + "description": "GettableSilence gettable silence", + "type": "object", + "required": [ + "comment", + "createdBy", + "endsAt", + "matchers", + "startsAt", + "id", + "status", + "updatedAt" + ], + "properties": { + "comment": { + "description": "comment", + "type": "string", + "x-go-name": "Comment" + }, + "createdBy": { + "description": "created by", + "type": "string", + "x-go-name": "CreatedBy" + }, + "endsAt": { + "description": "ends at", + "type": "string", + "format": "date-time", + "x-go-name": "EndsAt" + }, + "id": { + "description": "id", + "type": "string", + "x-go-name": "ID" + }, + "matchers": { + "$ref": "#/definitions/matchers" + }, + "startsAt": { + "description": "starts at", + "type": "string", + "format": "date-time", + "x-go-name": "StartsAt" + }, + "status": { + "$ref": "#/definitions/silenceStatus" + }, + "updatedAt": { + "description": "updated at", + "type": "string", + "format": "date-time", + "x-go-name": "UpdatedAt" + } + }, + "x-go-name": "GettableSilence", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "gettableSilences": { + "description": "GettableSilences gettable silences", + "type": "array", + "items": { + "$ref": "#/definitions/gettableSilence" + }, + "x-go-name": "GettableSilences", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "labelSet": { + "description": "LabelSet label set", + "type": "object", + "additionalProperties": { + "type": "string" + }, + "x-go-name": "LabelSet", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "labels": { + "description": "The custom marshaling for labels.Labels ends up doing this anyways.", + "type": "object", + "title": "override the labels type with a map for generation.", + "additionalProperties": { + "type": "string" + }, + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "matcher": { + "description": "Matcher matcher", + "type": "object", + "required": [ + "isRegex", + "name", + "value" + ], + "properties": { + "isRegex": { + "description": "is regex", + "type": "boolean", + "x-go-name": "IsRegex" + }, + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + }, + "value": { + "description": "value", + "type": "string", + "x-go-name": "Value" + } + }, + "x-go-name": "Matcher", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "matchers": { + "description": "Matchers matchers", + "type": "array", + "items": { + "$ref": "#/definitions/matcher" + }, + "x-go-name": "Matchers", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "peerStatus": { + "description": "PeerStatus peer status", + "type": "object", + "required": [ + "address", + "name" + ], + "properties": { + "address": { + "description": "address", + "type": "string", + "x-go-name": "Address" + }, + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-name": "PeerStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "postableAlert": { + "description": "PostableAlert postable alert", + "type": "object", + "required": [ + "labels" + ], + "properties": { + "annotations": { + "$ref": "#/definitions/labelSet" + }, + "endsAt": { + "description": "ends at\nFormat: date-time", + "type": "string", + "format": "date-time", + "x-go-name": "EndsAt" + }, + "generatorURL": { + "description": "generator URL\nFormat: uri", + "type": "string", + "format": "uri", + "x-go-name": "GeneratorURL" + }, + "labels": { + "$ref": "#/definitions/labelSet" + }, + "startsAt": { + "description": "starts at\nFormat: date-time", + "type": "string", + "format": "date-time", + "x-go-name": "StartsAt" + } + }, + "x-go-name": "PostableAlert", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "receiver": { + "description": "Receiver receiver", + "type": "object", + "required": [ + "name" + ], + "properties": { + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + } + }, + "x-go-name": "Receiver", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "ruleResponseBody": { + "description": "in: body", + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/RuleDiscovery" + }, + "error": { + "type": "string", + "x-go-name": "Error" + }, + "errorType": { + "$ref": "#/definitions/ErrorType" + }, + "status": { + "type": "string", + "x-go-name": "Status" + } + }, + "x-go-gen-location": "models" + }, + "silence": { + "description": "Silence silence", + "type": "object", + "required": [ + "comment", + "createdBy", + "endsAt", + "matchers", + "startsAt" + ], + "properties": { + "comment": { + "description": "comment", + "type": "string", + "x-go-name": "Comment" + }, + "createdBy": { + "description": "created by", + "type": "string", + "x-go-name": "CreatedBy" + }, + "endsAt": { + "description": "ends at", + "type": "string", + "format": "date-time", + "x-go-name": "EndsAt" + }, + "matchers": { + "$ref": "#/definitions/matchers" + }, + "startsAt": { + "description": "starts at", + "type": "string", + "format": "date-time", + "x-go-name": "StartsAt" + } + }, + "x-go-name": "Silence", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "silenceStatus": { + "description": "SilenceStatus silence status", + "type": "object", + "required": [ + "state" + ], + "properties": { + "state": { + "description": "state", + "type": "string", + "enum": [ + "[expired active pending]" + ], + "x-go-name": "State" + } + }, + "x-go-name": "SilenceStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "versionInfo": { + "description": "VersionInfo version info", + "type": "object", + "required": [ + "branch", + "buildDate", + "buildUser", + "goVersion", + "revision", + "version" + ], + "properties": { + "branch": { + "description": "branch", + "type": "string", + "x-go-name": "Branch" + }, + "buildDate": { + "description": "build date", + "type": "string", + "x-go-name": "BuildDate" + }, + "buildUser": { + "description": "build user", + "type": "string", + "x-go-name": "BuildUser" + }, + "goVersion": { + "description": "go version", + "type": "string", + "x-go-name": "GoVersion" + }, + "revision": { + "description": "revision", + "type": "string", + "x-go-name": "Revision" + }, + "version": { + "description": "version", + "type": "string", + "x-go-name": "Version" + } + }, + "x-go-name": "VersionInfo", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + } + }, + "securityDefinitions": { + "basic": { + "type": "basic" + } + } +}`)) +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_create_silence.go b/pkg/gen/restapi/operations/alertmanager/route_create_silence.go new file mode 100644 index 00000000000..726f5a2ee3a --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_create_silence.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteCreateSilenceHandlerFunc turns a function with the right signature into a route create silence handler +type RouteCreateSilenceHandlerFunc func(RouteCreateSilenceParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteCreateSilenceHandlerFunc) Handle(params RouteCreateSilenceParams) middleware.Responder { + return fn(params) +} + +// RouteCreateSilenceHandler interface for that can handle valid route create silence params +type RouteCreateSilenceHandler interface { + Handle(RouteCreateSilenceParams) middleware.Responder +} + +// NewRouteCreateSilence creates a new http.Handler for the route create silence operation +func NewRouteCreateSilence(ctx *middleware.Context, handler RouteCreateSilenceHandler) *RouteCreateSilence { + return &RouteCreateSilence{Context: ctx, Handler: handler} +} + +/*RouteCreateSilence swagger:route POST /alertmanager/{DatasourceId}/api/v2/silences alertmanager routeCreateSilence + +create silence + +*/ +type RouteCreateSilence struct { + Context *middleware.Context + Handler RouteCreateSilenceHandler +} + +func (o *RouteCreateSilence) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteCreateSilenceParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_create_silence_parameters.go b/pkg/gen/restapi/operations/alertmanager/route_create_silence_parameters.go new file mode 100644 index 00000000000..9086823c795 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_create_silence_parameters.go @@ -0,0 +1,95 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// NewRouteCreateSilenceParams creates a new RouteCreateSilenceParams object +// no default values defined in spec. +func NewRouteCreateSilenceParams() RouteCreateSilenceParams { + + return RouteCreateSilenceParams{} +} + +// RouteCreateSilenceParams contains all the bound params for the route create silence operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteCreateSilence +type RouteCreateSilenceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: body + */ + Body *models.SilenceBody + /* + Required: true + In: path + */ + DatasourceID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteCreateSilenceParams() beforehand. +func (o *RouteCreateSilenceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.SilenceBody + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("body", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Body = &body + } + } + } + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteCreateSilenceParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_create_silence_responses.go b/pkg/gen/restapi/operations/alertmanager/route_create_silence_responses.go new file mode 100644 index 00000000000..be1586e7d31 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_create_silence_responses.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteCreateSilenceCreatedCode is the HTTP code returned for type RouteCreateSilenceCreated +const RouteCreateSilenceCreatedCode int = 201 + +/*RouteCreateSilenceCreated GettableSilence + +swagger:response routeCreateSilenceCreated +*/ +type RouteCreateSilenceCreated struct { + + /* + In: Body + */ + Payload *models.GettableSilence `json:"body,omitempty"` +} + +// NewRouteCreateSilenceCreated creates RouteCreateSilenceCreated with default headers values +func NewRouteCreateSilenceCreated() *RouteCreateSilenceCreated { + + return &RouteCreateSilenceCreated{} +} + +// WithPayload adds the payload to the route create silence created response +func (o *RouteCreateSilenceCreated) WithPayload(payload *models.GettableSilence) *RouteCreateSilenceCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route create silence created response +func (o *RouteCreateSilenceCreated) SetPayload(payload *models.GettableSilence) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteCreateSilenceCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RouteCreateSilenceBadRequestCode is the HTTP code returned for type RouteCreateSilenceBadRequest +const RouteCreateSilenceBadRequestCode int = 400 + +/*RouteCreateSilenceBadRequest ValidationError + +swagger:response routeCreateSilenceBadRequest +*/ +type RouteCreateSilenceBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRouteCreateSilenceBadRequest creates RouteCreateSilenceBadRequest with default headers values +func NewRouteCreateSilenceBadRequest() *RouteCreateSilenceBadRequest { + + return &RouteCreateSilenceBadRequest{} +} + +// WithPayload adds the payload to the route create silence bad request response +func (o *RouteCreateSilenceBadRequest) WithPayload(payload *models.ValidationError) *RouteCreateSilenceBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route create silence bad request response +func (o *RouteCreateSilenceBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteCreateSilenceBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_create_silence_urlbuilder.go b/pkg/gen/restapi/operations/alertmanager/route_create_silence_urlbuilder.go new file mode 100644 index 00000000000..3c0a818fe1b --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_create_silence_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteCreateSilenceURL generates an URL for the route create silence operation +type RouteCreateSilenceURL struct { + DatasourceID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteCreateSilenceURL) WithBasePath(bp string) *RouteCreateSilenceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteCreateSilenceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteCreateSilenceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/alertmanager/{DatasourceId}/api/v2/silences" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteCreateSilenceURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteCreateSilenceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteCreateSilenceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteCreateSilenceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteCreateSilenceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteCreateSilenceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteCreateSilenceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config.go b/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config.go new file mode 100644 index 00000000000..22ebcaec019 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteDeleteAlertingConfigHandlerFunc turns a function with the right signature into a route delete alerting config handler +type RouteDeleteAlertingConfigHandlerFunc func(RouteDeleteAlertingConfigParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteDeleteAlertingConfigHandlerFunc) Handle(params RouteDeleteAlertingConfigParams) middleware.Responder { + return fn(params) +} + +// RouteDeleteAlertingConfigHandler interface for that can handle valid route delete alerting config params +type RouteDeleteAlertingConfigHandler interface { + Handle(RouteDeleteAlertingConfigParams) middleware.Responder +} + +// NewRouteDeleteAlertingConfig creates a new http.Handler for the route delete alerting config operation +func NewRouteDeleteAlertingConfig(ctx *middleware.Context, handler RouteDeleteAlertingConfigHandler) *RouteDeleteAlertingConfig { + return &RouteDeleteAlertingConfig{Context: ctx, Handler: handler} +} + +/*RouteDeleteAlertingConfig swagger:route DELETE /alertmanager/{DatasourceId}/config/api/v1/alerts alertmanager routeDeleteAlertingConfig + +deletes the Alerting config for a tenant + +*/ +type RouteDeleteAlertingConfig struct { + Context *middleware.Context + Handler RouteDeleteAlertingConfigHandler +} + +func (o *RouteDeleteAlertingConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteDeleteAlertingConfigParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config_parameters.go b/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config_parameters.go new file mode 100644 index 00000000000..c13fc064581 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config_parameters.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteDeleteAlertingConfigParams creates a new RouteDeleteAlertingConfigParams object +// no default values defined in spec. +func NewRouteDeleteAlertingConfigParams() RouteDeleteAlertingConfigParams { + + return RouteDeleteAlertingConfigParams{} +} + +// RouteDeleteAlertingConfigParams contains all the bound params for the route delete alerting config operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteDeleteAlertingConfig +type RouteDeleteAlertingConfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteDeleteAlertingConfigParams() beforehand. +func (o *RouteDeleteAlertingConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteDeleteAlertingConfigParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config_responses.go b/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config_responses.go new file mode 100644 index 00000000000..e1956d1aace --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config_responses.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteDeleteAlertingConfigOKCode is the HTTP code returned for type RouteDeleteAlertingConfigOK +const RouteDeleteAlertingConfigOKCode int = 200 + +/*RouteDeleteAlertingConfigOK Ack + +swagger:response routeDeleteAlertingConfigOK +*/ +type RouteDeleteAlertingConfigOK struct { + + /* + In: Body + */ + Payload models.Ack `json:"body,omitempty"` +} + +// NewRouteDeleteAlertingConfigOK creates RouteDeleteAlertingConfigOK with default headers values +func NewRouteDeleteAlertingConfigOK() *RouteDeleteAlertingConfigOK { + + return &RouteDeleteAlertingConfigOK{} +} + +// WithPayload adds the payload to the route delete alerting config o k response +func (o *RouteDeleteAlertingConfigOK) WithPayload(payload models.Ack) *RouteDeleteAlertingConfigOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route delete alerting config o k response +func (o *RouteDeleteAlertingConfigOK) SetPayload(payload models.Ack) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteDeleteAlertingConfigOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// RouteDeleteAlertingConfigBadRequestCode is the HTTP code returned for type RouteDeleteAlertingConfigBadRequest +const RouteDeleteAlertingConfigBadRequestCode int = 400 + +/*RouteDeleteAlertingConfigBadRequest ValidationError + +swagger:response routeDeleteAlertingConfigBadRequest +*/ +type RouteDeleteAlertingConfigBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRouteDeleteAlertingConfigBadRequest creates RouteDeleteAlertingConfigBadRequest with default headers values +func NewRouteDeleteAlertingConfigBadRequest() *RouteDeleteAlertingConfigBadRequest { + + return &RouteDeleteAlertingConfigBadRequest{} +} + +// WithPayload adds the payload to the route delete alerting config bad request response +func (o *RouteDeleteAlertingConfigBadRequest) WithPayload(payload *models.ValidationError) *RouteDeleteAlertingConfigBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route delete alerting config bad request response +func (o *RouteDeleteAlertingConfigBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteDeleteAlertingConfigBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config_urlbuilder.go b/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config_urlbuilder.go new file mode 100644 index 00000000000..c867ea5e4a9 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_delete_alerting_config_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteDeleteAlertingConfigURL generates an URL for the route delete alerting config operation +type RouteDeleteAlertingConfigURL struct { + DatasourceID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteDeleteAlertingConfigURL) WithBasePath(bp string) *RouteDeleteAlertingConfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteDeleteAlertingConfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteDeleteAlertingConfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/alertmanager/{DatasourceId}/config/api/v1/alerts" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteDeleteAlertingConfigURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteDeleteAlertingConfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteDeleteAlertingConfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteDeleteAlertingConfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteDeleteAlertingConfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteDeleteAlertingConfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteDeleteAlertingConfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_delete_silence.go b/pkg/gen/restapi/operations/alertmanager/route_delete_silence.go new file mode 100644 index 00000000000..dda64f7a087 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_delete_silence.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteDeleteSilenceHandlerFunc turns a function with the right signature into a route delete silence handler +type RouteDeleteSilenceHandlerFunc func(RouteDeleteSilenceParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteDeleteSilenceHandlerFunc) Handle(params RouteDeleteSilenceParams) middleware.Responder { + return fn(params) +} + +// RouteDeleteSilenceHandler interface for that can handle valid route delete silence params +type RouteDeleteSilenceHandler interface { + Handle(RouteDeleteSilenceParams) middleware.Responder +} + +// NewRouteDeleteSilence creates a new http.Handler for the route delete silence operation +func NewRouteDeleteSilence(ctx *middleware.Context, handler RouteDeleteSilenceHandler) *RouteDeleteSilence { + return &RouteDeleteSilence{Context: ctx, Handler: handler} +} + +/*RouteDeleteSilence swagger:route DELETE /alertmanager/{DatasourceId}/api/v2/silence/{SilenceId} alertmanager routeDeleteSilence + +delete silence + +*/ +type RouteDeleteSilence struct { + Context *middleware.Context + Handler RouteDeleteSilenceHandler +} + +func (o *RouteDeleteSilence) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteDeleteSilenceParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_delete_silence_parameters.go b/pkg/gen/restapi/operations/alertmanager/route_delete_silence_parameters.go new file mode 100644 index 00000000000..4016fad8bd6 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_delete_silence_parameters.go @@ -0,0 +1,97 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteDeleteSilenceParams creates a new RouteDeleteSilenceParams object +// no default values defined in spec. +func NewRouteDeleteSilenceParams() RouteDeleteSilenceParams { + + return RouteDeleteSilenceParams{} +} + +// RouteDeleteSilenceParams contains all the bound params for the route delete silence operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteDeleteSilence +type RouteDeleteSilenceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string + /* + Required: true + In: path + */ + SilenceID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteDeleteSilenceParams() beforehand. +func (o *RouteDeleteSilenceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + rSilenceID, rhkSilenceID, _ := route.Params.GetOK("SilenceId") + if err := o.bindSilenceID(rSilenceID, rhkSilenceID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteDeleteSilenceParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} + +// bindSilenceID binds and validates parameter SilenceID from path. +func (o *RouteDeleteSilenceParams) bindSilenceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.SilenceID = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_delete_silence_responses.go b/pkg/gen/restapi/operations/alertmanager/route_delete_silence_responses.go new file mode 100644 index 00000000000..8e5ed5f11f1 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_delete_silence_responses.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteDeleteSilenceOKCode is the HTTP code returned for type RouteDeleteSilenceOK +const RouteDeleteSilenceOKCode int = 200 + +/*RouteDeleteSilenceOK Ack + +swagger:response routeDeleteSilenceOK +*/ +type RouteDeleteSilenceOK struct { + + /* + In: Body + */ + Payload models.Ack `json:"body,omitempty"` +} + +// NewRouteDeleteSilenceOK creates RouteDeleteSilenceOK with default headers values +func NewRouteDeleteSilenceOK() *RouteDeleteSilenceOK { + + return &RouteDeleteSilenceOK{} +} + +// WithPayload adds the payload to the route delete silence o k response +func (o *RouteDeleteSilenceOK) WithPayload(payload models.Ack) *RouteDeleteSilenceOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route delete silence o k response +func (o *RouteDeleteSilenceOK) SetPayload(payload models.Ack) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteDeleteSilenceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// RouteDeleteSilenceBadRequestCode is the HTTP code returned for type RouteDeleteSilenceBadRequest +const RouteDeleteSilenceBadRequestCode int = 400 + +/*RouteDeleteSilenceBadRequest ValidationError + +swagger:response routeDeleteSilenceBadRequest +*/ +type RouteDeleteSilenceBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRouteDeleteSilenceBadRequest creates RouteDeleteSilenceBadRequest with default headers values +func NewRouteDeleteSilenceBadRequest() *RouteDeleteSilenceBadRequest { + + return &RouteDeleteSilenceBadRequest{} +} + +// WithPayload adds the payload to the route delete silence bad request response +func (o *RouteDeleteSilenceBadRequest) WithPayload(payload *models.ValidationError) *RouteDeleteSilenceBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route delete silence bad request response +func (o *RouteDeleteSilenceBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteDeleteSilenceBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_delete_silence_urlbuilder.go b/pkg/gen/restapi/operations/alertmanager/route_delete_silence_urlbuilder.go new file mode 100644 index 00000000000..0b79c2eab73 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_delete_silence_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteDeleteSilenceURL generates an URL for the route delete silence operation +type RouteDeleteSilenceURL struct { + DatasourceID string + SilenceID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteDeleteSilenceURL) WithBasePath(bp string) *RouteDeleteSilenceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteDeleteSilenceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteDeleteSilenceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/alertmanager/{DatasourceId}/api/v2/silence/{SilenceId}" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteDeleteSilenceURL") + } + + silenceID := o.SilenceID + if silenceID != "" { + _path = strings.Replace(_path, "{SilenceId}", silenceID, -1) + } else { + return nil, errors.New("silenceId is required on RouteDeleteSilenceURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteDeleteSilenceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteDeleteSilenceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteDeleteSilenceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteDeleteSilenceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteDeleteSilenceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteDeleteSilenceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config.go b/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config.go new file mode 100644 index 00000000000..92dd166aa77 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteGetAlertingConfigHandlerFunc turns a function with the right signature into a route get alerting config handler +type RouteGetAlertingConfigHandlerFunc func(RouteGetAlertingConfigParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteGetAlertingConfigHandlerFunc) Handle(params RouteGetAlertingConfigParams) middleware.Responder { + return fn(params) +} + +// RouteGetAlertingConfigHandler interface for that can handle valid route get alerting config params +type RouteGetAlertingConfigHandler interface { + Handle(RouteGetAlertingConfigParams) middleware.Responder +} + +// NewRouteGetAlertingConfig creates a new http.Handler for the route get alerting config operation +func NewRouteGetAlertingConfig(ctx *middleware.Context, handler RouteGetAlertingConfigHandler) *RouteGetAlertingConfig { + return &RouteGetAlertingConfig{Context: ctx, Handler: handler} +} + +/*RouteGetAlertingConfig swagger:route GET /alertmanager/{DatasourceId}/config/api/v1/alerts alertmanager routeGetAlertingConfig + +gets an Alerting config + +*/ +type RouteGetAlertingConfig struct { + Context *middleware.Context + Handler RouteGetAlertingConfigHandler +} + +func (o *RouteGetAlertingConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteGetAlertingConfigParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config_parameters.go b/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config_parameters.go new file mode 100644 index 00000000000..4f8883ae781 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config_parameters.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteGetAlertingConfigParams creates a new RouteGetAlertingConfigParams object +// no default values defined in spec. +func NewRouteGetAlertingConfigParams() RouteGetAlertingConfigParams { + + return RouteGetAlertingConfigParams{} +} + +// RouteGetAlertingConfigParams contains all the bound params for the route get alerting config operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteGetAlertingConfig +type RouteGetAlertingConfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteGetAlertingConfigParams() beforehand. +func (o *RouteGetAlertingConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteGetAlertingConfigParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config_responses.go b/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config_responses.go new file mode 100644 index 00000000000..61a89567a64 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config_responses.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteGetAlertingConfigOKCode is the HTTP code returned for type RouteGetAlertingConfigOK +const RouteGetAlertingConfigOKCode int = 200 + +/*RouteGetAlertingConfigOK AlertingConfigResponse + +swagger:response routeGetAlertingConfigOK +*/ +type RouteGetAlertingConfigOK struct { + + /* + In: Body + */ + Payload *models.AlertingConfigResponse `json:"body,omitempty"` +} + +// NewRouteGetAlertingConfigOK creates RouteGetAlertingConfigOK with default headers values +func NewRouteGetAlertingConfigOK() *RouteGetAlertingConfigOK { + + return &RouteGetAlertingConfigOK{} +} + +// WithPayload adds the payload to the route get alerting config o k response +func (o *RouteGetAlertingConfigOK) WithPayload(payload *models.AlertingConfigResponse) *RouteGetAlertingConfigOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get alerting config o k response +func (o *RouteGetAlertingConfigOK) SetPayload(payload *models.AlertingConfigResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetAlertingConfigOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RouteGetAlertingConfigBadRequestCode is the HTTP code returned for type RouteGetAlertingConfigBadRequest +const RouteGetAlertingConfigBadRequestCode int = 400 + +/*RouteGetAlertingConfigBadRequest ValidationError + +swagger:response routeGetAlertingConfigBadRequest +*/ +type RouteGetAlertingConfigBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRouteGetAlertingConfigBadRequest creates RouteGetAlertingConfigBadRequest with default headers values +func NewRouteGetAlertingConfigBadRequest() *RouteGetAlertingConfigBadRequest { + + return &RouteGetAlertingConfigBadRequest{} +} + +// WithPayload adds the payload to the route get alerting config bad request response +func (o *RouteGetAlertingConfigBadRequest) WithPayload(payload *models.ValidationError) *RouteGetAlertingConfigBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get alerting config bad request response +func (o *RouteGetAlertingConfigBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetAlertingConfigBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config_urlbuilder.go b/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config_urlbuilder.go new file mode 100644 index 00000000000..daa6ad2bd70 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_alerting_config_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteGetAlertingConfigURL generates an URL for the route get alerting config operation +type RouteGetAlertingConfigURL struct { + DatasourceID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetAlertingConfigURL) WithBasePath(bp string) *RouteGetAlertingConfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetAlertingConfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteGetAlertingConfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/alertmanager/{DatasourceId}/config/api/v1/alerts" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteGetAlertingConfigURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteGetAlertingConfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteGetAlertingConfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteGetAlertingConfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteGetAlertingConfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteGetAlertingConfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteGetAlertingConfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups.go b/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups.go new file mode 100644 index 00000000000..7a95a5ab1c9 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteGetAmAlertGroupsHandlerFunc turns a function with the right signature into a route get am alert groups handler +type RouteGetAmAlertGroupsHandlerFunc func(RouteGetAmAlertGroupsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteGetAmAlertGroupsHandlerFunc) Handle(params RouteGetAmAlertGroupsParams) middleware.Responder { + return fn(params) +} + +// RouteGetAmAlertGroupsHandler interface for that can handle valid route get am alert groups params +type RouteGetAmAlertGroupsHandler interface { + Handle(RouteGetAmAlertGroupsParams) middleware.Responder +} + +// NewRouteGetAmAlertGroups creates a new http.Handler for the route get am alert groups operation +func NewRouteGetAmAlertGroups(ctx *middleware.Context, handler RouteGetAmAlertGroupsHandler) *RouteGetAmAlertGroups { + return &RouteGetAmAlertGroups{Context: ctx, Handler: handler} +} + +/*RouteGetAmAlertGroups swagger:route GET /alertmanager/{DatasourceId}/api/v2/alerts/groups alertmanager routeGetAmAlertGroups + +get alertmanager alerts + +*/ +type RouteGetAmAlertGroups struct { + Context *middleware.Context + Handler RouteGetAmAlertGroupsHandler +} + +func (o *RouteGetAmAlertGroups) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteGetAmAlertGroupsParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups_parameters.go b/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups_parameters.go new file mode 100644 index 00000000000..e65f8b12653 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups_parameters.go @@ -0,0 +1,243 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewRouteGetAmAlertGroupsParams creates a new RouteGetAmAlertGroupsParams object +// no default values defined in spec. +func NewRouteGetAmAlertGroupsParams() RouteGetAmAlertGroupsParams { + + return RouteGetAmAlertGroupsParams{} +} + +// RouteGetAmAlertGroupsParams contains all the bound params for the route get am alert groups operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteGetAmAlertGroups +type RouteGetAmAlertGroupsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string + /*Show active alerts + In: query + */ + Active *bool + /*Show inhibited alerts + In: query + */ + Inhibited *bool + /*A list of matchers to filter alerts by + In: query + */ + Matchers []string + /*A list of receivers to filter alerts by + In: query + */ + Receivers []string + /*Show silenced alerts + In: query + */ + Silenced *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteGetAmAlertGroupsParams() beforehand. +func (o *RouteGetAmAlertGroupsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + qActive, qhkActive, _ := qs.GetOK("active") + if err := o.bindActive(qActive, qhkActive, route.Formats); err != nil { + res = append(res, err) + } + + qInhibited, qhkInhibited, _ := qs.GetOK("inhibited") + if err := o.bindInhibited(qInhibited, qhkInhibited, route.Formats); err != nil { + res = append(res, err) + } + + qMatchers, qhkMatchers, _ := qs.GetOK("matchers") + if err := o.bindMatchers(qMatchers, qhkMatchers, route.Formats); err != nil { + res = append(res, err) + } + + qReceivers, qhkReceivers, _ := qs.GetOK("receivers") + if err := o.bindReceivers(qReceivers, qhkReceivers, route.Formats); err != nil { + res = append(res, err) + } + + qSilenced, qhkSilenced, _ := qs.GetOK("silenced") + if err := o.bindSilenced(qSilenced, qhkSilenced, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteGetAmAlertGroupsParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} + +// bindActive binds and validates parameter Active from query. +func (o *RouteGetAmAlertGroupsParams) bindActive(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("active", "query", "bool", raw) + } + o.Active = &value + + return nil +} + +// bindInhibited binds and validates parameter Inhibited from query. +func (o *RouteGetAmAlertGroupsParams) bindInhibited(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("inhibited", "query", "bool", raw) + } + o.Inhibited = &value + + return nil +} + +// bindMatchers binds and validates array parameter Matchers from query. +// +// Arrays are parsed according to CollectionFormat: "" (defaults to "csv" when empty). +func (o *RouteGetAmAlertGroupsParams) bindMatchers(rawData []string, hasKey bool, formats strfmt.Registry) error { + + var qvMatchers string + if len(rawData) > 0 { + qvMatchers = rawData[len(rawData)-1] + } + + // CollectionFormat: + matchersIC := swag.SplitByFormat(qvMatchers, "") + if len(matchersIC) == 0 { + return nil + } + + var matchersIR []string + for _, matchersIV := range matchersIC { + matchersI := matchersIV + + matchersIR = append(matchersIR, matchersI) + } + + o.Matchers = matchersIR + + return nil +} + +// bindReceivers binds and validates array parameter Receivers from query. +// +// Arrays are parsed according to CollectionFormat: "" (defaults to "csv" when empty). +func (o *RouteGetAmAlertGroupsParams) bindReceivers(rawData []string, hasKey bool, formats strfmt.Registry) error { + + var qvReceivers string + if len(rawData) > 0 { + qvReceivers = rawData[len(rawData)-1] + } + + // CollectionFormat: + receiversIC := swag.SplitByFormat(qvReceivers, "") + if len(receiversIC) == 0 { + return nil + } + + var receiversIR []string + for _, receiversIV := range receiversIC { + receiversI := receiversIV + + receiversIR = append(receiversIR, receiversI) + } + + o.Receivers = receiversIR + + return nil +} + +// bindSilenced binds and validates parameter Silenced from query. +func (o *RouteGetAmAlertGroupsParams) bindSilenced(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("silenced", "query", "bool", raw) + } + o.Silenced = &value + + return nil +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups_responses.go b/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups_responses.go new file mode 100644 index 00000000000..899c70420b2 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups_responses.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteGetAmAlertGroupsOKCode is the HTTP code returned for type RouteGetAmAlertGroupsOK +const RouteGetAmAlertGroupsOKCode int = 200 + +/*RouteGetAmAlertGroupsOK AlertGroups + +swagger:response routeGetAmAlertGroupsOK +*/ +type RouteGetAmAlertGroupsOK struct { + + /* + In: Body + */ + Payload models.AlertGroups `json:"body,omitempty"` +} + +// NewRouteGetAmAlertGroupsOK creates RouteGetAmAlertGroupsOK with default headers values +func NewRouteGetAmAlertGroupsOK() *RouteGetAmAlertGroupsOK { + + return &RouteGetAmAlertGroupsOK{} +} + +// WithPayload adds the payload to the route get am alert groups o k response +func (o *RouteGetAmAlertGroupsOK) WithPayload(payload models.AlertGroups) *RouteGetAmAlertGroupsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get am alert groups o k response +func (o *RouteGetAmAlertGroupsOK) SetPayload(payload models.AlertGroups) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetAmAlertGroupsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// RouteGetAmAlertGroupsBadRequestCode is the HTTP code returned for type RouteGetAmAlertGroupsBadRequest +const RouteGetAmAlertGroupsBadRequestCode int = 400 + +/*RouteGetAmAlertGroupsBadRequest ValidationError + +swagger:response routeGetAmAlertGroupsBadRequest +*/ +type RouteGetAmAlertGroupsBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRouteGetAmAlertGroupsBadRequest creates RouteGetAmAlertGroupsBadRequest with default headers values +func NewRouteGetAmAlertGroupsBadRequest() *RouteGetAmAlertGroupsBadRequest { + + return &RouteGetAmAlertGroupsBadRequest{} +} + +// WithPayload adds the payload to the route get am alert groups bad request response +func (o *RouteGetAmAlertGroupsBadRequest) WithPayload(payload *models.ValidationError) *RouteGetAmAlertGroupsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get am alert groups bad request response +func (o *RouteGetAmAlertGroupsBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetAmAlertGroupsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups_urlbuilder.go b/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups_urlbuilder.go new file mode 100644 index 00000000000..f7095a72174 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_am_alert_groups_urlbuilder.go @@ -0,0 +1,169 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// RouteGetAmAlertGroupsURL generates an URL for the route get am alert groups operation +type RouteGetAmAlertGroupsURL struct { + DatasourceID string + + Active *bool + Inhibited *bool + Matchers []string + Receivers []string + Silenced *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetAmAlertGroupsURL) WithBasePath(bp string) *RouteGetAmAlertGroupsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetAmAlertGroupsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteGetAmAlertGroupsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/alertmanager/{DatasourceId}/api/v2/alerts/groups" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteGetAmAlertGroupsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var activeQ string + if o.Active != nil { + activeQ = swag.FormatBool(*o.Active) + } + if activeQ != "" { + qs.Set("active", activeQ) + } + + var inhibitedQ string + if o.Inhibited != nil { + inhibitedQ = swag.FormatBool(*o.Inhibited) + } + if inhibitedQ != "" { + qs.Set("inhibited", inhibitedQ) + } + + var matchersIR []string + for _, matchersI := range o.Matchers { + matchersIS := matchersI + if matchersIS != "" { + matchersIR = append(matchersIR, matchersIS) + } + } + + matchers := swag.JoinByFormat(matchersIR, "") + + if len(matchers) > 0 { + qsv := matchers[0] + if qsv != "" { + qs.Set("matchers", qsv) + } + } + + var receiversIR []string + for _, receiversI := range o.Receivers { + receiversIS := receiversI + if receiversIS != "" { + receiversIR = append(receiversIR, receiversIS) + } + } + + receivers := swag.JoinByFormat(receiversIR, "") + + if len(receivers) > 0 { + qsv := receivers[0] + if qsv != "" { + qs.Set("receivers", qsv) + } + } + + var silencedQ string + if o.Silenced != nil { + silencedQ = swag.FormatBool(*o.Silenced) + } + if silencedQ != "" { + qs.Set("silenced", silencedQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteGetAmAlertGroupsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteGetAmAlertGroupsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteGetAmAlertGroupsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteGetAmAlertGroupsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteGetAmAlertGroupsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteGetAmAlertGroupsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts.go b/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts.go new file mode 100644 index 00000000000..bd90ab549a9 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteGetAmAlertsHandlerFunc turns a function with the right signature into a route get am alerts handler +type RouteGetAmAlertsHandlerFunc func(RouteGetAmAlertsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteGetAmAlertsHandlerFunc) Handle(params RouteGetAmAlertsParams) middleware.Responder { + return fn(params) +} + +// RouteGetAmAlertsHandler interface for that can handle valid route get am alerts params +type RouteGetAmAlertsHandler interface { + Handle(RouteGetAmAlertsParams) middleware.Responder +} + +// NewRouteGetAmAlerts creates a new http.Handler for the route get am alerts operation +func NewRouteGetAmAlerts(ctx *middleware.Context, handler RouteGetAmAlertsHandler) *RouteGetAmAlerts { + return &RouteGetAmAlerts{Context: ctx, Handler: handler} +} + +/*RouteGetAmAlerts swagger:route GET /alertmanager/{DatasourceId}/api/v2/alerts alertmanager routeGetAmAlerts + +get alertmanager alerts + +*/ +type RouteGetAmAlerts struct { + Context *middleware.Context + Handler RouteGetAmAlertsHandler +} + +func (o *RouteGetAmAlerts) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteGetAmAlertsParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts_parameters.go b/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts_parameters.go new file mode 100644 index 00000000000..c7031f2080f --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts_parameters.go @@ -0,0 +1,243 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// NewRouteGetAmAlertsParams creates a new RouteGetAmAlertsParams object +// no default values defined in spec. +func NewRouteGetAmAlertsParams() RouteGetAmAlertsParams { + + return RouteGetAmAlertsParams{} +} + +// RouteGetAmAlertsParams contains all the bound params for the route get am alerts operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteGetAmAlerts +type RouteGetAmAlertsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string + /*Show active alerts + In: query + */ + Active *bool + /*Show inhibited alerts + In: query + */ + Inhibited *bool + /*A list of matchers to filter alerts by + In: query + */ + Matchers []string + /*A list of receivers to filter alerts by + In: query + */ + Receivers []string + /*Show silenced alerts + In: query + */ + Silenced *bool +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteGetAmAlertsParams() beforehand. +func (o *RouteGetAmAlertsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + qs := runtime.Values(r.URL.Query()) + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + qActive, qhkActive, _ := qs.GetOK("active") + if err := o.bindActive(qActive, qhkActive, route.Formats); err != nil { + res = append(res, err) + } + + qInhibited, qhkInhibited, _ := qs.GetOK("inhibited") + if err := o.bindInhibited(qInhibited, qhkInhibited, route.Formats); err != nil { + res = append(res, err) + } + + qMatchers, qhkMatchers, _ := qs.GetOK("matchers") + if err := o.bindMatchers(qMatchers, qhkMatchers, route.Formats); err != nil { + res = append(res, err) + } + + qReceivers, qhkReceivers, _ := qs.GetOK("receivers") + if err := o.bindReceivers(qReceivers, qhkReceivers, route.Formats); err != nil { + res = append(res, err) + } + + qSilenced, qhkSilenced, _ := qs.GetOK("silenced") + if err := o.bindSilenced(qSilenced, qhkSilenced, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteGetAmAlertsParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} + +// bindActive binds and validates parameter Active from query. +func (o *RouteGetAmAlertsParams) bindActive(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("active", "query", "bool", raw) + } + o.Active = &value + + return nil +} + +// bindInhibited binds and validates parameter Inhibited from query. +func (o *RouteGetAmAlertsParams) bindInhibited(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("inhibited", "query", "bool", raw) + } + o.Inhibited = &value + + return nil +} + +// bindMatchers binds and validates array parameter Matchers from query. +// +// Arrays are parsed according to CollectionFormat: "" (defaults to "csv" when empty). +func (o *RouteGetAmAlertsParams) bindMatchers(rawData []string, hasKey bool, formats strfmt.Registry) error { + + var qvMatchers string + if len(rawData) > 0 { + qvMatchers = rawData[len(rawData)-1] + } + + // CollectionFormat: + matchersIC := swag.SplitByFormat(qvMatchers, "") + if len(matchersIC) == 0 { + return nil + } + + var matchersIR []string + for _, matchersIV := range matchersIC { + matchersI := matchersIV + + matchersIR = append(matchersIR, matchersI) + } + + o.Matchers = matchersIR + + return nil +} + +// bindReceivers binds and validates array parameter Receivers from query. +// +// Arrays are parsed according to CollectionFormat: "" (defaults to "csv" when empty). +func (o *RouteGetAmAlertsParams) bindReceivers(rawData []string, hasKey bool, formats strfmt.Registry) error { + + var qvReceivers string + if len(rawData) > 0 { + qvReceivers = rawData[len(rawData)-1] + } + + // CollectionFormat: + receiversIC := swag.SplitByFormat(qvReceivers, "") + if len(receiversIC) == 0 { + return nil + } + + var receiversIR []string + for _, receiversIV := range receiversIC { + receiversI := receiversIV + + receiversIR = append(receiversIR, receiversI) + } + + o.Receivers = receiversIR + + return nil +} + +// bindSilenced binds and validates parameter Silenced from query. +func (o *RouteGetAmAlertsParams) bindSilenced(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: false + // AllowEmptyValue: false + if raw == "" { // empty values pass all other validations + return nil + } + + value, err := swag.ConvertBool(raw) + if err != nil { + return errors.InvalidType("silenced", "query", "bool", raw) + } + o.Silenced = &value + + return nil +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts_responses.go b/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts_responses.go new file mode 100644 index 00000000000..74b91ecb96b --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts_responses.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteGetAmAlertsOKCode is the HTTP code returned for type RouteGetAmAlertsOK +const RouteGetAmAlertsOKCode int = 200 + +/*RouteGetAmAlertsOK GettableAlerts + +swagger:response routeGetAmAlertsOK +*/ +type RouteGetAmAlertsOK struct { + + /* + In: Body + */ + Payload models.GettableAlerts `json:"body,omitempty"` +} + +// NewRouteGetAmAlertsOK creates RouteGetAmAlertsOK with default headers values +func NewRouteGetAmAlertsOK() *RouteGetAmAlertsOK { + + return &RouteGetAmAlertsOK{} +} + +// WithPayload adds the payload to the route get am alerts o k response +func (o *RouteGetAmAlertsOK) WithPayload(payload models.GettableAlerts) *RouteGetAmAlertsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get am alerts o k response +func (o *RouteGetAmAlertsOK) SetPayload(payload models.GettableAlerts) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetAmAlertsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// RouteGetAmAlertsBadRequestCode is the HTTP code returned for type RouteGetAmAlertsBadRequest +const RouteGetAmAlertsBadRequestCode int = 400 + +/*RouteGetAmAlertsBadRequest ValidationError + +swagger:response routeGetAmAlertsBadRequest +*/ +type RouteGetAmAlertsBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRouteGetAmAlertsBadRequest creates RouteGetAmAlertsBadRequest with default headers values +func NewRouteGetAmAlertsBadRequest() *RouteGetAmAlertsBadRequest { + + return &RouteGetAmAlertsBadRequest{} +} + +// WithPayload adds the payload to the route get am alerts bad request response +func (o *RouteGetAmAlertsBadRequest) WithPayload(payload *models.ValidationError) *RouteGetAmAlertsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get am alerts bad request response +func (o *RouteGetAmAlertsBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetAmAlertsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts_urlbuilder.go b/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts_urlbuilder.go new file mode 100644 index 00000000000..1fd8fa17d7c --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_am_alerts_urlbuilder.go @@ -0,0 +1,169 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/swag" +) + +// RouteGetAmAlertsURL generates an URL for the route get am alerts operation +type RouteGetAmAlertsURL struct { + DatasourceID string + + Active *bool + Inhibited *bool + Matchers []string + Receivers []string + Silenced *bool + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetAmAlertsURL) WithBasePath(bp string) *RouteGetAmAlertsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetAmAlertsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteGetAmAlertsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/alertmanager/{DatasourceId}/api/v2/alerts" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteGetAmAlertsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + qs := make(url.Values) + + var activeQ string + if o.Active != nil { + activeQ = swag.FormatBool(*o.Active) + } + if activeQ != "" { + qs.Set("active", activeQ) + } + + var inhibitedQ string + if o.Inhibited != nil { + inhibitedQ = swag.FormatBool(*o.Inhibited) + } + if inhibitedQ != "" { + qs.Set("inhibited", inhibitedQ) + } + + var matchersIR []string + for _, matchersI := range o.Matchers { + matchersIS := matchersI + if matchersIS != "" { + matchersIR = append(matchersIR, matchersIS) + } + } + + matchers := swag.JoinByFormat(matchersIR, "") + + if len(matchers) > 0 { + qsv := matchers[0] + if qsv != "" { + qs.Set("matchers", qsv) + } + } + + var receiversIR []string + for _, receiversI := range o.Receivers { + receiversIS := receiversI + if receiversIS != "" { + receiversIR = append(receiversIR, receiversIS) + } + } + + receivers := swag.JoinByFormat(receiversIR, "") + + if len(receivers) > 0 { + qsv := receivers[0] + if qsv != "" { + qs.Set("receivers", qsv) + } + } + + var silencedQ string + if o.Silenced != nil { + silencedQ = swag.FormatBool(*o.Silenced) + } + if silencedQ != "" { + qs.Set("silenced", silencedQ) + } + + _result.RawQuery = qs.Encode() + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteGetAmAlertsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteGetAmAlertsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteGetAmAlertsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteGetAmAlertsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteGetAmAlertsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteGetAmAlertsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_silence.go b/pkg/gen/restapi/operations/alertmanager/route_get_silence.go new file mode 100644 index 00000000000..8edafca97a2 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_silence.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteGetSilenceHandlerFunc turns a function with the right signature into a route get silence handler +type RouteGetSilenceHandlerFunc func(RouteGetSilenceParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteGetSilenceHandlerFunc) Handle(params RouteGetSilenceParams) middleware.Responder { + return fn(params) +} + +// RouteGetSilenceHandler interface for that can handle valid route get silence params +type RouteGetSilenceHandler interface { + Handle(RouteGetSilenceParams) middleware.Responder +} + +// NewRouteGetSilence creates a new http.Handler for the route get silence operation +func NewRouteGetSilence(ctx *middleware.Context, handler RouteGetSilenceHandler) *RouteGetSilence { + return &RouteGetSilence{Context: ctx, Handler: handler} +} + +/*RouteGetSilence swagger:route GET /alertmanager/{DatasourceId}/api/v2/silence/{SilenceId} alertmanager routeGetSilence + +get silence + +*/ +type RouteGetSilence struct { + Context *middleware.Context + Handler RouteGetSilenceHandler +} + +func (o *RouteGetSilence) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteGetSilenceParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_silence_parameters.go b/pkg/gen/restapi/operations/alertmanager/route_get_silence_parameters.go new file mode 100644 index 00000000000..66b8db185fc --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_silence_parameters.go @@ -0,0 +1,97 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteGetSilenceParams creates a new RouteGetSilenceParams object +// no default values defined in spec. +func NewRouteGetSilenceParams() RouteGetSilenceParams { + + return RouteGetSilenceParams{} +} + +// RouteGetSilenceParams contains all the bound params for the route get silence operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteGetSilence +type RouteGetSilenceParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string + /* + Required: true + In: path + */ + SilenceID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteGetSilenceParams() beforehand. +func (o *RouteGetSilenceParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + rSilenceID, rhkSilenceID, _ := route.Params.GetOK("SilenceId") + if err := o.bindSilenceID(rSilenceID, rhkSilenceID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteGetSilenceParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} + +// bindSilenceID binds and validates parameter SilenceID from path. +func (o *RouteGetSilenceParams) bindSilenceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.SilenceID = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_silence_responses.go b/pkg/gen/restapi/operations/alertmanager/route_get_silence_responses.go new file mode 100644 index 00000000000..af80d1c1bcd --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_silence_responses.go @@ -0,0 +1,102 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteGetSilenceOKCode is the HTTP code returned for type RouteGetSilenceOK +const RouteGetSilenceOKCode int = 200 + +/*RouteGetSilenceOK GettableSilence + +swagger:response routeGetSilenceOK +*/ +type RouteGetSilenceOK struct { + + /* + In: Body + */ + Payload *models.GettableSilence `json:"body,omitempty"` +} + +// NewRouteGetSilenceOK creates RouteGetSilenceOK with default headers values +func NewRouteGetSilenceOK() *RouteGetSilenceOK { + + return &RouteGetSilenceOK{} +} + +// WithPayload adds the payload to the route get silence o k response +func (o *RouteGetSilenceOK) WithPayload(payload *models.GettableSilence) *RouteGetSilenceOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get silence o k response +func (o *RouteGetSilenceOK) SetPayload(payload *models.GettableSilence) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetSilenceOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RouteGetSilenceBadRequestCode is the HTTP code returned for type RouteGetSilenceBadRequest +const RouteGetSilenceBadRequestCode int = 400 + +/*RouteGetSilenceBadRequest ValidationError + +swagger:response routeGetSilenceBadRequest +*/ +type RouteGetSilenceBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRouteGetSilenceBadRequest creates RouteGetSilenceBadRequest with default headers values +func NewRouteGetSilenceBadRequest() *RouteGetSilenceBadRequest { + + return &RouteGetSilenceBadRequest{} +} + +// WithPayload adds the payload to the route get silence bad request response +func (o *RouteGetSilenceBadRequest) WithPayload(payload *models.ValidationError) *RouteGetSilenceBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get silence bad request response +func (o *RouteGetSilenceBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetSilenceBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_silence_urlbuilder.go b/pkg/gen/restapi/operations/alertmanager/route_get_silence_urlbuilder.go new file mode 100644 index 00000000000..c958fcd6076 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_silence_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteGetSilenceURL generates an URL for the route get silence operation +type RouteGetSilenceURL struct { + DatasourceID string + SilenceID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetSilenceURL) WithBasePath(bp string) *RouteGetSilenceURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetSilenceURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteGetSilenceURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/alertmanager/{DatasourceId}/api/v2/silence/{SilenceId}" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteGetSilenceURL") + } + + silenceID := o.SilenceID + if silenceID != "" { + _path = strings.Replace(_path, "{SilenceId}", silenceID, -1) + } else { + return nil, errors.New("silenceId is required on RouteGetSilenceURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteGetSilenceURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteGetSilenceURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteGetSilenceURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteGetSilenceURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteGetSilenceURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteGetSilenceURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_silences.go b/pkg/gen/restapi/operations/alertmanager/route_get_silences.go new file mode 100644 index 00000000000..19e218e6335 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_silences.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteGetSilencesHandlerFunc turns a function with the right signature into a route get silences handler +type RouteGetSilencesHandlerFunc func(RouteGetSilencesParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteGetSilencesHandlerFunc) Handle(params RouteGetSilencesParams) middleware.Responder { + return fn(params) +} + +// RouteGetSilencesHandler interface for that can handle valid route get silences params +type RouteGetSilencesHandler interface { + Handle(RouteGetSilencesParams) middleware.Responder +} + +// NewRouteGetSilences creates a new http.Handler for the route get silences operation +func NewRouteGetSilences(ctx *middleware.Context, handler RouteGetSilencesHandler) *RouteGetSilences { + return &RouteGetSilences{Context: ctx, Handler: handler} +} + +/*RouteGetSilences swagger:route GET /alertmanager/{DatasourceId}/api/v2/silences alertmanager routeGetSilences + +get silences + +*/ +type RouteGetSilences struct { + Context *middleware.Context + Handler RouteGetSilencesHandler +} + +func (o *RouteGetSilences) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteGetSilencesParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_silences_parameters.go b/pkg/gen/restapi/operations/alertmanager/route_get_silences_parameters.go new file mode 100644 index 00000000000..a838f3f172a --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_silences_parameters.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteGetSilencesParams creates a new RouteGetSilencesParams object +// no default values defined in spec. +func NewRouteGetSilencesParams() RouteGetSilencesParams { + + return RouteGetSilencesParams{} +} + +// RouteGetSilencesParams contains all the bound params for the route get silences operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteGetSilences +type RouteGetSilencesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteGetSilencesParams() beforehand. +func (o *RouteGetSilencesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteGetSilencesParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_silences_responses.go b/pkg/gen/restapi/operations/alertmanager/route_get_silences_responses.go new file mode 100644 index 00000000000..809d11c98d6 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_silences_responses.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteGetSilencesOKCode is the HTTP code returned for type RouteGetSilencesOK +const RouteGetSilencesOKCode int = 200 + +/*RouteGetSilencesOK GettableSilences + +swagger:response routeGetSilencesOK +*/ +type RouteGetSilencesOK struct { + + /* + In: Body + */ + Payload models.GettableSilences `json:"body,omitempty"` +} + +// NewRouteGetSilencesOK creates RouteGetSilencesOK with default headers values +func NewRouteGetSilencesOK() *RouteGetSilencesOK { + + return &RouteGetSilencesOK{} +} + +// WithPayload adds the payload to the route get silences o k response +func (o *RouteGetSilencesOK) WithPayload(payload models.GettableSilences) *RouteGetSilencesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get silences o k response +func (o *RouteGetSilencesOK) SetPayload(payload models.GettableSilences) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetSilencesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.GettableSilences{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// RouteGetSilencesBadRequestCode is the HTTP code returned for type RouteGetSilencesBadRequest +const RouteGetSilencesBadRequestCode int = 400 + +/*RouteGetSilencesBadRequest ValidationError + +swagger:response routeGetSilencesBadRequest +*/ +type RouteGetSilencesBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRouteGetSilencesBadRequest creates RouteGetSilencesBadRequest with default headers values +func NewRouteGetSilencesBadRequest() *RouteGetSilencesBadRequest { + + return &RouteGetSilencesBadRequest{} +} + +// WithPayload adds the payload to the route get silences bad request response +func (o *RouteGetSilencesBadRequest) WithPayload(payload *models.ValidationError) *RouteGetSilencesBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get silences bad request response +func (o *RouteGetSilencesBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetSilencesBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_get_silences_urlbuilder.go b/pkg/gen/restapi/operations/alertmanager/route_get_silences_urlbuilder.go new file mode 100644 index 00000000000..6cd5e92ca46 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_get_silences_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteGetSilencesURL generates an URL for the route get silences operation +type RouteGetSilencesURL struct { + DatasourceID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetSilencesURL) WithBasePath(bp string) *RouteGetSilencesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetSilencesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteGetSilencesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/alertmanager/{DatasourceId}/api/v2/silences" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteGetSilencesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteGetSilencesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteGetSilencesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteGetSilencesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteGetSilencesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteGetSilencesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteGetSilencesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config.go b/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config.go new file mode 100644 index 00000000000..7e270cdf03e --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RoutePostAlertingConfigHandlerFunc turns a function with the right signature into a route post alerting config handler +type RoutePostAlertingConfigHandlerFunc func(RoutePostAlertingConfigParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RoutePostAlertingConfigHandlerFunc) Handle(params RoutePostAlertingConfigParams) middleware.Responder { + return fn(params) +} + +// RoutePostAlertingConfigHandler interface for that can handle valid route post alerting config params +type RoutePostAlertingConfigHandler interface { + Handle(RoutePostAlertingConfigParams) middleware.Responder +} + +// NewRoutePostAlertingConfig creates a new http.Handler for the route post alerting config operation +func NewRoutePostAlertingConfig(ctx *middleware.Context, handler RoutePostAlertingConfigHandler) *RoutePostAlertingConfig { + return &RoutePostAlertingConfig{Context: ctx, Handler: handler} +} + +/*RoutePostAlertingConfig swagger:route POST /alertmanager/{DatasourceId}/config/api/v1/alerts alertmanager routePostAlertingConfig + +sets an Alerting config + +*/ +type RoutePostAlertingConfig struct { + Context *middleware.Context + Handler RoutePostAlertingConfigHandler +} + +func (o *RoutePostAlertingConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRoutePostAlertingConfigParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config_parameters.go b/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config_parameters.go new file mode 100644 index 00000000000..6e0cf2928fe --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config_parameters.go @@ -0,0 +1,95 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// NewRoutePostAlertingConfigParams creates a new RoutePostAlertingConfigParams object +// no default values defined in spec. +func NewRoutePostAlertingConfigParams() RoutePostAlertingConfigParams { + + return RoutePostAlertingConfigParams{} +} + +// RoutePostAlertingConfigParams contains all the bound params for the route post alerting config operation +// typically these are obtained from a http.Request +// +// swagger:parameters RoutePostAlertingConfig +type RoutePostAlertingConfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: body + */ + Body *models.UserConfig + /* + Required: true + In: path + */ + DatasourceID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRoutePostAlertingConfigParams() beforehand. +func (o *RoutePostAlertingConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.UserConfig + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("body", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Body = &body + } + } + } + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RoutePostAlertingConfigParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config_responses.go b/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config_responses.go new file mode 100644 index 00000000000..f9e8704af90 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config_responses.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RoutePostAlertingConfigCreatedCode is the HTTP code returned for type RoutePostAlertingConfigCreated +const RoutePostAlertingConfigCreatedCode int = 201 + +/*RoutePostAlertingConfigCreated Ack + +swagger:response routePostAlertingConfigCreated +*/ +type RoutePostAlertingConfigCreated struct { + + /* + In: Body + */ + Payload models.Ack `json:"body,omitempty"` +} + +// NewRoutePostAlertingConfigCreated creates RoutePostAlertingConfigCreated with default headers values +func NewRoutePostAlertingConfigCreated() *RoutePostAlertingConfigCreated { + + return &RoutePostAlertingConfigCreated{} +} + +// WithPayload adds the payload to the route post alerting config created response +func (o *RoutePostAlertingConfigCreated) WithPayload(payload models.Ack) *RoutePostAlertingConfigCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route post alerting config created response +func (o *RoutePostAlertingConfigCreated) SetPayload(payload models.Ack) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RoutePostAlertingConfigCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// RoutePostAlertingConfigBadRequestCode is the HTTP code returned for type RoutePostAlertingConfigBadRequest +const RoutePostAlertingConfigBadRequestCode int = 400 + +/*RoutePostAlertingConfigBadRequest ValidationError + +swagger:response routePostAlertingConfigBadRequest +*/ +type RoutePostAlertingConfigBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRoutePostAlertingConfigBadRequest creates RoutePostAlertingConfigBadRequest with default headers values +func NewRoutePostAlertingConfigBadRequest() *RoutePostAlertingConfigBadRequest { + + return &RoutePostAlertingConfigBadRequest{} +} + +// WithPayload adds the payload to the route post alerting config bad request response +func (o *RoutePostAlertingConfigBadRequest) WithPayload(payload *models.ValidationError) *RoutePostAlertingConfigBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route post alerting config bad request response +func (o *RoutePostAlertingConfigBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RoutePostAlertingConfigBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config_urlbuilder.go b/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config_urlbuilder.go new file mode 100644 index 00000000000..b142f539b70 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_post_alerting_config_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RoutePostAlertingConfigURL generates an URL for the route post alerting config operation +type RoutePostAlertingConfigURL struct { + DatasourceID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RoutePostAlertingConfigURL) WithBasePath(bp string) *RoutePostAlertingConfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RoutePostAlertingConfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RoutePostAlertingConfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/alertmanager/{DatasourceId}/config/api/v1/alerts" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RoutePostAlertingConfigURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RoutePostAlertingConfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RoutePostAlertingConfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RoutePostAlertingConfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RoutePostAlertingConfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RoutePostAlertingConfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RoutePostAlertingConfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts.go b/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts.go new file mode 100644 index 00000000000..e16ed2dce75 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RoutePostAmAlertsHandlerFunc turns a function with the right signature into a route post am alerts handler +type RoutePostAmAlertsHandlerFunc func(RoutePostAmAlertsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RoutePostAmAlertsHandlerFunc) Handle(params RoutePostAmAlertsParams) middleware.Responder { + return fn(params) +} + +// RoutePostAmAlertsHandler interface for that can handle valid route post am alerts params +type RoutePostAmAlertsHandler interface { + Handle(RoutePostAmAlertsParams) middleware.Responder +} + +// NewRoutePostAmAlerts creates a new http.Handler for the route post am alerts operation +func NewRoutePostAmAlerts(ctx *middleware.Context, handler RoutePostAmAlertsHandler) *RoutePostAmAlerts { + return &RoutePostAmAlerts{Context: ctx, Handler: handler} +} + +/*RoutePostAmAlerts swagger:route POST /alertmanager/{DatasourceId}/api/v2/alerts alertmanager routePostAmAlerts + +create alertmanager alerts + +*/ +type RoutePostAmAlerts struct { + Context *middleware.Context + Handler RoutePostAmAlertsHandler +} + +func (o *RoutePostAmAlerts) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRoutePostAmAlertsParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts_parameters.go b/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts_parameters.go new file mode 100644 index 00000000000..97bd6421786 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts_parameters.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// NewRoutePostAmAlertsParams creates a new RoutePostAmAlertsParams object +// no default values defined in spec. +func NewRoutePostAmAlertsParams() RoutePostAmAlertsParams { + + return RoutePostAmAlertsParams{} +} + +// RoutePostAmAlertsParams contains all the bound params for the route post am alerts operation +// typically these are obtained from a http.Request +// +// swagger:parameters RoutePostAmAlerts +type RoutePostAmAlertsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string + /* + In: body + */ + PostableAlerts []*models.PostableAlert +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRoutePostAmAlertsParams() beforehand. +func (o *RoutePostAmAlertsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + if runtime.HasBody(r) { + defer r.Body.Close() + var body []*models.PostableAlert + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("postableAlerts", "body", "", err)) + } else { + // validate array of body objects + for i := range body { + if body[i] == nil { + continue + } + if err := body[i].Validate(route.Formats); err != nil { + res = append(res, err) + break + } + } + if len(res) == 0 { + o.PostableAlerts = body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RoutePostAmAlertsParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts_responses.go b/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts_responses.go new file mode 100644 index 00000000000..15e13f164b4 --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts_responses.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RoutePostAmAlertsOKCode is the HTTP code returned for type RoutePostAmAlertsOK +const RoutePostAmAlertsOKCode int = 200 + +/*RoutePostAmAlertsOK Ack + +swagger:response routePostAmAlertsOK +*/ +type RoutePostAmAlertsOK struct { + + /* + In: Body + */ + Payload models.Ack `json:"body,omitempty"` +} + +// NewRoutePostAmAlertsOK creates RoutePostAmAlertsOK with default headers values +func NewRoutePostAmAlertsOK() *RoutePostAmAlertsOK { + + return &RoutePostAmAlertsOK{} +} + +// WithPayload adds the payload to the route post am alerts o k response +func (o *RoutePostAmAlertsOK) WithPayload(payload models.Ack) *RoutePostAmAlertsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route post am alerts o k response +func (o *RoutePostAmAlertsOK) SetPayload(payload models.Ack) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RoutePostAmAlertsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// RoutePostAmAlertsBadRequestCode is the HTTP code returned for type RoutePostAmAlertsBadRequest +const RoutePostAmAlertsBadRequestCode int = 400 + +/*RoutePostAmAlertsBadRequest ValidationError + +swagger:response routePostAmAlertsBadRequest +*/ +type RoutePostAmAlertsBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRoutePostAmAlertsBadRequest creates RoutePostAmAlertsBadRequest with default headers values +func NewRoutePostAmAlertsBadRequest() *RoutePostAmAlertsBadRequest { + + return &RoutePostAmAlertsBadRequest{} +} + +// WithPayload adds the payload to the route post am alerts bad request response +func (o *RoutePostAmAlertsBadRequest) WithPayload(payload *models.ValidationError) *RoutePostAmAlertsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route post am alerts bad request response +func (o *RoutePostAmAlertsBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RoutePostAmAlertsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts_urlbuilder.go b/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts_urlbuilder.go new file mode 100644 index 00000000000..5c66b37bc9b --- /dev/null +++ b/pkg/gen/restapi/operations/alertmanager/route_post_am_alerts_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package alertmanager + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RoutePostAmAlertsURL generates an URL for the route post am alerts operation +type RoutePostAmAlertsURL struct { + DatasourceID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RoutePostAmAlertsURL) WithBasePath(bp string) *RoutePostAmAlertsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RoutePostAmAlertsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RoutePostAmAlertsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/alertmanager/{DatasourceId}/api/v2/alerts" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RoutePostAmAlertsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RoutePostAmAlertsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RoutePostAmAlertsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RoutePostAmAlertsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RoutePostAmAlertsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RoutePostAmAlertsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RoutePostAmAlertsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/documentation_of_the_api_api.go b/pkg/gen/restapi/operations/documentation_of_the_api_api.go new file mode 100644 index 00000000000..abe008a0e0e --- /dev/null +++ b/pkg/gen/restapi/operations/documentation_of_the_api_api.go @@ -0,0 +1,565 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "net/http" + "strings" + + "github.com/go-openapi/errors" + "github.com/go-openapi/loads" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/runtime/security" + "github.com/go-openapi/spec" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + + "github.com/grafana/alerting-api/pkg/gen/restapi/operations/alertmanager" + "github.com/grafana/alerting-api/pkg/gen/restapi/operations/permissions" + "github.com/grafana/alerting-api/pkg/gen/restapi/operations/prometheus" + "github.com/grafana/alerting-api/pkg/gen/restapi/operations/ruler" + "github.com/grafana/alerting-api/pkg/gen/restapi/operations/testing" +) + +// NewDocumentationOfTheAPIAPI creates a new DocumentationOfTheAPI instance +func NewDocumentationOfTheAPIAPI(spec *loads.Document) *DocumentationOfTheAPIAPI { + return &DocumentationOfTheAPIAPI{ + handlers: make(map[string]map[string]http.Handler), + formats: strfmt.Default, + defaultConsumes: "application/json", + defaultProduces: "application/json", + customConsumers: make(map[string]runtime.Consumer), + customProducers: make(map[string]runtime.Producer), + PreServerShutdown: func() {}, + ServerShutdown: func() {}, + spec: spec, + useSwaggerUI: false, + ServeError: errors.ServeError, + BasicAuthenticator: security.BasicAuth, + APIKeyAuthenticator: security.APIKeyAuth, + BearerAuthenticator: security.BearerAuth, + + JSONConsumer: runtime.JSONConsumer(), + YamlConsumer: yamlpc.YAMLConsumer(), + + JSONProducer: runtime.JSONProducer(), + + AlertmanagerRouteCreateSilenceHandler: alertmanager.RouteCreateSilenceHandlerFunc(func(params alertmanager.RouteCreateSilenceParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteCreateSilence has not yet been implemented") + }), + AlertmanagerRouteDeleteAlertingConfigHandler: alertmanager.RouteDeleteAlertingConfigHandlerFunc(func(params alertmanager.RouteDeleteAlertingConfigParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteDeleteAlertingConfig has not yet been implemented") + }), + RulerRouteDeleteNamespaceRulesConfigHandler: ruler.RouteDeleteNamespaceRulesConfigHandlerFunc(func(params ruler.RouteDeleteNamespaceRulesConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RouteDeleteNamespaceRulesConfig has not yet been implemented") + }), + RulerRouteDeleteRuleGroupConfigHandler: ruler.RouteDeleteRuleGroupConfigHandlerFunc(func(params ruler.RouteDeleteRuleGroupConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RouteDeleteRuleGroupConfig has not yet been implemented") + }), + AlertmanagerRouteDeleteSilenceHandler: alertmanager.RouteDeleteSilenceHandlerFunc(func(params alertmanager.RouteDeleteSilenceParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteDeleteSilence has not yet been implemented") + }), + PrometheusRouteGetAlertStatusesHandler: prometheus.RouteGetAlertStatusesHandlerFunc(func(params prometheus.RouteGetAlertStatusesParams) middleware.Responder { + return middleware.NotImplemented("operation prometheus.RouteGetAlertStatuses has not yet been implemented") + }), + AlertmanagerRouteGetAlertingConfigHandler: alertmanager.RouteGetAlertingConfigHandlerFunc(func(params alertmanager.RouteGetAlertingConfigParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteGetAlertingConfig has not yet been implemented") + }), + AlertmanagerRouteGetAmAlertGroupsHandler: alertmanager.RouteGetAmAlertGroupsHandlerFunc(func(params alertmanager.RouteGetAmAlertGroupsParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteGetAmAlertGroups has not yet been implemented") + }), + AlertmanagerRouteGetAmAlertsHandler: alertmanager.RouteGetAmAlertsHandlerFunc(func(params alertmanager.RouteGetAmAlertsParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteGetAmAlerts has not yet been implemented") + }), + PermissionsRouteGetNamespacePermissionsHandler: permissions.RouteGetNamespacePermissionsHandlerFunc(func(params permissions.RouteGetNamespacePermissionsParams) middleware.Responder { + return middleware.NotImplemented("operation permissions.RouteGetNamespacePermissions has not yet been implemented") + }), + RulerRouteGetNamespaceRulesConfigHandler: ruler.RouteGetNamespaceRulesConfigHandlerFunc(func(params ruler.RouteGetNamespaceRulesConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RouteGetNamespaceRulesConfig has not yet been implemented") + }), + PrometheusRouteGetRuleStatusesHandler: prometheus.RouteGetRuleStatusesHandlerFunc(func(params prometheus.RouteGetRuleStatusesParams) middleware.Responder { + return middleware.NotImplemented("operation prometheus.RouteGetRuleStatuses has not yet been implemented") + }), + RulerRouteGetRulegGroupConfigHandler: ruler.RouteGetRulegGroupConfigHandlerFunc(func(params ruler.RouteGetRulegGroupConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RouteGetRulegGroupConfig has not yet been implemented") + }), + RulerRouteGetRulesConfigHandler: ruler.RouteGetRulesConfigHandlerFunc(func(params ruler.RouteGetRulesConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RouteGetRulesConfig has not yet been implemented") + }), + AlertmanagerRouteGetSilenceHandler: alertmanager.RouteGetSilenceHandlerFunc(func(params alertmanager.RouteGetSilenceParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteGetSilence has not yet been implemented") + }), + AlertmanagerRouteGetSilencesHandler: alertmanager.RouteGetSilencesHandlerFunc(func(params alertmanager.RouteGetSilencesParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RouteGetSilences has not yet been implemented") + }), + AlertmanagerRoutePostAlertingConfigHandler: alertmanager.RoutePostAlertingConfigHandlerFunc(func(params alertmanager.RoutePostAlertingConfigParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RoutePostAlertingConfig has not yet been implemented") + }), + AlertmanagerRoutePostAmAlertsHandler: alertmanager.RoutePostAmAlertsHandlerFunc(func(params alertmanager.RoutePostAmAlertsParams) middleware.Responder { + return middleware.NotImplemented("operation alertmanager.RoutePostAmAlerts has not yet been implemented") + }), + RulerRoutePostNameRulesConfigHandler: ruler.RoutePostNameRulesConfigHandlerFunc(func(params ruler.RoutePostNameRulesConfigParams) middleware.Responder { + return middleware.NotImplemented("operation ruler.RoutePostNameRulesConfig has not yet been implemented") + }), + PermissionsRouteSetNamespacePermissionsHandler: permissions.RouteSetNamespacePermissionsHandlerFunc(func(params permissions.RouteSetNamespacePermissionsParams) middleware.Responder { + return middleware.NotImplemented("operation permissions.RouteSetNamespacePermissions has not yet been implemented") + }), + TestingRouteTestReceiverConfigHandler: testing.RouteTestReceiverConfigHandlerFunc(func(params testing.RouteTestReceiverConfigParams) middleware.Responder { + return middleware.NotImplemented("operation testing.RouteTestReceiverConfig has not yet been implemented") + }), + TestingRouteTestRuleConfigHandler: testing.RouteTestRuleConfigHandlerFunc(func(params testing.RouteTestRuleConfigParams) middleware.Responder { + return middleware.NotImplemented("operation testing.RouteTestRuleConfig has not yet been implemented") + }), + } +} + +/*DocumentationOfTheAPIAPI the documentation of the API API */ +type DocumentationOfTheAPIAPI struct { + spec *loads.Document + context *middleware.Context + handlers map[string]map[string]http.Handler + formats strfmt.Registry + customConsumers map[string]runtime.Consumer + customProducers map[string]runtime.Producer + defaultConsumes string + defaultProduces string + Middleware func(middleware.Builder) http.Handler + useSwaggerUI bool + + // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator + // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator + // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function. + // It has a default implementation in the security package, however you can replace it for your particular usage. + BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator + + // JSONConsumer registers a consumer for the following mime types: + // - application/json + JSONConsumer runtime.Consumer + // YamlConsumer registers a consumer for the following mime types: + // - application/yaml + YamlConsumer runtime.Consumer + + // JSONProducer registers a producer for the following mime types: + // - application/json + JSONProducer runtime.Producer + + // AlertmanagerRouteCreateSilenceHandler sets the operation handler for the route create silence operation + AlertmanagerRouteCreateSilenceHandler alertmanager.RouteCreateSilenceHandler + // AlertmanagerRouteDeleteAlertingConfigHandler sets the operation handler for the route delete alerting config operation + AlertmanagerRouteDeleteAlertingConfigHandler alertmanager.RouteDeleteAlertingConfigHandler + // RulerRouteDeleteNamespaceRulesConfigHandler sets the operation handler for the route delete namespace rules config operation + RulerRouteDeleteNamespaceRulesConfigHandler ruler.RouteDeleteNamespaceRulesConfigHandler + // RulerRouteDeleteRuleGroupConfigHandler sets the operation handler for the route delete rule group config operation + RulerRouteDeleteRuleGroupConfigHandler ruler.RouteDeleteRuleGroupConfigHandler + // AlertmanagerRouteDeleteSilenceHandler sets the operation handler for the route delete silence operation + AlertmanagerRouteDeleteSilenceHandler alertmanager.RouteDeleteSilenceHandler + // PrometheusRouteGetAlertStatusesHandler sets the operation handler for the route get alert statuses operation + PrometheusRouteGetAlertStatusesHandler prometheus.RouteGetAlertStatusesHandler + // AlertmanagerRouteGetAlertingConfigHandler sets the operation handler for the route get alerting config operation + AlertmanagerRouteGetAlertingConfigHandler alertmanager.RouteGetAlertingConfigHandler + // AlertmanagerRouteGetAmAlertGroupsHandler sets the operation handler for the route get am alert groups operation + AlertmanagerRouteGetAmAlertGroupsHandler alertmanager.RouteGetAmAlertGroupsHandler + // AlertmanagerRouteGetAmAlertsHandler sets the operation handler for the route get am alerts operation + AlertmanagerRouteGetAmAlertsHandler alertmanager.RouteGetAmAlertsHandler + // PermissionsRouteGetNamespacePermissionsHandler sets the operation handler for the route get namespace permissions operation + PermissionsRouteGetNamespacePermissionsHandler permissions.RouteGetNamespacePermissionsHandler + // RulerRouteGetNamespaceRulesConfigHandler sets the operation handler for the route get namespace rules config operation + RulerRouteGetNamespaceRulesConfigHandler ruler.RouteGetNamespaceRulesConfigHandler + // PrometheusRouteGetRuleStatusesHandler sets the operation handler for the route get rule statuses operation + PrometheusRouteGetRuleStatusesHandler prometheus.RouteGetRuleStatusesHandler + // RulerRouteGetRulegGroupConfigHandler sets the operation handler for the route get ruleg group config operation + RulerRouteGetRulegGroupConfigHandler ruler.RouteGetRulegGroupConfigHandler + // RulerRouteGetRulesConfigHandler sets the operation handler for the route get rules config operation + RulerRouteGetRulesConfigHandler ruler.RouteGetRulesConfigHandler + // AlertmanagerRouteGetSilenceHandler sets the operation handler for the route get silence operation + AlertmanagerRouteGetSilenceHandler alertmanager.RouteGetSilenceHandler + // AlertmanagerRouteGetSilencesHandler sets the operation handler for the route get silences operation + AlertmanagerRouteGetSilencesHandler alertmanager.RouteGetSilencesHandler + // AlertmanagerRoutePostAlertingConfigHandler sets the operation handler for the route post alerting config operation + AlertmanagerRoutePostAlertingConfigHandler alertmanager.RoutePostAlertingConfigHandler + // AlertmanagerRoutePostAmAlertsHandler sets the operation handler for the route post am alerts operation + AlertmanagerRoutePostAmAlertsHandler alertmanager.RoutePostAmAlertsHandler + // RulerRoutePostNameRulesConfigHandler sets the operation handler for the route post name rules config operation + RulerRoutePostNameRulesConfigHandler ruler.RoutePostNameRulesConfigHandler + // PermissionsRouteSetNamespacePermissionsHandler sets the operation handler for the route set namespace permissions operation + PermissionsRouteSetNamespacePermissionsHandler permissions.RouteSetNamespacePermissionsHandler + // TestingRouteTestReceiverConfigHandler sets the operation handler for the route test receiver config operation + TestingRouteTestReceiverConfigHandler testing.RouteTestReceiverConfigHandler + // TestingRouteTestRuleConfigHandler sets the operation handler for the route test rule config operation + TestingRouteTestRuleConfigHandler testing.RouteTestRuleConfigHandler + // ServeError is called when an error is received, there is a default handler + // but you can set your own with this + ServeError func(http.ResponseWriter, *http.Request, error) + + // PreServerShutdown is called before the HTTP(S) server is shutdown + // This allows for custom functions to get executed before the HTTP(S) server stops accepting traffic + PreServerShutdown func() + + // ServerShutdown is called when the HTTP(S) server is shut down and done + // handling all active connections and does not accept connections any more + ServerShutdown func() + + // Custom command line argument groups with their descriptions + CommandLineOptionsGroups []swag.CommandLineOptionsGroup + + // User defined logger function. + Logger func(string, ...interface{}) +} + +// UseRedoc for documentation at /docs +func (o *DocumentationOfTheAPIAPI) UseRedoc() { + o.useSwaggerUI = false +} + +// UseSwaggerUI for documentation at /docs +func (o *DocumentationOfTheAPIAPI) UseSwaggerUI() { + o.useSwaggerUI = true +} + +// SetDefaultProduces sets the default produces media type +func (o *DocumentationOfTheAPIAPI) SetDefaultProduces(mediaType string) { + o.defaultProduces = mediaType +} + +// SetDefaultConsumes returns the default consumes media type +func (o *DocumentationOfTheAPIAPI) SetDefaultConsumes(mediaType string) { + o.defaultConsumes = mediaType +} + +// SetSpec sets a spec that will be served for the clients. +func (o *DocumentationOfTheAPIAPI) SetSpec(spec *loads.Document) { + o.spec = spec +} + +// DefaultProduces returns the default produces media type +func (o *DocumentationOfTheAPIAPI) DefaultProduces() string { + return o.defaultProduces +} + +// DefaultConsumes returns the default consumes media type +func (o *DocumentationOfTheAPIAPI) DefaultConsumes() string { + return o.defaultConsumes +} + +// Formats returns the registered string formats +func (o *DocumentationOfTheAPIAPI) Formats() strfmt.Registry { + return o.formats +} + +// RegisterFormat registers a custom format validator +func (o *DocumentationOfTheAPIAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) { + o.formats.Add(name, format, validator) +} + +// Validate validates the registrations in the DocumentationOfTheAPIAPI +func (o *DocumentationOfTheAPIAPI) Validate() error { + var unregistered []string + + if o.JSONConsumer == nil { + unregistered = append(unregistered, "JSONConsumer") + } + if o.YamlConsumer == nil { + unregistered = append(unregistered, "YamlConsumer") + } + + if o.JSONProducer == nil { + unregistered = append(unregistered, "JSONProducer") + } + + if o.AlertmanagerRouteCreateSilenceHandler == nil { + unregistered = append(unregistered, "alertmanager.RouteCreateSilenceHandler") + } + if o.AlertmanagerRouteDeleteAlertingConfigHandler == nil { + unregistered = append(unregistered, "alertmanager.RouteDeleteAlertingConfigHandler") + } + if o.RulerRouteDeleteNamespaceRulesConfigHandler == nil { + unregistered = append(unregistered, "ruler.RouteDeleteNamespaceRulesConfigHandler") + } + if o.RulerRouteDeleteRuleGroupConfigHandler == nil { + unregistered = append(unregistered, "ruler.RouteDeleteRuleGroupConfigHandler") + } + if o.AlertmanagerRouteDeleteSilenceHandler == nil { + unregistered = append(unregistered, "alertmanager.RouteDeleteSilenceHandler") + } + if o.PrometheusRouteGetAlertStatusesHandler == nil { + unregistered = append(unregistered, "prometheus.RouteGetAlertStatusesHandler") + } + if o.AlertmanagerRouteGetAlertingConfigHandler == nil { + unregistered = append(unregistered, "alertmanager.RouteGetAlertingConfigHandler") + } + if o.AlertmanagerRouteGetAmAlertGroupsHandler == nil { + unregistered = append(unregistered, "alertmanager.RouteGetAmAlertGroupsHandler") + } + if o.AlertmanagerRouteGetAmAlertsHandler == nil { + unregistered = append(unregistered, "alertmanager.RouteGetAmAlertsHandler") + } + if o.PermissionsRouteGetNamespacePermissionsHandler == nil { + unregistered = append(unregistered, "permissions.RouteGetNamespacePermissionsHandler") + } + if o.RulerRouteGetNamespaceRulesConfigHandler == nil { + unregistered = append(unregistered, "ruler.RouteGetNamespaceRulesConfigHandler") + } + if o.PrometheusRouteGetRuleStatusesHandler == nil { + unregistered = append(unregistered, "prometheus.RouteGetRuleStatusesHandler") + } + if o.RulerRouteGetRulegGroupConfigHandler == nil { + unregistered = append(unregistered, "ruler.RouteGetRulegGroupConfigHandler") + } + if o.RulerRouteGetRulesConfigHandler == nil { + unregistered = append(unregistered, "ruler.RouteGetRulesConfigHandler") + } + if o.AlertmanagerRouteGetSilenceHandler == nil { + unregistered = append(unregistered, "alertmanager.RouteGetSilenceHandler") + } + if o.AlertmanagerRouteGetSilencesHandler == nil { + unregistered = append(unregistered, "alertmanager.RouteGetSilencesHandler") + } + if o.AlertmanagerRoutePostAlertingConfigHandler == nil { + unregistered = append(unregistered, "alertmanager.RoutePostAlertingConfigHandler") + } + if o.AlertmanagerRoutePostAmAlertsHandler == nil { + unregistered = append(unregistered, "alertmanager.RoutePostAmAlertsHandler") + } + if o.RulerRoutePostNameRulesConfigHandler == nil { + unregistered = append(unregistered, "ruler.RoutePostNameRulesConfigHandler") + } + if o.PermissionsRouteSetNamespacePermissionsHandler == nil { + unregistered = append(unregistered, "permissions.RouteSetNamespacePermissionsHandler") + } + if o.TestingRouteTestReceiverConfigHandler == nil { + unregistered = append(unregistered, "testing.RouteTestReceiverConfigHandler") + } + if o.TestingRouteTestRuleConfigHandler == nil { + unregistered = append(unregistered, "testing.RouteTestRuleConfigHandler") + } + + if len(unregistered) > 0 { + return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", ")) + } + + return nil +} + +// ServeErrorFor gets a error handler for a given operation id +func (o *DocumentationOfTheAPIAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) { + return o.ServeError +} + +// AuthenticatorsFor gets the authenticators for the specified security schemes +func (o *DocumentationOfTheAPIAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator { + return nil +} + +// Authorizer returns the registered authorizer +func (o *DocumentationOfTheAPIAPI) Authorizer() runtime.Authorizer { + return nil +} + +// ConsumersFor gets the consumers for the specified media types. +// MIME type parameters are ignored here. +func (o *DocumentationOfTheAPIAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer { + result := make(map[string]runtime.Consumer, len(mediaTypes)) + for _, mt := range mediaTypes { + switch mt { + case "application/json": + result["application/json"] = o.JSONConsumer + case "application/yaml": + result["application/yaml"] = o.YamlConsumer + } + + if c, ok := o.customConsumers[mt]; ok { + result[mt] = c + } + } + return result +} + +// ProducersFor gets the producers for the specified media types. +// MIME type parameters are ignored here. +func (o *DocumentationOfTheAPIAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer { + result := make(map[string]runtime.Producer, len(mediaTypes)) + for _, mt := range mediaTypes { + switch mt { + case "application/json": + result["application/json"] = o.JSONProducer + } + + if p, ok := o.customProducers[mt]; ok { + result[mt] = p + } + } + return result +} + +// HandlerFor gets a http.Handler for the provided operation method and path +func (o *DocumentationOfTheAPIAPI) HandlerFor(method, path string) (http.Handler, bool) { + if o.handlers == nil { + return nil, false + } + um := strings.ToUpper(method) + if _, ok := o.handlers[um]; !ok { + return nil, false + } + if path == "/" { + path = "" + } + h, ok := o.handlers[um][path] + return h, ok +} + +// Context returns the middleware context for the documentation of the API API +func (o *DocumentationOfTheAPIAPI) Context() *middleware.Context { + if o.context == nil { + o.context = middleware.NewRoutableContext(o.spec, o, nil) + } + + return o.context +} + +func (o *DocumentationOfTheAPIAPI) initHandlerCache() { + o.Context() // don't care about the result, just that the initialization happened + if o.handlers == nil { + o.handlers = make(map[string]map[string]http.Handler) + } + + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/alertmanager/{DatasourceId}/api/v2/silences"] = alertmanager.NewRouteCreateSilence(o.context, o.AlertmanagerRouteCreateSilenceHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/alertmanager/{DatasourceId}/config/api/v1/alerts"] = alertmanager.NewRouteDeleteAlertingConfig(o.context, o.AlertmanagerRouteDeleteAlertingConfigHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/ruler/{DatasourceId}/api/v1/rules/{Namespace}"] = ruler.NewRouteDeleteNamespaceRulesConfig(o.context, o.RulerRouteDeleteNamespaceRulesConfigHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/ruler/{DatasourceId}/api/v1/rules/{Namespace}/{Groupname}"] = ruler.NewRouteDeleteRuleGroupConfig(o.context, o.RulerRouteDeleteRuleGroupConfigHandler) + if o.handlers["DELETE"] == nil { + o.handlers["DELETE"] = make(map[string]http.Handler) + } + o.handlers["DELETE"]["/alertmanager/{DatasourceId}/api/v2/silence/{SilenceId}"] = alertmanager.NewRouteDeleteSilence(o.context, o.AlertmanagerRouteDeleteSilenceHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/prometheus/{DatasourceId}/api/v1/alerts"] = prometheus.NewRouteGetAlertStatuses(o.context, o.PrometheusRouteGetAlertStatusesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/alertmanager/{DatasourceId}/config/api/v1/alerts"] = alertmanager.NewRouteGetAlertingConfig(o.context, o.AlertmanagerRouteGetAlertingConfigHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/alertmanager/{DatasourceId}/api/v2/alerts/groups"] = alertmanager.NewRouteGetAmAlertGroups(o.context, o.AlertmanagerRouteGetAmAlertGroupsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/alertmanager/{DatasourceId}/api/v2/alerts"] = alertmanager.NewRouteGetAmAlerts(o.context, o.AlertmanagerRouteGetAmAlertsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/api/v1/namespace/{Namespace}/permissions"] = permissions.NewRouteGetNamespacePermissions(o.context, o.PermissionsRouteGetNamespacePermissionsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/ruler/{DatasourceId}/api/v1/rules/{Namespace}"] = ruler.NewRouteGetNamespaceRulesConfig(o.context, o.RulerRouteGetNamespaceRulesConfigHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/prometheus/{DatasourceId}/api/v1/rules"] = prometheus.NewRouteGetRuleStatuses(o.context, o.PrometheusRouteGetRuleStatusesHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/ruler/{DatasourceId}/api/v1/rules/{Namespace}/{Groupname}"] = ruler.NewRouteGetRulegGroupConfig(o.context, o.RulerRouteGetRulegGroupConfigHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/ruler/{DatasourceId}/api/v1/rules"] = ruler.NewRouteGetRulesConfig(o.context, o.RulerRouteGetRulesConfigHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/alertmanager/{DatasourceId}/api/v2/silence/{SilenceId}"] = alertmanager.NewRouteGetSilence(o.context, o.AlertmanagerRouteGetSilenceHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/alertmanager/{DatasourceId}/api/v2/silences"] = alertmanager.NewRouteGetSilences(o.context, o.AlertmanagerRouteGetSilencesHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/alertmanager/{DatasourceId}/config/api/v1/alerts"] = alertmanager.NewRoutePostAlertingConfig(o.context, o.AlertmanagerRoutePostAlertingConfigHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/alertmanager/{DatasourceId}/api/v2/alerts"] = alertmanager.NewRoutePostAmAlerts(o.context, o.AlertmanagerRoutePostAmAlertsHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/ruler/{DatasourceId}/api/v1/rules/{Namespace}"] = ruler.NewRoutePostNameRulesConfig(o.context, o.RulerRoutePostNameRulesConfigHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } + o.handlers["POST"]["/api/v1/namespace/{Namespace}/permissions"] = permissions.NewRouteSetNamespacePermissions(o.context, o.PermissionsRouteSetNamespacePermissionsHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/api/v1/receiver/test"] = testing.NewRouteTestReceiverConfig(o.context, o.TestingRouteTestReceiverConfigHandler) + if o.handlers["GET"] == nil { + o.handlers["GET"] = make(map[string]http.Handler) + } + o.handlers["GET"]["/api/v1/rule/test"] = testing.NewRouteTestRuleConfig(o.context, o.TestingRouteTestRuleConfigHandler) +} + +// Serve creates a http handler to serve the API over HTTP +// can be used directly in http.ListenAndServe(":8000", api.Serve(nil)) +func (o *DocumentationOfTheAPIAPI) Serve(builder middleware.Builder) http.Handler { + o.Init() + + if o.Middleware != nil { + return o.Middleware(builder) + } + if o.useSwaggerUI { + return o.context.APIHandlerSwaggerUI(builder) + } + return o.context.APIHandler(builder) +} + +// Init allows you to just initialize the handler cache, you can then recompose the middleware as you see fit +func (o *DocumentationOfTheAPIAPI) Init() { + if len(o.handlers) == 0 { + o.initHandlerCache() + } +} + +// RegisterConsumer allows you to add (or override) a consumer for a media type. +func (o *DocumentationOfTheAPIAPI) RegisterConsumer(mediaType string, consumer runtime.Consumer) { + o.customConsumers[mediaType] = consumer +} + +// RegisterProducer allows you to add (or override) a producer for a media type. +func (o *DocumentationOfTheAPIAPI) RegisterProducer(mediaType string, producer runtime.Producer) { + o.customProducers[mediaType] = producer +} + +// AddMiddlewareFor adds a http middleware to existing handler +func (o *DocumentationOfTheAPIAPI) AddMiddlewareFor(method, path string, builder middleware.Builder) { + um := strings.ToUpper(method) + if path == "/" { + path = "" + } + o.Init() + if h, ok := o.handlers[um][path]; ok { + o.handlers[method][path] = builder(h) + } +} diff --git a/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions.go b/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions.go new file mode 100644 index 00000000000..a7c555069c0 --- /dev/null +++ b/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package permissions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteGetNamespacePermissionsHandlerFunc turns a function with the right signature into a route get namespace permissions handler +type RouteGetNamespacePermissionsHandlerFunc func(RouteGetNamespacePermissionsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteGetNamespacePermissionsHandlerFunc) Handle(params RouteGetNamespacePermissionsParams) middleware.Responder { + return fn(params) +} + +// RouteGetNamespacePermissionsHandler interface for that can handle valid route get namespace permissions params +type RouteGetNamespacePermissionsHandler interface { + Handle(RouteGetNamespacePermissionsParams) middleware.Responder +} + +// NewRouteGetNamespacePermissions creates a new http.Handler for the route get namespace permissions operation +func NewRouteGetNamespacePermissions(ctx *middleware.Context, handler RouteGetNamespacePermissionsHandler) *RouteGetNamespacePermissions { + return &RouteGetNamespacePermissions{Context: ctx, Handler: handler} +} + +/*RouteGetNamespacePermissions swagger:route GET /api/v1/namespace/{Namespace}/permissions permissions routeGetNamespacePermissions + +sets an Alerting config + +*/ +type RouteGetNamespacePermissions struct { + Context *middleware.Context + Handler RouteGetNamespacePermissionsHandler +} + +func (o *RouteGetNamespacePermissions) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteGetNamespacePermissionsParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions_parameters.go b/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions_parameters.go new file mode 100644 index 00000000000..5951ab2df3b --- /dev/null +++ b/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions_parameters.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package permissions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteGetNamespacePermissionsParams creates a new RouteGetNamespacePermissionsParams object +// no default values defined in spec. +func NewRouteGetNamespacePermissionsParams() RouteGetNamespacePermissionsParams { + + return RouteGetNamespacePermissionsParams{} +} + +// RouteGetNamespacePermissionsParams contains all the bound params for the route get namespace permissions operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteGetNamespacePermissions +type RouteGetNamespacePermissionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*Namespace name + Required: true + In: path + */ + Namespace string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteGetNamespacePermissionsParams() beforehand. +func (o *RouteGetNamespacePermissionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rNamespace, rhkNamespace, _ := route.Params.GetOK("Namespace") + if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindNamespace binds and validates parameter Namespace from path. +func (o *RouteGetNamespacePermissionsParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Namespace = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions_responses.go b/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions_responses.go new file mode 100644 index 00000000000..10c872d214d --- /dev/null +++ b/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions_responses.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package permissions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteGetNamespacePermissionsOKCode is the HTTP code returned for type RouteGetNamespacePermissionsOK +const RouteGetNamespacePermissionsOKCode int = 200 + +/*RouteGetNamespacePermissionsOK Permissions + +swagger:response routeGetNamespacePermissionsOK +*/ +type RouteGetNamespacePermissionsOK struct { + + /* + In: Body + */ + Payload models.Permissions `json:"body,omitempty"` +} + +// NewRouteGetNamespacePermissionsOK creates RouteGetNamespacePermissionsOK with default headers values +func NewRouteGetNamespacePermissionsOK() *RouteGetNamespacePermissionsOK { + + return &RouteGetNamespacePermissionsOK{} +} + +// WithPayload adds the payload to the route get namespace permissions o k response +func (o *RouteGetNamespacePermissionsOK) WithPayload(payload models.Permissions) *RouteGetNamespacePermissionsOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get namespace permissions o k response +func (o *RouteGetNamespacePermissionsOK) SetPayload(payload models.Permissions) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetNamespacePermissionsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if payload == nil { + // return empty array + payload = models.Permissions{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// RouteGetNamespacePermissionsBadRequestCode is the HTTP code returned for type RouteGetNamespacePermissionsBadRequest +const RouteGetNamespacePermissionsBadRequestCode int = 400 + +/*RouteGetNamespacePermissionsBadRequest ValidationError + +swagger:response routeGetNamespacePermissionsBadRequest +*/ +type RouteGetNamespacePermissionsBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRouteGetNamespacePermissionsBadRequest creates RouteGetNamespacePermissionsBadRequest with default headers values +func NewRouteGetNamespacePermissionsBadRequest() *RouteGetNamespacePermissionsBadRequest { + + return &RouteGetNamespacePermissionsBadRequest{} +} + +// WithPayload adds the payload to the route get namespace permissions bad request response +func (o *RouteGetNamespacePermissionsBadRequest) WithPayload(payload *models.ValidationError) *RouteGetNamespacePermissionsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get namespace permissions bad request response +func (o *RouteGetNamespacePermissionsBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetNamespacePermissionsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions_urlbuilder.go b/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions_urlbuilder.go new file mode 100644 index 00000000000..87d072b0102 --- /dev/null +++ b/pkg/gen/restapi/operations/permissions/route_get_namespace_permissions_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package permissions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteGetNamespacePermissionsURL generates an URL for the route get namespace permissions operation +type RouteGetNamespacePermissionsURL struct { + Namespace string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetNamespacePermissionsURL) WithBasePath(bp string) *RouteGetNamespacePermissionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetNamespacePermissionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteGetNamespacePermissionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/api/v1/namespace/{Namespace}/permissions" + + namespace := o.Namespace + if namespace != "" { + _path = strings.Replace(_path, "{Namespace}", namespace, -1) + } else { + return nil, errors.New("namespace is required on RouteGetNamespacePermissionsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteGetNamespacePermissionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteGetNamespacePermissionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteGetNamespacePermissionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteGetNamespacePermissionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteGetNamespacePermissionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteGetNamespacePermissionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions.go b/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions.go new file mode 100644 index 00000000000..854b341be7f --- /dev/null +++ b/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package permissions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteSetNamespacePermissionsHandlerFunc turns a function with the right signature into a route set namespace permissions handler +type RouteSetNamespacePermissionsHandlerFunc func(RouteSetNamespacePermissionsParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteSetNamespacePermissionsHandlerFunc) Handle(params RouteSetNamespacePermissionsParams) middleware.Responder { + return fn(params) +} + +// RouteSetNamespacePermissionsHandler interface for that can handle valid route set namespace permissions params +type RouteSetNamespacePermissionsHandler interface { + Handle(RouteSetNamespacePermissionsParams) middleware.Responder +} + +// NewRouteSetNamespacePermissions creates a new http.Handler for the route set namespace permissions operation +func NewRouteSetNamespacePermissions(ctx *middleware.Context, handler RouteSetNamespacePermissionsHandler) *RouteSetNamespacePermissions { + return &RouteSetNamespacePermissions{Context: ctx, Handler: handler} +} + +/*RouteSetNamespacePermissions swagger:route POST /api/v1/namespace/{Namespace}/permissions permissions routeSetNamespacePermissions + +gets an Alerting config + +*/ +type RouteSetNamespacePermissions struct { + Context *middleware.Context + Handler RouteSetNamespacePermissionsHandler +} + +func (o *RouteSetNamespacePermissions) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteSetNamespacePermissionsParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions_parameters.go b/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions_parameters.go new file mode 100644 index 00000000000..1e342b26137 --- /dev/null +++ b/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions_parameters.go @@ -0,0 +1,95 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package permissions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// NewRouteSetNamespacePermissionsParams creates a new RouteSetNamespacePermissionsParams object +// no default values defined in spec. +func NewRouteSetNamespacePermissionsParams() RouteSetNamespacePermissionsParams { + + return RouteSetNamespacePermissionsParams{} +} + +// RouteSetNamespacePermissionsParams contains all the bound params for the route set namespace permissions operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteSetNamespacePermissions +type RouteSetNamespacePermissionsParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*New namespace permissions + In: body + */ + Body models.Permissions + /*Namespace name to apply perms to + Required: true + In: path + */ + Namespace string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteSetNamespacePermissionsParams() beforehand. +func (o *RouteSetNamespacePermissionsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.Permissions + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("body", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Body = body + } + } + } + rNamespace, rhkNamespace, _ := route.Params.GetOK("Namespace") + if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindNamespace binds and validates parameter Namespace from path. +func (o *RouteSetNamespacePermissionsParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Namespace = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions_responses.go b/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions_responses.go new file mode 100644 index 00000000000..59733210c56 --- /dev/null +++ b/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions_responses.go @@ -0,0 +1,100 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package permissions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteSetNamespacePermissionsCreatedCode is the HTTP code returned for type RouteSetNamespacePermissionsCreated +const RouteSetNamespacePermissionsCreatedCode int = 201 + +/*RouteSetNamespacePermissionsCreated Ack + +swagger:response routeSetNamespacePermissionsCreated +*/ +type RouteSetNamespacePermissionsCreated struct { + + /* + In: Body + */ + Payload models.Ack `json:"body,omitempty"` +} + +// NewRouteSetNamespacePermissionsCreated creates RouteSetNamespacePermissionsCreated with default headers values +func NewRouteSetNamespacePermissionsCreated() *RouteSetNamespacePermissionsCreated { + + return &RouteSetNamespacePermissionsCreated{} +} + +// WithPayload adds the payload to the route set namespace permissions created response +func (o *RouteSetNamespacePermissionsCreated) WithPayload(payload models.Ack) *RouteSetNamespacePermissionsCreated { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route set namespace permissions created response +func (o *RouteSetNamespacePermissionsCreated) SetPayload(payload models.Ack) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteSetNamespacePermissionsCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(201) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} + +// RouteSetNamespacePermissionsBadRequestCode is the HTTP code returned for type RouteSetNamespacePermissionsBadRequest +const RouteSetNamespacePermissionsBadRequestCode int = 400 + +/*RouteSetNamespacePermissionsBadRequest ValidationError + +swagger:response routeSetNamespacePermissionsBadRequest +*/ +type RouteSetNamespacePermissionsBadRequest struct { + + /* + In: Body + */ + Payload *models.ValidationError `json:"body,omitempty"` +} + +// NewRouteSetNamespacePermissionsBadRequest creates RouteSetNamespacePermissionsBadRequest with default headers values +func NewRouteSetNamespacePermissionsBadRequest() *RouteSetNamespacePermissionsBadRequest { + + return &RouteSetNamespacePermissionsBadRequest{} +} + +// WithPayload adds the payload to the route set namespace permissions bad request response +func (o *RouteSetNamespacePermissionsBadRequest) WithPayload(payload *models.ValidationError) *RouteSetNamespacePermissionsBadRequest { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route set namespace permissions bad request response +func (o *RouteSetNamespacePermissionsBadRequest) SetPayload(payload *models.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteSetNamespacePermissionsBadRequest) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(400) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions_urlbuilder.go b/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions_urlbuilder.go new file mode 100644 index 00000000000..f7b98897497 --- /dev/null +++ b/pkg/gen/restapi/operations/permissions/route_set_namespace_permissions_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package permissions + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteSetNamespacePermissionsURL generates an URL for the route set namespace permissions operation +type RouteSetNamespacePermissionsURL struct { + Namespace string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteSetNamespacePermissionsURL) WithBasePath(bp string) *RouteSetNamespacePermissionsURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteSetNamespacePermissionsURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteSetNamespacePermissionsURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/api/v1/namespace/{Namespace}/permissions" + + namespace := o.Namespace + if namespace != "" { + _path = strings.Replace(_path, "{Namespace}", namespace, -1) + } else { + return nil, errors.New("namespace is required on RouteSetNamespacePermissionsURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteSetNamespacePermissionsURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteSetNamespacePermissionsURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteSetNamespacePermissionsURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteSetNamespacePermissionsURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteSetNamespacePermissionsURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteSetNamespacePermissionsURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses.go b/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses.go new file mode 100644 index 00000000000..1bfcb672c67 --- /dev/null +++ b/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package prometheus + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteGetAlertStatusesHandlerFunc turns a function with the right signature into a route get alert statuses handler +type RouteGetAlertStatusesHandlerFunc func(RouteGetAlertStatusesParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteGetAlertStatusesHandlerFunc) Handle(params RouteGetAlertStatusesParams) middleware.Responder { + return fn(params) +} + +// RouteGetAlertStatusesHandler interface for that can handle valid route get alert statuses params +type RouteGetAlertStatusesHandler interface { + Handle(RouteGetAlertStatusesParams) middleware.Responder +} + +// NewRouteGetAlertStatuses creates a new http.Handler for the route get alert statuses operation +func NewRouteGetAlertStatuses(ctx *middleware.Context, handler RouteGetAlertStatusesHandler) *RouteGetAlertStatuses { + return &RouteGetAlertStatuses{Context: ctx, Handler: handler} +} + +/*RouteGetAlertStatuses swagger:route GET /prometheus/{DatasourceId}/api/v1/alerts prometheus routeGetAlertStatuses + +gets the current alerts + +*/ +type RouteGetAlertStatuses struct { + Context *middleware.Context + Handler RouteGetAlertStatusesHandler +} + +func (o *RouteGetAlertStatuses) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteGetAlertStatusesParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses_parameters.go b/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses_parameters.go new file mode 100644 index 00000000000..253a62aceef --- /dev/null +++ b/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses_parameters.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package prometheus + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteGetAlertStatusesParams creates a new RouteGetAlertStatusesParams object +// no default values defined in spec. +func NewRouteGetAlertStatusesParams() RouteGetAlertStatusesParams { + + return RouteGetAlertStatusesParams{} +} + +// RouteGetAlertStatusesParams contains all the bound params for the route get alert statuses operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteGetAlertStatuses +type RouteGetAlertStatusesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteGetAlertStatusesParams() beforehand. +func (o *RouteGetAlertStatusesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteGetAlertStatusesParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses_responses.go b/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses_responses.go new file mode 100644 index 00000000000..cb56a205461 --- /dev/null +++ b/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses_responses.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package prometheus + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteGetAlertStatusesOKCode is the HTTP code returned for type RouteGetAlertStatusesOK +const RouteGetAlertStatusesOKCode int = 200 + +/*RouteGetAlertStatusesOK AlertResponse + +swagger:response routeGetAlertStatusesOK +*/ +type RouteGetAlertStatusesOK struct { + + /* + In: Body + */ + Payload *models.AlertResponse `json:"body,omitempty"` +} + +// NewRouteGetAlertStatusesOK creates RouteGetAlertStatusesOK with default headers values +func NewRouteGetAlertStatusesOK() *RouteGetAlertStatusesOK { + + return &RouteGetAlertStatusesOK{} +} + +// WithPayload adds the payload to the route get alert statuses o k response +func (o *RouteGetAlertStatusesOK) WithPayload(payload *models.AlertResponse) *RouteGetAlertStatusesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get alert statuses o k response +func (o *RouteGetAlertStatusesOK) SetPayload(payload *models.AlertResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetAlertStatusesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses_urlbuilder.go b/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses_urlbuilder.go new file mode 100644 index 00000000000..11988c4c2e1 --- /dev/null +++ b/pkg/gen/restapi/operations/prometheus/route_get_alert_statuses_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package prometheus + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteGetAlertStatusesURL generates an URL for the route get alert statuses operation +type RouteGetAlertStatusesURL struct { + DatasourceID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetAlertStatusesURL) WithBasePath(bp string) *RouteGetAlertStatusesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetAlertStatusesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteGetAlertStatusesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/prometheus/{DatasourceId}/api/v1/alerts" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteGetAlertStatusesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteGetAlertStatusesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteGetAlertStatusesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteGetAlertStatusesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteGetAlertStatusesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteGetAlertStatusesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteGetAlertStatusesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses.go b/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses.go new file mode 100644 index 00000000000..c4cd542da14 --- /dev/null +++ b/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package prometheus + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteGetRuleStatusesHandlerFunc turns a function with the right signature into a route get rule statuses handler +type RouteGetRuleStatusesHandlerFunc func(RouteGetRuleStatusesParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteGetRuleStatusesHandlerFunc) Handle(params RouteGetRuleStatusesParams) middleware.Responder { + return fn(params) +} + +// RouteGetRuleStatusesHandler interface for that can handle valid route get rule statuses params +type RouteGetRuleStatusesHandler interface { + Handle(RouteGetRuleStatusesParams) middleware.Responder +} + +// NewRouteGetRuleStatuses creates a new http.Handler for the route get rule statuses operation +func NewRouteGetRuleStatuses(ctx *middleware.Context, handler RouteGetRuleStatusesHandler) *RouteGetRuleStatuses { + return &RouteGetRuleStatuses{Context: ctx, Handler: handler} +} + +/*RouteGetRuleStatuses swagger:route GET /prometheus/{DatasourceId}/api/v1/rules prometheus routeGetRuleStatuses + +gets the evaluation statuses of all rules + +*/ +type RouteGetRuleStatuses struct { + Context *middleware.Context + Handler RouteGetRuleStatusesHandler +} + +func (o *RouteGetRuleStatuses) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteGetRuleStatusesParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses_parameters.go b/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses_parameters.go new file mode 100644 index 00000000000..7228c5d35d9 --- /dev/null +++ b/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses_parameters.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package prometheus + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteGetRuleStatusesParams creates a new RouteGetRuleStatusesParams object +// no default values defined in spec. +func NewRouteGetRuleStatusesParams() RouteGetRuleStatusesParams { + + return RouteGetRuleStatusesParams{} +} + +// RouteGetRuleStatusesParams contains all the bound params for the route get rule statuses operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteGetRuleStatuses +type RouteGetRuleStatusesParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteGetRuleStatusesParams() beforehand. +func (o *RouteGetRuleStatusesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteGetRuleStatusesParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses_responses.go b/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses_responses.go new file mode 100644 index 00000000000..c4f910f1760 --- /dev/null +++ b/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses_responses.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package prometheus + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteGetRuleStatusesOKCode is the HTTP code returned for type RouteGetRuleStatusesOK +const RouteGetRuleStatusesOKCode int = 200 + +/*RouteGetRuleStatusesOK RuleResponse + +swagger:response routeGetRuleStatusesOK +*/ +type RouteGetRuleStatusesOK struct { + + /* + In: Body + */ + Payload *models.RuleResponse `json:"body,omitempty"` +} + +// NewRouteGetRuleStatusesOK creates RouteGetRuleStatusesOK with default headers values +func NewRouteGetRuleStatusesOK() *RouteGetRuleStatusesOK { + + return &RouteGetRuleStatusesOK{} +} + +// WithPayload adds the payload to the route get rule statuses o k response +func (o *RouteGetRuleStatusesOK) WithPayload(payload *models.RuleResponse) *RouteGetRuleStatusesOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get rule statuses o k response +func (o *RouteGetRuleStatusesOK) SetPayload(payload *models.RuleResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetRuleStatusesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses_urlbuilder.go b/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses_urlbuilder.go new file mode 100644 index 00000000000..9f1b65f8316 --- /dev/null +++ b/pkg/gen/restapi/operations/prometheus/route_get_rule_statuses_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package prometheus + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteGetRuleStatusesURL generates an URL for the route get rule statuses operation +type RouteGetRuleStatusesURL struct { + DatasourceID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetRuleStatusesURL) WithBasePath(bp string) *RouteGetRuleStatusesURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetRuleStatusesURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteGetRuleStatusesURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/prometheus/{DatasourceId}/api/v1/rules" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteGetRuleStatusesURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteGetRuleStatusesURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteGetRuleStatusesURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteGetRuleStatusesURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteGetRuleStatusesURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteGetRuleStatusesURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteGetRuleStatusesURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config.go b/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config.go new file mode 100644 index 00000000000..0f6389fb0f1 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteDeleteNamespaceRulesConfigHandlerFunc turns a function with the right signature into a route delete namespace rules config handler +type RouteDeleteNamespaceRulesConfigHandlerFunc func(RouteDeleteNamespaceRulesConfigParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteDeleteNamespaceRulesConfigHandlerFunc) Handle(params RouteDeleteNamespaceRulesConfigParams) middleware.Responder { + return fn(params) +} + +// RouteDeleteNamespaceRulesConfigHandler interface for that can handle valid route delete namespace rules config params +type RouteDeleteNamespaceRulesConfigHandler interface { + Handle(RouteDeleteNamespaceRulesConfigParams) middleware.Responder +} + +// NewRouteDeleteNamespaceRulesConfig creates a new http.Handler for the route delete namespace rules config operation +func NewRouteDeleteNamespaceRulesConfig(ctx *middleware.Context, handler RouteDeleteNamespaceRulesConfigHandler) *RouteDeleteNamespaceRulesConfig { + return &RouteDeleteNamespaceRulesConfig{Context: ctx, Handler: handler} +} + +/*RouteDeleteNamespaceRulesConfig swagger:route DELETE /ruler/{DatasourceId}/api/v1/rules/{Namespace} ruler routeDeleteNamespaceRulesConfig + +Delete namespace + +*/ +type RouteDeleteNamespaceRulesConfig struct { + Context *middleware.Context + Handler RouteDeleteNamespaceRulesConfigHandler +} + +func (o *RouteDeleteNamespaceRulesConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteDeleteNamespaceRulesConfigParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config_parameters.go b/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config_parameters.go new file mode 100644 index 00000000000..08a3e2302cf --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config_parameters.go @@ -0,0 +1,97 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteDeleteNamespaceRulesConfigParams creates a new RouteDeleteNamespaceRulesConfigParams object +// no default values defined in spec. +func NewRouteDeleteNamespaceRulesConfigParams() RouteDeleteNamespaceRulesConfigParams { + + return RouteDeleteNamespaceRulesConfigParams{} +} + +// RouteDeleteNamespaceRulesConfigParams contains all the bound params for the route delete namespace rules config operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteDeleteNamespaceRulesConfig +type RouteDeleteNamespaceRulesConfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string + /* + Required: true + In: path + */ + Namespace string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteDeleteNamespaceRulesConfigParams() beforehand. +func (o *RouteDeleteNamespaceRulesConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + rNamespace, rhkNamespace, _ := route.Params.GetOK("Namespace") + if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteDeleteNamespaceRulesConfigParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} + +// bindNamespace binds and validates parameter Namespace from path. +func (o *RouteDeleteNamespaceRulesConfigParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Namespace = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config_responses.go b/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config_responses.go new file mode 100644 index 00000000000..eeb58eb7b68 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config_responses.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteDeleteNamespaceRulesConfigAcceptedCode is the HTTP code returned for type RouteDeleteNamespaceRulesConfigAccepted +const RouteDeleteNamespaceRulesConfigAcceptedCode int = 202 + +/*RouteDeleteNamespaceRulesConfigAccepted Ack + +swagger:response routeDeleteNamespaceRulesConfigAccepted +*/ +type RouteDeleteNamespaceRulesConfigAccepted struct { + + /* + In: Body + */ + Payload models.Ack `json:"body,omitempty"` +} + +// NewRouteDeleteNamespaceRulesConfigAccepted creates RouteDeleteNamespaceRulesConfigAccepted with default headers values +func NewRouteDeleteNamespaceRulesConfigAccepted() *RouteDeleteNamespaceRulesConfigAccepted { + + return &RouteDeleteNamespaceRulesConfigAccepted{} +} + +// WithPayload adds the payload to the route delete namespace rules config accepted response +func (o *RouteDeleteNamespaceRulesConfigAccepted) WithPayload(payload models.Ack) *RouteDeleteNamespaceRulesConfigAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route delete namespace rules config accepted response +func (o *RouteDeleteNamespaceRulesConfigAccepted) SetPayload(payload models.Ack) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteDeleteNamespaceRulesConfigAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(202) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} diff --git a/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config_urlbuilder.go b/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config_urlbuilder.go new file mode 100644 index 00000000000..76d2f65f65b --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_delete_namespace_rules_config_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteDeleteNamespaceRulesConfigURL generates an URL for the route delete namespace rules config operation +type RouteDeleteNamespaceRulesConfigURL struct { + DatasourceID string + Namespace string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteDeleteNamespaceRulesConfigURL) WithBasePath(bp string) *RouteDeleteNamespaceRulesConfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteDeleteNamespaceRulesConfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteDeleteNamespaceRulesConfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/ruler/{DatasourceId}/api/v1/rules/{Namespace}" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteDeleteNamespaceRulesConfigURL") + } + + namespace := o.Namespace + if namespace != "" { + _path = strings.Replace(_path, "{Namespace}", namespace, -1) + } else { + return nil, errors.New("namespace is required on RouteDeleteNamespaceRulesConfigURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteDeleteNamespaceRulesConfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteDeleteNamespaceRulesConfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteDeleteNamespaceRulesConfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteDeleteNamespaceRulesConfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteDeleteNamespaceRulesConfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteDeleteNamespaceRulesConfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config.go b/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config.go new file mode 100644 index 00000000000..43fc3e5a32e --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteDeleteRuleGroupConfigHandlerFunc turns a function with the right signature into a route delete rule group config handler +type RouteDeleteRuleGroupConfigHandlerFunc func(RouteDeleteRuleGroupConfigParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteDeleteRuleGroupConfigHandlerFunc) Handle(params RouteDeleteRuleGroupConfigParams) middleware.Responder { + return fn(params) +} + +// RouteDeleteRuleGroupConfigHandler interface for that can handle valid route delete rule group config params +type RouteDeleteRuleGroupConfigHandler interface { + Handle(RouteDeleteRuleGroupConfigParams) middleware.Responder +} + +// NewRouteDeleteRuleGroupConfig creates a new http.Handler for the route delete rule group config operation +func NewRouteDeleteRuleGroupConfig(ctx *middleware.Context, handler RouteDeleteRuleGroupConfigHandler) *RouteDeleteRuleGroupConfig { + return &RouteDeleteRuleGroupConfig{Context: ctx, Handler: handler} +} + +/*RouteDeleteRuleGroupConfig swagger:route DELETE /ruler/{DatasourceId}/api/v1/rules/{Namespace}/{Groupname} ruler routeDeleteRuleGroupConfig + +Delete rule group + +*/ +type RouteDeleteRuleGroupConfig struct { + Context *middleware.Context + Handler RouteDeleteRuleGroupConfigHandler +} + +func (o *RouteDeleteRuleGroupConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteDeleteRuleGroupConfigParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config_parameters.go b/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config_parameters.go new file mode 100644 index 00000000000..5a6ed564f52 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config_parameters.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteDeleteRuleGroupConfigParams creates a new RouteDeleteRuleGroupConfigParams object +// no default values defined in spec. +func NewRouteDeleteRuleGroupConfigParams() RouteDeleteRuleGroupConfigParams { + + return RouteDeleteRuleGroupConfigParams{} +} + +// RouteDeleteRuleGroupConfigParams contains all the bound params for the route delete rule group config operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteDeleteRuleGroupConfig +type RouteDeleteRuleGroupConfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string + /* + Required: true + In: path + */ + Groupname string + /* + Required: true + In: path + */ + Namespace string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteDeleteRuleGroupConfigParams() beforehand. +func (o *RouteDeleteRuleGroupConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + rGroupname, rhkGroupname, _ := route.Params.GetOK("Groupname") + if err := o.bindGroupname(rGroupname, rhkGroupname, route.Formats); err != nil { + res = append(res, err) + } + + rNamespace, rhkNamespace, _ := route.Params.GetOK("Namespace") + if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteDeleteRuleGroupConfigParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} + +// bindGroupname binds and validates parameter Groupname from path. +func (o *RouteDeleteRuleGroupConfigParams) bindGroupname(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Groupname = raw + + return nil +} + +// bindNamespace binds and validates parameter Namespace from path. +func (o *RouteDeleteRuleGroupConfigParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Namespace = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config_responses.go b/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config_responses.go new file mode 100644 index 00000000000..305d72e13ba --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config_responses.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteDeleteRuleGroupConfigAcceptedCode is the HTTP code returned for type RouteDeleteRuleGroupConfigAccepted +const RouteDeleteRuleGroupConfigAcceptedCode int = 202 + +/*RouteDeleteRuleGroupConfigAccepted Ack + +swagger:response routeDeleteRuleGroupConfigAccepted +*/ +type RouteDeleteRuleGroupConfigAccepted struct { + + /* + In: Body + */ + Payload models.Ack `json:"body,omitempty"` +} + +// NewRouteDeleteRuleGroupConfigAccepted creates RouteDeleteRuleGroupConfigAccepted with default headers values +func NewRouteDeleteRuleGroupConfigAccepted() *RouteDeleteRuleGroupConfigAccepted { + + return &RouteDeleteRuleGroupConfigAccepted{} +} + +// WithPayload adds the payload to the route delete rule group config accepted response +func (o *RouteDeleteRuleGroupConfigAccepted) WithPayload(payload models.Ack) *RouteDeleteRuleGroupConfigAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route delete rule group config accepted response +func (o *RouteDeleteRuleGroupConfigAccepted) SetPayload(payload models.Ack) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteDeleteRuleGroupConfigAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(202) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} diff --git a/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config_urlbuilder.go b/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config_urlbuilder.go new file mode 100644 index 00000000000..7a95dc1923f --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_delete_rule_group_config_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteDeleteRuleGroupConfigURL generates an URL for the route delete rule group config operation +type RouteDeleteRuleGroupConfigURL struct { + DatasourceID string + Groupname string + Namespace string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteDeleteRuleGroupConfigURL) WithBasePath(bp string) *RouteDeleteRuleGroupConfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteDeleteRuleGroupConfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteDeleteRuleGroupConfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/ruler/{DatasourceId}/api/v1/rules/{Namespace}/{Groupname}" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteDeleteRuleGroupConfigURL") + } + + groupname := o.Groupname + if groupname != "" { + _path = strings.Replace(_path, "{Groupname}", groupname, -1) + } else { + return nil, errors.New("groupname is required on RouteDeleteRuleGroupConfigURL") + } + + namespace := o.Namespace + if namespace != "" { + _path = strings.Replace(_path, "{Namespace}", namespace, -1) + } else { + return nil, errors.New("namespace is required on RouteDeleteRuleGroupConfigURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteDeleteRuleGroupConfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteDeleteRuleGroupConfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteDeleteRuleGroupConfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteDeleteRuleGroupConfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteDeleteRuleGroupConfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteDeleteRuleGroupConfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config.go b/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config.go new file mode 100644 index 00000000000..0634097ed8b --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteGetNamespaceRulesConfigHandlerFunc turns a function with the right signature into a route get namespace rules config handler +type RouteGetNamespaceRulesConfigHandlerFunc func(RouteGetNamespaceRulesConfigParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteGetNamespaceRulesConfigHandlerFunc) Handle(params RouteGetNamespaceRulesConfigParams) middleware.Responder { + return fn(params) +} + +// RouteGetNamespaceRulesConfigHandler interface for that can handle valid route get namespace rules config params +type RouteGetNamespaceRulesConfigHandler interface { + Handle(RouteGetNamespaceRulesConfigParams) middleware.Responder +} + +// NewRouteGetNamespaceRulesConfig creates a new http.Handler for the route get namespace rules config operation +func NewRouteGetNamespaceRulesConfig(ctx *middleware.Context, handler RouteGetNamespaceRulesConfigHandler) *RouteGetNamespaceRulesConfig { + return &RouteGetNamespaceRulesConfig{Context: ctx, Handler: handler} +} + +/*RouteGetNamespaceRulesConfig swagger:route GET /ruler/{DatasourceId}/api/v1/rules/{Namespace} ruler routeGetNamespaceRulesConfig + +Get rule groups by namespace + +*/ +type RouteGetNamespaceRulesConfig struct { + Context *middleware.Context + Handler RouteGetNamespaceRulesConfigHandler +} + +func (o *RouteGetNamespaceRulesConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteGetNamespaceRulesConfigParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config_parameters.go b/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config_parameters.go new file mode 100644 index 00000000000..41f4b8385a0 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config_parameters.go @@ -0,0 +1,97 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteGetNamespaceRulesConfigParams creates a new RouteGetNamespaceRulesConfigParams object +// no default values defined in spec. +func NewRouteGetNamespaceRulesConfigParams() RouteGetNamespaceRulesConfigParams { + + return RouteGetNamespaceRulesConfigParams{} +} + +// RouteGetNamespaceRulesConfigParams contains all the bound params for the route get namespace rules config operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteGetNamespaceRulesConfig +type RouteGetNamespaceRulesConfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string + /* + Required: true + In: path + */ + Namespace string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteGetNamespaceRulesConfigParams() beforehand. +func (o *RouteGetNamespaceRulesConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + rNamespace, rhkNamespace, _ := route.Params.GetOK("Namespace") + if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteGetNamespaceRulesConfigParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} + +// bindNamespace binds and validates parameter Namespace from path. +func (o *RouteGetNamespaceRulesConfigParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Namespace = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config_responses.go b/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config_responses.go new file mode 100644 index 00000000000..a90f508a6f1 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config_responses.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteGetNamespaceRulesConfigAcceptedCode is the HTTP code returned for type RouteGetNamespaceRulesConfigAccepted +const RouteGetNamespaceRulesConfigAcceptedCode int = 202 + +/*RouteGetNamespaceRulesConfigAccepted NamespaceConfigResponse + +swagger:response routeGetNamespaceRulesConfigAccepted +*/ +type RouteGetNamespaceRulesConfigAccepted struct { + + /* + In: Body + */ + Payload models.NamespaceConfigResponse `json:"body,omitempty"` +} + +// NewRouteGetNamespaceRulesConfigAccepted creates RouteGetNamespaceRulesConfigAccepted with default headers values +func NewRouteGetNamespaceRulesConfigAccepted() *RouteGetNamespaceRulesConfigAccepted { + + return &RouteGetNamespaceRulesConfigAccepted{} +} + +// WithPayload adds the payload to the route get namespace rules config accepted response +func (o *RouteGetNamespaceRulesConfigAccepted) WithPayload(payload models.NamespaceConfigResponse) *RouteGetNamespaceRulesConfigAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get namespace rules config accepted response +func (o *RouteGetNamespaceRulesConfigAccepted) SetPayload(payload models.NamespaceConfigResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetNamespaceRulesConfigAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty map + payload = models.NamespaceConfigResponse{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config_urlbuilder.go b/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config_urlbuilder.go new file mode 100644 index 00000000000..4732409be46 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_namespace_rules_config_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteGetNamespaceRulesConfigURL generates an URL for the route get namespace rules config operation +type RouteGetNamespaceRulesConfigURL struct { + DatasourceID string + Namespace string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetNamespaceRulesConfigURL) WithBasePath(bp string) *RouteGetNamespaceRulesConfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetNamespaceRulesConfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteGetNamespaceRulesConfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/ruler/{DatasourceId}/api/v1/rules/{Namespace}" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteGetNamespaceRulesConfigURL") + } + + namespace := o.Namespace + if namespace != "" { + _path = strings.Replace(_path, "{Namespace}", namespace, -1) + } else { + return nil, errors.New("namespace is required on RouteGetNamespaceRulesConfigURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteGetNamespaceRulesConfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteGetNamespaceRulesConfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteGetNamespaceRulesConfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteGetNamespaceRulesConfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteGetNamespaceRulesConfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteGetNamespaceRulesConfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config.go b/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config.go new file mode 100644 index 00000000000..31801e59ae0 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteGetRulegGroupConfigHandlerFunc turns a function with the right signature into a route get ruleg group config handler +type RouteGetRulegGroupConfigHandlerFunc func(RouteGetRulegGroupConfigParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteGetRulegGroupConfigHandlerFunc) Handle(params RouteGetRulegGroupConfigParams) middleware.Responder { + return fn(params) +} + +// RouteGetRulegGroupConfigHandler interface for that can handle valid route get ruleg group config params +type RouteGetRulegGroupConfigHandler interface { + Handle(RouteGetRulegGroupConfigParams) middleware.Responder +} + +// NewRouteGetRulegGroupConfig creates a new http.Handler for the route get ruleg group config operation +func NewRouteGetRulegGroupConfig(ctx *middleware.Context, handler RouteGetRulegGroupConfigHandler) *RouteGetRulegGroupConfig { + return &RouteGetRulegGroupConfig{Context: ctx, Handler: handler} +} + +/*RouteGetRulegGroupConfig swagger:route GET /ruler/{DatasourceId}/api/v1/rules/{Namespace}/{Groupname} ruler routeGetRulegGroupConfig + +Get rule group + +*/ +type RouteGetRulegGroupConfig struct { + Context *middleware.Context + Handler RouteGetRulegGroupConfigHandler +} + +func (o *RouteGetRulegGroupConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteGetRulegGroupConfigParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config_parameters.go b/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config_parameters.go new file mode 100644 index 00000000000..f022c2ab03b --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config_parameters.go @@ -0,0 +1,122 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteGetRulegGroupConfigParams creates a new RouteGetRulegGroupConfigParams object +// no default values defined in spec. +func NewRouteGetRulegGroupConfigParams() RouteGetRulegGroupConfigParams { + + return RouteGetRulegGroupConfigParams{} +} + +// RouteGetRulegGroupConfigParams contains all the bound params for the route get ruleg group config operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteGetRulegGroupConfig +type RouteGetRulegGroupConfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string + /* + Required: true + In: path + */ + Groupname string + /* + Required: true + In: path + */ + Namespace string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteGetRulegGroupConfigParams() beforehand. +func (o *RouteGetRulegGroupConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + rGroupname, rhkGroupname, _ := route.Params.GetOK("Groupname") + if err := o.bindGroupname(rGroupname, rhkGroupname, route.Formats); err != nil { + res = append(res, err) + } + + rNamespace, rhkNamespace, _ := route.Params.GetOK("Namespace") + if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteGetRulegGroupConfigParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} + +// bindGroupname binds and validates parameter Groupname from path. +func (o *RouteGetRulegGroupConfigParams) bindGroupname(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Groupname = raw + + return nil +} + +// bindNamespace binds and validates parameter Namespace from path. +func (o *RouteGetRulegGroupConfigParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Namespace = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config_responses.go b/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config_responses.go new file mode 100644 index 00000000000..5b0bfc1db90 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config_responses.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteGetRulegGroupConfigAcceptedCode is the HTTP code returned for type RouteGetRulegGroupConfigAccepted +const RouteGetRulegGroupConfigAcceptedCode int = 202 + +/*RouteGetRulegGroupConfigAccepted RuleGroupConfigResponse + +swagger:response routeGetRulegGroupConfigAccepted +*/ +type RouteGetRulegGroupConfigAccepted struct { + + /* + In: Body + */ + Payload *models.RuleGroupConfigResponse `json:"body,omitempty"` +} + +// NewRouteGetRulegGroupConfigAccepted creates RouteGetRulegGroupConfigAccepted with default headers values +func NewRouteGetRulegGroupConfigAccepted() *RouteGetRulegGroupConfigAccepted { + + return &RouteGetRulegGroupConfigAccepted{} +} + +// WithPayload adds the payload to the route get ruleg group config accepted response +func (o *RouteGetRulegGroupConfigAccepted) WithPayload(payload *models.RuleGroupConfigResponse) *RouteGetRulegGroupConfigAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get ruleg group config accepted response +func (o *RouteGetRulegGroupConfigAccepted) SetPayload(payload *models.RuleGroupConfigResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetRulegGroupConfigAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(202) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config_urlbuilder.go b/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config_urlbuilder.go new file mode 100644 index 00000000000..557942f45f9 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_ruleg_group_config_urlbuilder.go @@ -0,0 +1,115 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteGetRulegGroupConfigURL generates an URL for the route get ruleg group config operation +type RouteGetRulegGroupConfigURL struct { + DatasourceID string + Groupname string + Namespace string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetRulegGroupConfigURL) WithBasePath(bp string) *RouteGetRulegGroupConfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetRulegGroupConfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteGetRulegGroupConfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/ruler/{DatasourceId}/api/v1/rules/{Namespace}/{Groupname}" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteGetRulegGroupConfigURL") + } + + groupname := o.Groupname + if groupname != "" { + _path = strings.Replace(_path, "{Groupname}", groupname, -1) + } else { + return nil, errors.New("groupname is required on RouteGetRulegGroupConfigURL") + } + + namespace := o.Namespace + if namespace != "" { + _path = strings.Replace(_path, "{Namespace}", namespace, -1) + } else { + return nil, errors.New("namespace is required on RouteGetRulegGroupConfigURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteGetRulegGroupConfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteGetRulegGroupConfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteGetRulegGroupConfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteGetRulegGroupConfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteGetRulegGroupConfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteGetRulegGroupConfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_rules_config.go b/pkg/gen/restapi/operations/ruler/route_get_rules_config.go new file mode 100644 index 00000000000..810965b26b5 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_rules_config.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteGetRulesConfigHandlerFunc turns a function with the right signature into a route get rules config handler +type RouteGetRulesConfigHandlerFunc func(RouteGetRulesConfigParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteGetRulesConfigHandlerFunc) Handle(params RouteGetRulesConfigParams) middleware.Responder { + return fn(params) +} + +// RouteGetRulesConfigHandler interface for that can handle valid route get rules config params +type RouteGetRulesConfigHandler interface { + Handle(RouteGetRulesConfigParams) middleware.Responder +} + +// NewRouteGetRulesConfig creates a new http.Handler for the route get rules config operation +func NewRouteGetRulesConfig(ctx *middleware.Context, handler RouteGetRulesConfigHandler) *RouteGetRulesConfig { + return &RouteGetRulesConfig{Context: ctx, Handler: handler} +} + +/*RouteGetRulesConfig swagger:route GET /ruler/{DatasourceId}/api/v1/rules ruler routeGetRulesConfig + +List rule groups + +*/ +type RouteGetRulesConfig struct { + Context *middleware.Context + Handler RouteGetRulesConfigHandler +} + +func (o *RouteGetRulesConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteGetRulesConfigParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_rules_config_parameters.go b/pkg/gen/restapi/operations/ruler/route_get_rules_config_parameters.go new file mode 100644 index 00000000000..e49affb35fa --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_rules_config_parameters.go @@ -0,0 +1,72 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" +) + +// NewRouteGetRulesConfigParams creates a new RouteGetRulesConfigParams object +// no default values defined in spec. +func NewRouteGetRulesConfigParams() RouteGetRulesConfigParams { + + return RouteGetRulesConfigParams{} +} + +// RouteGetRulesConfigParams contains all the bound params for the route get rules config operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteGetRulesConfig +type RouteGetRulesConfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + Required: true + In: path + */ + DatasourceID string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteGetRulesConfigParams() beforehand. +func (o *RouteGetRulesConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RouteGetRulesConfigParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_rules_config_responses.go b/pkg/gen/restapi/operations/ruler/route_get_rules_config_responses.go new file mode 100644 index 00000000000..c63138df0fe --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_rules_config_responses.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteGetRulesConfigAcceptedCode is the HTTP code returned for type RouteGetRulesConfigAccepted +const RouteGetRulesConfigAcceptedCode int = 202 + +/*RouteGetRulesConfigAccepted NamespaceConfigResponse + +swagger:response routeGetRulesConfigAccepted +*/ +type RouteGetRulesConfigAccepted struct { + + /* + In: Body + */ + Payload models.NamespaceConfigResponse `json:"body,omitempty"` +} + +// NewRouteGetRulesConfigAccepted creates RouteGetRulesConfigAccepted with default headers values +func NewRouteGetRulesConfigAccepted() *RouteGetRulesConfigAccepted { + + return &RouteGetRulesConfigAccepted{} +} + +// WithPayload adds the payload to the route get rules config accepted response +func (o *RouteGetRulesConfigAccepted) WithPayload(payload models.NamespaceConfigResponse) *RouteGetRulesConfigAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route get rules config accepted response +func (o *RouteGetRulesConfigAccepted) SetPayload(payload models.NamespaceConfigResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteGetRulesConfigAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(202) + payload := o.Payload + if payload == nil { + // return empty map + payload = models.NamespaceConfigResponse{} + } + + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} diff --git a/pkg/gen/restapi/operations/ruler/route_get_rules_config_urlbuilder.go b/pkg/gen/restapi/operations/ruler/route_get_rules_config_urlbuilder.go new file mode 100644 index 00000000000..6a5d28de757 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_get_rules_config_urlbuilder.go @@ -0,0 +1,99 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RouteGetRulesConfigURL generates an URL for the route get rules config operation +type RouteGetRulesConfigURL struct { + DatasourceID string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetRulesConfigURL) WithBasePath(bp string) *RouteGetRulesConfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteGetRulesConfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteGetRulesConfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/ruler/{DatasourceId}/api/v1/rules" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RouteGetRulesConfigURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteGetRulesConfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteGetRulesConfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteGetRulesConfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteGetRulesConfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteGetRulesConfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteGetRulesConfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/ruler/route_post_name_rules_config.go b/pkg/gen/restapi/operations/ruler/route_post_name_rules_config.go new file mode 100644 index 00000000000..938978ff483 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_post_name_rules_config.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RoutePostNameRulesConfigHandlerFunc turns a function with the right signature into a route post name rules config handler +type RoutePostNameRulesConfigHandlerFunc func(RoutePostNameRulesConfigParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RoutePostNameRulesConfigHandlerFunc) Handle(params RoutePostNameRulesConfigParams) middleware.Responder { + return fn(params) +} + +// RoutePostNameRulesConfigHandler interface for that can handle valid route post name rules config params +type RoutePostNameRulesConfigHandler interface { + Handle(RoutePostNameRulesConfigParams) middleware.Responder +} + +// NewRoutePostNameRulesConfig creates a new http.Handler for the route post name rules config operation +func NewRoutePostNameRulesConfig(ctx *middleware.Context, handler RoutePostNameRulesConfigHandler) *RoutePostNameRulesConfig { + return &RoutePostNameRulesConfig{Context: ctx, Handler: handler} +} + +/*RoutePostNameRulesConfig swagger:route POST /ruler/{DatasourceId}/api/v1/rules/{Namespace} ruler routePostNameRulesConfig + +Creates or updates a rule group + +*/ +type RoutePostNameRulesConfig struct { + Context *middleware.Context + Handler RoutePostNameRulesConfigHandler +} + +func (o *RoutePostNameRulesConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRoutePostNameRulesConfigParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/ruler/route_post_name_rules_config_parameters.go b/pkg/gen/restapi/operations/ruler/route_post_name_rules_config_parameters.go new file mode 100644 index 00000000000..59250d103fd --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_post_name_rules_config_parameters.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// NewRoutePostNameRulesConfigParams creates a new RoutePostNameRulesConfigParams object +// no default values defined in spec. +func NewRoutePostNameRulesConfigParams() RoutePostNameRulesConfigParams { + + return RoutePostNameRulesConfigParams{} +} + +// RoutePostNameRulesConfigParams contains all the bound params for the route post name rules config operation +// typically these are obtained from a http.Request +// +// swagger:parameters RoutePostNameRulesConfig +type RoutePostNameRulesConfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: body + */ + Body *models.RuleGroupConfig + /* + Required: true + In: path + */ + DatasourceID string + /* + Required: true + In: path + */ + Namespace string +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRoutePostNameRulesConfigParams() beforehand. +func (o *RoutePostNameRulesConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.RuleGroupConfig + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("body", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Body = &body + } + } + } + rDatasourceID, rhkDatasourceID, _ := route.Params.GetOK("DatasourceId") + if err := o.bindDatasourceID(rDatasourceID, rhkDatasourceID, route.Formats); err != nil { + res = append(res, err) + } + + rNamespace, rhkNamespace, _ := route.Params.GetOK("Namespace") + if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindDatasourceID binds and validates parameter DatasourceID from path. +func (o *RoutePostNameRulesConfigParams) bindDatasourceID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.DatasourceID = raw + + return nil +} + +// bindNamespace binds and validates parameter Namespace from path. +func (o *RoutePostNameRulesConfigParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + o.Namespace = raw + + return nil +} diff --git a/pkg/gen/restapi/operations/ruler/route_post_name_rules_config_responses.go b/pkg/gen/restapi/operations/ruler/route_post_name_rules_config_responses.go new file mode 100644 index 00000000000..0e97795a443 --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_post_name_rules_config_responses.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RoutePostNameRulesConfigAcceptedCode is the HTTP code returned for type RoutePostNameRulesConfigAccepted +const RoutePostNameRulesConfigAcceptedCode int = 202 + +/*RoutePostNameRulesConfigAccepted Ack + +swagger:response routePostNameRulesConfigAccepted +*/ +type RoutePostNameRulesConfigAccepted struct { + + /* + In: Body + */ + Payload models.Ack `json:"body,omitempty"` +} + +// NewRoutePostNameRulesConfigAccepted creates RoutePostNameRulesConfigAccepted with default headers values +func NewRoutePostNameRulesConfigAccepted() *RoutePostNameRulesConfigAccepted { + + return &RoutePostNameRulesConfigAccepted{} +} + +// WithPayload adds the payload to the route post name rules config accepted response +func (o *RoutePostNameRulesConfigAccepted) WithPayload(payload models.Ack) *RoutePostNameRulesConfigAccepted { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route post name rules config accepted response +func (o *RoutePostNameRulesConfigAccepted) SetPayload(payload models.Ack) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RoutePostNameRulesConfigAccepted) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(202) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} diff --git a/pkg/gen/restapi/operations/ruler/route_post_name_rules_config_urlbuilder.go b/pkg/gen/restapi/operations/ruler/route_post_name_rules_config_urlbuilder.go new file mode 100644 index 00000000000..b83dc67b25a --- /dev/null +++ b/pkg/gen/restapi/operations/ruler/route_post_name_rules_config_urlbuilder.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package ruler + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" +) + +// RoutePostNameRulesConfigURL generates an URL for the route post name rules config operation +type RoutePostNameRulesConfigURL struct { + DatasourceID string + Namespace string + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RoutePostNameRulesConfigURL) WithBasePath(bp string) *RoutePostNameRulesConfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RoutePostNameRulesConfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RoutePostNameRulesConfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/ruler/{DatasourceId}/api/v1/rules/{Namespace}" + + datasourceID := o.DatasourceID + if datasourceID != "" { + _path = strings.Replace(_path, "{DatasourceId}", datasourceID, -1) + } else { + return nil, errors.New("datasourceId is required on RoutePostNameRulesConfigURL") + } + + namespace := o.Namespace + if namespace != "" { + _path = strings.Replace(_path, "{Namespace}", namespace, -1) + } else { + return nil, errors.New("namespace is required on RoutePostNameRulesConfigURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RoutePostNameRulesConfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RoutePostNameRulesConfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RoutePostNameRulesConfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RoutePostNameRulesConfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RoutePostNameRulesConfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RoutePostNameRulesConfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/testing/route_test_receiver_config.go b/pkg/gen/restapi/operations/testing/route_test_receiver_config.go new file mode 100644 index 00000000000..613b098e452 --- /dev/null +++ b/pkg/gen/restapi/operations/testing/route_test_receiver_config.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package testing + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteTestReceiverConfigHandlerFunc turns a function with the right signature into a route test receiver config handler +type RouteTestReceiverConfigHandlerFunc func(RouteTestReceiverConfigParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteTestReceiverConfigHandlerFunc) Handle(params RouteTestReceiverConfigParams) middleware.Responder { + return fn(params) +} + +// RouteTestReceiverConfigHandler interface for that can handle valid route test receiver config params +type RouteTestReceiverConfigHandler interface { + Handle(RouteTestReceiverConfigParams) middleware.Responder +} + +// NewRouteTestReceiverConfig creates a new http.Handler for the route test receiver config operation +func NewRouteTestReceiverConfig(ctx *middleware.Context, handler RouteTestReceiverConfigHandler) *RouteTestReceiverConfig { + return &RouteTestReceiverConfig{Context: ctx, Handler: handler} +} + +/*RouteTestReceiverConfig swagger:route GET /api/v1/receiver/test testing routeTestReceiverConfig + +Test receiver + +*/ +type RouteTestReceiverConfig struct { + Context *middleware.Context + Handler RouteTestReceiverConfigHandler +} + +func (o *RouteTestReceiverConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteTestReceiverConfigParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/testing/route_test_receiver_config_parameters.go b/pkg/gen/restapi/operations/testing/route_test_receiver_config_parameters.go new file mode 100644 index 00000000000..8e6113f92f7 --- /dev/null +++ b/pkg/gen/restapi/operations/testing/route_test_receiver_config_parameters.go @@ -0,0 +1,69 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package testing + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// NewRouteTestReceiverConfigParams creates a new RouteTestReceiverConfigParams object +// no default values defined in spec. +func NewRouteTestReceiverConfigParams() RouteTestReceiverConfigParams { + + return RouteTestReceiverConfigParams{} +} + +// RouteTestReceiverConfigParams contains all the bound params for the route test receiver config operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteTestReceiverConfig +type RouteTestReceiverConfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: body + */ + Body *models.ExtendedReceiver +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteTestReceiverConfigParams() beforehand. +func (o *RouteTestReceiverConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.ExtendedReceiver + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("body", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Body = &body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/gen/restapi/operations/testing/route_test_receiver_config_responses.go b/pkg/gen/restapi/operations/testing/route_test_receiver_config_responses.go new file mode 100644 index 00000000000..965e5a82451 --- /dev/null +++ b/pkg/gen/restapi/operations/testing/route_test_receiver_config_responses.go @@ -0,0 +1,146 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package testing + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteTestReceiverConfigOKCode is the HTTP code returned for type RouteTestReceiverConfigOK +const RouteTestReceiverConfigOKCode int = 200 + +/*RouteTestReceiverConfigOK Success + +swagger:response routeTestReceiverConfigOK +*/ +type RouteTestReceiverConfigOK struct { + + /* + In: Body + */ + Payload *models.Success `json:"body,omitempty"` +} + +// NewRouteTestReceiverConfigOK creates RouteTestReceiverConfigOK with default headers values +func NewRouteTestReceiverConfigOK() *RouteTestReceiverConfigOK { + + return &RouteTestReceiverConfigOK{} +} + +// WithPayload adds the payload to the route test receiver config o k response +func (o *RouteTestReceiverConfigOK) WithPayload(payload *models.Success) *RouteTestReceiverConfigOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route test receiver config o k response +func (o *RouteTestReceiverConfigOK) SetPayload(payload *models.Success) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteTestReceiverConfigOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RouteTestReceiverConfigPreconditionFailedCode is the HTTP code returned for type RouteTestReceiverConfigPreconditionFailed +const RouteTestReceiverConfigPreconditionFailedCode int = 412 + +/*RouteTestReceiverConfigPreconditionFailed SmtpNotEnabled + +swagger:response routeTestReceiverConfigPreconditionFailed +*/ +type RouteTestReceiverConfigPreconditionFailed struct { + + /* + In: Body + */ + Payload *models.SMTPNotEnabled `json:"body,omitempty"` +} + +// NewRouteTestReceiverConfigPreconditionFailed creates RouteTestReceiverConfigPreconditionFailed with default headers values +func NewRouteTestReceiverConfigPreconditionFailed() *RouteTestReceiverConfigPreconditionFailed { + + return &RouteTestReceiverConfigPreconditionFailed{} +} + +// WithPayload adds the payload to the route test receiver config precondition failed response +func (o *RouteTestReceiverConfigPreconditionFailed) WithPayload(payload *models.SMTPNotEnabled) *RouteTestReceiverConfigPreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route test receiver config precondition failed response +func (o *RouteTestReceiverConfigPreconditionFailed) SetPayload(payload *models.SMTPNotEnabled) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteTestReceiverConfigPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// RouteTestReceiverConfigInternalServerErrorCode is the HTTP code returned for type RouteTestReceiverConfigInternalServerError +const RouteTestReceiverConfigInternalServerErrorCode int = 500 + +/*RouteTestReceiverConfigInternalServerError Failure + +swagger:response routeTestReceiverConfigInternalServerError +*/ +type RouteTestReceiverConfigInternalServerError struct { + + /* + In: Body + */ + Payload *models.Failure `json:"body,omitempty"` +} + +// NewRouteTestReceiverConfigInternalServerError creates RouteTestReceiverConfigInternalServerError with default headers values +func NewRouteTestReceiverConfigInternalServerError() *RouteTestReceiverConfigInternalServerError { + + return &RouteTestReceiverConfigInternalServerError{} +} + +// WithPayload adds the payload to the route test receiver config internal server error response +func (o *RouteTestReceiverConfigInternalServerError) WithPayload(payload *models.Failure) *RouteTestReceiverConfigInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route test receiver config internal server error response +func (o *RouteTestReceiverConfigInternalServerError) SetPayload(payload *models.Failure) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteTestReceiverConfigInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/testing/route_test_receiver_config_urlbuilder.go b/pkg/gen/restapi/operations/testing/route_test_receiver_config_urlbuilder.go new file mode 100644 index 00000000000..888a54c3fd1 --- /dev/null +++ b/pkg/gen/restapi/operations/testing/route_test_receiver_config_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package testing + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// RouteTestReceiverConfigURL generates an URL for the route test receiver config operation +type RouteTestReceiverConfigURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteTestReceiverConfigURL) WithBasePath(bp string) *RouteTestReceiverConfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteTestReceiverConfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteTestReceiverConfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/api/v1/receiver/test" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteTestReceiverConfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteTestReceiverConfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteTestReceiverConfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteTestReceiverConfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteTestReceiverConfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteTestReceiverConfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/operations/testing/route_test_rule_config.go b/pkg/gen/restapi/operations/testing/route_test_rule_config.go new file mode 100644 index 00000000000..3553a63884e --- /dev/null +++ b/pkg/gen/restapi/operations/testing/route_test_rule_config.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package testing + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// RouteTestRuleConfigHandlerFunc turns a function with the right signature into a route test rule config handler +type RouteTestRuleConfigHandlerFunc func(RouteTestRuleConfigParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn RouteTestRuleConfigHandlerFunc) Handle(params RouteTestRuleConfigParams) middleware.Responder { + return fn(params) +} + +// RouteTestRuleConfigHandler interface for that can handle valid route test rule config params +type RouteTestRuleConfigHandler interface { + Handle(RouteTestRuleConfigParams) middleware.Responder +} + +// NewRouteTestRuleConfig creates a new http.Handler for the route test rule config operation +func NewRouteTestRuleConfig(ctx *middleware.Context, handler RouteTestRuleConfigHandler) *RouteTestRuleConfig { + return &RouteTestRuleConfig{Context: ctx, Handler: handler} +} + +/*RouteTestRuleConfig swagger:route GET /api/v1/rule/test testing routeTestRuleConfig + +Test rule + +*/ +type RouteTestRuleConfig struct { + Context *middleware.Context + Handler RouteTestRuleConfigHandler +} + +func (o *RouteTestRuleConfig) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + r = rCtx + } + var Params = NewRouteTestRuleConfigParams() + + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/restapi/operations/testing/route_test_rule_config_parameters.go b/pkg/gen/restapi/operations/testing/route_test_rule_config_parameters.go new file mode 100644 index 00000000000..6d19a39be26 --- /dev/null +++ b/pkg/gen/restapi/operations/testing/route_test_rule_config_parameters.go @@ -0,0 +1,69 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package testing + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + "github.com/go-openapi/runtime/middleware" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// NewRouteTestRuleConfigParams creates a new RouteTestRuleConfigParams object +// no default values defined in spec. +func NewRouteTestRuleConfigParams() RouteTestRuleConfigParams { + + return RouteTestRuleConfigParams{} +} + +// RouteTestRuleConfigParams contains all the bound params for the route test rule config operation +// typically these are obtained from a http.Request +// +// swagger:parameters RouteTestRuleConfig +type RouteTestRuleConfigParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /* + In: body + */ + Body *models.TestRulePayload +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewRouteTestRuleConfigParams() beforehand. +func (o *RouteTestRuleConfigParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if runtime.HasBody(r) { + defer r.Body.Close() + var body models.TestRulePayload + if err := route.Consumer.Consume(r.Body, &body); err != nil { + res = append(res, errors.NewParseError("body", "body", "", err)) + } else { + // validate body object + if err := body.Validate(route.Formats); err != nil { + res = append(res, err) + } + + if len(res) == 0 { + o.Body = &body + } + } + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/gen/restapi/operations/testing/route_test_rule_config_responses.go b/pkg/gen/restapi/operations/testing/route_test_rule_config_responses.go new file mode 100644 index 00000000000..570e77d21c4 --- /dev/null +++ b/pkg/gen/restapi/operations/testing/route_test_rule_config_responses.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package testing + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/grafana/alerting-api/pkg/gen/models" +) + +// RouteTestRuleConfigOKCode is the HTTP code returned for type RouteTestRuleConfigOK +const RouteTestRuleConfigOKCode int = 200 + +/*RouteTestRuleConfigOK TestRuleResponse + +swagger:response routeTestRuleConfigOK +*/ +type RouteTestRuleConfigOK struct { + + /* + In: Body + */ + Payload *models.TestRuleResponse `json:"body,omitempty"` +} + +// NewRouteTestRuleConfigOK creates RouteTestRuleConfigOK with default headers values +func NewRouteTestRuleConfigOK() *RouteTestRuleConfigOK { + + return &RouteTestRuleConfigOK{} +} + +// WithPayload adds the payload to the route test rule config o k response +func (o *RouteTestRuleConfigOK) WithPayload(payload *models.TestRuleResponse) *RouteTestRuleConfigOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the route test rule config o k response +func (o *RouteTestRuleConfigOK) SetPayload(payload *models.TestRuleResponse) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *RouteTestRuleConfigOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/restapi/operations/testing/route_test_rule_config_urlbuilder.go b/pkg/gen/restapi/operations/testing/route_test_rule_config_urlbuilder.go new file mode 100644 index 00000000000..ecaedb0297f --- /dev/null +++ b/pkg/gen/restapi/operations/testing/route_test_rule_config_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package testing + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// RouteTestRuleConfigURL generates an URL for the route test rule config operation +type RouteTestRuleConfigURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteTestRuleConfigURL) WithBasePath(bp string) *RouteTestRuleConfigURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *RouteTestRuleConfigURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *RouteTestRuleConfigURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/api/v1/rule/test" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/api/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *RouteTestRuleConfigURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *RouteTestRuleConfigURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *RouteTestRuleConfigURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on RouteTestRuleConfigURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on RouteTestRuleConfigURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *RouteTestRuleConfigURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/restapi/server.go b/pkg/gen/restapi/server.go new file mode 100644 index 00000000000..fae396a2cf2 --- /dev/null +++ b/pkg/gen/restapi/server.go @@ -0,0 +1,512 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package restapi + +import ( + "context" + "crypto/tls" + "crypto/x509" + "errors" + "fmt" + "io/ioutil" + "log" + "net" + "net/http" + "os" + "os/signal" + "strconv" + "sync" + "sync/atomic" + "syscall" + "time" + + "github.com/go-openapi/runtime/flagext" + "github.com/go-openapi/swag" + flags "github.com/jessevdk/go-flags" + "golang.org/x/net/netutil" + + "github.com/grafana/alerting-api/pkg/gen/restapi/operations" +) + +const ( + schemeHTTP = "http" + schemeHTTPS = "https" + schemeUnix = "unix" +) + +var defaultSchemes []string + +func init() { + defaultSchemes = []string{ + schemeHTTP, + schemeHTTPS, + } +} + +// NewServer creates a new api documentation of the API server but does not configure it +func NewServer(api *operations.DocumentationOfTheAPIAPI) *Server { + s := new(Server) + + s.shutdown = make(chan struct{}) + s.api = api + s.interrupt = make(chan os.Signal, 1) + return s +} + +// ConfigureAPI configures the API and handlers. +func (s *Server) ConfigureAPI() { + if s.api != nil { + s.handler = configureAPI(s.api) + } +} + +// ConfigureFlags configures the additional flags defined by the handlers. Needs to be called before the parser.Parse +func (s *Server) ConfigureFlags() { + if s.api != nil { + configureFlags(s.api) + } +} + +// Server for the documentation of the API API +type Server struct { + EnabledListeners []string `long:"scheme" description:"the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec"` + CleanupTimeout time.Duration `long:"cleanup-timeout" description:"grace period for which to wait before killing idle connections" default:"10s"` + GracefulTimeout time.Duration `long:"graceful-timeout" description:"grace period for which to wait before shutting down the server" default:"15s"` + MaxHeaderSize flagext.ByteSize `long:"max-header-size" description:"controls the maximum number of bytes the server will read parsing the request header's keys and values, including the request line. It does not limit the size of the request body." default:"1MiB"` + + SocketPath flags.Filename `long:"socket-path" description:"the unix socket to listen on" default:"/var/run/documentation-of-the-api.sock"` + domainSocketL net.Listener + + Host string `long:"host" description:"the IP to listen on" default:"localhost" env:"HOST"` + Port int `long:"port" description:"the port to listen on for insecure connections, defaults to a random value" env:"PORT"` + ListenLimit int `long:"listen-limit" description:"limit the number of outstanding requests"` + KeepAlive time.Duration `long:"keep-alive" description:"sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)" default:"3m"` + ReadTimeout time.Duration `long:"read-timeout" description:"maximum duration before timing out read of the request" default:"30s"` + WriteTimeout time.Duration `long:"write-timeout" description:"maximum duration before timing out write of the response" default:"60s"` + httpServerL net.Listener + + TLSHost string `long:"tls-host" description:"the IP to listen on for tls, when not specified it's the same as --host" env:"TLS_HOST"` + TLSPort int `long:"tls-port" description:"the port to listen on for secure connections, defaults to a random value" env:"TLS_PORT"` + TLSCertificate flags.Filename `long:"tls-certificate" description:"the certificate to use for secure connections" env:"TLS_CERTIFICATE"` + TLSCertificateKey flags.Filename `long:"tls-key" description:"the private key to use for secure connections" env:"TLS_PRIVATE_KEY"` + TLSCACertificate flags.Filename `long:"tls-ca" description:"the certificate authority file to be used with mutual tls auth" env:"TLS_CA_CERTIFICATE"` + TLSListenLimit int `long:"tls-listen-limit" description:"limit the number of outstanding requests"` + TLSKeepAlive time.Duration `long:"tls-keep-alive" description:"sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)"` + TLSReadTimeout time.Duration `long:"tls-read-timeout" description:"maximum duration before timing out read of the request"` + TLSWriteTimeout time.Duration `long:"tls-write-timeout" description:"maximum duration before timing out write of the response"` + httpsServerL net.Listener + + api *operations.DocumentationOfTheAPIAPI + handler http.Handler + hasListeners bool + shutdown chan struct{} + shuttingDown int32 + interrupted bool + interrupt chan os.Signal +} + +// Logf logs message either via defined user logger or via system one if no user logger is defined. +func (s *Server) Logf(f string, args ...interface{}) { + if s.api != nil && s.api.Logger != nil { + s.api.Logger(f, args...) + } else { + log.Printf(f, args...) + } +} + +// Fatalf logs message either via defined user logger or via system one if no user logger is defined. +// Exits with non-zero status after printing +func (s *Server) Fatalf(f string, args ...interface{}) { + if s.api != nil && s.api.Logger != nil { + s.api.Logger(f, args...) + os.Exit(1) + } else { + log.Fatalf(f, args...) + } +} + +// SetAPI configures the server with the specified API. Needs to be called before Serve +func (s *Server) SetAPI(api *operations.DocumentationOfTheAPIAPI) { + if api == nil { + s.api = nil + s.handler = nil + return + } + + s.api = api + s.handler = configureAPI(api) +} + +func (s *Server) hasScheme(scheme string) bool { + schemes := s.EnabledListeners + if len(schemes) == 0 { + schemes = defaultSchemes + } + + for _, v := range schemes { + if v == scheme { + return true + } + } + return false +} + +// Serve the api +func (s *Server) Serve() (err error) { + if !s.hasListeners { + if err = s.Listen(); err != nil { + return err + } + } + + // set default handler, if none is set + if s.handler == nil { + if s.api == nil { + return errors.New("can't create the default handler, as no api is set") + } + + s.SetHandler(s.api.Serve(nil)) + } + + wg := new(sync.WaitGroup) + once := new(sync.Once) + signalNotify(s.interrupt) + go handleInterrupt(once, s) + + servers := []*http.Server{} + + if s.hasScheme(schemeUnix) { + domainSocket := new(http.Server) + domainSocket.MaxHeaderBytes = int(s.MaxHeaderSize) + domainSocket.Handler = s.handler + if int64(s.CleanupTimeout) > 0 { + domainSocket.IdleTimeout = s.CleanupTimeout + } + + configureServer(domainSocket, "unix", string(s.SocketPath)) + + servers = append(servers, domainSocket) + wg.Add(1) + s.Logf("Serving documentation of the API at unix://%s", s.SocketPath) + go func(l net.Listener) { + defer wg.Done() + if err := domainSocket.Serve(l); err != nil && err != http.ErrServerClosed { + s.Fatalf("%v", err) + } + s.Logf("Stopped serving documentation of the API at unix://%s", s.SocketPath) + }(s.domainSocketL) + } + + if s.hasScheme(schemeHTTP) { + httpServer := new(http.Server) + httpServer.MaxHeaderBytes = int(s.MaxHeaderSize) + httpServer.ReadTimeout = s.ReadTimeout + httpServer.WriteTimeout = s.WriteTimeout + httpServer.SetKeepAlivesEnabled(int64(s.KeepAlive) > 0) + if s.ListenLimit > 0 { + s.httpServerL = netutil.LimitListener(s.httpServerL, s.ListenLimit) + } + + if int64(s.CleanupTimeout) > 0 { + httpServer.IdleTimeout = s.CleanupTimeout + } + + httpServer.Handler = s.handler + + configureServer(httpServer, "http", s.httpServerL.Addr().String()) + + servers = append(servers, httpServer) + wg.Add(1) + s.Logf("Serving documentation of the API at http://%s", s.httpServerL.Addr()) + go func(l net.Listener) { + defer wg.Done() + if err := httpServer.Serve(l); err != nil && err != http.ErrServerClosed { + s.Fatalf("%v", err) + } + s.Logf("Stopped serving documentation of the API at http://%s", l.Addr()) + }(s.httpServerL) + } + + if s.hasScheme(schemeHTTPS) { + httpsServer := new(http.Server) + httpsServer.MaxHeaderBytes = int(s.MaxHeaderSize) + httpsServer.ReadTimeout = s.TLSReadTimeout + httpsServer.WriteTimeout = s.TLSWriteTimeout + httpsServer.SetKeepAlivesEnabled(int64(s.TLSKeepAlive) > 0) + if s.TLSListenLimit > 0 { + s.httpsServerL = netutil.LimitListener(s.httpsServerL, s.TLSListenLimit) + } + if int64(s.CleanupTimeout) > 0 { + httpsServer.IdleTimeout = s.CleanupTimeout + } + httpsServer.Handler = s.handler + + // Inspired by https://blog.bracebin.com/achieving-perfect-ssl-labs-score-with-go + httpsServer.TLSConfig = &tls.Config{ + // Causes servers to use Go's default ciphersuite preferences, + // which are tuned to avoid attacks. Does nothing on clients. + PreferServerCipherSuites: true, + // Only use curves which have assembly implementations + // https://github.com/golang/go/tree/master/src/crypto/elliptic + CurvePreferences: []tls.CurveID{tls.CurveP256}, + // Use modern tls mode https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility + NextProtos: []string{"h2", "http/1.1"}, + // https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Protocols + MinVersion: tls.VersionTLS12, + // These ciphersuites support Forward Secrecy: https://en.wikipedia.org/wiki/Forward_secrecy + CipherSuites: []uint16{ + tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, + tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, + }, + } + + // build standard config from server options + if s.TLSCertificate != "" && s.TLSCertificateKey != "" { + httpsServer.TLSConfig.Certificates = make([]tls.Certificate, 1) + httpsServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(string(s.TLSCertificate), string(s.TLSCertificateKey)) + if err != nil { + return err + } + } + + if s.TLSCACertificate != "" { + // include specified CA certificate + caCert, caCertErr := ioutil.ReadFile(string(s.TLSCACertificate)) + if caCertErr != nil { + return caCertErr + } + caCertPool := x509.NewCertPool() + ok := caCertPool.AppendCertsFromPEM(caCert) + if !ok { + return fmt.Errorf("cannot parse CA certificate") + } + httpsServer.TLSConfig.ClientCAs = caCertPool + httpsServer.TLSConfig.ClientAuth = tls.RequireAndVerifyClientCert + } + + // call custom TLS configurator + configureTLS(httpsServer.TLSConfig) + + if len(httpsServer.TLSConfig.Certificates) == 0 && httpsServer.TLSConfig.GetCertificate == nil { + // after standard and custom config are passed, this ends up with no certificate + if s.TLSCertificate == "" { + if s.TLSCertificateKey == "" { + s.Fatalf("the required flags `--tls-certificate` and `--tls-key` were not specified") + } + s.Fatalf("the required flag `--tls-certificate` was not specified") + } + if s.TLSCertificateKey == "" { + s.Fatalf("the required flag `--tls-key` was not specified") + } + // this happens with a wrong custom TLS configurator + s.Fatalf("no certificate was configured for TLS") + } + + // must have at least one certificate or panics + httpsServer.TLSConfig.BuildNameToCertificate() + + configureServer(httpsServer, "https", s.httpsServerL.Addr().String()) + + servers = append(servers, httpsServer) + wg.Add(1) + s.Logf("Serving documentation of the API at https://%s", s.httpsServerL.Addr()) + go func(l net.Listener) { + defer wg.Done() + if err := httpsServer.Serve(l); err != nil && err != http.ErrServerClosed { + s.Fatalf("%v", err) + } + s.Logf("Stopped serving documentation of the API at https://%s", l.Addr()) + }(tls.NewListener(s.httpsServerL, httpsServer.TLSConfig)) + } + + wg.Add(1) + go s.handleShutdown(wg, &servers) + + wg.Wait() + return nil +} + +// Listen creates the listeners for the server +func (s *Server) Listen() error { + if s.hasListeners { // already done this + return nil + } + + if s.hasScheme(schemeHTTPS) { + // Use http host if https host wasn't defined + if s.TLSHost == "" { + s.TLSHost = s.Host + } + // Use http listen limit if https listen limit wasn't defined + if s.TLSListenLimit == 0 { + s.TLSListenLimit = s.ListenLimit + } + // Use http tcp keep alive if https tcp keep alive wasn't defined + if int64(s.TLSKeepAlive) == 0 { + s.TLSKeepAlive = s.KeepAlive + } + // Use http read timeout if https read timeout wasn't defined + if int64(s.TLSReadTimeout) == 0 { + s.TLSReadTimeout = s.ReadTimeout + } + // Use http write timeout if https write timeout wasn't defined + if int64(s.TLSWriteTimeout) == 0 { + s.TLSWriteTimeout = s.WriteTimeout + } + } + + if s.hasScheme(schemeUnix) { + domSockListener, err := net.Listen("unix", string(s.SocketPath)) + if err != nil { + return err + } + s.domainSocketL = domSockListener + } + + if s.hasScheme(schemeHTTP) { + listener, err := net.Listen("tcp", net.JoinHostPort(s.Host, strconv.Itoa(s.Port))) + if err != nil { + return err + } + + h, p, err := swag.SplitHostPort(listener.Addr().String()) + if err != nil { + return err + } + s.Host = h + s.Port = p + s.httpServerL = listener + } + + if s.hasScheme(schemeHTTPS) { + tlsListener, err := net.Listen("tcp", net.JoinHostPort(s.TLSHost, strconv.Itoa(s.TLSPort))) + if err != nil { + return err + } + + sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) + if err != nil { + return err + } + s.TLSHost = sh + s.TLSPort = sp + s.httpsServerL = tlsListener + } + + s.hasListeners = true + return nil +} + +// Shutdown server and clean up resources +func (s *Server) Shutdown() error { + if atomic.CompareAndSwapInt32(&s.shuttingDown, 0, 1) { + close(s.shutdown) + } + return nil +} + +func (s *Server) handleShutdown(wg *sync.WaitGroup, serversPtr *[]*http.Server) { + // wg.Done must occur last, after s.api.ServerShutdown() + // (to preserve old behaviour) + defer wg.Done() + + <-s.shutdown + + servers := *serversPtr + + ctx, cancel := context.WithTimeout(context.TODO(), s.GracefulTimeout) + defer cancel() + + // first execute the pre-shutdown hook + s.api.PreServerShutdown() + + shutdownChan := make(chan bool) + for i := range servers { + server := servers[i] + go func() { + var success bool + defer func() { + shutdownChan <- success + }() + if err := server.Shutdown(ctx); err != nil { + // Error from closing listeners, or context timeout: + s.Logf("HTTP server Shutdown: %v", err) + } else { + success = true + } + }() + } + + // Wait until all listeners have successfully shut down before calling ServerShutdown + success := true + for range servers { + success = success && <-shutdownChan + } + if success { + s.api.ServerShutdown() + } +} + +// GetHandler returns a handler useful for testing +func (s *Server) GetHandler() http.Handler { + return s.handler +} + +// SetHandler allows for setting a http handler on this server +func (s *Server) SetHandler(handler http.Handler) { + s.handler = handler +} + +// UnixListener returns the domain socket listener +func (s *Server) UnixListener() (net.Listener, error) { + if !s.hasListeners { + if err := s.Listen(); err != nil { + return nil, err + } + } + return s.domainSocketL, nil +} + +// HTTPListener returns the http listener +func (s *Server) HTTPListener() (net.Listener, error) { + if !s.hasListeners { + if err := s.Listen(); err != nil { + return nil, err + } + } + return s.httpServerL, nil +} + +// TLSListener returns the https listener +func (s *Server) TLSListener() (net.Listener, error) { + if !s.hasListeners { + if err := s.Listen(); err != nil { + return nil, err + } + } + return s.httpsServerL, nil +} + +func handleInterrupt(once *sync.Once, s *Server) { + once.Do(func() { + for range s.interrupt { + if s.interrupted { + s.Logf("Server already shutting down") + continue + } + s.interrupted = true + s.Logf("Shutting down... ") + if err := s.Shutdown(); err != nil { + s.Logf("HTTP server Shutdown: %v", err) + } + } + }) +} + +func signalNotify(interrupt chan<- os.Signal) { + signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM) +} diff --git a/post.json b/post.json new file mode 100644 index 00000000000..793bd944a1e --- /dev/null +++ b/post.json @@ -0,0 +1,3622 @@ +{ + "basePath": "/api/v1", + "consumes": [ + "application/json" + ], + "definitions": { + "Ack": { + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Alert": { + "properties": { + "activeAt": { + "format": "date-time", + "type": "string", + "x-go-name": "ActiveAt" + }, + "annotations": { + "$ref": "#/definitions/labels" + }, + "labels": { + "$ref": "#/definitions/labels" + }, + "state": { + "type": "string", + "x-go-name": "State" + }, + "value": { + "type": "string", + "x-go-name": "Value" + } + }, + "title": "Alert has info for an alert.", + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertDiscovery": { + "properties": { + "alerts": { + "items": { + "$ref": "#/definitions/Alert" + }, + "type": "array", + "x-go-name": "Alerts" + } + }, + "title": "AlertDiscovery has info for all active alerts.", + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertGroups": { + "$ref": "#/definitions/alertGroups" + }, + "AlertInstancesResponse": { + "properties": { + "instances": { + "description": "Instances is an array of arrow encoded dataframes\neach frame has a single row, and a column for each instance (alert identified by unique labels) with a boolean value (firing/not firing)", + "items": { + "items": { + "format": "uint8", + "type": "integer" + }, + "type": "array" + }, + "type": "array", + "x-go-name": "Instances" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertNotification": { + "properties": { + "created": { + "format": "date-time", + "type": "string", + "x-go-name": "Created" + }, + "disableResolveMessage": { + "type": "boolean", + "x-go-name": "DisableResolveMessage" + }, + "frequency": { + "$ref": "#/definitions/Duration" + }, + "id": { + "format": "int64", + "type": "integer", + "x-go-name": "Id" + }, + "isDefault": { + "type": "boolean", + "x-go-name": "IsDefault" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "secureSettings": { + "$ref": "#/definitions/SecureJsonData" + }, + "sendReminder": { + "type": "boolean", + "x-go-name": "SendReminder" + }, + "settings": { + "$ref": "#/definitions/Json" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "updated": { + "format": "date-time", + "type": "string", + "x-go-name": "Updated" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "AlertQuery": { + "properties": { + "model": { + "description": "JSON is the raw JSON query and includes the above properties as well as custom properties.", + "type": "object", + "x-go-name": "Model" + }, + "queryType": { + "description": "QueryType is an optional identifier for the type of query.\nIt can be used to distinguish different types of queries.", + "type": "string", + "x-go-name": "QueryType" + }, + "refId": { + "description": "RefID is the unique identifier of the query, set by the frontend call.", + "type": "string", + "x-go-name": "RefID" + }, + "relativeTimeRange": { + "$ref": "#/definitions/RelativeTimeRange" + } + }, + "title": "AlertQuery represents a single query associated with an alert definition.", + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/eval" + }, + "AlertResponse": { + "properties": { + "Body": { + "description": "in: body", + "properties": { + "data": { + "$ref": "#/definitions/AlertDiscovery" + }, + "error": { + "type": "string", + "x-go-name": "Error" + }, + "errorType": { + "$ref": "#/definitions/ErrorType" + }, + "status": { + "type": "string", + "x-go-name": "Status" + } + }, + "type": "object" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertingConfigResponse": { + "properties": { + "Body": { + "$ref": "#/definitions/UserConfig" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "AlertingRule": { + "description": "adapted from cortex", + "properties": { + "alerts": { + "items": { + "$ref": "#/definitions/Alert" + }, + "type": "array", + "x-go-name": "Alerts" + }, + "annotations": { + "$ref": "#/definitions/labels" + }, + "duration": { + "format": "double", + "type": "number", + "x-go-name": "Duration" + }, + "evaluationTime": { + "format": "double", + "type": "number", + "x-go-name": "EvaluationTime" + }, + "health": { + "type": "string", + "x-go-name": "Health" + }, + "labels": { + "$ref": "#/definitions/labels" + }, + "lastError": { + "type": "string", + "x-go-name": "LastError" + }, + "lastEvaluation": { + "format": "date-time", + "type": "string", + "x-go-name": "LastEvaluation" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "query": { + "type": "string", + "x-go-name": "Query" + }, + "state": { + "description": "State can be \"pending\", \"firing\", \"inactive\".", + "type": "string", + "x-go-name": "State" + }, + "type": { + "$ref": "#/definitions/RuleType" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ApiAlertingConfig": { + "properties": { + "global": { + "$ref": "#/definitions/GlobalConfig" + }, + "inhibit_rules": { + "items": { + "$ref": "#/definitions/InhibitRule" + }, + "type": "array", + "x-go-name": "InhibitRules" + }, + "receivers": { + "description": "Override with our superset receiver type", + "items": { + "$ref": "#/definitions/ApiReceiver" + }, + "type": "array", + "x-go-name": "Receivers" + }, + "route": { + "$ref": "#/definitions/Route" + }, + "templates": { + "items": { + "type": "string" + }, + "type": "array", + "x-go-name": "Templates" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ApiReceiver": { + "properties": { + "email_configs": { + "items": { + "$ref": "#/definitions/EmailConfig" + }, + "type": "array", + "x-go-name": "EmailConfigs" + }, + "grafana_managed_receiver_configs": { + "items": { + "$ref": "#/definitions/GrafanaReceiver" + }, + "type": "array", + "x-go-name": "GrafanaManagedReceivers" + }, + "name": { + "description": "A unique identifier for this receiver.", + "type": "string", + "x-go-name": "Name" + }, + "opsgenie_configs": { + "items": { + "$ref": "#/definitions/OpsGenieConfig" + }, + "type": "array", + "x-go-name": "OpsGenieConfigs" + }, + "pagerduty_configs": { + "items": { + "$ref": "#/definitions/PagerdutyConfig" + }, + "type": "array", + "x-go-name": "PagerdutyConfigs" + }, + "pushover_configs": { + "items": { + "$ref": "#/definitions/PushoverConfig" + }, + "type": "array", + "x-go-name": "PushoverConfigs" + }, + "slack_configs": { + "items": { + "$ref": "#/definitions/SlackConfig" + }, + "type": "array", + "x-go-name": "SlackConfigs" + }, + "victorops_configs": { + "items": { + "$ref": "#/definitions/VictorOpsConfig" + }, + "type": "array", + "x-go-name": "VictorOpsConfigs" + }, + "webhook_configs": { + "items": { + "$ref": "#/definitions/WebhookConfig" + }, + "type": "array", + "x-go-name": "WebhookConfigs" + }, + "wechat_configs": { + "items": { + "$ref": "#/definitions/WechatConfig" + }, + "type": "array", + "x-go-name": "WechatConfigs" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ApiRuleNode": { + "properties": { + "alert": { + "type": "string", + "x-go-name": "Alert" + }, + "annotations": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "x-go-name": "Annotations" + }, + "expr": { + "type": "string", + "x-go-name": "Expr" + }, + "for": { + "$ref": "#/definitions/Duration" + }, + "labels": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "x-go-name": "Labels" + }, + "record": { + "type": "string", + "x-go-name": "Record" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "BasicAuth": { + "properties": { + "Password": { + "$ref": "#/definitions/Secret" + }, + "PasswordFile": { + "type": "string" + }, + "Username": { + "type": "string" + } + }, + "title": "BasicAuth contains basic HTTP authentication credentials.", + "type": "object", + "x-go-package": "github.com/prometheus/common/config" + }, + "BodyAlertingConfig": { + "properties": { + "Body": { + "$ref": "#/definitions/UserConfig" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Config": { + "properties": { + "global": { + "$ref": "#/definitions/GlobalConfig" + }, + "inhibit_rules": { + "items": { + "$ref": "#/definitions/InhibitRule" + }, + "type": "array", + "x-go-name": "InhibitRules" + }, + "receivers": { + "items": { + "$ref": "#/definitions/Receiver" + }, + "type": "array", + "x-go-name": "Receivers" + }, + "route": { + "$ref": "#/definitions/Route" + }, + "templates": { + "items": { + "type": "string" + }, + "type": "array", + "x-go-name": "Templates" + } + }, + "title": "Config is the top-level configuration for Alertmanager's config files.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "CreateAlertNotificationCommand": { + "properties": { + "Result": { + "$ref": "#/definitions/AlertNotification" + }, + "disableResolveMessage": { + "type": "boolean", + "x-go-name": "DisableResolveMessage" + }, + "frequency": { + "type": "string", + "x-go-name": "Frequency" + }, + "isDefault": { + "type": "boolean", + "x-go-name": "IsDefault" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "secureSettings": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "x-go-name": "SecureSettings" + }, + "sendReminder": { + "type": "boolean", + "x-go-name": "SendReminder" + }, + "settings": { + "$ref": "#/definitions/Json" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "uid": { + "type": "string", + "x-go-name": "Uid" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "DashboardAclUpdateItem": { + "properties": { + "permission": { + "$ref": "#/definitions/PermissionType" + }, + "role": { + "$ref": "#/definitions/RoleType" + }, + "teamId": { + "format": "int64", + "type": "integer", + "x-go-name": "TeamID" + }, + "userId": { + "format": "int64", + "type": "integer", + "x-go-name": "UserID" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/api/dtos" + }, + "DateTime": { + "description": "DateTime is a time but it serializes to ISO8601 format with millis\nIt knows how to read 3 different variations of a RFC3339 date time.\nMost APIs we encounter want either millisecond or second precision times.\nThis just tries to make it worry-free.", + "format": "date-time", + "type": "string", + "x-go-package": "github.com/go-openapi/strfmt" + }, + "Duration": { + "format": "int64", + "title": "Duration is a type used for marshalling durations.", + "type": "integer" + }, + "EmailConfig": { + "properties": { + "auth_identity": { + "type": "string", + "x-go-name": "AuthIdentity" + }, + "auth_password": { + "$ref": "#/definitions/Secret" + }, + "auth_secret": { + "$ref": "#/definitions/Secret" + }, + "auth_username": { + "type": "string", + "x-go-name": "AuthUsername" + }, + "from": { + "type": "string", + "x-go-name": "From" + }, + "headers": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "x-go-name": "Headers" + }, + "hello": { + "type": "string", + "x-go-name": "Hello" + }, + "html": { + "type": "string", + "x-go-name": "HTML" + }, + "require_tls": { + "type": "boolean", + "x-go-name": "RequireTLS" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "smarthost": { + "$ref": "#/definitions/HostPort" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "tls_config": { + "$ref": "#/definitions/TLSConfig" + }, + "to": { + "description": "Email address to notify.", + "type": "string", + "x-go-name": "To" + } + }, + "title": "EmailConfig configures notifications via mail.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "ErrorType": { + "title": "ErrorType models the different API error types.", + "type": "string", + "x-go-package": "github.com/prometheus/client_golang/api/prometheus/v1" + }, + "EvalAlertConditionCommand": { + "properties": { + "condition": { + "type": "string", + "x-go-name": "Condition" + }, + "data": { + "items": { + "$ref": "#/definitions/AlertQuery" + }, + "type": "array", + "x-go-name": "Data" + }, + "now": { + "format": "date-time", + "type": "string", + "x-go-name": "Now" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ExtendedReceiver": { + "properties": { + "email_configs": { + "$ref": "#/definitions/EmailConfig" + }, + "grafana_managed_receiver": { + "$ref": "#/definitions/GrafanaReceiver" + }, + "opsgenie_configs": { + "$ref": "#/definitions/OpsGenieConfig" + }, + "pagerduty_configs": { + "$ref": "#/definitions/PagerdutyConfig" + }, + "pushover_configs": { + "$ref": "#/definitions/PushoverConfig" + }, + "slack_configs": { + "$ref": "#/definitions/SlackConfig" + }, + "victorops_configs": { + "$ref": "#/definitions/VictorOpsConfig" + }, + "webhook_configs": { + "$ref": "#/definitions/WebhookConfig" + }, + "wechat_configs": { + "$ref": "#/definitions/WechatConfig" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ExtendedRuleNode": { + "properties": { + "alert": { + "type": "string", + "x-go-name": "Alert" + }, + "annotations": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "x-go-name": "Annotations" + }, + "expr": { + "type": "string", + "x-go-name": "Expr" + }, + "for": { + "$ref": "#/definitions/Duration" + }, + "grafana_alert": { + "$ref": "#/definitions/ExtendedUpsertAlertDefinitionCommand" + }, + "labels": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "x-go-name": "Labels" + }, + "record": { + "type": "string", + "x-go-name": "Record" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "ExtendedUpsertAlertDefinitionCommand": { + "description": "ExtendedUpsertAlertDefinitionCommand extends UpsertAlertDefinitionCommand\nwith properties of grafana dashboard alerts", + "properties": { + "condition": { + "description": "Condition is the refID of the query or expression to be evaluated", + "type": "string", + "x-go-name": "Condition" + }, + "data": { + "description": "Data is an array of the queries and expressions", + "items": { + "$ref": "#/definitions/AlertQuery" + }, + "type": "array", + "x-go-name": "Data" + }, + "exec_err_state": { + "enum": [ + "Alerting", + "KeepLastState" + ], + "type": "string", + "x-go-name": "ExecutionErrorState" + }, + "no_data_state": { + "enum": [ + "Alerting", + "NoData", + "KeepLastState", + "OK" + ], + "type": "string", + "x-go-name": "NoDataState" + }, + "receivers": { + "description": "Receivers are optional and used for migrating notification channels of existing alerts", + "items": { + "type": "string" + }, + "type": "array", + "x-go-name": "Receivers" + }, + "settings": { + "additionalProperties": { + "type": "object" + }, + "type": "object", + "x-go-name": "Settings" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "uid": { + "description": "UID is set only for existing definitions", + "type": "string", + "x-go-name": "UID" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Failure": { + "$ref": "#/definitions/ResponseDetails" + }, + "GettableAlerts": { + "$ref": "#/definitions/gettableAlerts" + }, + "GettableSilence": { + "$ref": "#/definitions/silence" + }, + "GettableSilences": { + "items": { + "$ref": "#/definitions/gettableSilences" + }, + "type": "array", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "GlobalConfig": { + "description": "GlobalConfig defines configuration parameters that are valid globally\nunless overwritten.", + "properties": { + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "opsgenie_api_key": { + "$ref": "#/definitions/Secret" + }, + "opsgenie_api_url": { + "$ref": "#/definitions/URL" + }, + "pagerduty_url": { + "$ref": "#/definitions/URL" + }, + "resolve_timeout": { + "$ref": "#/definitions/Duration" + }, + "slack_api_url": { + "$ref": "#/definitions/SecretURL" + }, + "smtp_auth_identity": { + "type": "string", + "x-go-name": "SMTPAuthIdentity" + }, + "smtp_auth_password": { + "$ref": "#/definitions/Secret" + }, + "smtp_auth_secret": { + "$ref": "#/definitions/Secret" + }, + "smtp_auth_username": { + "type": "string", + "x-go-name": "SMTPAuthUsername" + }, + "smtp_from": { + "type": "string", + "x-go-name": "SMTPFrom" + }, + "smtp_hello": { + "type": "string", + "x-go-name": "SMTPHello" + }, + "smtp_require_tls": { + "type": "boolean", + "x-go-name": "SMTPRequireTLS" + }, + "smtp_smarthost": { + "$ref": "#/definitions/HostPort" + }, + "victorops_api_key": { + "$ref": "#/definitions/Secret" + }, + "victorops_api_url": { + "$ref": "#/definitions/URL" + }, + "wechat_api_corp_id": { + "type": "string", + "x-go-name": "WeChatAPICorpID" + }, + "wechat_api_secret": { + "$ref": "#/definitions/Secret" + }, + "wechat_api_url": { + "$ref": "#/definitions/URL" + } + }, + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "GrafanaReceiver": { + "$ref": "#/definitions/CreateAlertNotificationCommand" + }, + "GrafanaReceivers": { + "properties": { + "grafana_managed_receiver_configs": { + "items": { + "$ref": "#/definitions/GrafanaReceiver" + }, + "type": "array", + "x-go-name": "GrafanaManagedReceivers" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "HTTPClientConfig": { + "properties": { + "BasicAuth": { + "$ref": "#/definitions/BasicAuth" + }, + "BearerToken": { + "$ref": "#/definitions/Secret" + }, + "BearerTokenFile": { + "description": "The bearer token file for the targets.", + "type": "string" + }, + "ProxyURL": { + "$ref": "#/definitions/URL" + }, + "TLSConfig": { + "$ref": "#/definitions/TLSConfig" + } + }, + "title": "HTTPClientConfig configures an HTTP client.", + "type": "object", + "x-go-package": "github.com/prometheus/common/config" + }, + "HostPort": { + "properties": { + "Host": { + "type": "string" + }, + "Port": { + "type": "string" + } + }, + "title": "HostPort represents a \"host:port\" network address.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "InhibitRule": { + "description": "InhibitRule defines an inhibition rule that mutes alerts that match the\ntarget labels if an alert matching the source labels exists.\nBoth alerts have to have a set of labels being equal.", + "properties": { + "equal": { + "$ref": "#/definitions/LabelNames" + }, + "source_match": { + "additionalProperties": { + "type": "string" + }, + "description": "SourceMatch defines a set of labels that have to equal the given\nvalue for source alerts. Deprecated. Remove before v1.0 release.", + "type": "object", + "x-go-name": "SourceMatch" + }, + "source_match_re": { + "$ref": "#/definitions/MatchRegexps" + }, + "source_matchers": { + "$ref": "#/definitions/Matchers" + }, + "target_match": { + "additionalProperties": { + "type": "string" + }, + "description": "TargetMatch defines a set of labels that have to equal the given\nvalue for target alerts. Deprecated. Remove before v1.0 release.", + "type": "object", + "x-go-name": "TargetMatch" + }, + "target_match_re": { + "$ref": "#/definitions/MatchRegexps" + }, + "target_matchers": { + "$ref": "#/definitions/Matchers" + } + }, + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "Json": { + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/components/simplejson" + }, + "Label": { + "properties": { + "Name": { + "type": "string", + "x-go-name": "Value" + } + }, + "title": "Label is a key/value pair of strings.", + "type": "object", + "x-go-package": "github.com/prometheus/prometheus/pkg/labels" + }, + "LabelName": { + "description": "A LabelName is a key for a LabelSet or Metric. It has a value associated\ntherewith.", + "type": "string", + "x-go-package": "github.com/prometheus/common/model" + }, + "LabelNames": { + "items": { + "$ref": "#/definitions/LabelName" + }, + "title": "LabelNames is a sortable LabelName slice. In implements sort.Interface.", + "type": "array", + "x-go-package": "github.com/prometheus/common/model" + }, + "Labels": { + "description": "Labels is a sorted set of labels. Order has to be guaranteed upon\ninstantiation.", + "items": { + "$ref": "#/definitions/Label" + }, + "type": "array", + "x-go-package": "github.com/prometheus/prometheus/pkg/labels" + }, + "LotexQuery": { + "properties": { + "Expr": { + "example": "(node_filesystem_avail_bytes{fstype!=\"\",job=\"integrations/node_exporter\"} node_filesystem_size_bytes{fstype!=\"\",job=\"integrations/node_exporter\"} * 100 \u003c 5 and node_filesystem_readonly{fstype!=\"\",job=\"integrations/node_exporter\"} == 0)", + "type": "string" + }, + "datasourceUid": { + "description": "DatasourceUID is required if the query will be sent to grafana to be executed", + "type": "string", + "x-go-name": "DatasourceUID" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "MatchRegexps": { + "additionalProperties": { + "$ref": "#/definitions/Regexp" + }, + "title": "MatchRegexps represents a map of Regexp.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "MatchType": { + "format": "int64", + "title": "MatchType is an enum for label matching types.", + "type": "integer", + "x-go-package": "github.com/prometheus/alertmanager/pkg/labels" + }, + "Matcher": { + "properties": { + "Name": { + "type": "string" + }, + "Type": { + "$ref": "#/definitions/MatchType" + }, + "Value": { + "type": "string" + } + }, + "title": "Matcher models the matching of a label.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/pkg/labels" + }, + "Matchers": { + "description": "Matchers is a slice of Matchers that is sortable, implements Stringer, and\nprovides a Matches method to match a LabelSet against all Matchers in the\nslice. Note that some users of Matchers might require it to be sorted.", + "items": { + "$ref": "#/definitions/Matcher" + }, + "type": "array" + }, + "NamespaceConfigResponse": { + "additionalProperties": { + "$ref": "#/definitions/RuleGroupConfig" + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "NotifierConfig": { + "properties": { + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + } + }, + "title": "NotifierConfig contains base options common across all notifier configurations.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "OpsGenieConfig": { + "properties": { + "api_key": { + "$ref": "#/definitions/Secret" + }, + "api_url": { + "$ref": "#/definitions/URL" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "details": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "x-go-name": "Details" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "note": { + "type": "string", + "x-go-name": "Note" + }, + "priority": { + "type": "string", + "x-go-name": "Priority" + }, + "responders": { + "items": { + "$ref": "#/definitions/OpsGenieConfigResponder" + }, + "type": "array", + "x-go-name": "Responders" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "source": { + "type": "string", + "x-go-name": "Source" + }, + "tags": { + "type": "string", + "x-go-name": "Tags" + } + }, + "title": "OpsGenieConfig configures notifications via OpsGenie.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "OpsGenieConfigResponder": { + "properties": { + "id": { + "description": "One of those 3 should be filled.", + "type": "string", + "x-go-name": "ID" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "type": { + "description": "team, user, escalation, schedule etc.", + "type": "string", + "x-go-name": "Type" + }, + "username": { + "type": "string", + "x-go-name": "Username" + } + }, + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PagerdutyConfig": { + "properties": { + "class": { + "type": "string", + "x-go-name": "Class" + }, + "client": { + "type": "string", + "x-go-name": "Client" + }, + "client_url": { + "type": "string", + "x-go-name": "ClientURL" + }, + "component": { + "type": "string", + "x-go-name": "Component" + }, + "description": { + "type": "string", + "x-go-name": "Description" + }, + "details": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "x-go-name": "Details" + }, + "group": { + "type": "string", + "x-go-name": "Group" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "images": { + "items": { + "$ref": "#/definitions/PagerdutyImage" + }, + "type": "array", + "x-go-name": "Images" + }, + "links": { + "items": { + "$ref": "#/definitions/PagerdutyLink" + }, + "type": "array", + "x-go-name": "Links" + }, + "routing_key": { + "$ref": "#/definitions/Secret" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "service_key": { + "$ref": "#/definitions/Secret" + }, + "severity": { + "type": "string", + "x-go-name": "Severity" + }, + "url": { + "$ref": "#/definitions/URL" + } + }, + "title": "PagerdutyConfig configures notifications via PagerDuty.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PagerdutyImage": { + "description": "PagerdutyImage is an image", + "properties": { + "alt": { + "type": "string", + "x-go-name": "Alt" + }, + "href": { + "type": "string", + "x-go-name": "Href" + }, + "src": { + "type": "string", + "x-go-name": "Src" + } + }, + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PagerdutyLink": { + "description": "PagerdutyLink is a link", + "properties": { + "href": { + "type": "string", + "x-go-name": "Href" + }, + "text": { + "type": "string", + "x-go-name": "Text" + } + }, + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "PermissionType": { + "format": "int64", + "type": "integer", + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "Permissions": { + "items": { + "$ref": "#/definitions/UpdateDashboardAclCommand" + }, + "type": "array", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Point": { + "properties": { + "T": { + "format": "int64", + "type": "integer" + }, + "V": { + "format": "double", + "type": "number" + } + }, + "title": "Point represents a single data point for a given timestamp.", + "type": "object", + "x-go-package": "github.com/prometheus/prometheus/promql" + }, + "PushoverConfig": { + "properties": { + "expire": { + "$ref": "#/definitions/duration" + }, + "html": { + "type": "boolean", + "x-go-name": "HTML" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "priority": { + "type": "string", + "x-go-name": "Priority" + }, + "retry": { + "$ref": "#/definitions/duration" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "sound": { + "type": "string", + "x-go-name": "Sound" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "token": { + "$ref": "#/definitions/Secret" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "url_title": { + "type": "string", + "x-go-name": "URLTitle" + }, + "user_key": { + "$ref": "#/definitions/Secret" + } + }, + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "Receiver": { + "properties": { + "email_configs": { + "items": { + "$ref": "#/definitions/EmailConfig" + }, + "type": "array", + "x-go-name": "EmailConfigs" + }, + "name": { + "description": "A unique identifier for this receiver.", + "type": "string", + "x-go-name": "Name" + }, + "opsgenie_configs": { + "items": { + "$ref": "#/definitions/OpsGenieConfig" + }, + "type": "array", + "x-go-name": "OpsGenieConfigs" + }, + "pagerduty_configs": { + "items": { + "$ref": "#/definitions/PagerdutyConfig" + }, + "type": "array", + "x-go-name": "PagerdutyConfigs" + }, + "pushover_configs": { + "items": { + "$ref": "#/definitions/PushoverConfig" + }, + "type": "array", + "x-go-name": "PushoverConfigs" + }, + "slack_configs": { + "items": { + "$ref": "#/definitions/SlackConfig" + }, + "type": "array", + "x-go-name": "SlackConfigs" + }, + "victorops_configs": { + "items": { + "$ref": "#/definitions/VictorOpsConfig" + }, + "type": "array", + "x-go-name": "VictorOpsConfigs" + }, + "webhook_configs": { + "items": { + "$ref": "#/definitions/WebhookConfig" + }, + "type": "array", + "x-go-name": "WebhookConfigs" + }, + "wechat_configs": { + "items": { + "$ref": "#/definitions/WechatConfig" + }, + "type": "array", + "x-go-name": "WechatConfigs" + } + }, + "title": "Receiver configuration provides configuration on how to contact a receiver.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "Regexp": { + "description": "A Regexp is safe for concurrent use by multiple goroutines,\nexcept for configuration methods, such as Longest.", + "title": "Regexp is the representation of a compiled regular expression.", + "type": "object", + "x-go-package": "regexp" + }, + "RelativeTimeRange": { + "description": "RelativeTimeRange is the per query start and end time\nfor requests.", + "properties": { + "from": { + "$ref": "#/definitions/Duration" + }, + "to": { + "$ref": "#/definitions/Duration" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/eval" + }, + "ResponseDetails": { + "properties": { + "msg": { + "type": "string", + "x-go-name": "Msg" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RoleType": { + "type": "string", + "x-go-package": "github.com/grafana/grafana/pkg/models" + }, + "Route": { + "properties": { + "continue": { + "type": "boolean", + "x-go-name": "Continue" + }, + "group_by": { + "items": { + "type": "string" + }, + "type": "array", + "x-go-name": "GroupByStr" + }, + "group_interval": { + "$ref": "#/definitions/Duration" + }, + "group_wait": { + "$ref": "#/definitions/Duration" + }, + "match": { + "additionalProperties": { + "type": "string" + }, + "description": "Deprecated. Remove before v1.0 release.", + "type": "object", + "x-go-name": "Match" + }, + "match_re": { + "$ref": "#/definitions/MatchRegexps" + }, + "matchers": { + "$ref": "#/definitions/Matchers" + }, + "receiver": { + "type": "string", + "x-go-name": "Receiver" + }, + "repeat_interval": { + "$ref": "#/definitions/Duration" + }, + "routes": { + "items": { + "$ref": "#/definitions/Route" + }, + "type": "array", + "x-go-name": "Routes" + } + }, + "title": "A Route is a node that contains definitions of how to handle alerts.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "Rule": { + "description": "adapted from cortex", + "properties": { + "evaluationTime": { + "format": "double", + "type": "number", + "x-go-name": "EvaluationTime" + }, + "health": { + "type": "string", + "x-go-name": "Health" + }, + "labels": { + "$ref": "#/definitions/labels" + }, + "lastError": { + "type": "string", + "x-go-name": "LastError" + }, + "lastEvaluation": { + "format": "date-time", + "type": "string", + "x-go-name": "LastEvaluation" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "query": { + "type": "string", + "x-go-name": "Query" + }, + "type": { + "$ref": "#/definitions/RuleType" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleDiscovery": { + "properties": { + "groups": { + "items": { + "$ref": "#/definitions/RuleGroup" + }, + "type": "array", + "x-go-name": "RuleGroups" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleGroup": { + "properties": { + "evaluationTime": { + "format": "double", + "type": "number", + "x-go-name": "EvaluationTime" + }, + "file": { + "type": "string", + "x-go-name": "File" + }, + "interval": { + "format": "double", + "type": "number", + "x-go-name": "Interval" + }, + "lastEvaluation": { + "format": "date-time", + "type": "string", + "x-go-name": "LastEvaluation" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "rules": { + "description": "In order to preserve rule ordering, while exposing type (alerting or recording)\nspecific properties, both alerting and recording rules are exposed in the\nsame array.", + "items": { + "$ref": "#/definitions/AlertingRule" + }, + "type": "array", + "x-go-name": "Rules" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleGroupConfig": { + "properties": { + "interval": { + "$ref": "#/definitions/Duration" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "rules": { + "items": { + "$ref": "#/definitions/ExtendedRuleNode" + }, + "type": "array", + "x-go-name": "Rules" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleGroupConfigResponse": { + "properties": { + "interval": { + "$ref": "#/definitions/Duration" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "rules": { + "items": { + "$ref": "#/definitions/ExtendedRuleNode" + }, + "type": "array", + "x-go-name": "Rules" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleResponse": { + "properties": { + "Body": { + "description": "in: body", + "properties": { + "data": { + "$ref": "#/definitions/RuleDiscovery" + }, + "error": { + "type": "string", + "x-go-name": "Error" + }, + "errorType": { + "$ref": "#/definitions/ErrorType" + }, + "status": { + "type": "string", + "x-go-name": "Status" + } + }, + "type": "object" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "RuleType": { + "title": "RuleType models the type of a rule.", + "type": "string", + "x-go-package": "github.com/prometheus/client_golang/api/prometheus/v1" + }, + "Sample": { + "properties": { + "Metric": { + "$ref": "#/definitions/Labels" + }, + "T": { + "format": "int64", + "type": "integer" + }, + "V": { + "format": "double", + "type": "number" + } + }, + "title": "Sample is a single sample belonging to a metric.", + "type": "object", + "x-go-package": "github.com/prometheus/prometheus/promql" + }, + "Secret": { + "title": "Secret special type for storing secrets.", + "type": "string", + "x-go-package": "github.com/prometheus/common/config" + }, + "SecretURL": { + "$ref": "#/definitions/URL", + "title": "SecretURL is a URL that must not be revealed on marshaling." + }, + "SecureJsonData": { + "additionalProperties": { + "items": { + "format": "uint8", + "type": "integer" + }, + "type": "array" + }, + "description": "SecureJsonData is used to store encrypted data (for example in data_source table). Only values are separately\nencrypted.", + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/components/securejsondata" + }, + "SilenceBody": { + "properties": { + "comment": { + "description": "comment", + "type": "string", + "x-go-name": "Comment" + }, + "createdBy": { + "description": "created by", + "type": "string", + "x-go-name": "CreatedBy" + }, + "endsAt": { + "description": "ends at", + "format": "date-time", + "type": "string", + "x-go-name": "EndsAt" + }, + "id": { + "type": "string", + "x-go-name": "Id" + }, + "matchers": { + "$ref": "#/definitions/matchers" + }, + "startsAt": { + "description": "starts at", + "format": "date-time", + "type": "string", + "x-go-name": "StartsAt" + } + }, + "required": [ + "comment", + "createdBy", + "endsAt", + "matchers", + "startsAt" + ], + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/tst" + }, + "SlackAction": { + "description": "See https://api.slack.com/docs/message-attachments#action_fields and https://api.slack.com/docs/message-buttons\nfor more information.", + "properties": { + "confirm": { + "$ref": "#/definitions/SlackConfirmationField" + }, + "name": { + "type": "string", + "x-go-name": "Name" + }, + "style": { + "type": "string", + "x-go-name": "Style" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "type": { + "type": "string", + "x-go-name": "Type" + }, + "url": { + "type": "string", + "x-go-name": "URL" + }, + "value": { + "type": "string", + "x-go-name": "Value" + } + }, + "title": "SlackAction configures a single Slack action that is sent with each notification.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SlackConfig": { + "properties": { + "actions": { + "items": { + "$ref": "#/definitions/SlackAction" + }, + "type": "array", + "x-go-name": "Actions" + }, + "api_url": { + "$ref": "#/definitions/SecretURL" + }, + "callback_id": { + "type": "string", + "x-go-name": "CallbackID" + }, + "channel": { + "description": "Slack channel override, (like #other-channel or @username).", + "type": "string", + "x-go-name": "Channel" + }, + "color": { + "type": "string", + "x-go-name": "Color" + }, + "fallback": { + "type": "string", + "x-go-name": "Fallback" + }, + "fields": { + "items": { + "$ref": "#/definitions/SlackField" + }, + "type": "array", + "x-go-name": "Fields" + }, + "footer": { + "type": "string", + "x-go-name": "Footer" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "icon_emoji": { + "type": "string", + "x-go-name": "IconEmoji" + }, + "icon_url": { + "type": "string", + "x-go-name": "IconURL" + }, + "image_url": { + "type": "string", + "x-go-name": "ImageURL" + }, + "link_names": { + "type": "boolean", + "x-go-name": "LinkNames" + }, + "mrkdwn_in": { + "items": { + "type": "string" + }, + "type": "array", + "x-go-name": "MrkdwnIn" + }, + "pretext": { + "type": "string", + "x-go-name": "Pretext" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "short_fields": { + "type": "boolean", + "x-go-name": "ShortFields" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "thumb_url": { + "type": "string", + "x-go-name": "ThumbURL" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "title_link": { + "type": "string", + "x-go-name": "TitleLink" + }, + "username": { + "type": "string", + "x-go-name": "Username" + } + }, + "title": "SlackConfig configures notifications via Slack.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SlackConfirmationField": { + "description": "SlackConfirmationField protect users from destructive actions or particularly distinguished decisions\nby asking them to confirm their button click one more time.\nSee https://api.slack.com/docs/interactive-message-field-guide#confirmation_fields for more information.", + "properties": { + "dismiss_text": { + "type": "string", + "x-go-name": "DismissText" + }, + "ok_text": { + "type": "string", + "x-go-name": "OkText" + }, + "text": { + "type": "string", + "x-go-name": "Text" + }, + "title": { + "type": "string", + "x-go-name": "Title" + } + }, + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SlackField": { + "description": "Each field must contain a title, value, and optionally, a boolean value to indicate if the field\nis short enough to be displayed next to other fields designated as short.\nSee https://api.slack.com/docs/message-attachments#fields for more information.", + "properties": { + "short": { + "type": "boolean", + "x-go-name": "Short" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "value": { + "type": "string", + "x-go-name": "Value" + } + }, + "title": "SlackField configures a single Slack field that is sent with each notification.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "SmtpNotEnabled": { + "$ref": "#/definitions/ResponseDetails" + }, + "Success": { + "$ref": "#/definitions/ResponseDetails" + }, + "TLSConfig": { + "properties": { + "CAFile": { + "description": "The CA cert to use for the targets.", + "type": "string" + }, + "CertFile": { + "description": "The client cert file for the targets.", + "type": "string" + }, + "InsecureSkipVerify": { + "description": "Disable target certificate validation.", + "type": "boolean" + }, + "KeyFile": { + "description": "The client key file for the targets.", + "type": "string" + }, + "ServerName": { + "description": "Used to verify the hostname for the targets.", + "type": "string" + } + }, + "title": "TLSConfig configures the options for TLS connections.", + "type": "object", + "x-go-package": "github.com/prometheus/common/config" + }, + "TestRulePayload": { + "properties": { + "expr": { + "$ref": "#/definitions/LotexQuery" + }, + "grafana_condition": { + "$ref": "#/definitions/EvalAlertConditionCommand" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "TestRuleResponse": { + "properties": { + "alerts": { + "$ref": "#/definitions/Vector" + }, + "grafana_alert_instances": { + "$ref": "#/definitions/AlertInstancesResponse" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "URL": { + "description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.", + "properties": { + "ForceQuery": { + "type": "boolean" + }, + "Fragment": { + "type": "string" + }, + "Host": { + "type": "string" + }, + "Opaque": { + "type": "string" + }, + "Path": { + "type": "string" + }, + "RawFragment": { + "type": "string" + }, + "RawPath": { + "type": "string" + }, + "RawQuery": { + "type": "string" + }, + "Scheme": { + "type": "string" + }, + "User": { + "$ref": "#/definitions/Userinfo" + } + }, + "title": "A URL represents a parsed URL (technically, a URI reference).", + "type": "object", + "x-go-package": "net/url" + }, + "UpdateDashboardAclCommand": { + "properties": { + "items": { + "items": { + "$ref": "#/definitions/DashboardAclUpdateItem" + }, + "type": "array", + "x-go-name": "Items" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/grafana/pkg/api/dtos" + }, + "UpsertAlertDefinitionCommand": { + "description": "https://github.com/grafana/grafana/blob/debb82e12417e82a0e2bd09e1a450065f884c1bc/pkg/services/ngalert/models.go#L85", + "properties": { + "condition": { + "description": "Condition is the refID of the query or expression to be evaluated", + "type": "string", + "x-go-name": "Condition" + }, + "data": { + "description": "Data is an array of the queries and expressions", + "items": { + "$ref": "#/definitions/AlertQuery" + }, + "type": "array", + "x-go-name": "Data" + }, + "title": { + "type": "string", + "x-go-name": "Title" + }, + "uid": { + "description": "UID is set only for existing definitions", + "type": "string", + "x-go-name": "UID" + } + }, + "title": "UpsertAlertDefinitionCommand is copy of the unexported struct:", + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "UserConfig": { + "properties": { + "alertmanager_config": { + "$ref": "#/definitions/ApiAlertingConfig" + }, + "template_files": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "x-go-name": "TemplateFiles" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/tst" + }, + "Userinfo": { + "description": "The Userinfo type is an immutable encapsulation of username and\npassword details for a URL. An existing Userinfo value is guaranteed\nto have a username set (potentially empty, as allowed by RFC 2396),\nand optionally a password.", + "type": "object", + "x-go-package": "net/url" + }, + "ValidationError": { + "properties": { + "msg": { + "type": "string", + "x-go-name": "Msg" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "Vector": { + "description": "Vector is basically only an alias for model.Samples, but the\ncontract is that in a Vector, all Samples have the same timestamp.", + "items": { + "$ref": "#/definitions/Sample" + }, + "type": "array", + "x-go-package": "github.com/prometheus/prometheus/promql" + }, + "VictorOpsConfig": { + "properties": { + "api_key": { + "$ref": "#/definitions/Secret" + }, + "api_url": { + "$ref": "#/definitions/URL" + }, + "custom_fields": { + "additionalProperties": { + "type": "string" + }, + "type": "object", + "x-go-name": "CustomFields" + }, + "entity_display_name": { + "type": "string", + "x-go-name": "EntityDisplayName" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message_type": { + "type": "string", + "x-go-name": "MessageType" + }, + "monitoring_tool": { + "type": "string", + "x-go-name": "MonitoringTool" + }, + "routing_key": { + "type": "string", + "x-go-name": "RoutingKey" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "state_message": { + "type": "string", + "x-go-name": "StateMessage" + } + }, + "title": "VictorOpsConfig configures notifications via VictorOps.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "WebhookConfig": { + "properties": { + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "max_alerts": { + "description": "MaxAlerts is the maximum number of alerts to be sent per webhook message.\nAlerts exceeding this threshold will be truncated. Setting this to 0\nallows an unlimited number of alerts.", + "format": "uint64", + "type": "integer", + "x-go-name": "MaxAlerts" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "url": { + "$ref": "#/definitions/URL" + } + }, + "title": "WebhookConfig configures notifications via a generic webhook.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "WechatConfig": { + "properties": { + "agent_id": { + "type": "string", + "x-go-name": "AgentID" + }, + "api_secret": { + "$ref": "#/definitions/Secret" + }, + "api_url": { + "$ref": "#/definitions/URL" + }, + "corp_id": { + "type": "string", + "x-go-name": "CorpID" + }, + "http_config": { + "$ref": "#/definitions/HTTPClientConfig" + }, + "message": { + "type": "string", + "x-go-name": "Message" + }, + "message_type": { + "type": "string", + "x-go-name": "MessageType" + }, + "send_resolved": { + "type": "boolean", + "x-go-name": "VSendResolved" + }, + "to_party": { + "type": "string", + "x-go-name": "ToParty" + }, + "to_tag": { + "type": "string", + "x-go-name": "ToTag" + }, + "to_user": { + "type": "string", + "x-go-name": "ToUser" + } + }, + "title": "WechatConfig configures notifications via Wechat.", + "type": "object", + "x-go-package": "github.com/prometheus/alertmanager/config" + }, + "alert": { + "description": "Alert alert", + "properties": { + "generatorURL": { + "description": "generator URL\nFormat: uri", + "format": "uri", + "type": "string", + "x-go-name": "GeneratorURL" + }, + "labels": { + "$ref": "#/definitions/labelSet" + } + }, + "required": [ + "labels" + ], + "type": "object", + "x-go-name": "Alert", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertGroup": { + "description": "AlertGroup alert group", + "properties": { + "alerts": { + "description": "alerts", + "items": { + "$ref": "#/definitions/gettableAlert" + }, + "type": "array", + "x-go-name": "Alerts" + }, + "labels": { + "$ref": "#/definitions/labelSet" + }, + "receiver": { + "$ref": "#/definitions/receiver" + } + }, + "required": [ + "alerts", + "labels", + "receiver" + ], + "type": "object", + "x-go-name": "AlertGroup", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertGroups": { + "description": "AlertGroups alert groups", + "items": { + "$ref": "#/definitions/alertGroup" + }, + "type": "array", + "x-go-name": "AlertGroups", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertStatus": { + "description": "AlertStatus alert status", + "properties": { + "inhibitedBy": { + "description": "inhibited by", + "items": { + "type": "string" + }, + "type": "array", + "x-go-name": "InhibitedBy" + }, + "silencedBy": { + "description": "silenced by", + "items": { + "type": "string" + }, + "type": "array", + "x-go-name": "SilencedBy" + }, + "state": { + "description": "state", + "enum": [ + "[unprocessed active suppressed]" + ], + "type": "string", + "x-go-name": "State" + } + }, + "required": [ + "inhibitedBy", + "silencedBy", + "state" + ], + "type": "object", + "x-go-name": "AlertStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertmanagerConfig": { + "description": "AlertmanagerConfig alertmanager config", + "properties": { + "original": { + "description": "original", + "type": "string", + "x-go-name": "Original" + } + }, + "required": [ + "original" + ], + "type": "object", + "x-go-name": "AlertmanagerConfig", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "alertmanagerStatus": { + "description": "AlertmanagerStatus alertmanager status", + "properties": { + "cluster": { + "$ref": "#/definitions/clusterStatus" + }, + "config": { + "$ref": "#/definitions/alertmanagerConfig" + }, + "uptime": { + "description": "uptime", + "format": "date-time", + "type": "string", + "x-go-name": "Uptime" + }, + "versionInfo": { + "$ref": "#/definitions/versionInfo" + } + }, + "required": [ + "cluster", + "config", + "uptime", + "versionInfo" + ], + "type": "object", + "x-go-name": "AlertmanagerStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "clusterStatus": { + "description": "ClusterStatus cluster status", + "properties": { + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + }, + "peers": { + "description": "peers", + "items": { + "$ref": "#/definitions/peerStatus" + }, + "type": "array", + "x-go-name": "Peers" + }, + "status": { + "description": "status", + "enum": [ + "[ready settling disabled]" + ], + "type": "string", + "x-go-name": "Status" + } + }, + "required": [ + "status" + ], + "type": "object", + "x-go-name": "ClusterStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "discoveryBase": { + "properties": { + "error": { + "type": "string", + "x-go-name": "Error" + }, + "errorType": { + "$ref": "#/definitions/ErrorType" + }, + "status": { + "type": "string", + "x-go-name": "Status" + } + }, + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "duration": { + "$ref": "#/definitions/Duration" + }, + "gettableAlert": { + "description": "GettableAlert gettable alert", + "properties": { + "annotations": { + "$ref": "#/definitions/labelSet" + }, + "endsAt": { + "description": "ends at", + "format": "date-time", + "type": "string", + "x-go-name": "EndsAt" + }, + "fingerprint": { + "description": "fingerprint", + "type": "string", + "x-go-name": "Fingerprint" + }, + "generatorURL": { + "description": "generator URL\nFormat: uri", + "format": "uri", + "type": "string", + "x-go-name": "GeneratorURL" + }, + "labels": { + "$ref": "#/definitions/labelSet" + }, + "receivers": { + "description": "receivers", + "items": { + "$ref": "#/definitions/receiver" + }, + "type": "array", + "x-go-name": "Receivers" + }, + "startsAt": { + "description": "starts at", + "format": "date-time", + "type": "string", + "x-go-name": "StartsAt" + }, + "status": { + "$ref": "#/definitions/alertStatus" + }, + "updatedAt": { + "description": "updated at", + "format": "date-time", + "type": "string", + "x-go-name": "UpdatedAt" + } + }, + "required": [ + "labels", + "annotations", + "endsAt", + "fingerprint", + "receivers", + "startsAt", + "status", + "updatedAt" + ], + "type": "object", + "x-go-name": "GettableAlert", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "gettableAlerts": { + "description": "GettableAlerts gettable alerts", + "items": { + "$ref": "#/definitions/gettableAlert" + }, + "type": "array", + "x-go-name": "GettableAlerts", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "gettableSilence": { + "description": "GettableSilence gettable silence", + "properties": { + "comment": { + "description": "comment", + "type": "string", + "x-go-name": "Comment" + }, + "createdBy": { + "description": "created by", + "type": "string", + "x-go-name": "CreatedBy" + }, + "endsAt": { + "description": "ends at", + "format": "date-time", + "type": "string", + "x-go-name": "EndsAt" + }, + "id": { + "description": "id", + "type": "string", + "x-go-name": "ID" + }, + "matchers": { + "$ref": "#/definitions/matchers" + }, + "startsAt": { + "description": "starts at", + "format": "date-time", + "type": "string", + "x-go-name": "StartsAt" + }, + "status": { + "$ref": "#/definitions/silenceStatus" + }, + "updatedAt": { + "description": "updated at", + "format": "date-time", + "type": "string", + "x-go-name": "UpdatedAt" + } + }, + "required": [ + "comment", + "createdBy", + "endsAt", + "matchers", + "startsAt", + "id", + "status", + "updatedAt" + ], + "type": "object", + "x-go-name": "GettableSilence", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "gettableSilences": { + "description": "GettableSilences gettable silences", + "items": { + "$ref": "#/definitions/gettableSilence" + }, + "type": "array", + "x-go-name": "GettableSilences", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "labelSet": { + "additionalProperties": { + "type": "string" + }, + "description": "LabelSet label set", + "type": "object", + "x-go-name": "LabelSet", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "labels": { + "additionalProperties": { + "type": "string" + }, + "description": "The custom marshaling for labels.Labels ends up doing this anyways.", + "title": "override the labels type with a map for generation.", + "type": "object", + "x-go-package": "github.com/grafana/alerting-api/pkg/api" + }, + "matcher": { + "description": "Matcher matcher", + "properties": { + "isRegex": { + "description": "is regex", + "type": "boolean", + "x-go-name": "IsRegex" + }, + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + }, + "value": { + "description": "value", + "type": "string", + "x-go-name": "Value" + } + }, + "required": [ + "isRegex", + "name", + "value" + ], + "type": "object", + "x-go-name": "Matcher", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "matchers": { + "description": "Matchers matchers", + "items": { + "$ref": "#/definitions/matcher" + }, + "type": "array", + "x-go-name": "Matchers", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "peerStatus": { + "description": "PeerStatus peer status", + "properties": { + "address": { + "description": "address", + "type": "string", + "x-go-name": "Address" + }, + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + } + }, + "required": [ + "address", + "name" + ], + "type": "object", + "x-go-name": "PeerStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "postableAlert": { + "description": "PostableAlert postable alert", + "properties": { + "annotations": { + "$ref": "#/definitions/labelSet" + }, + "endsAt": { + "description": "ends at\nFormat: date-time", + "format": "date-time", + "type": "string", + "x-go-name": "EndsAt" + }, + "generatorURL": { + "description": "generator URL\nFormat: uri", + "format": "uri", + "type": "string", + "x-go-name": "GeneratorURL" + }, + "labels": { + "$ref": "#/definitions/labelSet" + }, + "startsAt": { + "description": "starts at\nFormat: date-time", + "format": "date-time", + "type": "string", + "x-go-name": "StartsAt" + } + }, + "required": [ + "labels" + ], + "type": "object", + "x-go-name": "PostableAlert", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "postableAlerts": { + "description": "PostableAlerts postable alerts", + "items": { + "$ref": "#/definitions/postableAlert" + }, + "type": "array", + "x-go-name": "PostableAlerts", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "postableSilence": { + "description": "PostableSilence postable silence", + "properties": { + "comment": { + "description": "comment", + "type": "string", + "x-go-name": "Comment" + }, + "createdBy": { + "description": "created by", + "type": "string", + "x-go-name": "CreatedBy" + }, + "endsAt": { + "description": "ends at", + "format": "date-time", + "type": "string", + "x-go-name": "EndsAt" + }, + "id": { + "description": "id", + "type": "string", + "x-go-name": "ID" + }, + "matchers": { + "$ref": "#/definitions/matchers" + }, + "startsAt": { + "description": "starts at", + "format": "date-time", + "type": "string", + "x-go-name": "StartsAt" + } + }, + "required": [ + "comment", + "createdBy", + "endsAt", + "matchers", + "startsAt" + ], + "type": "object", + "x-go-name": "PostableSilence", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "receiver": { + "description": "Receiver receiver", + "properties": { + "name": { + "description": "name", + "type": "string", + "x-go-name": "Name" + } + }, + "required": [ + "name" + ], + "type": "object", + "x-go-name": "Receiver", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "silence": { + "description": "Silence silence", + "properties": { + "comment": { + "description": "comment", + "type": "string", + "x-go-name": "Comment" + }, + "createdBy": { + "description": "created by", + "type": "string", + "x-go-name": "CreatedBy" + }, + "endsAt": { + "description": "ends at", + "format": "date-time", + "type": "string", + "x-go-name": "EndsAt" + }, + "matchers": { + "$ref": "#/definitions/matchers" + }, + "startsAt": { + "description": "starts at", + "format": "date-time", + "type": "string", + "x-go-name": "StartsAt" + } + }, + "required": [ + "comment", + "createdBy", + "endsAt", + "matchers", + "startsAt" + ], + "type": "object", + "x-go-name": "Silence", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "silenceStatus": { + "description": "SilenceStatus silence status", + "properties": { + "state": { + "description": "state", + "enum": [ + "[expired active pending]" + ], + "type": "string", + "x-go-name": "State" + } + }, + "required": [ + "state" + ], + "type": "object", + "x-go-name": "SilenceStatus", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + }, + "versionInfo": { + "description": "VersionInfo version info", + "properties": { + "branch": { + "description": "branch", + "type": "string", + "x-go-name": "Branch" + }, + "buildDate": { + "description": "build date", + "type": "string", + "x-go-name": "BuildDate" + }, + "buildUser": { + "description": "build user", + "type": "string", + "x-go-name": "BuildUser" + }, + "goVersion": { + "description": "go version", + "type": "string", + "x-go-name": "GoVersion" + }, + "revision": { + "description": "revision", + "type": "string", + "x-go-name": "Revision" + }, + "version": { + "description": "version", + "type": "string", + "x-go-name": "Version" + } + }, + "required": [ + "branch", + "buildDate", + "buildUser", + "goVersion", + "revision", + "version" + ], + "type": "object", + "x-go-name": "VersionInfo", + "x-go-package": "github.com/prometheus/alertmanager/api/v2/models" + } + }, + "info": { + "title": "Documentation of the API.", + "version": "1.0.0" + }, + "paths": { + "/alertmanager/{DatasourceId}/api/v2/alerts": { + "get": { + "description": "get alertmanager alerts", + "operationId": "RouteGetAmAlerts", + "parameters": [ + { + "description": "Show active alerts", + "in": "query", + "name": "active", + "type": "boolean", + "x-go-name": "Active" + }, + { + "description": "Show silenced alerts", + "in": "query", + "name": "silenced", + "type": "boolean", + "x-go-name": "Silenced" + }, + { + "description": "Show inhibited alerts", + "in": "query", + "name": "inhibited", + "type": "boolean", + "x-go-name": "Inhibited" + }, + { + "description": "A list of matchers to filter alerts by", + "in": "query", + "items": { + "type": "string" + }, + "name": "matchers", + "type": "array", + "x-go-name": "Matchers" + }, + { + "description": "A list of receivers to filter alerts by", + "in": "query", + "items": { + "type": "string" + }, + "name": "receivers", + "type": "array", + "x-go-name": "Receivers" + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "GettableAlerts", + "schema": { + "$ref": "#/definitions/GettableAlerts" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "alertmanager" + ] + }, + "post": { + "description": "create alertmanager alerts", + "operationId": "RoutePostAmAlerts", + "parameters": [ + { + "in": "body", + "name": "PostableAlerts", + "schema": { + "items": { + "$ref": "#/definitions/postableAlert" + }, + "type": "array" + } + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "alertmanager" + ] + } + }, + "/alertmanager/{DatasourceId}/api/v2/alerts/groups": { + "get": { + "description": "get alertmanager alerts", + "operationId": "RouteGetAmAlertGroups", + "parameters": [ + { + "description": "Show active alerts", + "in": "query", + "name": "active", + "type": "boolean", + "x-go-name": "Active" + }, + { + "description": "Show silenced alerts", + "in": "query", + "name": "silenced", + "type": "boolean", + "x-go-name": "Silenced" + }, + { + "description": "Show inhibited alerts", + "in": "query", + "name": "inhibited", + "type": "boolean", + "x-go-name": "Inhibited" + }, + { + "description": "A list of matchers to filter alerts by", + "in": "query", + "items": { + "type": "string" + }, + "name": "matchers", + "type": "array", + "x-go-name": "Matchers" + }, + { + "description": "A list of receivers to filter alerts by", + "in": "query", + "items": { + "type": "string" + }, + "name": "receivers", + "type": "array", + "x-go-name": "Receivers" + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "AlertGroups", + "schema": { + "$ref": "#/definitions/AlertGroups" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "alertmanager" + ] + } + }, + "/alertmanager/{DatasourceId}/api/v2/silence/{SilenceId}": { + "delete": { + "description": "delete silence", + "operationId": "RouteDeleteSilence", + "parameters": [ + { + "in": "path", + "name": "SilenceId", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "alertmanager" + ] + }, + "get": { + "description": "get silence", + "operationId": "RouteGetSilence", + "parameters": [ + { + "in": "path", + "name": "SilenceId", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "GettableSilence", + "schema": { + "$ref": "#/definitions/GettableSilence" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "alertmanager" + ] + } + }, + "/alertmanager/{DatasourceId}/api/v2/silences": { + "get": { + "description": "get silences", + "operationId": "RouteGetSilences", + "parameters": [ + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "GettableSilences", + "schema": { + "$ref": "#/definitions/GettableSilences" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "alertmanager" + ] + }, + "post": { + "description": "create silence", + "operationId": "RouteCreateSilence", + "parameters": [ + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/SilenceBody" + } + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "201": { + "description": "GettableSilence", + "schema": { + "$ref": "#/definitions/GettableSilence" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "alertmanager" + ] + } + }, + "/alertmanager/{DatasourceId}/config/api/v1/alerts": { + "delete": { + "description": "deletes the Alerting config for a tenant", + "operationId": "RouteDeleteAlertingConfig", + "parameters": [ + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "alertmanager" + ] + }, + "get": { + "description": "gets an Alerting config", + "operationId": "RouteGetAlertingConfig", + "parameters": [ + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "AlertingConfigResponse", + "schema": { + "$ref": "#/definitions/AlertingConfigResponse" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "alertmanager" + ] + }, + "post": { + "description": "sets an Alerting config", + "operationId": "RoutePostAlertingConfig", + "parameters": [ + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/UserConfig" + } + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "201": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "alertmanager" + ] + } + }, + "/api/v1/namespace/{Namespace}/permissions": { + "get": { + "description": "sets an Alerting config", + "operationId": "RouteGetNamespacePermissions", + "parameters": [ + { + "description": "Namespace name", + "in": "path", + "name": "Namespace", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "Permissions", + "schema": { + "$ref": "#/definitions/Permissions" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "permissions" + ] + }, + "post": { + "description": "gets an Alerting config", + "operationId": "RouteSetNamespacePermissions", + "parameters": [ + { + "description": "Namespace name to apply perms to", + "in": "path", + "name": "Namespace", + "required": true, + "type": "string" + }, + { + "description": "New namespace permissions", + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/Permissions" + } + } + ], + "responses": { + "201": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + }, + "400": { + "description": "ValidationError", + "schema": { + "$ref": "#/definitions/ValidationError" + } + } + }, + "tags": [ + "permissions" + ] + } + }, + "/api/v1/receiver/test": { + "get": { + "consumes": [ + "application/json" + ], + "description": "Test receiver", + "operationId": "RouteTestReceiverConfig", + "parameters": [ + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/ExtendedReceiver" + } + } + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "Success", + "schema": { + "$ref": "#/definitions/Success" + } + }, + "412": { + "description": "SmtpNotEnabled", + "schema": { + "$ref": "#/definitions/SmtpNotEnabled" + } + }, + "500": { + "description": "Failure", + "schema": { + "$ref": "#/definitions/Failure" + } + } + }, + "tags": [ + "testing" + ] + } + }, + "/api/v1/rule/test": { + "get": { + "consumes": [ + "application/json" + ], + "description": "Test rule", + "operationId": "RouteTestRuleConfig", + "parameters": [ + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/TestRulePayload" + } + } + ], + "produces": [ + "application/json" + ], + "responses": { + "200": { + "description": "TestRuleResponse", + "schema": { + "$ref": "#/definitions/TestRuleResponse" + } + } + }, + "tags": [ + "testing" + ] + } + }, + "/prometheus/{DatasourceId}/api/v1/alerts": { + "get": { + "description": "gets the current alerts", + "operationId": "RouteGetAlertStatuses", + "parameters": [ + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "AlertResponse", + "schema": { + "$ref": "#/definitions/AlertResponse" + } + } + }, + "tags": [ + "prometheus" + ] + } + }, + "/prometheus/{DatasourceId}/api/v1/rules": { + "get": { + "description": "gets the evaluation statuses of all rules", + "operationId": "RouteGetRuleStatuses", + "parameters": [ + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "200": { + "description": "RuleResponse", + "schema": { + "$ref": "#/definitions/RuleResponse" + } + } + }, + "tags": [ + "prometheus" + ] + } + }, + "/ruler/{DatasourceId}/api/v1/rules": { + "get": { + "description": "List rule groups", + "operationId": "RouteGetRulesConfig", + "parameters": [ + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "202": { + "description": "NamespaceConfigResponse", + "schema": { + "$ref": "#/definitions/NamespaceConfigResponse" + } + } + }, + "tags": [ + "ruler" + ] + } + }, + "/ruler/{DatasourceId}/api/v1/rules/{Namespace}": { + "delete": { + "description": "Delete namespace", + "operationId": "RouteDeleteNamespaceRulesConfig", + "parameters": [ + { + "in": "path", + "name": "Namespace", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "202": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + } + }, + "tags": [ + "ruler" + ] + }, + "get": { + "description": "Get rule groups by namespace", + "operationId": "RouteGetNamespaceRulesConfig", + "parameters": [ + { + "in": "path", + "name": "Namespace", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "202": { + "description": "NamespaceConfigResponse", + "schema": { + "$ref": "#/definitions/NamespaceConfigResponse" + } + } + }, + "tags": [ + "ruler" + ] + }, + "post": { + "consumes": [ + "application/json", + "application/yaml" + ], + "description": "Creates or updates a rule group", + "operationId": "RoutePostNameRulesConfig", + "parameters": [ + { + "in": "path", + "name": "Namespace", + "required": true, + "type": "string" + }, + { + "in": "body", + "name": "Body", + "schema": { + "$ref": "#/definitions/RuleGroupConfig" + } + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "202": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + } + }, + "tags": [ + "ruler" + ] + } + }, + "/ruler/{DatasourceId}/api/v1/rules/{Namespace}/{Groupname}": { + "delete": { + "description": "Delete rule group", + "operationId": "RouteDeleteRuleGroupConfig", + "parameters": [ + { + "in": "path", + "name": "Namespace", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "Groupname", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "responses": { + "202": { + "description": "Ack", + "schema": { + "$ref": "#/definitions/Ack" + } + } + }, + "tags": [ + "ruler" + ] + }, + "get": { + "description": "Get rule group", + "operationId": "RouteGetRulegGroupConfig", + "parameters": [ + { + "in": "path", + "name": "Namespace", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "Groupname", + "required": true, + "type": "string" + }, + { + "in": "path", + "name": "DatasourceId", + "required": true, + "type": "string" + } + ], + "produces": [ + "application/json" + ], + "responses": { + "202": { + "description": "RuleGroupConfigResponse", + "schema": { + "$ref": "#/definitions/RuleGroupConfigResponse" + } + } + }, + "tags": [ + "ruler" + ] + } + } + }, + "produces": [ + "application/json" + ], + "schemes": [ + "http", + "https" + ], + "securityDefinitions": { + "basic": { + "type": "basic" + } + }, + "swagger": "2.0" +} \ No newline at end of file diff --git a/spec.json b/spec.json index e877a10615d..e74adc4df04 100644 --- a/spec.json +++ b/spec.json @@ -671,13 +671,13 @@ "parameters": [ { "type": "string", - "name": "DatasourceId", + "name": "Namespace", "in": "path", "required": true }, { "type": "string", - "name": "Namespace", + "name": "DatasourceId", "in": "path", "required": true } @@ -702,12 +702,6 @@ ], "operationId": "RoutePostNameRulesConfig", "parameters": [ - { - "type": "string", - "name": "DatasourceId", - "in": "path", - "required": true - }, { "type": "string", "name": "Namespace", @@ -720,6 +714,12 @@ "schema": { "$ref": "#/definitions/RuleGroupConfig" } + }, + { + "type": "string", + "name": "DatasourceId", + "in": "path", + "required": true } ], "responses": { @@ -740,13 +740,13 @@ "parameters": [ { "type": "string", - "name": "DatasourceId", + "name": "Namespace", "in": "path", "required": true }, { "type": "string", - "name": "Namespace", + "name": "DatasourceId", "in": "path", "required": true } @@ -774,19 +774,19 @@ "parameters": [ { "type": "string", - "name": "DatasourceId", + "name": "Namespace", "in": "path", "required": true }, { "type": "string", - "name": "Namespace", + "name": "Groupname", "in": "path", "required": true }, { "type": "string", - "name": "Groupname", + "name": "DatasourceId", "in": "path", "required": true } @@ -809,19 +809,19 @@ "parameters": [ { "type": "string", - "name": "DatasourceId", + "name": "Namespace", "in": "path", "required": true }, { "type": "string", - "name": "Namespace", + "name": "Groupname", "in": "path", "required": true }, { "type": "string", - "name": "Groupname", + "name": "DatasourceId", "in": "path", "required": true } @@ -2521,7 +2521,7 @@ "x-go-name": "StartsAt" } }, - "x-go-package": "github.com/grafana/alerting-api/pkg/api" + "x-go-package": "github.com/grafana/alerting-api/pkg/tst" }, "SlackAction": { "description": "See https://api.slack.com/docs/message-attachments#action_fields and https://api.slack.com/docs/message-buttons\nfor more information.", @@ -2856,7 +2856,7 @@ "x-go-name": "TemplateFiles" } }, - "x-go-package": "github.com/grafana/alerting-api/pkg/api" + "x-go-package": "github.com/grafana/alerting-api/pkg/tst" }, "Userinfo": { "description": "The Userinfo type is an immutable encapsulation of username and\npassword details for a URL. An existing Userinfo value is guaranteed\nto have a username set (potentially empty, as allowed by RFC 2396),\nand optionally a password.",