github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/token.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 "github.com/go-openapi/validate" 15 ) 16 17 // Token token 18 // 19 // swagger:model Token 20 type Token struct { 21 22 // name 23 Name string `json:"name,omitempty"` 24 25 // token ID 26 // Format: uuid 27 TokenID strfmt.UUID `json:"tokenID,omitempty"` 28 } 29 30 // Validate validates this token 31 func (m *Token) Validate(formats strfmt.Registry) error { 32 var res []error 33 34 if err := m.validateTokenID(formats); err != nil { 35 res = append(res, err) 36 } 37 38 if len(res) > 0 { 39 return errors.CompositeValidationError(res...) 40 } 41 return nil 42 } 43 44 func (m *Token) validateTokenID(formats strfmt.Registry) error { 45 if swag.IsZero(m.TokenID) { // not required 46 return nil 47 } 48 49 if err := validate.FormatOf("tokenID", "body", "uuid", m.TokenID.String(), formats); err != nil { 50 return err 51 } 52 53 return nil 54 } 55 56 // ContextValidate validates this token based on context it is used 57 func (m *Token) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 58 return nil 59 } 60 61 // MarshalBinary interface implementation 62 func (m *Token) MarshalBinary() ([]byte, error) { 63 if m == nil { 64 return nil, nil 65 } 66 return swag.WriteJSON(m) 67 } 68 69 // UnmarshalBinary interface implementation 70 func (m *Token) UnmarshalBinary(b []byte) error { 71 var res Token 72 if err := swag.ReadJSON(b, &res); err != nil { 73 return err 74 } 75 *m = res 76 return nil 77 }