27 lines
448 B
Go
27 lines
448 B
Go
package models
|
|
|
|
import (
|
|
"io"
|
|
"encoding/json"
|
|
_ "fmt"
|
|
)
|
|
|
|
type Resource struct {
|
|
Id string `json:"id",omitempty`
|
|
Resource string `json:"resource",omitempty`
|
|
Tags []string `json:"tags"`
|
|
}
|
|
|
|
func NewResource() *Resource {
|
|
return &Resource{}
|
|
}
|
|
|
|
func NewResourceFromJson(jsonReader io.Reader) (*Resource, error) {
|
|
r := NewResource()
|
|
err := json.NewDecoder(jsonReader).Decode(r)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return r, nil
|
|
}
|