Debian Codegraph @

README.md

raw symbols SCIP
1 ## vmware-govcd
2
3 This package was originally forked from [github.com/vmware/govcloudair](https://github.com/vmware/govcloudair) before pulling in [rickard-von-essen's](https://github.com/rickard-von-essen)
4 great changes to allow using a [vCloud Director API](https://github.com/rickard-von-essen/govcloudair/tree/vcd-5.5). On top of this I have added features as needed for a terraform provider for vCloud Director
5
6 ### Example ###
7
8 ```go
9 package main
10
11 import (
12 "fmt"
13 "net/url"
14 "os"
15
16 "github.com/hmrc/vmware-govcd"
17 )
18
19 type Config struct {
20 User string
21 Password string
22 Org string
23 Href string
24 VDC string
25 Insecure bool
26 }
27
28 func (c *Config) Client() (*govcd.VCDClient, error) {
29 u, err := url.ParseRequestURI(c.Href)
30 if err != nil {
31 return nil, fmt.Errorf("Unable to pass url: %s", err)
32 }
33
34 vcdclient := govcd.NewVCDClient(*u, c.Insecure)
35 org, vcd, err := vcdclient.Authenticate(c.User, c.Password, c.Org, c.VDC)
36 if err != nil {
37 return nil, fmt.Errorf("Unable to authenticate: %s", err)
38 }
39 vcdclient.Org = org
40 vcdclient.OrgVdc = vcd
41 return vcdclient, nil
42 }
43
44 func main() {
45 config := Config{
46 User: "Username",
47 Password: "password",
48 Org: "vcd org",
49 Href: "vcd api url",
50 VDC: "vcd virtual datacenter name",
51 }
52
53 client, err := config.Client() // We now have a client
54 if err != nil {
55 fmt.Println(err)
56 os.Exit(1)
57 }
58 fmt.Printf("Org URL: %s\n", client.OrgHREF.String())
59 }
60 ```