Skip to content

ldez/go-semaphoreci

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go library for accessing the Semaphore CI API

Build Status PkgGoDev Go Report Card

Sponsor

go-semaphoreci is a Go client library for accessing the Semaphore CI API.

  • API v1

  • API v2

    • ✓ read operations

    • ❏ write operations

Examples

API v1

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

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)
	}
}