...

Source file src/github.com/prometheus/alertmanager/api/v2/models/gettable_alerts.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  	"strconv"
    25  
    26  	"github.com/go-openapi/errors"
    27  	"github.com/go-openapi/strfmt"
    28  	"github.com/go-openapi/swag"
    29  )
    30  
    31  // GettableAlerts gettable alerts
    32  //
    33  // swagger:model gettableAlerts
    34  type GettableAlerts []*GettableAlert
    35  
    36  // Validate validates this gettable alerts
    37  func (m GettableAlerts) Validate(formats strfmt.Registry) error {
    38  	var res []error
    39  
    40  	for i := 0; i < len(m); i++ {
    41  		if swag.IsZero(m[i]) { // not required
    42  			continue
    43  		}
    44  
    45  		if m[i] != nil {
    46  			if err := m[i].Validate(formats); err != nil {
    47  				if ve, ok := err.(*errors.Validation); ok {
    48  					return ve.ValidateName(strconv.Itoa(i))
    49  				} else if ce, ok := err.(*errors.CompositeError); ok {
    50  					return ce.ValidateName(strconv.Itoa(i))
    51  				}
    52  				return err
    53  			}
    54  		}
    55  
    56  	}
    57  
    58  	if len(res) > 0 {
    59  		return errors.CompositeValidationError(res...)
    60  	}
    61  	return nil
    62  }
    63  
    64  // ContextValidate validate this gettable alerts based on the context it is used
    65  func (m GettableAlerts) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    66  	var res []error
    67  
    68  	for i := 0; i < len(m); i++ {
    69  
    70  		if m[i] != nil {
    71  			if err := m[i].ContextValidate(ctx, formats); err != nil {
    72  				if ve, ok := err.(*errors.Validation); ok {
    73  					return ve.ValidateName(strconv.Itoa(i))
    74  				} else if ce, ok := err.(*errors.CompositeError); ok {
    75  					return ce.ValidateName(strconv.Itoa(i))
    76  				}
    77  				return err
    78  			}
    79  		}
    80  
    81  	}
    82  
    83  	if len(res) > 0 {
    84  		return errors.CompositeValidationError(res...)
    85  	}
    86  	return nil
    87  }
    88  

View as plain text