An open API service indexing awesome lists of open source software.

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:

Awesome Lists containing this project

README

          


go-octopusdeploy Logo

go-octopusdeploy


Go API Client for Octopus Deploy 🐙



GitHub release
PkgGoDev
Go Report


---

## 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 space

apiURL, 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 = username

createdAccount, 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.