github.com/goharbor/go-client@v0.210.0/pkg/sdk/v2.0/models/action_request.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 // ActionRequest The request to stop, pause or resume 19 // 20 // swagger:model ActionRequest 21 type ActionRequest struct { 22 23 // The action of the request, should be stop, pause or resume 24 // Enum: [stop pause resume] 25 Action string `json:"action,omitempty"` 26 } 27 28 // Validate validates this action request 29 func (m *ActionRequest) Validate(formats strfmt.Registry) error { 30 var res []error 31 32 if err := m.validateAction(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 var actionRequestTypeActionPropEnum []interface{} 43 44 func init() { 45 var res []string 46 if err := json.Unmarshal([]byte(`["stop","pause","resume"]`), &res); err != nil { 47 panic(err) 48 } 49 for _, v := range res { 50 actionRequestTypeActionPropEnum = append(actionRequestTypeActionPropEnum, v) 51 } 52 } 53 54 const ( 55 56 // ActionRequestActionStop captures enum value "stop" 57 ActionRequestActionStop string = "stop" 58 59 // ActionRequestActionPause captures enum value "pause" 60 ActionRequestActionPause string = "pause" 61 62 // ActionRequestActionResume captures enum value "resume" 63 ActionRequestActionResume string = "resume" 64 ) 65 66 // prop value enum 67 func (m *ActionRequest) validateActionEnum(path, location string, value string) error { 68 if err := validate.EnumCase(path, location, value, actionRequestTypeActionPropEnum, true); err != nil { 69 return err 70 } 71 return nil 72 } 73 74 func (m *ActionRequest) validateAction(formats strfmt.Registry) error { 75 if swag.IsZero(m.Action) { // not required 76 return nil 77 } 78 79 // value enum 80 if err := m.validateActionEnum("action", "body", m.Action); err != nil { 81 return err 82 } 83 84 return nil 85 } 86 87 // ContextValidate validates this action request based on context it is used 88 func (m *ActionRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 89 return nil 90 } 91 92 // MarshalBinary interface implementation 93 func (m *ActionRequest) MarshalBinary() ([]byte, error) { 94 if m == nil { 95 return nil, nil 96 } 97 return swag.WriteJSON(m) 98 } 99 100 // UnmarshalBinary interface implementation 101 func (m *ActionRequest) UnmarshalBinary(b []byte) error { 102 var res ActionRequest 103 if err := swag.ReadJSON(b, &res); err != nil { 104 return err 105 } 106 *m = res 107 return nil 108 }