createProjectStatusUpdate creates a new status update for a project via GraphQL.
(ctx context.Context, gqlClient *githubv4.Client, owner, ownerType string, projectNumber int, body, status, startDate, targetDate string)
| 1253 | |
| 1254 | // createProjectStatusUpdate creates a new status update for a project via GraphQL. |
| 1255 | func createProjectStatusUpdate(ctx context.Context, gqlClient *githubv4.Client, owner, ownerType string, projectNumber int, body, status, startDate, targetDate string) (*mcp.CallToolResult, any, error) { |
| 1256 | // Validate inputs |
| 1257 | if ownerType != "user" && ownerType != "org" { |
| 1258 | return utils.NewToolResultError(fmt.Sprintf("invalid owner_type %q: must be \"user\" or \"org\"", ownerType)), nil, nil |
| 1259 | } |
| 1260 | if status != "" && !validProjectV2StatusUpdateStatuses[status] { |
| 1261 | return utils.NewToolResultError(fmt.Sprintf("invalid status %q: must be one of INACTIVE, ON_TRACK, AT_RISK, OFF_TRACK, COMPLETE", status)), nil, nil |
| 1262 | } |
| 1263 | if startDate != "" { |
| 1264 | if err := validateDateFormat(startDate, "start_date"); err != nil { |
| 1265 | return utils.NewToolResultError(err.Error()), nil, nil |
| 1266 | } |
| 1267 | } |
| 1268 | if targetDate != "" { |
| 1269 | if err := validateDateFormat(targetDate, "target_date"); err != nil { |
| 1270 | return utils.NewToolResultError(err.Error()), nil, nil |
| 1271 | } |
| 1272 | } |
| 1273 | |
| 1274 | // Resolve project number to project node ID |
| 1275 | projectID, err := resolveProjectNodeID(ctx, gqlClient, owner, ownerType, projectNumber) |
| 1276 | if err != nil { |
| 1277 | return utils.NewToolResultError(err.Error()), nil, nil |
| 1278 | } |
| 1279 | |
| 1280 | // Build mutation input |
| 1281 | input := CreateProjectV2StatusUpdateInput{ |
| 1282 | ProjectID: projectID, |
| 1283 | } |
| 1284 | |
| 1285 | if body != "" { |
| 1286 | s := githubv4.String(body) |
| 1287 | input.Body = &s |
| 1288 | } |
| 1289 | if status != "" { |
| 1290 | s := githubv4.String(status) |
| 1291 | input.Status = &s |
| 1292 | } |
| 1293 | if startDate != "" { |
| 1294 | s := githubv4.String(startDate) |
| 1295 | input.StartDate = &s |
| 1296 | } |
| 1297 | if targetDate != "" { |
| 1298 | s := githubv4.String(targetDate) |
| 1299 | input.TargetDate = &s |
| 1300 | } |
| 1301 | |
| 1302 | // Execute mutation |
| 1303 | var mutation struct { |
| 1304 | CreateProjectV2StatusUpdate struct { |
| 1305 | StatusUpdate statusUpdateNode |
| 1306 | } `graphql:"createProjectV2StatusUpdate(input: $input)"` |
| 1307 | } |
| 1308 | |
| 1309 | err = gqlClient.Mutate(ctx, &mutation, input, nil) |
| 1310 | if err != nil { |
| 1311 | return utils.NewToolResultError(fmt.Sprintf("%s: %v", ProjectStatusUpdateCreateFailedError, err)), nil, nil |
| 1312 | } |
no test coverage detected