...

Source file src/github.com/prometheus/alertmanager/api/v2/models/matcher.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  
    25  	"github.com/go-openapi/errors"
    26  	"github.com/go-openapi/strfmt"
    27  	"github.com/go-openapi/swag"
    28  	"github.com/go-openapi/validate"
    29  )
    30  
    31  // Matcher matcher
    32  //
    33  // swagger:model matcher
    34  type Matcher struct {
    35  
    36  	// is equal
    37  	IsEqual *bool `json:"isEqual,omitempty"`
    38  
    39  	// is regex
    40  	// Required: true
    41  	IsRegex *bool `json:"isRegex"`
    42  
    43  	// name
    44  	// Required: true
    45  	Name *string `json:"name"`
    46  
    47  	// value
    48  	// Required: true
    49  	Value *string `json:"value"`
    50  }
    51  
    52  // Validate validates this matcher
    53  func (m *Matcher) Validate(formats strfmt.Registry) error {
    54  	var res []error
    55  
    56  	if err := m.validateIsRegex(formats); err != nil {
    57  		res = append(res, err)
    58  	}
    59  
    60  	if err := m.validateName(formats); err != nil {
    61  		res = append(res, err)
    62  	}
    63  
    64  	if err := m.validateValue(formats); err != nil {
    65  		res = append(res, err)
    66  	}
    67  
    68  	if len(res) > 0 {
    69  		return errors.CompositeValidationError(res...)
    70  	}
    71  	return nil
    72  }
    73  
    74  func (m *Matcher) validateIsRegex(formats strfmt.Registry) error {
    75  
    76  	if err := validate.Required("isRegex", "body", m.IsRegex); err != nil {
    77  		return err
    78  	}
    79  
    80  	return nil
    81  }
    82  
    83  func (m *Matcher) validateName(formats strfmt.Registry) error {
    84  
    85  	if err := validate.Required("name", "body", m.Name); err != nil {
    86  		return err
    87  	}
    88  
    89  	return nil
    90  }
    91  
    92  func (m *Matcher) validateValue(formats strfmt.Registry) error {
    93  
    94  	if err := validate.Required("value", "body", m.Value); err != nil {
    95  		return err
    96  	}
    97  
    98  	return nil
    99  }
   100  
   101  // ContextValidate validates this matcher based on context it is used
   102  func (m *Matcher) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   103  	return nil
   104  }
   105  
   106  // MarshalBinary interface implementation
   107  func (m *Matcher) MarshalBinary() ([]byte, error) {
   108  	if m == nil {
   109  		return nil, nil
   110  	}
   111  	return swag.WriteJSON(m)
   112  }
   113  
   114  // UnmarshalBinary interface implementation
   115  func (m *Matcher) UnmarshalBinary(b []byte) error {
   116  	var res Matcher
   117  	if err := swag.ReadJSON(b, &res); err != nil {
   118  		return err
   119  	}
   120  	*m = res
   121  	return nil
   122  }
   123  

View as plain text