github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/api/models/reason.go (about)

     1  package models
     2  
     3  // This file was generated by the swagger tool.
     4  // Editing this file might prove futile when you re-run the swagger generate command
     5  
     6  import (
     7  	"encoding/json"
     8  
     9  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/validate"
    13  )
    14  
    15  /*Reason Machine usable reason for job being in this state.
    16  Valid values for error status are `timeout | killed | bad_exit`.
    17  Valid values for cancelled status are `client_request`.
    18  For everything else, this is undefined.
    19  
    20  
    21  swagger:model Reason
    22  */
    23  type Reason string
    24  
    25  // for schema
    26  var reasonEnum []interface{}
    27  
    28  func (m Reason) validateReasonEnum(path, location string, value Reason) error {
    29  	if reasonEnum == nil {
    30  		var res []Reason
    31  		if err := json.Unmarshal([]byte(`["timeout","killed","bad_exit","client_request"]`), &res); err != nil {
    32  			return err
    33  		}
    34  		for _, v := range res {
    35  			reasonEnum = append(reasonEnum, v)
    36  		}
    37  	}
    38  	if err := validate.Enum(path, location, value, reasonEnum); err != nil {
    39  		return err
    40  	}
    41  	return nil
    42  }
    43  
    44  // Validate validates this reason
    45  func (m Reason) Validate(formats strfmt.Registry) error {
    46  	var res []error
    47  
    48  	// value enum
    49  	if err := m.validateReasonEnum("", "body", m); err != nil {
    50  		return err
    51  	}
    52  
    53  	if len(res) > 0 {
    54  		return errors.CompositeValidationError(res...)
    55  	}
    56  	return nil
    57  }