https://github.com/octopusdeploy/go-octopusdeploy
| Public | Go API Client for Octopus Deploy :octopus:
https://github.com/octopusdeploy/go-octopusdeploy
go public
Last synced: 6 months ago
JSON representation
| Public | Go API Client for Octopus Deploy :octopus:
- Host: GitHub
- URL: https://github.com/octopusdeploy/go-octopusdeploy
- Owner: OctopusDeploy
- License: other
- Created: 2019-03-26T07:40:36.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-03-20T04:08:23.000Z (7 months ago)
- Last Synced: 2025-03-30T20:11:39.023Z (6 months ago)
- Topics: go, public
- Language: Go
- Homepage:
- Size: 5.89 MB
- Stars: 13
- Watchers: 10
- Forks: 26
- Open Issues: 31
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
---
## Install
```bash
go get "github.com/OctopusDeploy/go-octopusdeploy/v2"
```## Usage
```go
import "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
```The [Octopus REST API](https://octopus.com/docs/octopus-rest-api) is exposed through service fields of the client. An API key is required to communicate with the API (see [How to Create an API Key](https://octopus.com/docs/octopus-rest-api/how-to-create-an-api-key) for more information).
```go
apiKey := "API-YOUR_API_KEY"
octopusURL := "https://your_octopus_url"
spaceID := "space-id" // can also be blank to assume the default spaceapiURL, err := url.Parse(octopusURL)
if err != nil {
_ = fmt.Errorf("error parsing URL for Octopus API: %v", err)
return
}// the first parameter for NewClient can accept a http.Client if you wish to
// override the default; also, the spaceID may be an empty string (i.e. "") if
// you wish to load the default space
octopusClient, err := client.NewClient(nil, apiURL, apiKey, spaceID)
if err != nil {
_ = fmt.Errorf("error creating API client: %v", err)
return
}
```Once the client has been initialized, APIs can be targeted through the model and services available:
```go
usernamePasswordAccount := accounts.NewUsernamePasswordAccount(name)
usernamePasswordAccount.Username = usernamecreatedAccount, err := accounts.Add(octopusClient, usernamePasswordAccount)
if err != nil {
_ = fmt.Errorf("error adding account: %v", err)
}
```Operations like `Add`, `DeleteByID`, `GetByID`, and `Update` are supported by most services that are exposed through the client if not exposed in the package. These operations are configured at runtime since the Octopus REST API is hypermedia-driven.
Numerous code samples that showcase the API and this client are available in the [examples](/examples) directory. There are also many [integration](/test) and unit tests available to examine that demonstrate the capabilities of this API client.
## 🤝 Contributions
Contributions are welcome! :heart: Please read our [Contributing Guide](CONTRIBUTING.md) for information about how to get involved in this project.