Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06b11d8121 | ||
|
|
4f7f1f0fba |
@@ -16,7 +16,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const Version = "0.3.0"
|
||||
const Version = "0.5.0"
|
||||
|
||||
type Logger interface {
|
||||
Printf(format string, args ...any)
|
||||
|
||||
@@ -190,6 +190,23 @@ func TestInstanceChangePricingAndAsyncTraffic(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExpandRootVolumePathAndBody(t *testing.T) {
|
||||
client, _ := testClient(t, func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPatch || r.URL.Path != "/api/sdk/v1/regions/us-east-1/instances/local-1/root-volume" {
|
||||
t.Fatalf("unexpected request %s %s", r.Method, r.URL.Path)
|
||||
}
|
||||
var body ExpandRootVolumeRequest
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil || body.SizeGiB != 80 || body.ExpectedConfigurationFingerprint != "fp" {
|
||||
t.Fatalf("unexpected body %#v err=%v", body, err)
|
||||
}
|
||||
_, _ = w.Write([]byte(`{"code":202,"message":"Accepted","data":{"task_id":"task-root","status":"queued"}}`))
|
||||
})
|
||||
operation, err := client.Volumes.ExpandRoot(context.Background(), "us-east-1", "local-1", ExpandRootVolumeRequest{SizeGiB: 80, ExpectedConfigurationFingerprint: "fp"}, WithIdempotencyKey("root-expand"))
|
||||
if err != nil || operation.TaskID != "task-root" {
|
||||
t.Fatalf("operation=%#v err=%v", operation, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInstanceDetailsExposeCatalogMetadata(t *testing.T) {
|
||||
client, _ := testClient(t, func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
@@ -86,6 +86,10 @@ type ModifyVolumeRequest struct {
|
||||
Throughput int32 `json:"throughput,omitempty"`
|
||||
ExpectedConfigurationFingerprint string `json:"expected_configuration_fingerprint,omitempty"`
|
||||
}
|
||||
type ExpandRootVolumeRequest struct {
|
||||
SizeGiB int32 `json:"size_gib"`
|
||||
ExpectedConfigurationFingerprint string `json:"expected_configuration_fingerprint,omitempty"`
|
||||
}
|
||||
|
||||
func (s *VolumeService) List(ctx context.Context, region, instanceID string) ([]Volume, error) {
|
||||
var result struct {
|
||||
@@ -106,6 +110,9 @@ func (s *VolumeService) Detach(ctx context.Context, region, instanceID, volumeID
|
||||
func (s *VolumeService) Modify(ctx context.Context, region, instanceID, volumeID string, input ModifyVolumeRequest, options ...RequestOption) (*Operation, error) {
|
||||
return (&InstancesService{client: s.client}).operation(ctx, http.MethodPatch, instancesPath(region, instanceID)+"/volumes/"+escaped(volumeID), input, options...)
|
||||
}
|
||||
func (s *VolumeService) ExpandRoot(ctx context.Context, region, instanceID string, input ExpandRootVolumeRequest, options ...RequestOption) (*Operation, error) {
|
||||
return (&InstancesService{client: s.client}).operation(ctx, http.MethodPatch, instancesPath(region, instanceID)+"/root-volume", input, options...)
|
||||
}
|
||||
func (s *VolumeService) Delete(ctx context.Context, region, instanceID, volumeID string, force bool, options ...RequestOption) (*Operation, error) {
|
||||
return (&InstancesService{client: s.client}).operation(ctx, http.MethodDelete, instancesPath(region, instanceID)+"/volumes/"+escaped(volumeID), map[string]bool{"force": force}, options...)
|
||||
}
|
||||
|
||||
@@ -164,11 +164,13 @@ type PriceEstimate struct {
|
||||
}
|
||||
|
||||
const (
|
||||
InstanceChangeEIPAdd = "eip_add"
|
||||
InstanceChangeVolumeCreate = "volume_create"
|
||||
InstanceChangeVolumeExpand = "volume_expand"
|
||||
InstanceChangeRebuildImage = "rebuild_image"
|
||||
InstanceChangeTrafficLimit = "traffic_limit"
|
||||
InstanceChangeEIPAdd = "eip_add"
|
||||
InstanceChangeEIPReplace = "eip_replace"
|
||||
InstanceChangeVolumeCreate = "volume_create"
|
||||
InstanceChangeVolumeExpand = "volume_expand"
|
||||
InstanceChangeRootVolumeExpand = "root_volume_expand"
|
||||
InstanceChangeRebuildImage = "rebuild_image"
|
||||
InstanceChangeTrafficLimit = "traffic_limit"
|
||||
)
|
||||
|
||||
type InstanceChangePriceRequest struct {
|
||||
|
||||
Reference in New Issue
Block a user