go-octopusdeploy

command module
v1.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

go-octopusdeploy

PkgGoDev Run Integration Tests Go Report

A Go client for the Octopus Deploy API. This client is used by the Octopus Deploy Terraform Provider.

Install

go get "github.com/pemaxim/go-octopusdeploy"

Usage

import "github.com/pemaxim/go-octopusdeploy/octopusdeploy"

The 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 for more information).

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
client, err := octopusdeploy.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:

usernamePasswordAccount := octopusdeploy.NewUsernamePasswordAccount(name)
usernamePasswordAccount.Username = username

createdAccount, err := client.Accounts.Add(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. 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 directory. There are also many integration and unit tests available to examine that demonstrate the capabilities of this API client.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
examples
Package uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf.org/html/rfc6570).
Package uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf.org/html/rfc6570).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL