Skip to content

Commit

Permalink
Add binding archetype
Browse files Browse the repository at this point in the history
Signed-off-by: Marek Aufart <[email protected]>
  • Loading branch information
aufi committed Nov 24, 2023
1 parent 4b03bca commit 06d40e4
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions binding/archetype.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
}

0 comments on commit 06d40e4

Please sign in to comment.