github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/worker.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 "github.com/go-openapi/validate" 15 ) 16 17 // Worker worker in the pool 18 // 19 // swagger:model Worker 20 type Worker struct { 21 22 // the checkin of the running job in the worker 23 CheckIn string `json:"check_in,omitempty"` 24 25 // The checkin time of the worker 26 // Format: date-time 27 CheckinAt *strfmt.DateTime `json:"checkin_at,omitempty"` 28 29 // the id of the worker 30 ID string `json:"id,omitempty"` 31 32 // the id of the running job in the worker 33 JobID string `json:"job_id,omitempty"` 34 35 // the name of the running job in the worker 36 JobName string `json:"job_name,omitempty"` 37 38 // the id of the worker pool 39 PoolID string `json:"pool_id,omitempty"` 40 41 // The start time of the worker 42 // Format: date-time 43 StartAt *strfmt.DateTime `json:"start_at,omitempty"` 44 } 45 46 // Validate validates this worker 47 func (m *Worker) Validate(formats strfmt.Registry) error { 48 var res []error 49 50 if err := m.validateCheckinAt(formats); err != nil { 51 res = append(res, err) 52 } 53 54 if err := m.validateStartAt(formats); err != nil { 55 res = append(res, err) 56 } 57 58 if len(res) > 0 { 59 return errors.CompositeValidationError(res...) 60 } 61 return nil 62 } 63 64 func (m *Worker) validateCheckinAt(formats strfmt.Registry) error { 65 if swag.IsZero(m.CheckinAt) { // not required 66 return nil 67 } 68 69 if err := validate.FormatOf("checkin_at", "body", "date-time", m.CheckinAt.String(), formats); err != nil { 70 return err 71 } 72 73 return nil 74 } 75 76 func (m *Worker) validateStartAt(formats strfmt.Registry) error { 77 if swag.IsZero(m.StartAt) { // not required 78 return nil 79 } 80 81 if err := validate.FormatOf("start_at", "body", "date-time", m.StartAt.String(), formats); err != nil { 82 return err 83 } 84 85 return nil 86 } 87 88 // ContextValidate validates this worker based on context it is used 89 func (m *Worker) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 90 return nil 91 } 92 93 // MarshalBinary interface implementation 94 func (m *Worker) MarshalBinary() ([]byte, error) { 95 if m == nil { 96 return nil, nil 97 } 98 return swag.WriteJSON(m) 99 } 100 101 // UnmarshalBinary interface implementation 102 func (m *Worker) UnmarshalBinary(b []byte) error { 103 var res Worker 104 if err := swag.ReadJSON(b, &res); err != nil { 105 return err 106 } 107 *m = res 108 return nil 109 }