GetAuthToken returns the authentication token for API requests.
()
| 139 | |
| 140 | // GetAuthToken returns the authentication token for API requests. |
| 141 | func (c *Client) GetAuthToken() string { |
| 142 | if c.httpClient.apiToken != "" { |
| 143 | return c.httpClient.apiToken |
| 144 | } |
| 145 | |
| 146 | // For ticket-based authentication, get the current ticket |
| 147 | if c.authManager != nil { |
| 148 | ctx := context.Background() |
| 149 | |
| 150 | token, err := c.authManager.GetValidToken(ctx) |
| 151 | if err == nil && token != nil { |
| 152 | return fmt.Sprintf("PVEAuthCookie=%s", token.Ticket) |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | return "" |
| 157 | } |
| 158 | |
| 159 | // GetWithCache makes a GET request to the Proxmox API with caching. |
| 160 | func (c *Client) GetWithCache(path string, result *map[string]interface{}, ttl time.Duration) error { |
no test coverage detected