github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/schedule_obj.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 "encoding/json" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/strfmt" 14 "github.com/go-openapi/swag" 15 "github.com/go-openapi/validate" 16 ) 17 18 // ScheduleObj schedule obj 19 // 20 // swagger:model ScheduleObj 21 type ScheduleObj struct { 22 23 // A cron expression, a time-based job scheduler. 24 Cron string `json:"cron,omitempty"` 25 26 // The next time to schedule to run the job. 27 // Format: date-time 28 NextScheduledTime strfmt.DateTime `json:"next_scheduled_time,omitempty"` 29 30 // The schedule type. The valid values are 'Hourly', 'Daily', 'Weekly', 'Custom', 'Manual', 'None' and 'Schedule'. 31 // 'Manual' means to trigger it right away, 'Schedule' means to trigger it by a specified cron schedule and 32 // 'None' means to cancel the schedule. 33 // 34 // Enum: [Hourly Daily Weekly Custom Manual None Schedule] 35 Type string `json:"type,omitempty"` 36 } 37 38 // Validate validates this schedule obj 39 func (m *ScheduleObj) Validate(formats strfmt.Registry) error { 40 var res []error 41 42 if err := m.validateNextScheduledTime(formats); err != nil { 43 res = append(res, err) 44 } 45 46 if err := m.validateType(formats); err != nil { 47 res = append(res, err) 48 } 49 50 if len(res) > 0 { 51 return errors.CompositeValidationError(res...) 52 } 53 return nil 54 } 55 56 func (m *ScheduleObj) validateNextScheduledTime(formats strfmt.Registry) error { 57 if swag.IsZero(m.NextScheduledTime) { // not required 58 return nil 59 } 60 61 if err := validate.FormatOf("next_scheduled_time", "body", "date-time", m.NextScheduledTime.String(), formats); err != nil { 62 return err 63 } 64 65 return nil 66 } 67 68 var scheduleObjTypeTypePropEnum []interface{} 69 70 func init() { 71 var res []string 72 if err := json.Unmarshal([]byte(`["Hourly","Daily","Weekly","Custom","Manual","None","Schedule"]`), &res); err != nil { 73 panic(err) 74 } 75 for _, v := range res { 76 scheduleObjTypeTypePropEnum = append(scheduleObjTypeTypePropEnum, v) 77 } 78 } 79 80 const ( 81 82 // ScheduleObjTypeHourly captures enum value "Hourly" 83 ScheduleObjTypeHourly string = "Hourly" 84 85 // ScheduleObjTypeDaily captures enum value "Daily" 86 ScheduleObjTypeDaily string = "Daily" 87 88 // ScheduleObjTypeWeekly captures enum value "Weekly" 89 ScheduleObjTypeWeekly string = "Weekly" 90 91 // ScheduleObjTypeCustom captures enum value "Custom" 92 ScheduleObjTypeCustom string = "Custom" 93 94 // ScheduleObjTypeManual captures enum value "Manual" 95 ScheduleObjTypeManual string = "Manual" 96 97 // ScheduleObjTypeNone captures enum value "None" 98 ScheduleObjTypeNone string = "None" 99 100 // ScheduleObjTypeSchedule captures enum value "Schedule" 101 ScheduleObjTypeSchedule string = "Schedule" 102 ) 103 104 // prop value enum 105 func (m *ScheduleObj) validateTypeEnum(path, location string, value string) error { 106 if err := validate.EnumCase(path, location, value, scheduleObjTypeTypePropEnum, true); err != nil { 107 return err 108 } 109 return nil 110 } 111 112 func (m *ScheduleObj) validateType(formats strfmt.Registry) error { 113 if swag.IsZero(m.Type) { // not required 114 return nil 115 } 116 117 // value enum 118 if err := m.validateTypeEnum("type", "body", m.Type); err != nil { 119 return err 120 } 121 122 return nil 123 } 124 125 // ContextValidate validates this schedule obj based on context it is used 126 func (m *ScheduleObj) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 127 return nil 128 } 129 130 // MarshalBinary interface implementation 131 func (m *ScheduleObj) MarshalBinary() ([]byte, error) { 132 if m == nil { 133 return nil, nil 134 } 135 return swag.WriteJSON(m) 136 } 137 138 // UnmarshalBinary interface implementation 139 func (m *ScheduleObj) UnmarshalBinary(b []byte) error { 140 var res ScheduleObj 141 if err := swag.ReadJSON(b, &res); err != nil { 142 return err 143 } 144 *m = res 145 return nil 146 }