ModifyInstance modifies an existing instance configuration.
(instanceID string, req InstanceModifyRequest)
| 267 | |
| 268 | // ModifyInstance modifies an existing instance configuration. |
| 269 | func (c *Client) ModifyInstance(instanceID string, req InstanceModifyRequest) (*InstanceModifyResponse, error) { |
| 270 | var resp InstanceModifyResponse |
| 271 | err := c.doRequest(context.Background(), "POST", fmt.Sprintf("/v1/instances/%s/modify", instanceID), req, &resp) |
| 272 | if err != nil { |
| 273 | var apiErr *APIError |
| 274 | if errors.As(err, &apiErr) { |
| 275 | switch apiErr.StatusCode { |
| 276 | case 404: |
| 277 | return nil, fmt.Errorf("instance not found") |
| 278 | case 409: |
| 279 | return nil, fmt.Errorf("instance cannot be modified (may not be in RUNNING state)") |
| 280 | } |
| 281 | } |
| 282 | return nil, err |
| 283 | } |
| 284 | return &resp, nil |
| 285 | } |
| 286 | |
| 287 | // UpdatePorts atomically adds and removes forwarded HTTP ports on an instance. |
| 288 | func (c *Client) UpdatePorts(instanceID string, addPorts, removePorts []int) (*PortAddResponse, error) { |
no test coverage detected