Git Product home page Git Product logo

go-sonarqube's Introduction

go-sonarqube

Alt

Quality Gate Status Codacy Badge

An HTTP client to interact with the SonarQube API from Go. It uses a service structure similar to that of go-github.

Most code is generated by the code in sonarqube-gen, using webservices.json as source of truth for the API endpoints. This is one of the first iterations of generating the API. It only supports JSON return types and skips some endpoints that need special handling of the return values.

See https://pkg.go.dev/github.com/shijl0925/go-sonarqube/sonarqube for supported endpoints.

Installation

go get github.com/shijl0925/go-sonarqube

Usage

Use sonarqube.NewClient to create a new client. It needs a SonarQube baseUrl and username / password or token, and optionally accepts an existing *http.Client.

After creating the client, create a new request from one of the endpoint-specific packages, i.e. projects.SearchRequest from github.com/shijl0925/go-sonarqube/sonarqube/projects. If an endpoint supports paging, you need to supply ppaging.Params as well, though in that case it might be easier to use the All variant of the function. The example below, for instance, uses client.Projects.SearchAll(req) instead of client.Projects.Search(req, paging).

The page size for automatic paging is currently set to 100, but might be configurable later.

package main
import (
	"context"
	"fmt"
	"log"
)

func main() {
    ctx := context.Background()
    baseUrl := "https://next.sonarqube.com/sonarqube"
    client := sonarqube.NewClient(baseUrl, "", "", nil)
    req := projects.SearchRequest{}

    res, err := client.Projects.SearchAll(ctx, req)
    if err != nil {
        log.Fatalf("could not search projects: %+v", err)
    }

    fmt.Printf("%+v\n", res)
}

go-sonarqube's People

Contributors

shijl0925 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.