Post makes a POST request to the Proxmox API with timeout.
(path string, data interface{})
| 65 | |
| 66 | // Post makes a POST request to the Proxmox API with timeout. |
| 67 | func (c *Client) Post(path string, data interface{}) error { |
| 68 | ctx, cancel := context.WithTimeout(context.Background(), DefaultAPITimeout) |
| 69 | defer cancel() |
| 70 | |
| 71 | c.logger.Debug("API POST: %s", path) |
| 72 | // Convert data to map[string]interface{} if it's not nil |
| 73 | var postData interface{} |
| 74 | |
| 75 | if data != nil { |
| 76 | var ok bool |
| 77 | |
| 78 | postData, ok = data.(map[string]interface{}) |
| 79 | if !ok { |
| 80 | return fmt.Errorf("data must be of type map[string]interface{}") |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | return c.httpClient.Post(ctx, path, postData, nil) |
| 85 | } |
| 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 { |
no test coverage detected