(ctx context.Context, client *github.Client, owner, ownerType string, projectNumber int, fieldID int64)
| 997 | } |
| 998 | |
| 999 | func getProjectField(ctx context.Context, client *github.Client, owner, ownerType string, projectNumber int, fieldID int64) (*mcp.CallToolResult, any, error) { |
| 1000 | var resp *github.Response |
| 1001 | var projectField *github.ProjectV2Field |
| 1002 | var err error |
| 1003 | |
| 1004 | if ownerType == "org" { |
| 1005 | projectField, resp, err = client.Projects.GetOrganizationProjectField(ctx, owner, projectNumber, fieldID) |
| 1006 | } else { |
| 1007 | projectField, resp, err = client.Projects.GetUserProjectField(ctx, owner, projectNumber, fieldID) |
| 1008 | } |
| 1009 | |
| 1010 | if err != nil { |
| 1011 | return ghErrors.NewGitHubAPIErrorResponse(ctx, |
| 1012 | "failed to get project field", |
| 1013 | resp, |
| 1014 | err, |
| 1015 | ), nil, nil |
| 1016 | } |
| 1017 | defer func() { _ = resp.Body.Close() }() |
| 1018 | |
| 1019 | if resp.StatusCode != http.StatusOK { |
| 1020 | body, err := io.ReadAll(resp.Body) |
| 1021 | if err != nil { |
| 1022 | return nil, nil, fmt.Errorf("failed to read response body: %w", err) |
| 1023 | } |
| 1024 | return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to get project field", resp, body), nil, nil |
| 1025 | } |
| 1026 | r, err := json.Marshal(projectField) |
| 1027 | if err != nil { |
| 1028 | return nil, nil, fmt.Errorf("failed to marshal response: %w", err) |
| 1029 | } |
| 1030 | |
| 1031 | return utils.NewToolResultText(string(r)), nil, nil |
| 1032 | } |
| 1033 | |
| 1034 | func getProjectItem(ctx context.Context, client *github.Client, owner, ownerType string, projectNumber int, itemID int64, fields []int64) (*mcp.CallToolResult, any, error) { |
| 1035 | var resp *github.Response |
no test coverage detected