{"id":18512809,"url":"https://github.com/vmware/go-vcloud-director","last_synced_at":"2025-05-16T03:02:30.279Z","repository":{"id":37445063,"uuid":"140753907","full_name":"vmware/go-vcloud-director","owner":"vmware","description":"Golang SDK for VMware Cloud Director","archived":false,"fork":false,"pushed_at":"2024-10-25T09:43:17.000Z","size":23944,"stargazers_count":80,"open_issues_count":48,"forks_count":76,"subscribers_count":14,"default_branch":"main","last_synced_at":"2024-10-25T12:09:50.617Z","etag":null,"topics":["go","golang","sdk","vcd","vmware"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vmware.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":"support/Dockerfile.jenkins","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-12T19:04:07.000Z","updated_at":"2024-10-25T09:42:42.000Z","dependencies_parsed_at":"2023-10-04T18:11:49.613Z","dependency_job_id":"a1bedc4e-5dbc-4633-9e87-77e6e180ad6d","html_url":"https://github.com/vmware/go-vcloud-director","commit_stats":null,"previous_names":[],"tags_count":281,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fgo-vcloud-director","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fgo-vcloud-director/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fgo-vcloud-director/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fgo-vcloud-director/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vmware","download_url":"https://codeload.github.com/vmware/go-vcloud-director/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254459079,"owners_count":22074604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","sdk","vcd","vmware"],"created_at":"2024-11-06T15:35:31.494Z","updated_at":"2025-05-16T03:02:25.269Z","avatar_url":"https://github.com/vmware.png","language":"Go","readme":"# go-vcloud-director [![GoDoc](https://godoc.org/github.com/vmware/go-vcloud-director?status.svg)](http://godoc.org/github.com/vmware/go-vcloud-director) [![Chat](https://img.shields.io/badge/chat-on%20slack-brightgreen.svg)](https://vmwarecode.slack.com/messages/CBBBXVB16)\n\nThis repo contains the `go-vcloud-director` package which implements\nan SDK for VMware Cloud Director. The project serves the needs of Golang\ndevelopers who need to integrate with VMware Cloud Director. It is also the\nbasis of the [vCD Terraform\nProvider](https://github.com/vmware/terraform-provider-vcd).\n\n## Contributions ##\n\nContributions to `go-vcloud-director` are gladly welcome and range\nfrom participating in community discussions to submitting pull\nrequests.  Please see the [contributing guide](CONTRIBUTING.md) for\ndetails on joining the community.\n\n### Install and Build ###\n\nThis project started using Go [modules](https://github.com/golang/go/wiki/Modules)\nstarting with version 2.1 and `vendor` directory is no longer bundled.\n\nAs per the [modules documentation](https://github.com/golang/go/wiki/Modules)\nyou no longer need to use `GOPATH`. You can clone the branch in any directory\nyou like and go will fetch dependencies specified in the `go.mod` file:\n```\ncd ~/Documents/mycode\ngit clone https://github.com/vmware/go-vcloud-director.git\ncd go-vcloud-director/govcd\ngo build\n```\n\n**Note** Do not forget to set `GO111MODULE=on` if you are in your GOPATH.\n[Read more about this.](https://github.com/golang/go/wiki/Modules#how-to-install-and-activate-module-support)\n\n#### Example code ####\n\nTo show the SDK in action run the example:\n```\nmkdir ~/govcd_example\ngo mod init govcd_example\ngo get github.com/vmware/go-vcloud-director/v3@main\ngo build -o example\n./example user_name \"password\" org_name vcd_IP vdc_name \n```\n\nHere's the code:\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/url\"\n\t\"os\"\n\n\t\"github.com/vmware/go-vcloud-director/v3/govcd\"\n)\n\ntype Config struct {\n\tUser     string\n\tPassword string\n\tOrg      string\n\tHref     string\n\tVDC      string\n\tInsecure bool\n}\n\nfunc (c *Config) Client() (*govcd.VCDClient, error) {\n\tu, err := url.ParseRequestURI(c.Href)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to pass url: %s\", err)\n\t}\n\n\tvcdclient := govcd.NewVCDClient(*u, c.Insecure)\n\terr = vcdclient.Authenticate(c.User, c.Password, c.Org)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to authenticate: %s\", err)\n\t}\n\treturn vcdclient, nil\n}\n\nfunc main() {\n\tif len(os.Args) \u003c 6 {\n\t\tfmt.Println(\"Syntax: example user password org VCD_IP VDC \")\n\t\tos.Exit(1)\n\t}\n\tconfig := Config{\n\t\tUser:     os.Args[1],\n\t\tPassword: os.Args[2],\n\t\tOrg:      os.Args[3],\n\t\tHref:     fmt.Sprintf(\"https://%s/api\", os.Args[4]),\n\t\tVDC:      os.Args[5],\n\t\tInsecure: true,\n\t}\n\n\tclient, err := config.Client() // We now have a client\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tos.Exit(1)\n\t}\n\torg, err := client.GetOrgByName(config.Org)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tos.Exit(1)\n\t}\n\tvdc, err := org.GetVDCByName(config.VDC, false)\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tos.Exit(1)\n\t}\n\tfmt.Printf(\"Org URL: %s\\n\", org.Org.HREF)\n\tfmt.Printf(\"VDC URL: %s\\n\", vdc.Vdc.HREF)\n}\n\n```\n\n## Authentication\n\nYou can authenticate to the vCD in five ways:\n\n* With a System Administration user and password (`administrator@system`)\n* With an Organization user and password (`tenant-admin@org-name`)\n\nFor the above two methods, you use: \n```go\n\terr := vcdClient.Authenticate(User, Password, Org)\n\t// or\n\tresp, err := vcdClient.GetAuthResponse(User, Password, Org)\n```\n\n* With an authorization token\n```go\n\terr := vcdClient.SetToken(Org, govcd.AuthorizationHeader, Token)\n```\nThe file `scripts/get_token.sh` provides a handy method of extracting the token\n(`x-vcloud-authorization` value) for future use.\n\n* With a service account token (the file needs to have `r+w` rights)\n```go\n\terr := vcdClient.SetServiceAccountApiToken(Org, \"tokenfile.json\")\n```\n\n* SAML user and password (works with ADFS as IdP using WS-TRUST endpoint\n  \"/adfs/services/trust/13/usernamemixed\"). One must pass `govcd.WithSamlAdfs(true,customAdfsRptId)`\n  and username must be formatted so that ADFS understands it ('user@contoso.com' or\n  'contoso.com\\user') You can find usage example in\n  [samples/saml_auth_adfs](/samples/saml_auth_adfs). \n```go\nvcdCli := govcd.NewVCDClient(*vcdURL, true, govcd.WithSamlAdfs(true, customAdfsRptId))\nerr = vcdCli.Authenticate(username, password, org)\n```\n\nMore information about inner workings of SAML auth flow in this codebase can be found in\n`saml_auth.go:authorizeSamlAdfs(...)`. Additionaly this flow is documented in [vCD\ndocumentation](https://code.vmware.com/docs/10000/vcloud-api-programming-guide-for-service-providers/GUID-335CFC35-7AD8-40E5-91BE-53971937A2BB.html).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware%2Fgo-vcloud-director","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvmware%2Fgo-vcloud-director","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware%2Fgo-vcloud-director/lists"}