alertmanager/api/v2/models/silence.go

258 lines
5.3 KiB
Go

// 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"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// Silence silence
// swagger:model silence
type Silence struct {
// comment
Comment string `json:"comment,omitempty"`
// created by
CreatedBy string `json:"createdBy,omitempty"`
// ends at
// Format: date-time
EndsAt strfmt.DateTime `json:"endsAt,omitempty"`
// id
ID string `json:"id,omitempty"`
// matchers
// Required: true
Matchers Matchers `json:"matchers"`
// starts at
// Format: date-time
StartsAt strfmt.DateTime `json:"startsAt,omitempty"`
// status
Status *SilenceStatus `json:"status,omitempty"`
// updated at
// Format: date-time
UpdatedAt strfmt.DateTime `json:"updatedAt,omitempty"`
}
// Validate validates this silence
func (m *Silence) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateEndsAt(formats); err != nil {
res = append(res, err)
}
if err := m.validateMatchers(formats); err != nil {
res = append(res, err)
}
if err := m.validateStartsAt(formats); err != nil {
res = append(res, err)
}
if err := m.validateStatus(formats); err != nil {
res = append(res, err)
}
if err := m.validateUpdatedAt(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Silence) 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 *Silence) validateMatchers(formats strfmt.Registry) error {
if err := validate.Required("matchers", "body", m.Matchers); err != nil {
return err
}
if err := m.Matchers.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("matchers")
}
return err
}
return nil
}
func (m *Silence) validateStartsAt(formats strfmt.Registry) error {
if 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 *Silence) validateStatus(formats strfmt.Registry) error {
if swag.IsZero(m.Status) { // not required
return nil
}
if m.Status != nil {
if err := m.Status.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("status")
}
return err
}
}
return nil
}
func (m *Silence) validateUpdatedAt(formats strfmt.Registry) error {
if swag.IsZero(m.UpdatedAt) { // not required
return nil
}
if err := validate.FormatOf("updatedAt", "body", "date-time", m.UpdatedAt.String(), formats); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *Silence) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Silence) UnmarshalBinary(b []byte) error {
var res Silence
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}
// SilenceStatus silence status
// swagger:model SilenceStatus
type SilenceStatus struct {
// state
// Enum: [expired active pending]
State string `json:"state,omitempty"`
}
// Validate validates this silence status
func (m *SilenceStatus) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateState(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var silenceStatusTypeStatePropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["expired","active","pending"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
silenceStatusTypeStatePropEnum = append(silenceStatusTypeStatePropEnum, v)
}
}
const (
// SilenceStatusStateExpired captures enum value "expired"
SilenceStatusStateExpired string = "expired"
// SilenceStatusStateActive captures enum value "active"
SilenceStatusStateActive string = "active"
// SilenceStatusStatePending captures enum value "pending"
SilenceStatusStatePending string = "pending"
)
// prop value enum
func (m *SilenceStatus) validateStateEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, silenceStatusTypeStatePropEnum); err != nil {
return err
}
return nil
}
func (m *SilenceStatus) validateState(formats strfmt.Registry) error {
if swag.IsZero(m.State) { // not required
return nil
}
// value enum
if err := m.validateStateEnum("status"+"."+"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
}