GetIntegrationStatus gets the current integration status from server
(ctx context.Context)
| 206 | |
| 207 | // GetIntegrationStatus gets the current integration status from server |
| 208 | func (c *Client) GetIntegrationStatus(ctx context.Context) (*models.IntegrationStatusResponse, error) { |
| 209 | url := fmt.Sprintf("%s/api/%s/hosts/integrations", c.config.PatchmonServer, c.config.APIVersion) |
| 210 | |
| 211 | c.logger.Debug("Getting integration status from server") |
| 212 | |
| 213 | resp, err := c.client.R(). |
| 214 | SetContext(ctx). |
| 215 | SetHeader("Content-Type", "application/json"). |
| 216 | SetHeader("X-API-ID", c.credentials.APIID). |
| 217 | SetHeader("X-API-KEY", c.credentials.APIKey). |
| 218 | SetResult(&models.IntegrationStatusResponse{}). |
| 219 | Get(url) |
| 220 | |
| 221 | if err != nil { |
| 222 | return nil, fmt.Errorf("integration status request failed: %w", err) |
| 223 | } |
| 224 | |
| 225 | if resp.StatusCode() != 200 { |
| 226 | c.logger.WithField("response", resp.String()).Debug("Full error response from integration status request") |
| 227 | return nil, fmt.Errorf("integration status request failed with status %d: %s", resp.StatusCode(), truncateResponse(resp.String(), 200)) |
| 228 | } |
| 229 | |
| 230 | result, ok := resp.Result().(*models.IntegrationStatusResponse) |
| 231 | if !ok { |
| 232 | return nil, fmt.Errorf("invalid response format") |
| 233 | } |
| 234 | |
| 235 | return result, nil |
| 236 | } |
| 237 | |
| 238 | // SendIntegrationSetupStatus sends the setup status of an integration to the server |
| 239 | func (c *Client) SendIntegrationSetupStatus(ctx context.Context, status *models.IntegrationSetupStatus) error { |
no test coverage detected