SendPatchOutput sends patch run output/status to the server (agent-facing patching endpoint)
(ctx context.Context, patchRunID, stage, output, errorMessage string)
| 366 | |
| 367 | // SendPatchOutput sends patch run output/status to the server (agent-facing patching endpoint) |
| 368 | func (c *Client) SendPatchOutput(ctx context.Context, patchRunID, stage, output, errorMessage string) error { |
| 369 | url := fmt.Sprintf("%s/api/%s/patching/runs/%s/output", c.config.PatchmonServer, c.config.APIVersion, patchRunID) |
| 370 | |
| 371 | body := map[string]interface{}{ |
| 372 | "stage": stage, |
| 373 | } |
| 374 | if output != "" { |
| 375 | body["output"] = output |
| 376 | } |
| 377 | if errorMessage != "" { |
| 378 | body["error_message"] = errorMessage |
| 379 | } |
| 380 | |
| 381 | resp, err := c.client.R(). |
| 382 | SetContext(ctx). |
| 383 | SetHeader("Content-Type", "application/json"). |
| 384 | SetHeader("X-API-ID", c.credentials.APIID). |
| 385 | SetHeader("X-API-KEY", c.credentials.APIKey). |
| 386 | SetBody(body). |
| 387 | Post(url) |
| 388 | |
| 389 | if err != nil { |
| 390 | return fmt.Errorf("patch output request failed: %w", err) |
| 391 | } |
| 392 | |
| 393 | if resp.StatusCode() != 200 { |
| 394 | return fmt.Errorf("patch output request failed with status %d: %s", resp.StatusCode(), truncateResponse(resp.String(), 200)) |
| 395 | } |
| 396 | |
| 397 | return nil |
| 398 | } |
| 399 | |
| 400 | // WindowsUpdateResult reports the outcome of a single Windows Update installation. |
| 401 | type WindowsUpdateResult struct { |
no test coverage detected