diff --git a/libclient/client.go b/libclient/client.go index 0ffbd6fdad878de651bdc700c0b9974cf3a858d5..7a09dec65074bff816d40fcd89595fa913929a2e 100644 --- a/libclient/client.go +++ b/libclient/client.go @@ -50,7 +50,7 @@ func New(host string) (*NexusClient, error) { // Returns an JWT token if authentication succeeded or an error if it failed. // IMPORTANT: caller MUST call the Cleanup() function before exiting! func (nc *NexusClient) Authenticate(user, pwd string) (string, error) { - loginArgs := ¶ms.Login{user, pwd} + loginArgs := ¶ms.Login{Email: user, Pwd: pwd} resp, err := nc.client.R().SetBody(loginArgs).Post("/login") if err != nil { return "", err diff --git a/libclient/template.go b/libclient/template.go index 20c324070fc3a00fa0716fd7d4120f278d1467c9..5c2d981e98741a83a05e25327daca50a3ed338c7 100644 --- a/libclient/template.go +++ b/libclient/template.go @@ -1,22 +1,15 @@ package nexusclient import ( - "errors" - - "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/response" - "encoding/json" - - t "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/template" - - u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/utils" + "errors" "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/params" "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/template" - - "github.com/google/uuid" - + "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/response" + u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/utils" "github.com/go-resty/resty/v2" + "github.com/google/uuid" ) func (nc *NexusClient) TemplateDel(tplID string) error { @@ -32,7 +25,7 @@ func (nc *NexusClient) TemplateDel(tplID string) error { } func (nc *NexusClient) TemplateCreate(vmID uuid.UUID, name, access string) (*template.TemplateSerialized, error) { - p := ¶ms.TplCreate{vmID, name, access} + p := ¶ms.TplCreate{VMID: vmID, Name: name, Access: access} resp, err := nc.client.R().SetBody(p).Post("/templates/vm") if err != nil { return nil, err @@ -48,7 +41,7 @@ func (nc *NexusClient) TemplateCreate(vmID uuid.UUID, name, access string) (*tem } } -func (nc *NexusClient) GetTemplates() ([]t.TemplateSerialized, error) { +func (nc *NexusClient) GetTemplates() ([]template.TemplateSerialized, error) { resp, err := nc.client.R().Get("/templates") if err != nil { return nil, err @@ -65,7 +58,7 @@ func (nc *NexusClient) GetTemplates() ([]t.TemplateSerialized, error) { } } -func (nc *NexusClient) GetTemplate(uuid string) (*t.TemplateSerialized, error) { +func (nc *NexusClient) GetTemplate(uuid string) (*template.TemplateSerialized, error) { resp, err := nc.client.R().Get("/templates/" + uuid) if err != nil { return nil, err @@ -113,8 +106,8 @@ func (nc *NexusClient) TemplateExportDisk(tplID, outputFile string) error { } // Deserialize a list of templates from an http response (no filtering). -func deserializeTemplates(resp *resty.Response) ([]t.TemplateSerialized, error) { - templates := []t.TemplateSerialized{} +func deserializeTemplates(resp *resty.Response) ([]template.TemplateSerialized, error) { + templates := []template.TemplateSerialized{} if err := json.Unmarshal(resp.Body(), &templates); err != nil { return nil, err } @@ -122,8 +115,8 @@ func deserializeTemplates(resp *resty.Response) ([]t.TemplateSerialized, error) } // Deserialize a single template from an http response. -func deserializeTemplate(resp *resty.Response) (*t.TemplateSerialized, error) { - tpl := t.TemplateSerialized{} +func deserializeTemplate(resp *resty.Response) (*template.TemplateSerialized, error) { + tpl := template.TemplateSerialized{} if err := json.Unmarshal(resp.Body(), &tpl); err != nil { return nil, err } diff --git a/libclient/user.go b/libclient/user.go index 8888d9c6d7773653308816bfde37508647525506..1dc97df52113c607be84a4f1cbda323d5e38cfb7 100644 --- a/libclient/user.go +++ b/libclient/user.go @@ -76,7 +76,7 @@ func (nc *NexusClient) UserUnlock(email string) error { } func (nc *NexusClient) UserUpdatePwd(newPwd string) error { - p := ¶ms.UserSetPwd{newPwd} + p := ¶ms.UserSetPwd{Pwd: newPwd} resp, err := nc.client.R().SetBody(p).Put("/users/pwd") if err != nil { return err