3
0
Files
corteza/internal/rules/resource.go
Tit Petric 876a304def upd(all):
- moved Access type from system to internal/rules,
- moved Resource from system to internal/rules,
- update imports for new type locations,
- add scope list container to inject permissions,
- update permissions API call to return default perms,
- update codegen for generated Rules types
2019-02-06 11:19:32 +01:00

40 lines
663 B
Go

package rules
import (
"fmt"
"encoding/json"
)
type Resource struct {
ID uint64 `json:"id,string"`
Name string `json:"name"`
Scope string `json:"scope"`
}
type ResourceJSON struct {
ID uint64 `json:"id,string"`
Name string `json:"name"`
Scope string `json:"scope"`
ResourceID string `json:"resource"`
}
func (r Resource) String() string {
return fmt.Sprintf("%s:%d", r.Scope, r.ID)
}
func (r Resource) All() string {
return fmt.Sprintf("%s:*", r.Scope)
}
func (r Resource) MarshalJSON() ([]byte, error) {
return json.Marshal(ResourceJSON{
r.ID,
r.Name,
r.Scope,
r.String(),
})
}
var _ fmt.Stringer = Resource{}