Skip to content

Commit

Permalink
FIX: set the correct path
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred78290 committed Jan 25, 2024
1 parent 3c8e467 commit 81d4f32
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions client/api/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import (
"github.com/Fred78290/vmrest-go-client/client/model"
)

const (
kApiVM = "/api/vms/%s"
)

type managementApiService struct {
client Client
}
Expand All @@ -41,7 +45,7 @@ func NewManagementApiService(client Client) ManagementApiService {
func (a *managementApiService) ConfigVMParams(id string, parameters *model.ConfigVmParamsParameter) (*model.ErrorModel, error) {
var returnValue model.ErrorModel

if err := a.client.Put(fmt.Sprintf("/api/vms/%s/configparams", id), parameters, &returnValue); err != nil {
if err := a.client.Put(fmt.Sprintf("/api/vms/%s/params", id), parameters, &returnValue); err != nil {
return nil, err
} else {
return &returnValue, err
Expand All @@ -65,7 +69,7 @@ func (a *managementApiService) CreateVM(parameters *model.VmCloneParameter) (*mo
// DeleteVM Deletes a VM
// - @param id ID of VM
func (a *managementApiService) DeleteVM(id string) error {
return a.client.Delete(fmt.Sprintf("/api/vms/%s", id), nil)
return a.client.Delete(fmt.Sprintf(kApiVM, id), nil)
}

// GetAllVMs Returns a list of VM IDs and paths for all VMs
Expand All @@ -87,7 +91,7 @@ func (a *managementApiService) GetAllVMs() ([]model.Vmid, error) {
func (a *managementApiService) GetVM(id string) (*model.VmInformation, error) {
var returnValue model.VmInformation

if err := a.client.Get(fmt.Sprintf("/api/vms/%s", id), &returnValue); err != nil {
if err := a.client.Get(fmt.Sprintf(kApiVM, id), &returnValue); err != nil {
return nil, err
} else {
return &returnValue, err
Expand Down Expand Up @@ -146,7 +150,7 @@ func (a *managementApiService) UpdateVM(id string, parameters *model.VmParameter
var returnValue model.VmInformation

// body params
if err := a.client.Put(fmt.Sprintf("/api/vms/%s", id), parameters, &returnValue); err != nil {
if err := a.client.Put(fmt.Sprintf(kApiVM, id), parameters, &returnValue); err != nil {
return nil, err
} else {
return &returnValue, err
Expand Down

0 comments on commit 81d4f32

Please sign in to comment.