diff --git a/.stats.yml b/.stats.yml
index 52b47b0..baf4dec 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,2 +1,2 @@
configured_endpoints: 22
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nirvana-labs%2Fnirvana-103a418ce8e7c594165303b86b52547fae832297c274951cb5025d917622fbc6.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nirvana-labs%2Fnirvana-6e3dd3baf6a65944d5c5468740fb292207576dfa404bcff24a77d4b6ad6d4a82.yml
diff --git a/README.md b/README.md
index 6a266cc..f77d777 100644
--- a/README.md
+++ b/README.md
@@ -40,42 +40,19 @@ package main
import (
"context"
- "fmt"
"github.com/nirvana-labs/nirvana-go"
"github.com/nirvana-labs/nirvana-go/option"
- "github.com/nirvana-labs/nirvana-go/shared"
- "github.com/nirvana-labs/nirvana-go/vms"
)
func main() {
client := nirvana.NewClient(
option.WithAuthToken("My Auth Token"), // defaults to os.LookupEnv("NIRVANA_LABS_AUTH_TOKEN")
)
- operation, err := client.VMs.New(context.TODO(), vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- })
+ operations, err := client.Operations.List(context.TODO())
if err != nil {
panic(err.Error())
}
- fmt.Printf("%+v\n", operation.ID)
}
```
@@ -164,7 +141,7 @@ client := nirvana.NewClient(
option.WithHeader("X-Some-Header", "custom_header_info"),
)
-client.VMs.New(context.TODO(), ...,
+client.Operations.List(context.TODO(), ...,
// Override the header
option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
// Add an undocumented field to the request body, using sjson syntax
@@ -193,33 +170,14 @@ When the API returns a non-success status code, we return an error with type
To handle errors, we recommend that you use the `errors.As` pattern:
```go
-_, err := client.VMs.New(context.TODO(), vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
-})
+_, err := client.Operations.List(context.TODO())
if err != nil {
var apierr *nirvana.Error
if errors.As(err, &apierr) {
println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request
println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
}
- panic(err.Error()) // GET "/vms": 400 Bad Request { ... }
+ panic(err.Error()) // GET "/operations": 400 Bad Request { ... }
}
```
@@ -237,28 +195,8 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`.
// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
-client.VMs.New(
+client.Operations.List(
ctx,
- vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- },
// This sets the per-retry timeout
option.WithRequestTimeout(20*time.Second),
)
@@ -292,30 +230,7 @@ client := nirvana.NewClient(
)
// Override per-request:
-client.VMs.New(
- context.TODO(),
- vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- },
- option.WithMaxRetries(5),
-)
+client.Operations.List(context.TODO(), option.WithMaxRetries(5))
```
### Making custom/undocumented requests
diff --git a/api.md b/api.md
index 740ce3a..3d010af 100644
--- a/api.md
+++ b/api.md
@@ -7,7 +7,20 @@
- shared.RegionName
- shared.ResourceStatus
-# VMs
+# Operations
+
+Response Types:
+
+- operations.Operation
+
+Methods:
+
+- client.Operations.List(ctx context.Context) ([]operations.Operation, error)
+- client.Operations.Get(ctx context.Context, operationID string) (operations.Operation, error)
+
+# Compute
+
+## VMs
Params Types:
@@ -25,81 +38,72 @@ Response Types:
Methods:
-- client.VMs.New(ctx context.Context, body vms.VMNewParams) (operations.Operation, error)
-- client.VMs.Update(ctx context.Context, vmID string, body vms.VMUpdateParams) (operations.Operation, error)
-- client.VMs.List(ctx context.Context) (vms.VMList, error)
-- client.VMs.Delete(ctx context.Context, vmID string) (operations.Operation, error)
-- client.VMs.Get(ctx context.Context, vmID string) (vms.VM, error)
-
-## OSImages
-
-Methods:
-
-- client.VMs.OSImages.List(ctx context.Context) ([]vms.OSImage, error)
+- client.Compute.VMs.New(ctx context.Context, body vms.VMNewParams) (operations.Operation, error)
+- client.Compute.VMs.Update(ctx context.Context, vmID string, body vms.VMUpdateParams) (operations.Operation, error)
+- client.Compute.VMs.List(ctx context.Context) (vms.VMList, error)
+- client.Compute.VMs.Delete(ctx context.Context, vmID string) (operations.Operation, error)
+- client.Compute.VMs.Get(ctx context.Context, vmID string) (vms.VM, error)
-# VPCs
-
-Response Types:
-
-- vpcs.Subnet
-- vpcs.VPC
-- vpcs.VPCList
+### OSImages
Methods:
-- client.VPCs.New(ctx context.Context, body vpcs.VPCNewParams) (operations.Operation, error)
-- client.VPCs.List(ctx context.Context) (vpcs.VPCList, error)
-- client.VPCs.Delete(ctx context.Context, vpcID string) (operations.Operation, error)
-- client.VPCs.Get(ctx context.Context, vpcID string) (vpcs.VPC, error)
+- client.Compute.VMs.OSImages.List(ctx context.Context) ([]vms.OSImage, error)
-# FirewallRules
+## Volumes
Params Types:
-- firewall_rules.FirewallRuleEndpointParam
+- volumes.StorageType
Response Types:
-- firewall_rules.FirewallRule
-- firewall_rules.FirewallRuleEndpoint
-- firewall_rules.FirewallRuleList
+- volumes.StorageType
+- volumes.Volume
+- volumes.VolumeKind
+- volumes.VolumeListResponse
Methods:
-- client.FirewallRules.New(ctx context.Context, vpcID string, body firewall_rules.FirewallRuleNewParams) (operations.Operation, error)
-- client.FirewallRules.Update(ctx context.Context, vpcID string, firewallRuleID string, body firewall_rules.FirewallRuleUpdateParams) (operations.Operation, error)
-- client.FirewallRules.List(ctx context.Context, vpcID string) (firewall_rules.FirewallRuleList, error)
-- client.FirewallRules.Delete(ctx context.Context, vpcID string, firewallRuleID string) (operations.Operation, error)
-- client.FirewallRules.Get(ctx context.Context, vpcID string, firewallRuleID string) (firewall_rules.FirewallRule, error)
+- client.Compute.Volumes.New(ctx context.Context, body volumes.VolumeNewParams) (operations.Operation, error)
+- client.Compute.Volumes.Update(ctx context.Context, volumeID string, body volumes.VolumeUpdateParams) (operations.Operation, error)
+- client.Compute.Volumes.List(ctx context.Context) (volumes.VolumeListResponse, error)
+- client.Compute.Volumes.Delete(ctx context.Context, volumeID string, body volumes.VolumeDeleteParams) (operations.Operation, error)
+- client.Compute.Volumes.Get(ctx context.Context, volumeID string) (volumes.Volume, error)
-# Volumes
+# Networking
-Params Types:
-
-- volumes.StorageType
+## VPCs
Response Types:
-- volumes.StorageType
-- volumes.Volume
-- volumes.VolumeKind
-- volumes.VolumeListResponse
+- vpcs.Subnet
+- vpcs.VPC
+- vpcs.VPCList
Methods:
-- client.Volumes.New(ctx context.Context, body volumes.VolumeNewParams) (operations.Operation, error)
-- client.Volumes.Update(ctx context.Context, volumeID string, body volumes.VolumeUpdateParams) (operations.Operation, error)
-- client.Volumes.List(ctx context.Context) (volumes.VolumeListResponse, error)
-- client.Volumes.Delete(ctx context.Context, volumeID string, body volumes.VolumeDeleteParams) (operations.Operation, error)
-- client.Volumes.Get(ctx context.Context, volumeID string) (volumes.Volume, error)
+- client.Networking.VPCs.New(ctx context.Context, body vpcs.VPCNewParams) (operations.Operation, error)
+- client.Networking.VPCs.List(ctx context.Context) (vpcs.VPCList, error)
+- client.Networking.VPCs.Delete(ctx context.Context, vpcID string) (operations.Operation, error)
+- client.Networking.VPCs.Get(ctx context.Context, vpcID string) (vpcs.VPC, error)
-# Operations
+## FirewallRules
+
+Params Types:
+
+- firewall_rules.FirewallRuleEndpointParam
Response Types:
-- operations.Operation
+- firewall_rules.FirewallRule
+- firewall_rules.FirewallRuleEndpoint
+- firewall_rules.FirewallRuleList
Methods:
-- client.Operations.List(ctx context.Context) ([]operations.Operation, error)
-- client.Operations.Get(ctx context.Context, operationID string) (operations.Operation, error)
+- client.Networking.FirewallRules.New(ctx context.Context, vpcID string, body firewall_rules.FirewallRuleNewParams) (operations.Operation, error)
+- client.Networking.FirewallRules.Update(ctx context.Context, vpcID string, firewallRuleID string, body firewall_rules.FirewallRuleUpdateParams) (operations.Operation, error)
+- client.Networking.FirewallRules.List(ctx context.Context, vpcID string) (firewall_rules.FirewallRuleList, error)
+- client.Networking.FirewallRules.Delete(ctx context.Context, vpcID string, firewallRuleID string) (operations.Operation, error)
+- client.Networking.FirewallRules.Get(ctx context.Context, vpcID string, firewallRuleID string) (firewall_rules.FirewallRule, error)
diff --git a/client.go b/client.go
index e5b4ac2..fd812e4 100644
--- a/client.go
+++ b/client.go
@@ -7,25 +7,21 @@ import (
"net/http"
"os"
- "github.com/nirvana-labs/nirvana-go/firewall_rules"
+ "github.com/nirvana-labs/nirvana-go/compute"
"github.com/nirvana-labs/nirvana-go/internal/requestconfig"
+ "github.com/nirvana-labs/nirvana-go/networking"
"github.com/nirvana-labs/nirvana-go/operations"
"github.com/nirvana-labs/nirvana-go/option"
- "github.com/nirvana-labs/nirvana-go/vms"
- "github.com/nirvana-labs/nirvana-go/volumes"
- "github.com/nirvana-labs/nirvana-go/vpcs"
)
// Client creates a struct with services and top level methods that help with
// interacting with the Nirvana Labs API. You should not instantiate this client
// directly, and instead use the [NewClient] method instead.
type Client struct {
- Options []option.RequestOption
- VMs *vms.VMService
- VPCs *vpcs.VPCService
- FirewallRules *firewall_rules.FirewallRuleService
- Volumes *volumes.VolumeService
- Operations *operations.OperationService
+ Options []option.RequestOption
+ Operations *operations.OperationService
+ Compute *compute.ComputeService
+ Networking *networking.NetworkingService
}
// NewClient generates a new client with the default option read from the
@@ -41,11 +37,9 @@ func NewClient(opts ...option.RequestOption) (r *Client) {
r = &Client{Options: opts}
- r.VMs = vms.NewVMService(opts...)
- r.VPCs = vpcs.NewVPCService(opts...)
- r.FirewallRules = firewall_rules.NewFirewallRuleService(opts...)
- r.Volumes = volumes.NewVolumeService(opts...)
r.Operations = operations.NewOperationService(opts...)
+ r.Compute = compute.NewComputeService(opts...)
+ r.Networking = networking.NewNetworkingService(opts...)
return
}
diff --git a/client_test.go b/client_test.go
index 4096aff..c7c190c 100644
--- a/client_test.go
+++ b/client_test.go
@@ -13,8 +13,6 @@ import (
"github.com/nirvana-labs/nirvana-go"
"github.com/nirvana-labs/nirvana-go/internal"
"github.com/nirvana-labs/nirvana-go/option"
- "github.com/nirvana-labs/nirvana-go/shared"
- "github.com/nirvana-labs/nirvana-go/vms"
)
type closureTransport struct {
@@ -39,26 +37,7 @@ func TestUserAgentHeader(t *testing.T) {
},
}),
)
- client.VMs.New(context.Background(), vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- })
+ client.Operations.List(context.Background())
if userAgent != fmt.Sprintf("NirvanaLabs/Go %s", internal.PackageVersion) {
t.Errorf("Expected User-Agent to be correct, but got: %#v", userAgent)
}
@@ -81,26 +60,7 @@ func TestRetryAfter(t *testing.T) {
},
}),
)
- res, err := client.VMs.New(context.Background(), vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- })
+ res, err := client.Operations.List(context.Background())
if err == nil || res != nil {
t.Error("Expected there to be a cancel error and for the response to be nil")
}
@@ -134,26 +94,7 @@ func TestDeleteRetryCountHeader(t *testing.T) {
}),
option.WithHeaderDel("X-Stainless-Retry-Count"),
)
- res, err := client.VMs.New(context.Background(), vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- })
+ res, err := client.Operations.List(context.Background())
if err == nil || res != nil {
t.Error("Expected there to be a cancel error and for the response to be nil")
}
@@ -182,26 +123,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
}),
option.WithHeader("X-Stainless-Retry-Count", "42"),
)
- res, err := client.VMs.New(context.Background(), vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- })
+ res, err := client.Operations.List(context.Background())
if err == nil || res != nil {
t.Error("Expected there to be a cancel error and for the response to be nil")
}
@@ -229,26 +151,7 @@ func TestRetryAfterMs(t *testing.T) {
},
}),
)
- res, err := client.VMs.New(context.Background(), vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- })
+ res, err := client.Operations.List(context.Background())
if err == nil || res != nil {
t.Error("Expected there to be a cancel error and for the response to be nil")
}
@@ -270,26 +173,7 @@ func TestContextCancel(t *testing.T) {
)
cancelCtx, cancel := context.WithCancel(context.Background())
cancel()
- res, err := client.VMs.New(cancelCtx, vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- })
+ res, err := client.Operations.List(cancelCtx)
if err == nil || res != nil {
t.Error("Expected there to be a cancel error and for the response to be nil")
}
@@ -308,26 +192,7 @@ func TestContextCancelDelay(t *testing.T) {
)
cancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond)
defer cancel()
- res, err := client.VMs.New(cancelCtx, vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- })
+ res, err := client.Operations.List(cancelCtx)
if err == nil || res != nil {
t.Error("expected there to be a cancel error and for the response to be nil")
}
@@ -352,26 +217,7 @@ func TestContextDeadline(t *testing.T) {
},
}),
)
- res, err := client.VMs.New(deadlineCtx, vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- })
+ res, err := client.Operations.List(deadlineCtx)
if err == nil || res != nil {
t.Error("expected there to be a deadline error and for the response to be nil")
}
diff --git a/compute/aliases.go b/compute/aliases.go
new file mode 100644
index 0000000..7f0e6ef
--- /dev/null
+++ b/compute/aliases.go
@@ -0,0 +1,79 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package compute
+
+import (
+ "github.com/nirvana-labs/nirvana-go/internal/apierror"
+ "github.com/nirvana-labs/nirvana-go/shared"
+)
+
+type Error = apierror.Error
+
+// This is an alias to an internal type.
+type RegionName = shared.RegionName
+
+// This is an alias to an internal value.
+const RegionNameAmsterdam = shared.RegionNameAmsterdam
+
+// This is an alias to an internal value.
+const RegionNameChicago = shared.RegionNameChicago
+
+// This is an alias to an internal value.
+const RegionNameFrankfurt = shared.RegionNameFrankfurt
+
+// This is an alias to an internal value.
+const RegionNameHongkong = shared.RegionNameHongkong
+
+// This is an alias to an internal value.
+const RegionNameLondon = shared.RegionNameLondon
+
+// This is an alias to an internal value.
+const RegionNameMumbai = shared.RegionNameMumbai
+
+// This is an alias to an internal value.
+const RegionNameSaopaulo = shared.RegionNameSaopaulo
+
+// This is an alias to an internal value.
+const RegionNameSeattle = shared.RegionNameSeattle
+
+// This is an alias to an internal value.
+const RegionNameSiliconvalley = shared.RegionNameSiliconvalley
+
+// This is an alias to an internal value.
+const RegionNameSingapore = shared.RegionNameSingapore
+
+// This is an alias to an internal value.
+const RegionNameStockholm = shared.RegionNameStockholm
+
+// This is an alias to an internal value.
+const RegionNameSydney = shared.RegionNameSydney
+
+// This is an alias to an internal value.
+const RegionNameTokyo = shared.RegionNameTokyo
+
+// This is an alias to an internal value.
+const RegionNameWashingtondc = shared.RegionNameWashingtondc
+
+// This is an alias to an internal type.
+type ResourceStatus = shared.ResourceStatus
+
+// This is an alias to an internal value.
+const ResourceStatusPending = shared.ResourceStatusPending
+
+// This is an alias to an internal value.
+const ResourceStatusCreating = shared.ResourceStatusCreating
+
+// This is an alias to an internal value.
+const ResourceStatusUpdating = shared.ResourceStatusUpdating
+
+// This is an alias to an internal value.
+const ResourceStatusReady = shared.ResourceStatusReady
+
+// This is an alias to an internal value.
+const ResourceStatusDeleting = shared.ResourceStatusDeleting
+
+// This is an alias to an internal value.
+const ResourceStatusDeleted = shared.ResourceStatusDeleted
+
+// This is an alias to an internal value.
+const ResourceStatusFailed = shared.ResourceStatusFailed
diff --git a/compute/compute.go b/compute/compute.go
new file mode 100644
index 0000000..fca51c6
--- /dev/null
+++ b/compute/compute.go
@@ -0,0 +1,30 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package compute
+
+import (
+ "github.com/nirvana-labs/nirvana-go/option"
+)
+
+// ComputeService contains methods and other services that help with interacting
+// with the Nirvana Labs API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewComputeService] method instead.
+type ComputeService struct {
+ Options []option.RequestOption
+ VMs *VMService
+ Volumes *VolumeService
+}
+
+// NewComputeService generates a new service that applies the given options to each
+// request. These options are applied after the parent client's options (if there
+// is one), and before any request-specific options.
+func NewComputeService(opts ...option.RequestOption) (r *ComputeService) {
+ r = &ComputeService{}
+ r.Options = opts
+ r.VMs = NewVMService(opts...)
+ r.Volumes = NewVolumeService(opts...)
+ return
+}
diff --git a/firewall_rules/firewallrule.go b/firewall_rules/firewallrule.go
index 443dff4..bef7f3e 100644
--- a/firewall_rules/firewallrule.go
+++ b/firewall_rules/firewallrule.go
@@ -42,7 +42,7 @@ func (r *FirewallRuleService) New(ctx context.Context, vpcID string, body Firewa
err = errors.New("missing required vpc_id parameter")
return
}
- path := fmt.Sprintf("vpcs/%s/firewall_rules", vpcID)
+ path := fmt.Sprintf("networking/vpcs/%s/firewall_rules", vpcID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
@@ -58,7 +58,7 @@ func (r *FirewallRuleService) Update(ctx context.Context, vpcID string, firewall
err = errors.New("missing required firewall_rule_id parameter")
return
}
- path := fmt.Sprintf("vpcs/%s/firewall_rules/%s", vpcID, firewallRuleID)
+ path := fmt.Sprintf("networking/vpcs/%s/firewall_rules/%s", vpcID, firewallRuleID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
return
}
@@ -70,7 +70,7 @@ func (r *FirewallRuleService) List(ctx context.Context, vpcID string, opts ...op
err = errors.New("missing required vpc_id parameter")
return
}
- path := fmt.Sprintf("vpcs/%s/firewall_rules", vpcID)
+ path := fmt.Sprintf("networking/vpcs/%s/firewall_rules", vpcID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
@@ -86,7 +86,7 @@ func (r *FirewallRuleService) Delete(ctx context.Context, vpcID string, firewall
err = errors.New("missing required firewall_rule_id parameter")
return
}
- path := fmt.Sprintf("vpcs/%s/firewall_rules/%s", vpcID, firewallRuleID)
+ path := fmt.Sprintf("networking/vpcs/%s/firewall_rules/%s", vpcID, firewallRuleID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return
}
@@ -102,7 +102,7 @@ func (r *FirewallRuleService) Get(ctx context.Context, vpcID string, firewallRul
err = errors.New("missing required firewall_rule_id parameter")
return
}
- path := fmt.Sprintf("vpcs/%s/firewall_rules/%s", vpcID, firewallRuleID)
+ path := fmt.Sprintf("networking/vpcs/%s/firewall_rules/%s", vpcID, firewallRuleID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
diff --git a/firewall_rules/firewallrule_test.go b/firewall_rules/firewallrule_test.go
index 6f36b7f..5a7d95f 100644
--- a/firewall_rules/firewallrule_test.go
+++ b/firewall_rules/firewallrule_test.go
@@ -26,7 +26,7 @@ func TestFirewallRuleNewWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.FirewallRules.New(
+ _, err := client.Networking.FirewallRules.New(
context.TODO(),
"vpc_id",
firewall_rules.FirewallRuleNewParams{
@@ -63,7 +63,7 @@ func TestFirewallRuleUpdateWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.FirewallRules.Update(
+ _, err := client.Networking.FirewallRules.Update(
context.TODO(),
"vpc_id",
"firewall_rule_id",
@@ -101,7 +101,7 @@ func TestFirewallRuleList(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.FirewallRules.List(context.TODO(), "vpc_id")
+ _, err := client.Networking.FirewallRules.List(context.TODO(), "vpc_id")
if err != nil {
var apierr *nirvana.Error
if errors.As(err, &apierr) {
@@ -123,7 +123,7 @@ func TestFirewallRuleDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.FirewallRules.Delete(
+ _, err := client.Networking.FirewallRules.Delete(
context.TODO(),
"vpc_id",
"firewall_rule_id",
@@ -149,7 +149,7 @@ func TestFirewallRuleGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.FirewallRules.Get(
+ _, err := client.Networking.FirewallRules.Get(
context.TODO(),
"vpc_id",
"firewall_rule_id",
diff --git a/networking/aliases.go b/networking/aliases.go
new file mode 100644
index 0000000..bd25d5d
--- /dev/null
+++ b/networking/aliases.go
@@ -0,0 +1,79 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package networking
+
+import (
+ "github.com/nirvana-labs/nirvana-go/internal/apierror"
+ "github.com/nirvana-labs/nirvana-go/shared"
+)
+
+type Error = apierror.Error
+
+// This is an alias to an internal type.
+type RegionName = shared.RegionName
+
+// This is an alias to an internal value.
+const RegionNameAmsterdam = shared.RegionNameAmsterdam
+
+// This is an alias to an internal value.
+const RegionNameChicago = shared.RegionNameChicago
+
+// This is an alias to an internal value.
+const RegionNameFrankfurt = shared.RegionNameFrankfurt
+
+// This is an alias to an internal value.
+const RegionNameHongkong = shared.RegionNameHongkong
+
+// This is an alias to an internal value.
+const RegionNameLondon = shared.RegionNameLondon
+
+// This is an alias to an internal value.
+const RegionNameMumbai = shared.RegionNameMumbai
+
+// This is an alias to an internal value.
+const RegionNameSaopaulo = shared.RegionNameSaopaulo
+
+// This is an alias to an internal value.
+const RegionNameSeattle = shared.RegionNameSeattle
+
+// This is an alias to an internal value.
+const RegionNameSiliconvalley = shared.RegionNameSiliconvalley
+
+// This is an alias to an internal value.
+const RegionNameSingapore = shared.RegionNameSingapore
+
+// This is an alias to an internal value.
+const RegionNameStockholm = shared.RegionNameStockholm
+
+// This is an alias to an internal value.
+const RegionNameSydney = shared.RegionNameSydney
+
+// This is an alias to an internal value.
+const RegionNameTokyo = shared.RegionNameTokyo
+
+// This is an alias to an internal value.
+const RegionNameWashingtondc = shared.RegionNameWashingtondc
+
+// This is an alias to an internal type.
+type ResourceStatus = shared.ResourceStatus
+
+// This is an alias to an internal value.
+const ResourceStatusPending = shared.ResourceStatusPending
+
+// This is an alias to an internal value.
+const ResourceStatusCreating = shared.ResourceStatusCreating
+
+// This is an alias to an internal value.
+const ResourceStatusUpdating = shared.ResourceStatusUpdating
+
+// This is an alias to an internal value.
+const ResourceStatusReady = shared.ResourceStatusReady
+
+// This is an alias to an internal value.
+const ResourceStatusDeleting = shared.ResourceStatusDeleting
+
+// This is an alias to an internal value.
+const ResourceStatusDeleted = shared.ResourceStatusDeleted
+
+// This is an alias to an internal value.
+const ResourceStatusFailed = shared.ResourceStatusFailed
diff --git a/networking/networking.go b/networking/networking.go
new file mode 100644
index 0000000..9ffd089
--- /dev/null
+++ b/networking/networking.go
@@ -0,0 +1,30 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+package networking
+
+import (
+ "github.com/nirvana-labs/nirvana-go/option"
+)
+
+// NetworkingService contains methods and other services that help with interacting
+// with the Nirvana Labs API.
+//
+// Note, unlike clients, this service does not read variables from the environment
+// automatically. You should not instantiate this service directly, and instead use
+// the [NewNetworkingService] method instead.
+type NetworkingService struct {
+ Options []option.RequestOption
+ VPCs *VPCService
+ FirewallRules *FirewallRuleService
+}
+
+// NewNetworkingService generates a new service that applies the given options to
+// each request. These options are applied after the parent client's options (if
+// there is one), and before any request-specific options.
+func NewNetworkingService(opts ...option.RequestOption) (r *NetworkingService) {
+ r = &NetworkingService{}
+ r.Options = opts
+ r.VPCs = NewVPCService(opts...)
+ r.FirewallRules = NewFirewallRuleService(opts...)
+ return
+}
diff --git a/shared/shared.go b/shared/shared.go
index 8f320eb..2ce147b 100644
--- a/shared/shared.go
+++ b/shared/shared.go
@@ -32,13 +32,13 @@ func (r RegionName) IsKnown() bool {
type ResourceStatus string
const (
- ResourceStatusPending ResourceStatus = "PENDING"
- ResourceStatusCreating ResourceStatus = "CREATING"
- ResourceStatusUpdating ResourceStatus = "UPDATING"
- ResourceStatusReady ResourceStatus = "READY"
- ResourceStatusDeleting ResourceStatus = "DELETING"
- ResourceStatusDeleted ResourceStatus = "DELETED"
- ResourceStatusFailed ResourceStatus = "FAILED"
+ ResourceStatusPending ResourceStatus = "pending"
+ ResourceStatusCreating ResourceStatus = "creating"
+ ResourceStatusUpdating ResourceStatus = "updating"
+ ResourceStatusReady ResourceStatus = "ready"
+ ResourceStatusDeleting ResourceStatus = "deleting"
+ ResourceStatusDeleted ResourceStatus = "deleted"
+ ResourceStatusFailed ResourceStatus = "failed"
)
func (r ResourceStatus) IsKnown() bool {
diff --git a/usage_test.go b/usage_test.go
index 2a80e9f..82c650d 100644
--- a/usage_test.go
+++ b/usage_test.go
@@ -10,8 +10,6 @@ import (
"github.com/nirvana-labs/nirvana-go"
"github.com/nirvana-labs/nirvana-go/internal/testutil"
"github.com/nirvana-labs/nirvana-go/option"
- "github.com/nirvana-labs/nirvana-go/shared"
- "github.com/nirvana-labs/nirvana-go/vms"
)
func TestUsage(t *testing.T) {
@@ -26,28 +24,8 @@ func TestUsage(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- operation, err := client.VMs.New(context.TODO(), vms.VMNewParams{
- BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
- Size: nirvana.F(int64(100)),
- }),
- CPU: nirvana.F(vms.CPUParam{
- Cores: nirvana.F(int64(2)),
- }),
- Name: nirvana.F("my-vm"),
- NeedPublicIP: nirvana.F(true),
- OSImageName: nirvana.F("noble-2024-12-06"),
- Ports: nirvana.F([]string{"22", "80", "443"}),
- Ram: nirvana.F(vms.RamParam{
- Size: nirvana.F(int64(2)),
- }),
- Region: nirvana.F(shared.RegionNameAmsterdam),
- SourceAddress: nirvana.F("0.0.0.0/0"),
- SSHKey: nirvana.F(vms.SSHKeyParam{
- PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
- }),
- })
+ _, err := client.Operations.List(context.TODO())
if err != nil {
t.Error(err)
}
- t.Logf("%+v\n", operation.ID)
}
diff --git a/vms/osimage.go b/vms/osimage.go
index 1256b72..a43f293 100644
--- a/vms/osimage.go
+++ b/vms/osimage.go
@@ -32,7 +32,7 @@ func NewOSImageService(opts ...option.RequestOption) (r *OSImageService) {
// List all OS Images
func (r *OSImageService) List(ctx context.Context, opts ...option.RequestOption) (res *[]OSImage, err error) {
opts = append(r.Options[:], opts...)
- path := "vms/os_images"
+ path := "compute/vms/os_images"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
diff --git a/vms/osimage_test.go b/vms/osimage_test.go
index f2eb926..d712dd8 100644
--- a/vms/osimage_test.go
+++ b/vms/osimage_test.go
@@ -25,7 +25,7 @@ func TestOSImageList(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.VMs.OSImages.List(context.TODO())
+ _, err := client.Compute.VMs.OSImages.List(context.TODO())
if err != nil {
var apierr *nirvana.Error
if errors.As(err, &apierr) {
diff --git a/vms/vm.go b/vms/vm.go
index 5a10c75..10abe20 100644
--- a/vms/vm.go
+++ b/vms/vm.go
@@ -41,7 +41,7 @@ func NewVMService(opts ...option.RequestOption) (r *VMService) {
// Create a VM
func (r *VMService) New(ctx context.Context, body VMNewParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
- path := "vms"
+ path := "compute/vms"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
@@ -53,7 +53,7 @@ func (r *VMService) Update(ctx context.Context, vmID string, body VMUpdateParams
err = errors.New("missing required vm_id parameter")
return
}
- path := fmt.Sprintf("vms/%s", vmID)
+ path := fmt.Sprintf("compute/vms/%s", vmID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
return
}
@@ -61,7 +61,7 @@ func (r *VMService) Update(ctx context.Context, vmID string, body VMUpdateParams
// List all VMs
func (r *VMService) List(ctx context.Context, opts ...option.RequestOption) (res *VMList, err error) {
opts = append(r.Options[:], opts...)
- path := "vms"
+ path := "compute/vms"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
@@ -73,7 +73,7 @@ func (r *VMService) Delete(ctx context.Context, vmID string, opts ...option.Requ
err = errors.New("missing required vm_id parameter")
return
}
- path := fmt.Sprintf("vms/%s", vmID)
+ path := fmt.Sprintf("compute/vms/%s", vmID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return
}
@@ -85,7 +85,7 @@ func (r *VMService) Get(ctx context.Context, vmID string, opts ...option.Request
err = errors.New("missing required vm_id parameter")
return
}
- path := fmt.Sprintf("vms/%s", vmID)
+ path := fmt.Sprintf("compute/vms/%s", vmID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
diff --git a/vms/vm_test.go b/vms/vm_test.go
index ae25ed3..9042fec 100644
--- a/vms/vm_test.go
+++ b/vms/vm_test.go
@@ -28,7 +28,7 @@ func TestVMNewWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.VMs.New(context.TODO(), vms.VMNewParams{
+ _, err := client.Compute.VMs.New(context.TODO(), vms.VMNewParams{
BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
@@ -74,7 +74,7 @@ func TestVMUpdateWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.VMs.Update(
+ _, err := client.Compute.VMs.Update(
context.TODO(),
"vm_id",
vms.VMUpdateParams{
@@ -114,7 +114,7 @@ func TestVMList(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.VMs.List(context.TODO())
+ _, err := client.Compute.VMs.List(context.TODO())
if err != nil {
var apierr *nirvana.Error
if errors.As(err, &apierr) {
@@ -136,7 +136,7 @@ func TestVMDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.VMs.Delete(context.TODO(), "vm_id")
+ _, err := client.Compute.VMs.Delete(context.TODO(), "vm_id")
if err != nil {
var apierr *nirvana.Error
if errors.As(err, &apierr) {
@@ -158,7 +158,7 @@ func TestVMGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.VMs.Get(context.TODO(), "vm_id")
+ _, err := client.Compute.VMs.Get(context.TODO(), "vm_id")
if err != nil {
var apierr *nirvana.Error
if errors.As(err, &apierr) {
diff --git a/volumes/volume.go b/volumes/volume.go
index a761f9c..9992ce0 100644
--- a/volumes/volume.go
+++ b/volumes/volume.go
@@ -37,7 +37,7 @@ func NewVolumeService(opts ...option.RequestOption) (r *VolumeService) {
// Create a Volume. Only data volumes can be created.
func (r *VolumeService) New(ctx context.Context, body VolumeNewParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
- path := "volumes"
+ path := "compute/volumes"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
@@ -49,7 +49,7 @@ func (r *VolumeService) Update(ctx context.Context, volumeID string, body Volume
err = errors.New("missing required volume_id parameter")
return
}
- path := fmt.Sprintf("volumes/%s", volumeID)
+ path := fmt.Sprintf("compute/volumes/%s", volumeID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
return
}
@@ -57,7 +57,7 @@ func (r *VolumeService) Update(ctx context.Context, volumeID string, body Volume
// List all volumes
func (r *VolumeService) List(ctx context.Context, opts ...option.RequestOption) (res *VolumeListResponse, err error) {
opts = append(r.Options[:], opts...)
- path := "volumes"
+ path := "compute/volumes"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
@@ -69,7 +69,7 @@ func (r *VolumeService) Delete(ctx context.Context, volumeID string, body Volume
err = errors.New("missing required volume_id parameter")
return
}
- path := fmt.Sprintf("volumes/%s", volumeID)
+ path := fmt.Sprintf("compute/volumes/%s", volumeID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...)
return
}
@@ -81,7 +81,7 @@ func (r *VolumeService) Get(ctx context.Context, volumeID string, opts ...option
err = errors.New("missing required volume_id parameter")
return
}
- path := fmt.Sprintf("volumes/%s", volumeID)
+ path := fmt.Sprintf("compute/volumes/%s", volumeID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
diff --git a/volumes/volume_test.go b/volumes/volume_test.go
index f125456..6de5c81 100644
--- a/volumes/volume_test.go
+++ b/volumes/volume_test.go
@@ -26,7 +26,7 @@ func TestVolumeNewWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.Volumes.New(context.TODO(), volumes.VolumeNewParams{
+ _, err := client.Compute.Volumes.New(context.TODO(), volumes.VolumeNewParams{
Size: nirvana.F(int64(100)),
VMID: nirvana.F("vm_id"),
Type: nirvana.F(volumes.StorageTypeNvme),
@@ -52,7 +52,7 @@ func TestVolumeUpdate(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.Volumes.Update(
+ _, err := client.Compute.Volumes.Update(
context.TODO(),
"volume_id",
volumes.VolumeUpdateParams{
@@ -81,7 +81,7 @@ func TestVolumeList(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.Volumes.List(context.TODO())
+ _, err := client.Compute.Volumes.List(context.TODO())
if err != nil {
var apierr *nirvana.Error
if errors.As(err, &apierr) {
@@ -103,7 +103,7 @@ func TestVolumeDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.Volumes.Delete(
+ _, err := client.Compute.Volumes.Delete(
context.TODO(),
"volume_id",
volumes.VolumeDeleteParams{
@@ -131,7 +131,7 @@ func TestVolumeGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.Volumes.Get(context.TODO(), "volume_id")
+ _, err := client.Compute.Volumes.Get(context.TODO(), "volume_id")
if err != nil {
var apierr *nirvana.Error
if errors.As(err, &apierr) {
diff --git a/vpcs/vpc.go b/vpcs/vpc.go
index fdc1e04..060de4f 100644
--- a/vpcs/vpc.go
+++ b/vpcs/vpc.go
@@ -39,7 +39,7 @@ func NewVPCService(opts ...option.RequestOption) (r *VPCService) {
// Create a VPC
func (r *VPCService) New(ctx context.Context, body VPCNewParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
- path := "vpcs"
+ path := "networking/vpcs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
@@ -47,7 +47,7 @@ func (r *VPCService) New(ctx context.Context, body VPCNewParams, opts ...option.
// List all VPCs
func (r *VPCService) List(ctx context.Context, opts ...option.RequestOption) (res *VPCList, err error) {
opts = append(r.Options[:], opts...)
- path := "vpcs"
+ path := "networking/vpcs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
@@ -59,7 +59,7 @@ func (r *VPCService) Delete(ctx context.Context, vpcID string, opts ...option.Re
err = errors.New("missing required vpc_id parameter")
return
}
- path := fmt.Sprintf("vpcs/%s", vpcID)
+ path := fmt.Sprintf("networking/vpcs/%s", vpcID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...)
return
}
@@ -71,7 +71,7 @@ func (r *VPCService) Get(ctx context.Context, vpcID string, opts ...option.Reque
err = errors.New("missing required vpc_id parameter")
return
}
- path := fmt.Sprintf("vpcs/%s", vpcID)
+ path := fmt.Sprintf("networking/vpcs/%s", vpcID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
diff --git a/vpcs/vpc_test.go b/vpcs/vpc_test.go
index e10f318..218a83d 100644
--- a/vpcs/vpc_test.go
+++ b/vpcs/vpc_test.go
@@ -27,7 +27,7 @@ func TestVPCNew(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.VPCs.New(context.TODO(), vpcs.VPCNewParams{
+ _, err := client.Networking.VPCs.New(context.TODO(), vpcs.VPCNewParams{
Name: nirvana.F("my-vpc"),
Region: nirvana.F(shared.RegionNameAmsterdam),
SubnetName: nirvana.F("my-subnet"),
@@ -53,7 +53,7 @@ func TestVPCList(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.VPCs.List(context.TODO())
+ _, err := client.Networking.VPCs.List(context.TODO())
if err != nil {
var apierr *nirvana.Error
if errors.As(err, &apierr) {
@@ -75,7 +75,7 @@ func TestVPCDelete(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.VPCs.Delete(context.TODO(), "vpc_id")
+ _, err := client.Networking.VPCs.Delete(context.TODO(), "vpc_id")
if err != nil {
var apierr *nirvana.Error
if errors.As(err, &apierr) {
@@ -97,7 +97,7 @@ func TestVPCGet(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.VPCs.Get(context.TODO(), "vpc_id")
+ _, err := client.Networking.VPCs.Get(context.TODO(), "vpc_id")
if err != nil {
var apierr *nirvana.Error
if errors.As(err, &apierr) {