gocd-go-api-client

command module
v0.0.0-...-02d28e6 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 0 Imported by: 0

README

GoCD Golang API Client

Go Reference codecov

A golang client for the GoCD API.

Installation

go get github.com/AlinScreciu/gocd-go-api-client

Usage/Examples

package main

import (
	"fmt"
	"os"

	"github.com/AlinScreciu/gocd-go-api-client/pkg/client"
)

func main() {

	client, err := client.NewClient("https://gocd.8x8.com/go")
	if err != nil {
		fmt.Printf("failed to create client: '%s'\n", err.Error())
		os.Exit(1)
	}

	client.SetAccessToken("<YOUR_ACCESS_TOKEN>")
	// client.SetBasicAuth("<USERNAME>", "<PASSWORD>")

	version, err := client.GetVersion()
	if err != nil {
		os.Exit(1)
	}

	currentUser, err := client.GetCurrentUser()
	if err != nil {
		os.Exit(1)
	}

	fmt.Printf("I am %s, GoCD version: %s\n", currentUser.DisplayName, version.Version)
}

License

MIT

Contributing

Contributions are always welcome!

See CONTRIBUTING.md for ways to get started.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
pkg

Jump to

Keyboard shortcuts

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