This repository contains killbill go client library (kbclient) and killbill command line tool (kbcmd)
KB Version | KBCli Version |
---|---|
0.20.x | 1.x.y |
0.22.x | 2.x.y |
Kill bill go client library is a go package that can be used to connect to kill bill.
go get -u github.com/killbill/kbcli/v2
trp := httptransport.New("127.0.0.1:8080", "", nil)
// Add text/xml producer which is not handled by openapi runtime.
trp.Producers["text/xml"] = runtime.TextProducer()
// Set this to true to dump http messages
trp.Debug = false
// Authentication
authWriter := runtime.ClientAuthInfoWriterFunc(func(r runtime.ClientRequest, _ strfmt.Registry) error {
encoded := base64.StdEncoding.EncodeToString([]byte("admin"/*username*/ + ":" + "password" /**password*/))
if err := r.SetHeaderParam("Authorization", "Basic "+encoded); err != nil {
return err
}
if err := r.SetHeaderParam("X-KillBill-ApiKey", apiKey); err != nil {
return err
}
if err := r.SetHeaderParam("X-KillBill-ApiSecret", apiSecret); err != nil {
return err
}
return nil
})
client := kbclient.New(trp, strfmt.Default, authWriter, kbclient.KillbillDefaults{})
Look at the complete example here. For more examples, look at kbcmd tool.
This client code was generated by the go-swagger tool.
We use a modified generator and templates to generate the client, and the sources are here.
To generate:
# Update swagger.json
curl http://localhost:8080/swagger.json | jq "." >swagger.json
# Install swagger tool
mkdir -p $GOPATH/src/github.com/go-swagger
cd $GOPATH/src/github.com/go-swagger
git clone git@github.com:killbill/go-swagger.git
# Required each time the templates change
go install github.com/go-swagger/go-swagger/cmd/swagger
# You must be in $GOPATH/src to regenerate the files, consider creating a symlink in
# ln -s /path/to/killbill/go-swagger go-swagger
cd $GOPATH/src/github.com/killbill/kbcli
# Regenerate the tool
swagger generate client -f swagger.json -m kbmodel -c kbclient --default-scheme=http
We also have dev extension APIs (like clock etc), that are in swagger-dev.json. To generate, run the following.
# Regenerate the tool
swagger generate client -f swagger-dev.json -m kbmodel -c kbclient --default-scheme=http
# Delete the client file.
rm kbclient/kill_bill_dev_client.go
kbcmd is a command line tool that uses the go client library. This tool can do many of the kill bill operations. More details are available here in README.