Skip to content

Commit f54b056

Browse files
tkAcharya007Harness
authored andcommitted
feat: [STO-9671]: Enhance Exemption model and API for Global Exemptions (#166)
* feat: [STO-9671]: Enhance Exemption model and API for Global Exemptions - Added OrgName and ProjectName fields to the Exemption struct. - Introduced IsOccurrenceLevelExemption field in FrontendExemption struct. - Created GlobalExemptionsRequestBody model for handling organization:project pairs. - Updated FrontendGlobalExemptions API to accept a request body. - Removed MatchesProject parameter from the tool and adjusted the request handling accordingly.
1 parent 6cdc45e commit f54b056

File tree

2 files changed

+93
-38
lines changed

2 files changed

+93
-38
lines changed

client/sto/generated/sto.gen.go

Lines changed: 86 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/harness/tools/sto.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func StoGlobalExemptionsTool(config *config.Config, client *generated.ClientWith
291291
mcp.WithString("projectId", mcp.Required(), mcp.Description("Harness Project ID")),
292292
mcp.WithNumber("page", mcp.Description("Page number to fetch (starting from 0)"), mcp.Min(0), mcp.DefaultNumber(0)),
293293
mcp.WithNumber("pageSize", mcp.Description("Number of results per page"), mcp.DefaultNumber(5)),
294-
mcp.WithString("matchesProject", mcp.Description("Comma-separated list of organization:project pairs to filter exemptions by project scope (e.g., \"default:STO,default:CCM\").")),
294+
295295
mcp.WithString("status", mcp.Description("Required. Exemption status: Pending, Approved, Rejected, Expired. You must provide exactly one status.")),
296296
mcp.WithString("search", mcp.Description(`Free-text search that matches both issue titles and exemption titles.
297297
@@ -331,17 +331,18 @@ func StoGlobalExemptionsTool(config *config.Config, client *generated.ClientWith
331331
} else {
332332
params.PageSize = &size
333333
}
334-
if v, _ := OptionalParam[string](request, "matchesProject"); v != "" {
335-
params.MatchesProject = &v
336-
}
334+
337335
if v, _ := OptionalParam[string](request, "status"); v != "" {
338336
params.Status = generated.FrontendGlobalExemptionsParamsStatus(v)
339337
}
340338
if v, _ := OptionalParam[string](request, "search"); v != "" {
341339
params.Search = &v
342340
}
343341

344-
resp, err := client.FrontendGlobalExemptionsWithResponse(ctx, params)
342+
// Create request body for the new POST API
343+
body := generated.GlobalExemptionsRequestBody{}
344+
345+
resp, err := client.FrontendGlobalExemptionsWithResponse(ctx, params, body)
345346
if err != nil {
346347
return mcp.NewToolResultError(err.Error()), nil
347348
}
@@ -373,7 +374,7 @@ func StoGlobalExemptionsTool(config *config.Config, client *generated.ClientWith
373374
}
374375
// PrincipalService: GetUserInfo(ctx, scope, userID, page, size)
375376
userInfo, err := principalClient.GetUserInfo(ctx, scope, userID, 0, 1)
376-
if err == nil && userInfo != nil && &userInfo.Data != nil && &userInfo.Data.User != nil {
377+
if err == nil && userInfo != nil {
377378
if userInfo.Data.User.Name != "" {
378379
name = userInfo.Data.User.Name
379380
} else if userInfo.Data.User.Email != "" {

0 commit comments

Comments
 (0)