bitbucket.org/Aishee/synsec@v0.0.0-20210414005726-236fc01a153d/pkg/models/source.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 // Source Source 16 // 17 // swagger:model Source 18 type Source struct { 19 20 // provided as a convenience when the source is an IP 21 AsName string `json:"as_name,omitempty"` 22 23 // provided as a convenience when the source is an IP 24 AsNumber string `json:"as_number,omitempty"` 25 26 // cn 27 Cn string `json:"cn,omitempty"` 28 29 // provided as a convenience when the source is an IP 30 IP string `json:"ip,omitempty"` 31 32 // latitude 33 Latitude float32 `json:"latitude,omitempty"` 34 35 // longitude 36 Longitude float32 `json:"longitude,omitempty"` 37 38 // provided as a convenience when the source is an IP 39 Range string `json:"range,omitempty"` 40 41 // the scope of a source : ip,range,username,etc 42 // Required: true 43 Scope *string `json:"scope"` 44 45 // the value of a source : the ip, the range, the username,etc 46 // Required: true 47 Value *string `json:"value"` 48 } 49 50 // Validate validates this source 51 func (m *Source) Validate(formats strfmt.Registry) error { 52 var res []error 53 54 if err := m.validateScope(formats); err != nil { 55 res = append(res, err) 56 } 57 58 if err := m.validateValue(formats); err != nil { 59 res = append(res, err) 60 } 61 62 if len(res) > 0 { 63 return errors.CompositeValidationError(res...) 64 } 65 return nil 66 } 67 68 func (m *Source) validateScope(formats strfmt.Registry) error { 69 70 if err := validate.Required("scope", "body", m.Scope); err != nil { 71 return err 72 } 73 74 return nil 75 } 76 77 func (m *Source) validateValue(formats strfmt.Registry) error { 78 79 if err := validate.Required("value", "body", m.Value); err != nil { 80 return err 81 } 82 83 return nil 84 } 85 86 // MarshalBinary interface implementation 87 func (m *Source) MarshalBinary() ([]byte, error) { 88 if m == nil { 89 return nil, nil 90 } 91 return swag.WriteJSON(m) 92 } 93 94 // UnmarshalBinary interface implementation 95 func (m *Source) UnmarshalBinary(b []byte) error { 96 var res Source 97 if err := swag.ReadJSON(b, &res); err != nil { 98 return err 99 } 100 *m = res 101 return nil 102 }