github.com/daeMOn63/bitclient@v0.0.0-20190425080230-bfee94efac35/sonar.go (about)

     1  package bitclient
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  func (bc *BitClient) GetSonarSettings(projectKey string, repositorySlug string) (SonarSettings, error) {
     8  	rError := new(ErrorResponse)
     9  	settings := SonarSettings{}
    10  
    11  	url := fmt.Sprintf("/rest/sonar4stash/1.0/projects/%s/repos/%s/settings", projectKey, repositorySlug)
    12  	resp, _ := bc.sling.New().Get(url).Receive(&settings, rError)
    13  
    14  	resp, err := bc.checkReponse(resp, rError)
    15  
    16  	return settings, err
    17  }
    18  
    19  func (bc *BitClient) SetSonarSettings(projectKey string, repositorySlug string, settings SonarSettings) error {
    20  	rError := new(ErrorResponse)
    21  
    22  	url := fmt.Sprintf("/rest/sonar4stash/1.0/projects/%s/repos/%s/settings", projectKey, repositorySlug)
    23  	resp, _ := bc.sling.New().Post(url).BodyJSON(settings).Receive(nil, rError)
    24  
    25  	resp, err := bc.checkReponse(resp, rError)
    26  
    27  	return err
    28  }