MCPcopy Create free account
hub / github.com/git-bug/git-bug / GetProject

Method GetProject

bridge/jira/client.go:910–948  ·  view source on GitHub ↗

GetProject returns the project JSON object given its id or key

(projectIDOrKey string)

Source from the content-addressed store, hash-verified

908
909// GetProject returns the project JSON object given its id or key
910func (client *Client) GetProject(projectIDOrKey string) (*Project, error) {
911 url := fmt.Sprintf(
912 "%s/rest/api/2/project/%s", client.serverURL, projectIDOrKey)
913
914 request, err := http.NewRequest("GET", url, nil)
915 if err != nil {
916 return nil, err
917 }
918
919 if client.ctx != nil {
920 ctx, cancel := context.WithTimeout(client.ctx, defaultTimeout)
921 defer cancel()
922 request = request.WithContext(ctx)
923 }
924
925 response, err := client.Do(request)
926 if err != nil {
927 return nil, err
928 }
929
930 defer response.Body.Close()
931
932 if response.StatusCode != http.StatusOK {
933 err := fmt.Errorf(
934 "HTTP response %d, query was %s", response.StatusCode, url)
935 return nil, err
936 }
937
938 var project Project
939
940 data, _ := io.ReadAll(response.Body)
941 err = json.Unmarshal(data, &project)
942 if err != nil {
943 err := fmt.Errorf("Decoding response %v", err)
944 return nil, err
945 }
946
947 return &project, nil
948}
949
950// CreateIssue creates a new JIRA issue and returns it
951func (client *Client) CreateIssue(projectIDOrKey, title, body string,

Callers 3

InitMethod · 0.95
validateProjectURLFunction · 0.80
ConfigureMethod · 0.80

Implementers 1

Clientbridge/github/mocks/Client.go

Calls 3

ErrorfMethod · 0.80
CloseMethod · 0.65
ReadAllMethod · 0.65

Tested by

no test coverage detected