mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-19 04:33:28 +02:00
9bcdcc128f
An empty stream isn't valid JSON, so we shouldn't silently ignore it.
28 lines
756 B
Go
28 lines
756 B
Go
package jira
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
|
|
)
|
|
|
|
// https://docs.atlassian.com/jira/REST/cloud/#api/2/project-getProjectComponents
|
|
func (j *Jira) GetProjectComponents(project string) (*jiradata.Components, error) {
|
|
return GetProjectComponents(j.UA, j.Endpoint, project)
|
|
}
|
|
|
|
func GetProjectComponents(ua HttpClient, endpoint string, project string) (*jiradata.Components, error) {
|
|
uri := URLJoin(endpoint, "rest/api/2/project", project, "components")
|
|
resp, err := ua.GetJSON(uri)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
if resp.StatusCode == 200 {
|
|
results := jiradata.Components{}
|
|
return &results, json.NewDecoder(resp.Body).Decode(&results)
|
|
}
|
|
return nil, responseError(resp)
|
|
}
|