...

Source file src/github.com/prometheus/alertmanager/api/v2/models/alert_status.go

Documentation: github.com/prometheus/alertmanager/api/v2/models

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright Prometheus Team
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  // http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  // Unless required by applicable law or agreed to in writing, software
    11  // distributed under the License is distributed on an "AS IS" BASIS,
    12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  // See the License for the specific language governing permissions and
    14  // limitations under the License.
    15  //
    16  
    17  package models
    18  
    19  // This file was generated by the swagger tool.
    20  // Editing this file might prove futile when you re-run the swagger generate command
    21  
    22  import (
    23  	"context"
    24  	"encoding/json"
    25  
    26  	"github.com/go-openapi/errors"
    27  	"github.com/go-openapi/strfmt"
    28  	"github.com/go-openapi/swag"
    29  	"github.com/go-openapi/validate"
    30  )
    31  
    32  // AlertStatus alert status
    33  //
    34  // swagger:model alertStatus
    35  type AlertStatus struct {
    36  
    37  	// inhibited by
    38  	// Required: true
    39  	InhibitedBy []string `json:"inhibitedBy"`
    40  
    41  	// silenced by
    42  	// Required: true
    43  	SilencedBy []string `json:"silencedBy"`
    44  
    45  	// state
    46  	// Required: true
    47  	// Enum: [unprocessed active suppressed]
    48  	State *string `json:"state"`
    49  }
    50  
    51  // Validate validates this alert status
    52  func (m *AlertStatus) Validate(formats strfmt.Registry) error {
    53  	var res []error
    54  
    55  	if err := m.validateInhibitedBy(formats); err != nil {
    56  		res = append(res, err)
    57  	}
    58  
    59  	if err := m.validateSilencedBy(formats); err != nil {
    60  		res = append(res, err)
    61  	}
    62  
    63  	if err := m.validateState(formats); err != nil {
    64  		res = append(res, err)
    65  	}
    66  
    67  	if len(res) > 0 {
    68  		return errors.CompositeValidationError(res...)
    69  	}
    70  	return nil
    71  }
    72  
    73  func (m *AlertStatus) validateInhibitedBy(formats strfmt.Registry) error {
    74  
    75  	if err := validate.Required("inhibitedBy", "body", m.InhibitedBy); err != nil {
    76  		return err
    77  	}
    78  
    79  	return nil
    80  }
    81  
    82  func (m *AlertStatus) validateSilencedBy(formats strfmt.Registry) error {
    83  
    84  	if err := validate.Required("silencedBy", "body", m.SilencedBy); err != nil {
    85  		return err
    86  	}
    87  
    88  	return nil
    89  }
    90  
    91  var alertStatusTypeStatePropEnum []interface{}
    92  
    93  func init() {
    94  	var res []string
    95  	if err := json.Unmarshal([]byte(`["unprocessed","active","suppressed"]`), &res); err != nil {
    96  		panic(err)
    97  	}
    98  	for _, v := range res {
    99  		alertStatusTypeStatePropEnum = append(alertStatusTypeStatePropEnum, v)
   100  	}
   101  }
   102  
   103  const (
   104  
   105  	// AlertStatusStateUnprocessed captures enum value "unprocessed"
   106  	AlertStatusStateUnprocessed string = "unprocessed"
   107  
   108  	// AlertStatusStateActive captures enum value "active"
   109  	AlertStatusStateActive string = "active"
   110  
   111  	// AlertStatusStateSuppressed captures enum value "suppressed"
   112  	AlertStatusStateSuppressed string = "suppressed"
   113  )
   114  
   115  // prop value enum
   116  func (m *AlertStatus) validateStateEnum(path, location string, value string) error {
   117  	if err := validate.EnumCase(path, location, value, alertStatusTypeStatePropEnum, true); err != nil {
   118  		return err
   119  	}
   120  	return nil
   121  }
   122  
   123  func (m *AlertStatus) validateState(formats strfmt.Registry) error {
   124  
   125  	if err := validate.Required("state", "body", m.State); err != nil {
   126  		return err
   127  	}
   128  
   129  	// value enum
   130  	if err := m.validateStateEnum("state", "body", *m.State); err != nil {
   131  		return err
   132  	}
   133  
   134  	return nil
   135  }
   136  
   137  // ContextValidate validates this alert status based on context it is used
   138  func (m *AlertStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   139  	return nil
   140  }
   141  
   142  // MarshalBinary interface implementation
   143  func (m *AlertStatus) MarshalBinary() ([]byte, error) {
   144  	if m == nil {
   145  		return nil, nil
   146  	}
   147  	return swag.WriteJSON(m)
   148  }
   149  
   150  // UnmarshalBinary interface implementation
   151  func (m *AlertStatus) UnmarshalBinary(b []byte) error {
   152  	var res AlertStatus
   153  	if err := swag.ReadJSON(b, &res); err != nil {
   154  		return err
   155  	}
   156  	*m = res
   157  	return nil
   158  }
   159  

View as plain text