github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/j_w_t.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package mono_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 // JWT j w t 17 // 18 // swagger:model JWT 19 type JWT struct { 20 21 // token 22 Token string `json:"token,omitempty"` 23 24 // user 25 User *User `json:"user,omitempty"` 26 } 27 28 // Validate validates this j w t 29 func (m *JWT) Validate(formats strfmt.Registry) error { 30 var res []error 31 32 if err := m.validateUser(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 *JWT) validateUser(formats strfmt.Registry) error { 43 if swag.IsZero(m.User) { // not required 44 return nil 45 } 46 47 if m.User != nil { 48 if err := m.User.Validate(formats); err != nil { 49 if ve, ok := err.(*errors.Validation); ok { 50 return ve.ValidateName("user") 51 } 52 return err 53 } 54 } 55 56 return nil 57 } 58 59 // ContextValidate validate this j w t based on the context it is used 60 func (m *JWT) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 61 var res []error 62 63 if err := m.contextValidateUser(ctx, formats); err != nil { 64 res = append(res, err) 65 } 66 67 if len(res) > 0 { 68 return errors.CompositeValidationError(res...) 69 } 70 return nil 71 } 72 73 func (m *JWT) contextValidateUser(ctx context.Context, formats strfmt.Registry) error { 74 75 if m.User != nil { 76 if err := m.User.ContextValidate(ctx, formats); err != nil { 77 if ve, ok := err.(*errors.Validation); ok { 78 return ve.ValidateName("user") 79 } 80 return err 81 } 82 } 83 84 return nil 85 } 86 87 // MarshalBinary interface implementation 88 func (m *JWT) MarshalBinary() ([]byte, error) { 89 if m == nil { 90 return nil, nil 91 } 92 return swag.WriteJSON(m) 93 } 94 95 // UnmarshalBinary interface implementation 96 func (m *JWT) UnmarshalBinary(b []byte) error { 97 var res JWT 98 if err := swag.ReadJSON(b, &res); err != nil { 99 return err 100 } 101 *m = res 102 return nil 103 }