= Go library for accessing the Semaphore CI API
image:https://travis-ci.org/ldez/go-semaphoreci.svg?branch=master["Build Status", link="https://travis-ci.org/ldez/go-semaphoreci"]
image:https://godoc.org/github.com/ldez/go-semaphoreci?status.svg["GoDoc", link="https://godoc.org/github.com/ldez/go-semaphoreci"]
image:https://goreportcard.com/badge/github.com/ldez/go-semaphoreci["Go Report Card", link="https://goreportcard.com/report/github.com/ldez/go-semaphoreci"]
image:https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg["Say Thanks!", link="https://saythanks.io/to/ldez"]
go-semaphoreci is a Go client library for accessing the https://semaphoreci.com/[Semaphore CI] API.
* [x] link:https://semaphoreci.com/docs/branches-and-builds-api.html[API v1]
* link:http://semaphoreci.com/docs/api-v2-overview.html[API v2]
** [x] read operations
** [ ] write operations
== Examples
=== API v1
[source, golang]
----
import (
"log"
"github.com/ldez/go-semaphoreci/v1"
)
func main() {
transport := v1.TokenTransport{
Token: "your-token",
}
client := v1.NewClient(transport.Client())
projects, _, err := client.Projects.Get()
if err != nil {
log.Fatal(err)
}
for _, project := range projects {
log.Println(project)
}
}
----
=== API v2
[source, golang]
----
import (
"log"
"github.com/ldez/go-semaphoreci/v2"
)
func main() {
authToken := v2.TokenTransport{
Token: "your-token",
}
client := v2.NewClient(authToken.Client())
projects, resp, err := client.Projects.GetByOrg("your-organization")
if err != nil {
log.Fatal(err)
}
log.Println("HTTP response: ", resp)
for _, project := range projects {
log.Println(project)
}
}
----