Skip to content

hivelocity/hivelocity-client-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hivelocity Go Client

GoDoc Build Status

This project github.com/hivelocity/hivelocity-client-go/client is an autogenerated OpenAPI v3 client from our Hosted API Specification.

Hivelocity API Docs: developers.hivelocity.net/docs

Getting Started

If you're just looking to use this client in your project, simply run go get -u github.com/hivelocity/hivelocity-client-go/client. Then checkout the GoDoc.

Example Code

Here is an example how to list all available service types.

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	hv "github.com/hivelocity/hivelocity-client-go/client"
)

func main() {
	apiKey := os.Getenv("HIVELOCITY_API_KEY")
	if apiKey == "" {
		log.Fatalln("Missing environment variable HIVELOCITY_API_KEY")
		os.Exit(1)
	}
	authContext := context.WithValue(context.Background(), hv.ContextAPIKey, hv.APIKey{
		Key: apiKey,
	})
	apiClient := hv.NewAPIClient(hv.NewConfiguration())
	serviceTypes, _, err := apiClient.ServiceApi.GetServiceTypeResource(authContext, nil)
	if err != nil {
		log.Fatalln(err)
		os.Exit(1)
	}
	for _, st := range serviceTypes {
		fmt.Printf("service type: %+v\n", st)
	}
}

Internal Development

The code in the directory "client" was auto-generated by swagger. Do not change this code, since changes will be overwritten the next time make client gets called.

Generating a fresh client with latest API changes

To generate a client, first you need java, make, and wget install. These should be available in your package manager:

# Debian/Ubuntu Linux or WSL
$ sudo apt-get install -y make wget java

# Homebrew (OSX)
$ brew install make wget
$ brew cask install java

After all the dependencies are installed, run the following make command to update the client code from the latest Swagger Specification:

$ make client

Releasing

Get the current changes:

git switch main
git pull
make client
git diff

If there is something not commited yet, then create a PR first an merge that to main.

Have a look at the current (old) version: Github Releases / Tags

export RELEASE_TAG=<the tag of the release to be cut> (eg. export RELEASE_TAG=v0.1.0)
git tag -a ${RELEASE_TAG} -m ${RELEASE_TAG}

Push the tag to the GitHub repository.

NOTE: origin should be the name of the remote pointing to github.com/hivelocity/hivelocity-client-go

git push origin ${RELEASE_TAG}