PostWithResponse makes a POST request to the Proxmox API and returns the response with timeout.
(path string, data interface{}, result *map[string]interface{})
| 86 | |
| 87 | // PostWithResponse makes a POST request to the Proxmox API and returns the response with timeout. |
| 88 | func (c *Client) PostWithResponse(path string, data interface{}, result *map[string]interface{}) error { |
| 89 | ctx, cancel := context.WithTimeout(context.Background(), DefaultAPITimeout) |
| 90 | defer cancel() |
| 91 | |
| 92 | c.logger.Debug("API POST with response: %s", path) |
| 93 | // Convert data to map[string]interface{} if it's not nil |
| 94 | var postData interface{} |
| 95 | |
| 96 | if data != nil { |
| 97 | var ok bool |
| 98 | |
| 99 | postData, ok = data.(map[string]interface{}) |
| 100 | if !ok { |
| 101 | return fmt.Errorf("data must be of type map[string]interface{}") |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | return c.httpClient.Post(ctx, path, postData, result) |
| 106 | } |
| 107 | |
| 108 | // Delete makes a DELETE request to the Proxmox API with timeout. |
| 109 | func (c *Client) Delete(path string) error { |
no test coverage detected