github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/task.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package 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 "context" 10 11 "github.com/go-openapi/errors" 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 ) 15 16 // Task task 17 // 18 // swagger:model Task 19 type Task struct { 20 21 // The creation time of task 22 CreationTime string `json:"creation_time,omitempty"` 23 24 // The end time of task 25 EndTime string `json:"end_time,omitempty"` 26 27 // The ID of task execution 28 ExecutionID int64 `json:"execution_id,omitempty"` 29 30 // extra attrs 31 ExtraAttrs ExtraAttrs `json:"extra_attrs,omitempty"` 32 33 // The ID of task 34 ID int64 `json:"id,omitempty"` 35 36 // The count of task run 37 RunCount int32 `json:"run_count,omitempty"` 38 39 // The start time of task 40 StartTime string `json:"start_time,omitempty"` 41 42 // The status of task 43 Status string `json:"status,omitempty"` 44 45 // The status message of task 46 StatusMessage string `json:"status_message,omitempty"` 47 48 // The update time of task 49 UpdateTime string `json:"update_time,omitempty"` 50 } 51 52 // Validate validates this task 53 func (m *Task) Validate(formats strfmt.Registry) error { 54 var res []error 55 56 if err := m.validateExtraAttrs(formats); err != nil { 57 res = append(res, err) 58 } 59 60 if len(res) > 0 { 61 return errors.CompositeValidationError(res...) 62 } 63 return nil 64 } 65 66 func (m *Task) validateExtraAttrs(formats strfmt.Registry) error { 67 if swag.IsZero(m.ExtraAttrs) { // not required 68 return nil 69 } 70 71 if m.ExtraAttrs != nil { 72 if err := m.ExtraAttrs.Validate(formats); err != nil { 73 if ve, ok := err.(*errors.Validation); ok { 74 return ve.ValidateName("extra_attrs") 75 } else if ce, ok := err.(*errors.CompositeError); ok { 76 return ce.ValidateName("extra_attrs") 77 } 78 return err 79 } 80 } 81 82 return nil 83 } 84 85 // ContextValidate validate this task based on the context it is used 86 func (m *Task) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 87 var res []error 88 89 if err := m.contextValidateExtraAttrs(ctx, formats); err != nil { 90 res = append(res, err) 91 } 92 93 if len(res) > 0 { 94 return errors.CompositeValidationError(res...) 95 } 96 return nil 97 } 98 99 func (m *Task) contextValidateExtraAttrs(ctx context.Context, formats strfmt.Registry) error { 100 101 if err := m.ExtraAttrs.ContextValidate(ctx, formats); err != nil { 102 if ve, ok := err.(*errors.Validation); ok { 103 return ve.ValidateName("extra_attrs") 104 } else if ce, ok := err.(*errors.CompositeError); ok { 105 return ce.ValidateName("extra_attrs") 106 } 107 return err 108 } 109 110 return nil 111 } 112 113 // MarshalBinary interface implementation 114 func (m *Task) MarshalBinary() ([]byte, error) { 115 if m == nil { 116 return nil, nil 117 } 118 return swag.WriteJSON(m) 119 } 120 121 // UnmarshalBinary interface implementation 122 func (m *Task) UnmarshalBinary(b []byte) error { 123 var res Task 124 if err := swag.ReadJSON(b, &res); err != nil { 125 return err 126 } 127 *m = res 128 return nil 129 }