| 47 | } |
| 48 | |
| 49 | func (s *EntityService) Save(kind string, input EntityDTO) (EntityDTO, error) { |
| 50 | store, err := entityStore(kind) |
| 51 | if err != nil { |
| 52 | return EntityDTO{}, err |
| 53 | } |
| 54 | entity := entities.Entity{ |
| 55 | Name: input.Name, Description: input.Description, Content: input.Content, Path: input.Path, |
| 56 | Apps: input.Apps, Tags: input.Tags, Metadata: input.Metadata, |
| 57 | } |
| 58 | if err := store.Put(entity); err != nil { |
| 59 | return EntityDTO{}, wrapError("ENTITY_SAVE_FAILED", err) |
| 60 | } |
| 61 | saved, err := store.Get(input.Name) |
| 62 | if err != nil { |
| 63 | return EntityDTO{}, wrapError("ENTITY_LOAD_FAILED", err) |
| 64 | } |
| 65 | return entityDTO(saved), nil |
| 66 | } |
| 67 | |
| 68 | func (s *EntityService) Uninstall(kind, name string) (OperationResult, error) { |
| 69 | store, err := entityStore(kind) |