NewResource is a constructor for a resource
(schema *Schema, properties map[string]interface{})
| 96 | |
| 97 | //NewResource is a constructor for a resource |
| 98 | func NewResource(schema *Schema, properties map[string]interface{}) (*Resource, error) { |
| 99 | resource := &Resource{ |
| 100 | schema: schema, |
| 101 | properties: properties, |
| 102 | } |
| 103 | resource.tags = make(Tags) |
| 104 | if schema.Parent != "" { |
| 105 | parentID, ok := properties[schema.Parent+"_id"] |
| 106 | if ok { |
| 107 | parentIDStr, _ := parentID.(string) |
| 108 | resource.SetParentID(parentIDStr) |
| 109 | } |
| 110 | } |
| 111 | return resource, nil |
| 112 | } |
| 113 | |
| 114 | //String return string form representation |
| 115 | func (resource *Resource) String() string { |
no test coverage detected