-
Notifications
You must be signed in to change notification settings - Fork 29
/
archetype.go
50 lines (43 loc) · 1007 Bytes
/
archetype.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package binding
import (
"github.com/konveyor/tackle2-hub/api"
)
//
// Archetype API.
type Archetype struct {
client *Client
}
//
// Create a Archetype.
func (h *Archetype) Create(r *api.Archetype) (err error) {
err = h.client.Post(api.ArchetypesRoot, &r)
return
}
//
// Get a Archetype by ID.
func (h *Archetype) Get(id uint) (r *api.Archetype, err error) {
r = &api.Archetype{}
path := Path(api.ArchetypeRoot).Inject(Params{api.ID: id})
err = h.client.Get(path, r)
return
}
//
// List Archetypes.
func (h *Archetype) List() (list []api.Archetype, err error) {
list = []api.Archetype{}
err = h.client.Get(api.ArchetypesRoot, &list)
return
}
//
// Update a Archetype.
func (h *Archetype) Update(r *api.Archetype) (err error) {
path := Path(api.ArchetypeRoot).Inject(Params{api.ID: r.ID})
err = h.client.Put(path, r)
return
}
//
// Delete a Archetype.
func (h *Archetype) Delete(id uint) (err error) {
err = h.client.Delete(Path(api.ArchetypeRoot).Inject(Params{api.ID: id}))
return
}