| 154 | } |
| 155 | |
| 156 | func (c *Client) WorkspaceProxyByName(ctx context.Context, name string) (WorkspaceProxy, error) { |
| 157 | res, err := c.Request(ctx, http.MethodGet, |
| 158 | fmt.Sprintf("/api/v2/workspaceproxies/%s", name), |
| 159 | nil, |
| 160 | ) |
| 161 | if err != nil { |
| 162 | return WorkspaceProxy{}, xerrors.Errorf("make request: %w", err) |
| 163 | } |
| 164 | defer res.Body.Close() |
| 165 | |
| 166 | if res.StatusCode != http.StatusOK { |
| 167 | return WorkspaceProxy{}, ReadBodyAsError(res) |
| 168 | } |
| 169 | |
| 170 | var resp WorkspaceProxy |
| 171 | return resp, json.NewDecoder(res.Body).Decode(&resp) |
| 172 | } |
| 173 | |
| 174 | func (c *Client) WorkspaceProxyByID(ctx context.Context, id uuid.UUID) (WorkspaceProxy, error) { |
| 175 | return c.WorkspaceProxyByName(ctx, id.String()) |