github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/headchef/headchef_models/rest_api_error.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package headchef_models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 strfmt "github.com/go-openapi/strfmt" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/swag" 13 "github.com/go-openapi/validate" 14 ) 15 16 // RestAPIError REST API error body 17 // 18 // A shared generic error response body for REST APIs. 19 // swagger:model restApiError 20 type RestAPIError struct { 21 22 // Link to an existing conflicting resource 23 // Format: uri 24 Existing strfmt.URI `json:"existing,omitempty"` 25 26 // message 27 // Required: true 28 Message *string `json:"message"` 29 } 30 31 // Validate validates this rest Api error 32 func (m *RestAPIError) Validate(formats strfmt.Registry) error { 33 var res []error 34 35 if err := m.validateExisting(formats); err != nil { 36 res = append(res, err) 37 } 38 39 if err := m.validateMessage(formats); err != nil { 40 res = append(res, err) 41 } 42 43 if len(res) > 0 { 44 return errors.CompositeValidationError(res...) 45 } 46 return nil 47 } 48 49 func (m *RestAPIError) validateExisting(formats strfmt.Registry) error { 50 51 if swag.IsZero(m.Existing) { // not required 52 return nil 53 } 54 55 if err := validate.FormatOf("existing", "body", "uri", m.Existing.String(), formats); err != nil { 56 return err 57 } 58 59 return nil 60 } 61 62 func (m *RestAPIError) validateMessage(formats strfmt.Registry) error { 63 64 if err := validate.Required("message", "body", m.Message); err != nil { 65 return err 66 } 67 68 return nil 69 } 70 71 // MarshalBinary interface implementation 72 func (m *RestAPIError) MarshalBinary() ([]byte, error) { 73 if m == nil { 74 return nil, nil 75 } 76 return swag.WriteJSON(m) 77 } 78 79 // UnmarshalBinary interface implementation 80 func (m *RestAPIError) UnmarshalBinary(b []byte) error { 81 var res RestAPIError 82 if err := swag.ReadJSON(b, &res); err != nil { 83 return err 84 } 85 *m = res 86 return nil 87 }