github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/webhook_target_object.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 // WebhookTargetObject The webhook policy target object. 17 // 18 // swagger:model WebhookTargetObject 19 type WebhookTargetObject struct { 20 21 // The webhook target address. 22 Address string `json:"address,omitempty"` 23 24 // The webhook auth header. 25 AuthHeader string `json:"auth_header,omitempty"` 26 27 // The payload format of webhook, by default is Default for http type. 28 PayloadFormat PayloadFormatType `json:"payload_format,omitempty"` 29 30 // Whether or not to skip cert verify. 31 SkipCertVerify bool `json:"skip_cert_verify,omitempty"` 32 33 // The webhook target notify type. 34 Type string `json:"type,omitempty"` 35 } 36 37 // Validate validates this webhook target object 38 func (m *WebhookTargetObject) Validate(formats strfmt.Registry) error { 39 var res []error 40 41 if err := m.validatePayloadFormat(formats); err != nil { 42 res = append(res, err) 43 } 44 45 if len(res) > 0 { 46 return errors.CompositeValidationError(res...) 47 } 48 return nil 49 } 50 51 func (m *WebhookTargetObject) validatePayloadFormat(formats strfmt.Registry) error { 52 if swag.IsZero(m.PayloadFormat) { // not required 53 return nil 54 } 55 56 if err := m.PayloadFormat.Validate(formats); err != nil { 57 if ve, ok := err.(*errors.Validation); ok { 58 return ve.ValidateName("payload_format") 59 } else if ce, ok := err.(*errors.CompositeError); ok { 60 return ce.ValidateName("payload_format") 61 } 62 return err 63 } 64 65 return nil 66 } 67 68 // ContextValidate validate this webhook target object based on the context it is used 69 func (m *WebhookTargetObject) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 70 var res []error 71 72 if err := m.contextValidatePayloadFormat(ctx, formats); err != nil { 73 res = append(res, err) 74 } 75 76 if len(res) > 0 { 77 return errors.CompositeValidationError(res...) 78 } 79 return nil 80 } 81 82 func (m *WebhookTargetObject) contextValidatePayloadFormat(ctx context.Context, formats strfmt.Registry) error { 83 84 if err := m.PayloadFormat.ContextValidate(ctx, formats); err != nil { 85 if ve, ok := err.(*errors.Validation); ok { 86 return ve.ValidateName("payload_format") 87 } else if ce, ok := err.(*errors.CompositeError); ok { 88 return ce.ValidateName("payload_format") 89 } 90 return err 91 } 92 93 return nil 94 } 95 96 // MarshalBinary interface implementation 97 func (m *WebhookTargetObject) MarshalBinary() ([]byte, error) { 98 if m == nil { 99 return nil, nil 100 } 101 return swag.WriteJSON(m) 102 } 103 104 // UnmarshalBinary interface implementation 105 func (m *WebhookTargetObject) UnmarshalBinary(b []byte) error { 106 var res WebhookTargetObject 107 if err := swag.ReadJSON(b, &res); err != nil { 108 return err 109 } 110 *m = res 111 return nil 112 }