GetSSGVersion fetches the server's embedded SSG version and available content files.
(ctx context.Context)
| 322 | |
| 323 | // GetSSGVersion fetches the server's embedded SSG version and available content files. |
| 324 | func (c *Client) GetSSGVersion(ctx context.Context) (*SSGVersionResponse, error) { |
| 325 | url := fmt.Sprintf("%s/api/%s/compliance/ssg-version", c.config.PatchmonServer, c.config.APIVersion) |
| 326 | |
| 327 | resp, err := c.client.R(). |
| 328 | SetContext(ctx). |
| 329 | SetHeader("X-API-ID", c.credentials.APIID). |
| 330 | SetHeader("X-API-KEY", c.credentials.APIKey). |
| 331 | SetResult(&SSGVersionResponse{}). |
| 332 | Get(url) |
| 333 | |
| 334 | if err != nil { |
| 335 | return nil, fmt.Errorf("ssg-version request failed: %w", err) |
| 336 | } |
| 337 | if resp.StatusCode() != 200 { |
| 338 | return nil, fmt.Errorf("ssg-version request failed with status %d", resp.StatusCode()) |
| 339 | } |
| 340 | result, ok := resp.Result().(*SSGVersionResponse) |
| 341 | if !ok { |
| 342 | return nil, fmt.Errorf("invalid ssg-version response format") |
| 343 | } |
| 344 | return result, nil |
| 345 | } |
| 346 | |
| 347 | // DownloadSSGContent downloads a specific SSG datastream file from the server. |
| 348 | func (c *Client) DownloadSSGContent(ctx context.Context, filename, destPath string) error { |