bitbucket.org/Aishee/synsec@v0.0.0-20210414005726-236fc01a153d/pkg/models/decision.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 "github.com/go-openapi/errors" 10 "github.com/go-openapi/strfmt" 11 "github.com/go-openapi/swag" 12 "github.com/go-openapi/validate" 13 ) 14 15 // Decision Decision 16 // 17 // swagger:model Decision 18 type Decision struct { 19 20 // duration 21 // Required: true 22 Duration *string `json:"duration"` 23 24 // (only relevant for GET ops) the unique id 25 // Read Only: true 26 ID int64 `json:"id,omitempty"` 27 28 // the origin of the decision : ccscli, synsec 29 // Required: true 30 Origin *string `json:"origin"` 31 32 // scenario 33 // Required: true 34 Scenario *string `json:"scenario"` 35 36 // the scope of decision : does it apply to an IP, a range, a username, etc 37 // Required: true 38 Scope *string `json:"scope"` 39 40 // true if the decision result from a scenario in simulation mode 41 // Read Only: true 42 Simulated *bool `json:"simulated,omitempty"` 43 44 // the type of decision, might be 'ban', 'captcha' or something custom. Ignored when watcher (ccscli/synsec) is pushing to APIL. 45 // Required: true 46 Type *string `json:"type"` 47 48 // the value of the decision scope : an IP, a range, a username, etc 49 // Required: true 50 Value *string `json:"value"` 51 } 52 53 // Validate validates this decision 54 func (m *Decision) Validate(formats strfmt.Registry) error { 55 var res []error 56 57 if err := m.validateDuration(formats); err != nil { 58 res = append(res, err) 59 } 60 61 if err := m.validateOrigin(formats); err != nil { 62 res = append(res, err) 63 } 64 65 if err := m.validateScenario(formats); err != nil { 66 res = append(res, err) 67 } 68 69 if err := m.validateScope(formats); err != nil { 70 res = append(res, err) 71 } 72 73 if err := m.validateType(formats); err != nil { 74 res = append(res, err) 75 } 76 77 if err := m.validateValue(formats); err != nil { 78 res = append(res, err) 79 } 80 81 if len(res) > 0 { 82 return errors.CompositeValidationError(res...) 83 } 84 return nil 85 } 86 87 func (m *Decision) validateDuration(formats strfmt.Registry) error { 88 89 if err := validate.Required("duration", "body", m.Duration); err != nil { 90 return err 91 } 92 93 return nil 94 } 95 96 func (m *Decision) validateOrigin(formats strfmt.Registry) error { 97 98 if err := validate.Required("origin", "body", m.Origin); err != nil { 99 return err 100 } 101 102 return nil 103 } 104 105 func (m *Decision) validateScenario(formats strfmt.Registry) error { 106 107 if err := validate.Required("scenario", "body", m.Scenario); err != nil { 108 return err 109 } 110 111 return nil 112 } 113 114 func (m *Decision) validateScope(formats strfmt.Registry) error { 115 116 if err := validate.Required("scope", "body", m.Scope); err != nil { 117 return err 118 } 119 120 return nil 121 } 122 123 func (m *Decision) validateType(formats strfmt.Registry) error { 124 125 if err := validate.Required("type", "body", m.Type); err != nil { 126 return err 127 } 128 129 return nil 130 } 131 132 func (m *Decision) validateValue(formats strfmt.Registry) error { 133 134 if err := validate.Required("value", "body", m.Value); err != nil { 135 return err 136 } 137 138 return nil 139 } 140 141 // MarshalBinary interface implementation 142 func (m *Decision) MarshalBinary() ([]byte, error) { 143 if m == nil { 144 return nil, nil 145 } 146 return swag.WriteJSON(m) 147 } 148 149 // UnmarshalBinary interface implementation 150 func (m *Decision) UnmarshalBinary(b []byte) error { 151 var res Decision 152 if err := swag.ReadJSON(b, &res); err != nil { 153 return err 154 } 155 *m = res 156 return nil 157 }