wharf-api-client-go

module
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2022 License: MIT

README

Go-lang RPC client for Wharf

Codacy Badge Go Reference

A library to talk to Wharf via Wharf's main API written in Go.

Uses net/http to send HTTP requests and encoding/json to serialize/deserialize each message back and forth.

This project is for example used inside the providers to create projects into the database when importing from GitLab, GitHub, or Azure DevOps.

Compatibility

wharf-api-client-go wharf-api
v1 v0, v1, v2, v3, v4, and v51
v2 v5, and beyond

1: The PUT endpoints /api/project, /api/token, and /api/provider were removed in wharf-api v5.0.0.

Usage

$ go get github.com/iver-wharf/wharf-api-client-go/v2/pkg/wharfapi
package main

import (
	"fmt"
	"github.com/iver-wharf/wharf-api-client-go/v2/pkg/wharfapi"
)

func main() {
	client := wharfapi.Client{
		APIURL:     "https://example.wharf.com",
		AuthHeader: "Bearer some-auth-token",
	}

	project,err := client.GetProjectByID(125)

	if err != nil {
		fmt.Printf("Unable to find project\n")
	} else {
		fmt.Printf("Project #%d: %s\n", project.ProjectID, project.Name)
	}
}
Sample output
GET | PROJECT | 125
Project #125: MyProject

Linting

make deps # download linting dependencies

make lint

make lint-go # only lint Go code
make lint-md # only lint Markdown files

Some errors can be fixed automatically. Keep in mind that this updates the files in place.

make lint-fix

make lint-fix-go # only lint and fix Go files
make lint-fix-md # only lint and fix Markdown files

Maintained by Iver. Licensed under the MIT license.

Directories

Path Synopsis
api
pkg
model/request
Package request contains plain old Go types used in the Gin endpoint handlers and Swaggo documentation for the HTTP request models, with Gin- and Swaggo-specific Go tags.
Package request contains plain old Go types used in the Gin endpoint handlers and Swaggo documentation for the HTTP request models, with Gin- and Swaggo-specific Go tags.
model/response
Package response contains plain old Go types returned by wharf-web in the HTTP responses, with Swaggo-specific Go tags.
Package response contains plain old Go types returned by wharf-web in the HTTP responses, with Swaggo-specific Go tags.
wharfapi
Package wharfapi has a list of type-safe functions used to access Wharf's main API (wharf-api).
Package wharfapi has a list of type-safe functions used to access Wharf's main API (wharf-api).

Jump to

Keyboard shortcuts

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