github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/replication_trigger.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 // ReplicationTrigger replication trigger 17 // 18 // swagger:model ReplicationTrigger 19 type ReplicationTrigger struct { 20 21 // trigger settings 22 TriggerSettings *ReplicationTriggerSettings `json:"trigger_settings,omitempty"` 23 24 // The replication policy trigger type. The valid values are manual, event_based and scheduled. 25 Type string `json:"type,omitempty"` 26 } 27 28 // Validate validates this replication trigger 29 func (m *ReplicationTrigger) Validate(formats strfmt.Registry) error { 30 var res []error 31 32 if err := m.validateTriggerSettings(formats); err != nil { 33 res = append(res, err) 34 } 35 36 if len(res) > 0 { 37 return errors.CompositeValidationError(res...) 38 } 39 return nil 40 } 41 42 func (m *ReplicationTrigger) validateTriggerSettings(formats strfmt.Registry) error { 43 if swag.IsZero(m.TriggerSettings) { // not required 44 return nil 45 } 46 47 if m.TriggerSettings != nil { 48 if err := m.TriggerSettings.Validate(formats); err != nil { 49 if ve, ok := err.(*errors.Validation); ok { 50 return ve.ValidateName("trigger_settings") 51 } else if ce, ok := err.(*errors.CompositeError); ok { 52 return ce.ValidateName("trigger_settings") 53 } 54 return err 55 } 56 } 57 58 return nil 59 } 60 61 // ContextValidate validate this replication trigger based on the context it is used 62 func (m *ReplicationTrigger) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 63 var res []error 64 65 if err := m.contextValidateTriggerSettings(ctx, formats); err != nil { 66 res = append(res, err) 67 } 68 69 if len(res) > 0 { 70 return errors.CompositeValidationError(res...) 71 } 72 return nil 73 } 74 75 func (m *ReplicationTrigger) contextValidateTriggerSettings(ctx context.Context, formats strfmt.Registry) error { 76 77 if m.TriggerSettings != nil { 78 if err := m.TriggerSettings.ContextValidate(ctx, formats); err != nil { 79 if ve, ok := err.(*errors.Validation); ok { 80 return ve.ValidateName("trigger_settings") 81 } else if ce, ok := err.(*errors.CompositeError); ok { 82 return ce.ValidateName("trigger_settings") 83 } 84 return err 85 } 86 } 87 88 return nil 89 } 90 91 // MarshalBinary interface implementation 92 func (m *ReplicationTrigger) MarshalBinary() ([]byte, error) { 93 if m == nil { 94 return nil, nil 95 } 96 return swag.WriteJSON(m) 97 } 98 99 // UnmarshalBinary interface implementation 100 func (m *ReplicationTrigger) UnmarshalBinary(b []byte) error { 101 var res ReplicationTrigger 102 if err := swag.ReadJSON(b, &res); err != nil { 103 return err 104 } 105 *m = res 106 return nil 107 }