github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/mono/mono_models/role.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 "encoding/json" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/strfmt" 14 "github.com/go-openapi/validate" 15 ) 16 17 // Role role 18 // 19 // swagger:model Role 20 type Role string 21 22 func NewRole(value Role) *Role { 23 v := value 24 return &v 25 } 26 27 const ( 28 29 // RoleAdmin captures enum value "admin" 30 RoleAdmin Role = "admin" 31 32 // RoleEditor captures enum value "editor" 33 RoleEditor Role = "editor" 34 35 // RoleReader captures enum value "reader" 36 RoleReader Role = "reader" 37 ) 38 39 // for schema 40 var roleEnum []interface{} 41 42 func init() { 43 var res []Role 44 if err := json.Unmarshal([]byte(`["admin","editor","reader"]`), &res); err != nil { 45 panic(err) 46 } 47 for _, v := range res { 48 roleEnum = append(roleEnum, v) 49 } 50 } 51 52 func (m Role) validateRoleEnum(path, location string, value Role) error { 53 if err := validate.EnumCase(path, location, value, roleEnum, true); err != nil { 54 return err 55 } 56 return nil 57 } 58 59 // Validate validates this role 60 func (m Role) Validate(formats strfmt.Registry) error { 61 var res []error 62 63 // value enum 64 if err := m.validateRoleEnum("", "body", m); err != nil { 65 return err 66 } 67 68 if len(res) > 0 { 69 return errors.CompositeValidationError(res...) 70 } 71 return nil 72 } 73 74 // ContextValidate validates this role based on context it is used 75 func (m Role) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 76 return nil 77 }