cloud/azure/batch/models/job_scheduling_error.go
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
// JobSchedulingError An error encountered by the Batch service when scheduling a job.
// swagger:model JobSchedulingError
type JobSchedulingError struct {
// The category of the job scheduling error.
// Required: true
Category *string `json:"category"`
// An identifier for the job scheduling error. Codes are invariant and are intended to be consumed programmatically.
Code string `json:"code,omitempty"`
// A list of additional error details related to the scheduling error.
Details []*NameValuePair `json:"details"`
// A message describing the job scheduling error, intended to be suitable for display in a user interface.
Message string `json:"message,omitempty"`
}
// Validate validates this job scheduling error
func (m *JobSchedulingError) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCategory(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateDetails(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var jobSchedulingErrorTypeCategoryPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["usererror","servererror","unmapped"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
jobSchedulingErrorTypeCategoryPropEnum = append(jobSchedulingErrorTypeCategoryPropEnum, v)
}
}
const (
// JobSchedulingErrorCategoryUsererror captures enum value "usererror"
JobSchedulingErrorCategoryUsererror string = "usererror"
// JobSchedulingErrorCategoryServererror captures enum value "servererror"
JobSchedulingErrorCategoryServererror string = "servererror"
// JobSchedulingErrorCategoryUnmapped captures enum value "unmapped"
JobSchedulingErrorCategoryUnmapped string = "unmapped"
)
// prop value enum
func (m *JobSchedulingError) validateCategoryEnum(path, location string, value string) error {
if err := validate.Enum(path, location, value, jobSchedulingErrorTypeCategoryPropEnum); err != nil {
return err
}
return nil
}
func (m *JobSchedulingError) validateCategory(formats strfmt.Registry) error {
if err := validate.Required("category", "body", m.Category); err != nil {
return err
}
// value enum
if err := m.validateCategoryEnum("category", "body", *m.Category); err != nil {
return err
}
return nil
}
func (m *JobSchedulingError) validateDetails(formats strfmt.Registry) error {
if swag.IsZero(m.Details) { // not required
return nil
}
for i := 0; i < len(m.Details); i++ {
if swag.IsZero(m.Details[i]) { // not required
continue
}
if m.Details[i] != nil {
if err := m.Details[i].Validate(formats); err != nil {
return err
}
}
}
return nil
}