| 162 | } |
| 163 | |
| 164 | func (c *Client) AgentConnectionInfo(ctx context.Context, agentID uuid.UUID) (AgentConnectionInfo, error) { |
| 165 | res, err := c.client.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/workspaceagents/%s/connection", agentID), nil) |
| 166 | if err != nil { |
| 167 | return AgentConnectionInfo{}, err |
| 168 | } |
| 169 | defer res.Body.Close() |
| 170 | if res.StatusCode != http.StatusOK { |
| 171 | return AgentConnectionInfo{}, codersdk.ReadBodyAsError(res) |
| 172 | } |
| 173 | |
| 174 | var connInfo AgentConnectionInfo |
| 175 | return connInfo, json.NewDecoder(res.Body).Decode(&connInfo) |
| 176 | } |
| 177 | |
| 178 | // AgentConnFunc returns a new connection to the specified agent. If release is |
| 179 | // non-nil, callers must invoke it after they are done with the AgentConn. |