github.com/giantswarm/gsclientgen

Go client library for the deprecatd Giant Swarm Rest API, generated based on a Swagger/OAI spec with go-swagger


License
Apache-2.0
Install
go get github.com/giantswarm/gsclientgen

Documentation

GoDoc Go Report Card

Giant Swarm Go Client (generated)

Experimental Go/Golang client for the Giant Swarm API, auto-generated based on the OAI/Swagger specification using go-swagger.

Usage

Here is a simplistic example of how to use the client for listing clusters:

package main

import (
	"fmt"

	"github.com/giantswarm/gsclientgen/v2/client"
	"github.com/giantswarm/gsclientgen/v2/client/clusters"

	httptransport "github.com/go-openapi/runtime/client"
	"github.com/go-openapi/strfmt"
)

func main() {
	// You'll need the correct host name and probably "https" instead of "http"
	tp := httptransport.New("localhost:8000", "", []string{"http"})

	// You'll need a proper token
	token := "some-example-token"
	auth := httptransport.APIKeyAuth("Authorization", "header", "giantswarm " + token))

	params := clusters.NewGetClustersParams()
	c := client.New(tp, strfmt.Default)

	response, err := c.Clusters.GetClusters(params, auth)
	if err != nil {
		fmt.Println(err)
	}

	fmt.Printf("First cluster ID is '%s'\n", response.Payload[0].ID)
}

Development

To pull the latest api-spec master and generate documentation and Go code:

$ make generate

To work on a different branch of the api-spec, edit the BRANCH variable in the top of Makefile.

To double-check the spec's validity do this:

$ make validate