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.
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
.
$ 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)
}
}
GET | PROJECT | 125
Project #125: MyProject
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.