-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Marek Aufart <[email protected]>
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |