Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
added Vdcorg, use httpclient for all requests
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankammermann committed Dec 3, 2017
1 parent 80fa33e commit e828198
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
4 changes: 4 additions & 0 deletions vcdapi/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func decodeBody(resp *http.Response, out interface{}) error {
fmt.Println("response Body:", string(body))
}

if out == nil {
return nil
}

// Unmarshal the XML.
if err = xml.Unmarshal(body, &out); err != nil {
return err
Expand Down
25 changes: 13 additions & 12 deletions vcdapi/vcdapiclient.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
package vcdapi

import (
"net/http"
"fmt"
"github.com/floriankammermann/vcloud-cli/types"
"errors"
)

func GetAllVApp(url string) {
req, err := http.NewRequest("GET", url+"/api/query?type=vApp&fields=name&pageSize=512", nil)
req.Header.Set("x-vcloud-authorization", vcdClient.VAToken)
req.Header.Set("Accept", "application/*+xml;version=5.5")

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
func GetAllVdcorg(url string) {

path := "/api/query?type=orgVdc&fields=name&pageSize=512"
queryRes := new(types.QueryResultRecordsType)
ExecRequest(url, path, queryRes)

for _, vapp := range queryRes.OrgVdcRecord {
fmt.Printf("orgVdc Name [%s]\n", vapp.Name)
}

defer resp.Body.Close()
}

func GetAllVApp(url string) {

path := "/api/query?type=vApp&fields=name&pageSize=512"
queryRes := new(types.QueryResultRecordsType)
decodeBody(resp, queryRes)
ExecRequest(url, path, queryRes)

for _, vapp := range queryRes.VAppRecord {
fmt.Printf("vApp Name [%s]\n", vapp.Name)
Expand Down

0 comments on commit e828198

Please sign in to comment.