Skip to content

Commit 7fdf859

Browse files
author
Prem Ramanathan
committed
Update README
1 parent 439fa86 commit 7fdf859

File tree

3 files changed

+76
-7
lines changed

3 files changed

+76
-7
lines changed

README.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
1-
# Kill Bill go client library
1+
# Kill Bill go client library and kill bill command line
2+
This repository contains killbill go client library (kbclient)
3+
and killbill command line tool (kbcmd)
24

3-
This is a basic implementation of a client library written in go to interract with Kill Bill.
5+
## Kill bill go client library
6+
Kill bill go client library is a go package that can be used to connect to
7+
kill bill.
48

5-
The http layer has been adapated from the existing [napping](https://github.com/jmcvetta/napping) go repository (which was itself inspired by Python's excellent [Requests](http://docs.python-requests.org/en/latest/) library.
9+
### Install
10+
```bash
11+
go get -u src/github.com/killbill/kbcli/kbclient
12+
```
613

7-
# Status
14+
### Creating new client
15+
```go
16+
trp := httptransport.New("127.0.0.1:8080", "", nil)
17+
// Add text/xml producer which is not handled by openapi runtime.
18+
trp.Producers["text/xml"] = runtime.TextProducer()
19+
// Set this to true to dump http messages
20+
trp.Debug = false
21+
authWriter := httptransport.BasicAuth("admin"/*username*/, "password" /**password*/)
22+
client := kbclient.New(trp, strfmt.Default, authWriter, kbclient.KillbillDefaults{})
823

9-
Only a few APIs have been implemented so far, mostly around payments call. There is an [example](https://github.com/sbrossie/kbcli/blob/master/examples/payments.go) which using go concurrency feature to throw some load at an existing running Kill Bill instance.
24+
```
1025

26+
Look at the [complete example here](examples/listaccounts/main.go).
27+
For more examples, look at [kbcmd tool](kbcmd/README.md).
1128

29+
## Kill bill command line tool (kbcmd)
30+
kbcmd is a command line tool that uses the go client library. This tool can do many of the
31+
kill bill operations. More details are [available here in README](kbcmd/README.md).

examples/listaccounts/main.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"github.com/go-openapi/runtime"
8+
httptransport "github.com/go-openapi/runtime/client"
9+
"github.com/go-openapi/strfmt"
10+
"github.com/killbill/kbcli/kbclient"
11+
"github.com/killbill/kbcli/kbclient/account"
12+
)
13+
14+
// NewClient creates new kill bill client
15+
func NewClient() *kbclient.KillBill {
16+
trp := httptransport.New("127.0.0.1:8080", "", nil)
17+
// Add text/xml producer which is not handled by openapi runtime.
18+
trp.Producers["text/xml"] = runtime.TextProducer()
19+
// Set this to true to dump http messages
20+
trp.Debug = false
21+
authWriter := httptransport.BasicAuth("admin" /*username*/, "password" /**password*/)
22+
client := kbclient.New(trp, strfmt.Default, authWriter, kbclient.KillbillDefaults{})
23+
24+
// Set defaults. You can override them in each API call.
25+
apiKey := "bob"
26+
apiSecret := "lazar"
27+
createdBy := "John Doe"
28+
comment := "Created by John Doe"
29+
reason := ""
30+
31+
client.SetDefaults(kbclient.KillbillDefaults{
32+
APIKey: &apiKey,
33+
APISecret: &apiSecret,
34+
CreatedBy: &createdBy,
35+
Comment: &comment,
36+
Reason: &reason,
37+
})
38+
return client
39+
}
40+
41+
func main() {
42+
c := NewClient()
43+
resp, err := c.Account.GetAccounts(context.Background(), &account.GetAccountsParams{})
44+
if err != nil {
45+
panic(err)
46+
}
47+
for _, acc := range resp.Payload {
48+
fmt.Printf("%s %s %s\n", acc.AccountID, acc.ExternalKey, acc.Email)
49+
}
50+
}

kbcmd/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ to talk to killbill.
55

66
## Installing
77
```bash
8-
cd $GOPATH
98
go get -u src/github.com/killbill/kbcli/kbcmd
109
go install src/github.com/killbill/kbcli/kbcmd
1110

1211
# For bash completion
1312
source src/github.com/killbill/kbcli/kbcmd/bash-autocomplete
1413

1514
# If you haven't added Go bin path to PATH
16-
export PATH=$PWD/bin:$PATH
15+
export PATH=$GOPATH/bin:$PATH
1716
```
1817

1918
## Running the command

0 commit comments

Comments
 (0)