...

Source file src/github.com/prometheus/alertmanager/api/v2/models/receiver.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  // Receiver receiver
    32  //
    33  // swagger:model receiver
    34  type Receiver struct {
    35  
    36  	// name
    37  	// Required: true
    38  	Name *string `json:"name"`
    39  }
    40  
    41  // Validate validates this receiver
    42  func (m *Receiver) Validate(formats strfmt.Registry) error {
    43  	var res []error
    44  
    45  	if err := m.validateName(formats); err != nil {
    46  		res = append(res, err)
    47  	}
    48  
    49  	if len(res) > 0 {
    50  		return errors.CompositeValidationError(res...)
    51  	}
    52  	return nil
    53  }
    54  
    55  func (m *Receiver) validateName(formats strfmt.Registry) error {
    56  
    57  	if err := validate.Required("name", "body", m.Name); err != nil {
    58  		return err
    59  	}
    60  
    61  	return nil
    62  }
    63  
    64  // ContextValidate validates this receiver based on context it is used
    65  func (m *Receiver) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    66  	return nil
    67  }
    68  
    69  // MarshalBinary interface implementation
    70  func (m *Receiver) MarshalBinary() ([]byte, error) {
    71  	if m == nil {
    72  		return nil, nil
    73  	}
    74  	return swag.WriteJSON(m)
    75  }
    76  
    77  // UnmarshalBinary interface implementation
    78  func (m *Receiver) UnmarshalBinary(b []byte) error {
    79  	var res Receiver
    80  	if err := swag.ReadJSON(b, &res); err != nil {
    81  		return err
    82  	}
    83  	*m = res
    84  	return nil
    85  }
    86  

View as plain text