diff --git a/README.md b/README.md
index c9d3d1b..8b4c98b 100644
--- a/README.md
+++ b/README.md
@@ -52,8 +52,8 @@ func main() {
client := nirvana.NewClient(
option.WithAuthToken("My Auth Token"), // defaults to os.LookupEnv("NIRVANA_LABS_AUTH_TOKEN")
)
- operation, err := client.Compute.VMs.New(context.TODO(), vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ operation, err := client.Compute.VMs.New(context.TODO(), vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
@@ -193,8 +193,8 @@ 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.Compute.VMs.New(context.TODO(), vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+_, err := client.Compute.VMs.New(context.TODO(), vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
@@ -239,8 +239,8 @@ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Compute.VMs.New(
ctx,
- vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
@@ -294,8 +294,8 @@ client := nirvana.NewClient(
// Override per-request:
client.Compute.VMs.New(
context.TODO(),
- vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
diff --git a/api.md b/api.md
index 3f3de32..3d010af 100644
--- a/api.md
+++ b/api.md
@@ -38,11 +38,11 @@ Response Types:
Methods:
-- client.Compute.VMs.New(ctx context.Context, body vms.ComputeVMNewParams) (operations.Operation, error)
-- client.Compute.VMs.Update(ctx context.Context, vmID string, body vms.ComputeVMUpdateParams) (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)
+- 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)
### OSImages
@@ -61,15 +61,15 @@ Response Types:
- volumes.StorageType
- volumes.Volume
- volumes.VolumeKind
-- volumes.ComputeVolumeListResponse
+- volumes.VolumeListResponse
Methods:
-- client.Compute.Volumes.New(ctx context.Context, body volumes.ComputeVolumeNewParams) (operations.Operation, error)
-- client.Compute.Volumes.Update(ctx context.Context, volumeID string, body volumes.ComputeVolumeUpdateParams) (operations.Operation, error)
-- client.Compute.Volumes.List(ctx context.Context) (volumes.ComputeVolumeListResponse, error)
-- client.Compute.Volumes.Delete(ctx context.Context, volumeID string, body volumes.ComputeVolumeDeleteParams) (operations.Operation, error)
-- client.Compute.Volumes.Get(ctx context.Context, volumeID string) (volumes.Volume, 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)
# Networking
@@ -83,10 +83,10 @@ Response Types:
Methods:
-- client.Networking.VPCs.New(ctx context.Context, body vpcs.NetworkingVPCNewParams) (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)
+- 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)
## FirewallRules
@@ -102,8 +102,8 @@ Response Types:
Methods:
-- client.Networking.FirewallRules.New(ctx context.Context, vpcID string, body firewall_rules.NetworkingFirewallRuleNewParams) (operations.Operation, error)
-- client.Networking.FirewallRules.Update(ctx context.Context, vpcID string, firewallRuleID string, body firewall_rules.NetworkingFirewallRuleUpdateParams) (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)
+- 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 7910c4c..fd812e4 100644
--- a/client.go
+++ b/client.go
@@ -7,7 +7,9 @@ import (
"net/http"
"os"
+ "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"
)
@@ -18,8 +20,8 @@ import (
type Client struct {
Options []option.RequestOption
Operations *operations.OperationService
- Compute *ComputeService
- Networking *NetworkingService
+ Compute *compute.ComputeService
+ Networking *networking.NetworkingService
}
// NewClient generates a new client with the default option read from the
@@ -36,8 +38,8 @@ func NewClient(opts ...option.RequestOption) (r *Client) {
r = &Client{Options: opts}
r.Operations = operations.NewOperationService(opts...)
- r.Compute = NewComputeService(opts...)
- r.Networking = NewNetworkingService(opts...)
+ r.Compute = compute.NewComputeService(opts...)
+ r.Networking = networking.NewNetworkingService(opts...)
return
}
diff --git a/client_test.go b/client_test.go
index c15fb42..522a816 100644
--- a/client_test.go
+++ b/client_test.go
@@ -39,8 +39,8 @@ func TestUserAgentHeader(t *testing.T) {
},
}),
)
- client.Compute.VMs.New(context.Background(), vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ client.Compute.VMs.New(context.Background(), vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
@@ -81,8 +81,8 @@ func TestRetryAfter(t *testing.T) {
},
}),
)
- res, err := client.Compute.VMs.New(context.Background(), vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ res, err := client.Compute.VMs.New(context.Background(), vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
@@ -134,8 +134,8 @@ func TestDeleteRetryCountHeader(t *testing.T) {
}),
option.WithHeaderDel("X-Stainless-Retry-Count"),
)
- res, err := client.Compute.VMs.New(context.Background(), vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ res, err := client.Compute.VMs.New(context.Background(), vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
@@ -182,8 +182,8 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
}),
option.WithHeader("X-Stainless-Retry-Count", "42"),
)
- res, err := client.Compute.VMs.New(context.Background(), vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ res, err := client.Compute.VMs.New(context.Background(), vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
@@ -229,8 +229,8 @@ func TestRetryAfterMs(t *testing.T) {
},
}),
)
- res, err := client.Compute.VMs.New(context.Background(), vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ res, err := client.Compute.VMs.New(context.Background(), vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
@@ -270,8 +270,8 @@ func TestContextCancel(t *testing.T) {
)
cancelCtx, cancel := context.WithCancel(context.Background())
cancel()
- res, err := client.Compute.VMs.New(cancelCtx, vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ res, err := client.Compute.VMs.New(cancelCtx, vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
@@ -308,8 +308,8 @@ func TestContextCancelDelay(t *testing.T) {
)
cancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond)
defer cancel()
- res, err := client.Compute.VMs.New(cancelCtx, vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ res, err := client.Compute.VMs.New(cancelCtx, vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
@@ -352,8 +352,8 @@ func TestContextDeadline(t *testing.T) {
},
}),
)
- res, err := client.Compute.VMs.New(deadlineCtx, vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ res, err := client.Compute.VMs.New(deadlineCtx, vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
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.go b/compute/compute.go
similarity index 84%
rename from compute.go
rename to compute/compute.go
index a92c564..fca51c6 100644
--- a/compute.go
+++ b/compute/compute.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package nirvana
+package compute
import (
"github.com/nirvana-labs/nirvana-go/option"
@@ -14,8 +14,8 @@ import (
// the [NewComputeService] method instead.
type ComputeService struct {
Options []option.RequestOption
- VMs *ComputeVMService
- Volumes *ComputeVolumeService
+ VMs *VMService
+ Volumes *VolumeService
}
// NewComputeService generates a new service that applies the given options to each
@@ -24,7 +24,7 @@ type ComputeService struct {
func NewComputeService(opts ...option.RequestOption) (r *ComputeService) {
r = &ComputeService{}
r.Options = opts
- r.VMs = NewComputeVMService(opts...)
- r.Volumes = NewComputeVolumeService(opts...)
+ r.VMs = NewVMService(opts...)
+ r.Volumes = NewVolumeService(opts...)
return
}
diff --git a/firewall_rules/networkingfirewallrule.go b/firewall_rules/firewallrule.go
similarity index 73%
rename from firewall_rules/networkingfirewallrule.go
rename to firewall_rules/firewallrule.go
index f0614b6..bef7f3e 100644
--- a/firewall_rules/networkingfirewallrule.go
+++ b/firewall_rules/firewallrule.go
@@ -16,27 +16,27 @@ import (
"github.com/nirvana-labs/nirvana-go/shared"
)
-// NetworkingFirewallRuleService contains methods and other services that help with
+// FirewallRuleService 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 [NewNetworkingFirewallRuleService] method instead.
-type NetworkingFirewallRuleService struct {
+// the [NewFirewallRuleService] method instead.
+type FirewallRuleService struct {
Options []option.RequestOption
}
-// NewNetworkingFirewallRuleService 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 NewNetworkingFirewallRuleService(opts ...option.RequestOption) (r *NetworkingFirewallRuleService) {
- r = &NetworkingFirewallRuleService{}
+// NewFirewallRuleService 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 NewFirewallRuleService(opts ...option.RequestOption) (r *FirewallRuleService) {
+ r = &FirewallRuleService{}
r.Options = opts
return
}
// Create a firewall rule
-func (r *NetworkingFirewallRuleService) New(ctx context.Context, vpcID string, body NetworkingFirewallRuleNewParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
+func (r *FirewallRuleService) New(ctx context.Context, vpcID string, body FirewallRuleNewParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
if vpcID == "" {
err = errors.New("missing required vpc_id parameter")
@@ -48,7 +48,7 @@ func (r *NetworkingFirewallRuleService) New(ctx context.Context, vpcID string, b
}
// Update a firewall rule
-func (r *NetworkingFirewallRuleService) Update(ctx context.Context, vpcID string, firewallRuleID string, body NetworkingFirewallRuleUpdateParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
+func (r *FirewallRuleService) Update(ctx context.Context, vpcID string, firewallRuleID string, body FirewallRuleUpdateParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
if vpcID == "" {
err = errors.New("missing required vpc_id parameter")
@@ -64,7 +64,7 @@ func (r *NetworkingFirewallRuleService) Update(ctx context.Context, vpcID string
}
// List all firewall rules
-func (r *NetworkingFirewallRuleService) List(ctx context.Context, vpcID string, opts ...option.RequestOption) (res *FirewallRuleList, err error) {
+func (r *FirewallRuleService) List(ctx context.Context, vpcID string, opts ...option.RequestOption) (res *FirewallRuleList, err error) {
opts = append(r.Options[:], opts...)
if vpcID == "" {
err = errors.New("missing required vpc_id parameter")
@@ -76,7 +76,7 @@ func (r *NetworkingFirewallRuleService) List(ctx context.Context, vpcID string,
}
// Delete a firewall rule
-func (r *NetworkingFirewallRuleService) Delete(ctx context.Context, vpcID string, firewallRuleID string, opts ...option.RequestOption) (res *operations.Operation, err error) {
+func (r *FirewallRuleService) Delete(ctx context.Context, vpcID string, firewallRuleID string, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
if vpcID == "" {
err = errors.New("missing required vpc_id parameter")
@@ -92,7 +92,7 @@ func (r *NetworkingFirewallRuleService) Delete(ctx context.Context, vpcID string
}
// Get details about a firewall rule
-func (r *NetworkingFirewallRuleService) Get(ctx context.Context, vpcID string, firewallRuleID string, opts ...option.RequestOption) (res *FirewallRule, err error) {
+func (r *FirewallRuleService) Get(ctx context.Context, vpcID string, firewallRuleID string, opts ...option.RequestOption) (res *FirewallRule, err error) {
opts = append(r.Options[:], opts...)
if vpcID == "" {
err = errors.New("missing required vpc_id parameter")
@@ -201,7 +201,7 @@ func (r firewallRuleListJSON) RawJSON() string {
return r.raw
}
-type NetworkingFirewallRuleNewParams struct {
+type FirewallRuleNewParams struct {
// Firewall rule endpoint.
Destination param.Field[FirewallRuleEndpointParam] `json:"destination,required"`
Name param.Field[string] `json:"name,required"`
@@ -211,35 +211,35 @@ type NetworkingFirewallRuleNewParams struct {
Source param.Field[FirewallRuleEndpointParam] `json:"source,required"`
}
-func (r NetworkingFirewallRuleNewParams) MarshalJSON() (data []byte, err error) {
+func (r FirewallRuleNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-type NetworkingFirewallRuleUpdateParams struct {
+type FirewallRuleUpdateParams struct {
// Firewall rule endpoint.
Destination param.Field[FirewallRuleEndpointParam] `json:"destination,required"`
Name param.Field[string] `json:"name,required"`
// Supported protocols.
- Protocol param.Field[NetworkingFirewallRuleUpdateParamsProtocol] `json:"protocol,required"`
+ Protocol param.Field[FirewallRuleUpdateParamsProtocol] `json:"protocol,required"`
// Firewall rule endpoint.
Source param.Field[FirewallRuleEndpointParam] `json:"source,required"`
}
-func (r NetworkingFirewallRuleUpdateParams) MarshalJSON() (data []byte, err error) {
+func (r FirewallRuleUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Supported protocols.
-type NetworkingFirewallRuleUpdateParamsProtocol string
+type FirewallRuleUpdateParamsProtocol string
const (
- NetworkingFirewallRuleUpdateParamsProtocolTcp NetworkingFirewallRuleUpdateParamsProtocol = "tcp"
- NetworkingFirewallRuleUpdateParamsProtocolUdp NetworkingFirewallRuleUpdateParamsProtocol = "udp"
+ FirewallRuleUpdateParamsProtocolTcp FirewallRuleUpdateParamsProtocol = "tcp"
+ FirewallRuleUpdateParamsProtocolUdp FirewallRuleUpdateParamsProtocol = "udp"
)
-func (r NetworkingFirewallRuleUpdateParamsProtocol) IsKnown() bool {
+func (r FirewallRuleUpdateParamsProtocol) IsKnown() bool {
switch r {
- case NetworkingFirewallRuleUpdateParamsProtocolTcp, NetworkingFirewallRuleUpdateParamsProtocolUdp:
+ case FirewallRuleUpdateParamsProtocolTcp, FirewallRuleUpdateParamsProtocolUdp:
return true
}
return false
diff --git a/firewall_rules/networkingfirewallrule_test.go b/firewall_rules/firewallrule_test.go
similarity index 88%
rename from firewall_rules/networkingfirewallrule_test.go
rename to firewall_rules/firewallrule_test.go
index 666c835..5a7d95f 100644
--- a/firewall_rules/networkingfirewallrule_test.go
+++ b/firewall_rules/firewallrule_test.go
@@ -14,7 +14,7 @@ import (
"github.com/nirvana-labs/nirvana-go/option"
)
-func TestNetworkingFirewallRuleNewWithOptionalParams(t *testing.T) {
+func TestFirewallRuleNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -29,7 +29,7 @@ func TestNetworkingFirewallRuleNewWithOptionalParams(t *testing.T) {
_, err := client.Networking.FirewallRules.New(
context.TODO(),
"vpc_id",
- firewall_rules.NetworkingFirewallRuleNewParams{
+ firewall_rules.FirewallRuleNewParams{
Destination: nirvana.F(firewall_rules.FirewallRuleEndpointParam{
Address: nirvana.F("0.0.0.0/0"),
Ports: nirvana.F([]string{"22", "80", "443"}),
@@ -51,7 +51,7 @@ func TestNetworkingFirewallRuleNewWithOptionalParams(t *testing.T) {
}
}
-func TestNetworkingFirewallRuleUpdateWithOptionalParams(t *testing.T) {
+func TestFirewallRuleUpdateWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -67,13 +67,13 @@ func TestNetworkingFirewallRuleUpdateWithOptionalParams(t *testing.T) {
context.TODO(),
"vpc_id",
"firewall_rule_id",
- firewall_rules.NetworkingFirewallRuleUpdateParams{
+ firewall_rules.FirewallRuleUpdateParams{
Destination: nirvana.F(firewall_rules.FirewallRuleEndpointParam{
Address: nirvana.F("0.0.0.0/0"),
Ports: nirvana.F([]string{"22", "80", "443"}),
}),
Name: nirvana.F("my-firewall-rule"),
- Protocol: nirvana.F(firewall_rules.NetworkingFirewallRuleUpdateParamsProtocolTcp),
+ Protocol: nirvana.F(firewall_rules.FirewallRuleUpdateParamsProtocolTcp),
Source: nirvana.F(firewall_rules.FirewallRuleEndpointParam{
Address: nirvana.F("0.0.0.0/0"),
Ports: nirvana.F([]string{"22", "80", "443"}),
@@ -89,7 +89,7 @@ func TestNetworkingFirewallRuleUpdateWithOptionalParams(t *testing.T) {
}
}
-func TestNetworkingFirewallRuleList(t *testing.T) {
+func TestFirewallRuleList(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -111,7 +111,7 @@ func TestNetworkingFirewallRuleList(t *testing.T) {
}
}
-func TestNetworkingFirewallRuleDelete(t *testing.T) {
+func TestFirewallRuleDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -137,7 +137,7 @@ func TestNetworkingFirewallRuleDelete(t *testing.T) {
}
}
-func TestNetworkingFirewallRuleGet(t *testing.T) {
+func TestFirewallRuleGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
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.go b/networking/networking.go
similarity index 81%
rename from networking.go
rename to networking/networking.go
index eb5415b..9ffd089 100644
--- a/networking.go
+++ b/networking/networking.go
@@ -1,6 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
-package nirvana
+package networking
import (
"github.com/nirvana-labs/nirvana-go/option"
@@ -14,8 +14,8 @@ import (
// the [NewNetworkingService] method instead.
type NetworkingService struct {
Options []option.RequestOption
- VPCs *NetworkingVPCService
- FirewallRules *NetworkingFirewallRuleService
+ VPCs *VPCService
+ FirewallRules *FirewallRuleService
}
// NewNetworkingService generates a new service that applies the given options to
@@ -24,7 +24,7 @@ type NetworkingService struct {
func NewNetworkingService(opts ...option.RequestOption) (r *NetworkingService) {
r = &NetworkingService{}
r.Options = opts
- r.VPCs = NewNetworkingVPCService(opts...)
- r.FirewallRules = NewNetworkingFirewallRuleService(opts...)
+ r.VPCs = NewVPCService(opts...)
+ r.FirewallRules = NewFirewallRuleService(opts...)
return
}
diff --git a/usage_test.go b/usage_test.go
index 5ba3d78..71e1daf 100644
--- a/usage_test.go
+++ b/usage_test.go
@@ -26,8 +26,8 @@ func TestUsage(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- operation, err := client.Compute.VMs.New(context.TODO(), vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ operation, err := client.Compute.VMs.New(context.TODO(), vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
diff --git a/vms/computevm.go b/vms/vm.go
similarity index 75%
rename from vms/computevm.go
rename to vms/vm.go
index 8f4d091..10abe20 100644
--- a/vms/computevm.go
+++ b/vms/vm.go
@@ -17,29 +17,29 @@ import (
"github.com/nirvana-labs/nirvana-go/volumes"
)
-// ComputeVMService contains methods and other services that help with interacting
-// with the Nirvana Labs API.
+// VMService 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 [NewComputeVMService] method instead.
-type ComputeVMService struct {
+// the [NewVMService] method instead.
+type VMService struct {
Options []option.RequestOption
OSImages *OSImageService
}
-// NewComputeVMService 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 NewComputeVMService(opts ...option.RequestOption) (r *ComputeVMService) {
- r = &ComputeVMService{}
+// NewVMService 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 NewVMService(opts ...option.RequestOption) (r *VMService) {
+ r = &VMService{}
r.Options = opts
r.OSImages = NewOSImageService(opts...)
return
}
// Create a VM
-func (r *ComputeVMService) New(ctx context.Context, body ComputeVMNewParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
+func (r *VMService) New(ctx context.Context, body VMNewParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
path := "compute/vms"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
@@ -47,7 +47,7 @@ func (r *ComputeVMService) New(ctx context.Context, body ComputeVMNewParams, opt
}
// Update a VM
-func (r *ComputeVMService) Update(ctx context.Context, vmID string, body ComputeVMUpdateParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
+func (r *VMService) Update(ctx context.Context, vmID string, body VMUpdateParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
if vmID == "" {
err = errors.New("missing required vm_id parameter")
@@ -59,7 +59,7 @@ func (r *ComputeVMService) Update(ctx context.Context, vmID string, body Compute
}
// List all VMs
-func (r *ComputeVMService) List(ctx context.Context, opts ...option.RequestOption) (res *VMList, err error) {
+func (r *VMService) List(ctx context.Context, opts ...option.RequestOption) (res *VMList, err error) {
opts = append(r.Options[:], opts...)
path := "compute/vms"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
@@ -67,7 +67,7 @@ func (r *ComputeVMService) List(ctx context.Context, opts ...option.RequestOptio
}
// Delete a VM
-func (r *ComputeVMService) Delete(ctx context.Context, vmID string, opts ...option.RequestOption) (res *operations.Operation, err error) {
+func (r *VMService) Delete(ctx context.Context, vmID string, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
if vmID == "" {
err = errors.New("missing required vm_id parameter")
@@ -79,7 +79,7 @@ func (r *ComputeVMService) Delete(ctx context.Context, vmID string, opts ...opti
}
// Get details about a VM
-func (r *ComputeVMService) Get(ctx context.Context, vmID string, opts ...option.RequestOption) (res *VM, err error) {
+func (r *VMService) Get(ctx context.Context, vmID string, opts ...option.RequestOption) (res *VM, err error) {
opts = append(r.Options[:], opts...)
if vmID == "" {
err = errors.New("missing required vm_id parameter")
@@ -251,9 +251,9 @@ func (r vmListJSON) RawJSON() string {
return r.raw
}
-type ComputeVMNewParams struct {
+type VMNewParams struct {
// Boot volume create request.
- BootVolume param.Field[ComputeVMNewParamsBootVolume] `json:"boot_volume,required"`
+ BootVolume param.Field[VMNewParamsBootVolume] `json:"boot_volume,required"`
// CPU details.
CPU param.Field[CPUParam] `json:"cpu,required"`
Name param.Field[string] `json:"name,required"`
@@ -265,65 +265,65 @@ type ComputeVMNewParams struct {
Region param.Field[shared.RegionName] `json:"region,required"`
SourceAddress param.Field[string] `json:"source_address,required"`
// SSH key details.
- SSHKey param.Field[SSHKeyParam] `json:"ssh_key,required"`
- DataVolumes param.Field[[]ComputeVMNewParamsDataVolume] `json:"data_volumes"`
- SubnetID param.Field[string] `json:"subnet_id"`
+ SSHKey param.Field[SSHKeyParam] `json:"ssh_key,required"`
+ DataVolumes param.Field[[]VMNewParamsDataVolume] `json:"data_volumes"`
+ SubnetID param.Field[string] `json:"subnet_id"`
}
-func (r ComputeVMNewParams) MarshalJSON() (data []byte, err error) {
+func (r VMNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Boot volume create request.
-type ComputeVMNewParamsBootVolume struct {
+type VMNewParamsBootVolume struct {
Size param.Field[int64] `json:"size,required"`
}
-func (r ComputeVMNewParamsBootVolume) MarshalJSON() (data []byte, err error) {
+func (r VMNewParamsBootVolume) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// VM data volume create request.
-type ComputeVMNewParamsDataVolume struct {
+type VMNewParamsDataVolume struct {
Size param.Field[int64] `json:"size,required"`
// Storage type.
Type param.Field[volumes.StorageType] `json:"type"`
}
-func (r ComputeVMNewParamsDataVolume) MarshalJSON() (data []byte, err error) {
+func (r VMNewParamsDataVolume) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-type ComputeVMUpdateParams struct {
+type VMUpdateParams struct {
// Boot volume create request.
- BootVolume param.Field[ComputeVMUpdateParamsBootVolume] `json:"boot_volume"`
+ BootVolume param.Field[VMUpdateParamsBootVolume] `json:"boot_volume"`
// CPU details.
- CPU param.Field[CPUParam] `json:"cpu"`
- DataVolumes param.Field[[]ComputeVMUpdateParamsDataVolume] `json:"data_volumes"`
+ CPU param.Field[CPUParam] `json:"cpu"`
+ DataVolumes param.Field[[]VMUpdateParamsDataVolume] `json:"data_volumes"`
// RAM details.
Ram param.Field[RamParam] `json:"ram"`
}
-func (r ComputeVMUpdateParams) MarshalJSON() (data []byte, err error) {
+func (r VMUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Boot volume create request.
-type ComputeVMUpdateParamsBootVolume struct {
+type VMUpdateParamsBootVolume struct {
Size param.Field[int64] `json:"size,required"`
}
-func (r ComputeVMUpdateParamsBootVolume) MarshalJSON() (data []byte, err error) {
+func (r VMUpdateParamsBootVolume) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// VM data volume create request.
-type ComputeVMUpdateParamsDataVolume struct {
+type VMUpdateParamsDataVolume struct {
Size param.Field[int64] `json:"size,required"`
// Storage type.
Type param.Field[volumes.StorageType] `json:"type"`
}
-func (r ComputeVMUpdateParamsDataVolume) MarshalJSON() (data []byte, err error) {
+func (r VMUpdateParamsDataVolume) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
diff --git a/vms/computevm_test.go b/vms/vm_test.go
similarity index 87%
rename from vms/computevm_test.go
rename to vms/vm_test.go
index ea8924b..9042fec 100644
--- a/vms/computevm_test.go
+++ b/vms/vm_test.go
@@ -16,7 +16,7 @@ import (
"github.com/nirvana-labs/nirvana-go/volumes"
)
-func TestComputeVMNewWithOptionalParams(t *testing.T) {
+func TestVMNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -28,8 +28,8 @@ func TestComputeVMNewWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.Compute.VMs.New(context.TODO(), vms.ComputeVMNewParams{
- BootVolume: nirvana.F(vms.ComputeVMNewParamsBootVolume{
+ _, err := client.Compute.VMs.New(context.TODO(), vms.VMNewParams{
+ BootVolume: nirvana.F(vms.VMNewParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
@@ -47,7 +47,7 @@ func TestComputeVMNewWithOptionalParams(t *testing.T) {
SSHKey: nirvana.F(vms.SSHKeyParam{
PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"),
}),
- DataVolumes: nirvana.F([]vms.ComputeVMNewParamsDataVolume{{
+ DataVolumes: nirvana.F([]vms.VMNewParamsDataVolume{{
Size: nirvana.F(int64(100)),
Type: nirvana.F(volumes.StorageTypeNvme),
}}),
@@ -62,7 +62,7 @@ func TestComputeVMNewWithOptionalParams(t *testing.T) {
}
}
-func TestComputeVMUpdateWithOptionalParams(t *testing.T) {
+func TestVMUpdateWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -77,14 +77,14 @@ func TestComputeVMUpdateWithOptionalParams(t *testing.T) {
_, err := client.Compute.VMs.Update(
context.TODO(),
"vm_id",
- vms.ComputeVMUpdateParams{
- BootVolume: nirvana.F(vms.ComputeVMUpdateParamsBootVolume{
+ vms.VMUpdateParams{
+ BootVolume: nirvana.F(vms.VMUpdateParamsBootVolume{
Size: nirvana.F(int64(100)),
}),
CPU: nirvana.F(vms.CPUParam{
Cores: nirvana.F(int64(2)),
}),
- DataVolumes: nirvana.F([]vms.ComputeVMUpdateParamsDataVolume{{
+ DataVolumes: nirvana.F([]vms.VMUpdateParamsDataVolume{{
Size: nirvana.F(int64(100)),
Type: nirvana.F(volumes.StorageTypeNvme),
}}),
@@ -102,7 +102,7 @@ func TestComputeVMUpdateWithOptionalParams(t *testing.T) {
}
}
-func TestComputeVMList(t *testing.T) {
+func TestVMList(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -124,7 +124,7 @@ func TestComputeVMList(t *testing.T) {
}
}
-func TestComputeVMDelete(t *testing.T) {
+func TestVMDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -146,7 +146,7 @@ func TestComputeVMDelete(t *testing.T) {
}
}
-func TestComputeVMGet(t *testing.T) {
+func TestVMGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
diff --git a/volumes/computevolume.go b/volumes/volume.go
similarity index 65%
rename from volumes/computevolume.go
rename to volumes/volume.go
index da01370..9992ce0 100644
--- a/volumes/computevolume.go
+++ b/volumes/volume.go
@@ -15,27 +15,27 @@ import (
"github.com/nirvana-labs/nirvana-go/option"
)
-// ComputeVolumeService contains methods and other services that help with
-// interacting with the Nirvana Labs API.
+// VolumeService 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 [NewComputeVolumeService] method instead.
-type ComputeVolumeService struct {
+// the [NewVolumeService] method instead.
+type VolumeService struct {
Options []option.RequestOption
}
-// NewComputeVolumeService 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 NewComputeVolumeService(opts ...option.RequestOption) (r *ComputeVolumeService) {
- r = &ComputeVolumeService{}
+// NewVolumeService 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 NewVolumeService(opts ...option.RequestOption) (r *VolumeService) {
+ r = &VolumeService{}
r.Options = opts
return
}
// Create a Volume. Only data volumes can be created.
-func (r *ComputeVolumeService) New(ctx context.Context, body ComputeVolumeNewParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
+func (r *VolumeService) New(ctx context.Context, body VolumeNewParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
path := "compute/volumes"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
@@ -43,7 +43,7 @@ func (r *ComputeVolumeService) New(ctx context.Context, body ComputeVolumeNewPar
}
// Update a Volume. Boot or data volumes can be updated.
-func (r *ComputeVolumeService) Update(ctx context.Context, volumeID string, body ComputeVolumeUpdateParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
+func (r *VolumeService) Update(ctx context.Context, volumeID string, body VolumeUpdateParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
if volumeID == "" {
err = errors.New("missing required volume_id parameter")
@@ -55,7 +55,7 @@ func (r *ComputeVolumeService) Update(ctx context.Context, volumeID string, body
}
// List all volumes
-func (r *ComputeVolumeService) List(ctx context.Context, opts ...option.RequestOption) (res *ComputeVolumeListResponse, err error) {
+func (r *VolumeService) List(ctx context.Context, opts ...option.RequestOption) (res *VolumeListResponse, err error) {
opts = append(r.Options[:], opts...)
path := "compute/volumes"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
@@ -63,7 +63,7 @@ func (r *ComputeVolumeService) List(ctx context.Context, opts ...option.RequestO
}
// Delete a Volume. Boot or data volumes can be deleted.
-func (r *ComputeVolumeService) Delete(ctx context.Context, volumeID string, body ComputeVolumeDeleteParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
+func (r *VolumeService) Delete(ctx context.Context, volumeID string, body VolumeDeleteParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
if volumeID == "" {
err = errors.New("missing required volume_id parameter")
@@ -75,7 +75,7 @@ func (r *ComputeVolumeService) Delete(ctx context.Context, volumeID string, body
}
// Get a Volume.
-func (r *ComputeVolumeService) Get(ctx context.Context, volumeID string, opts ...option.RequestOption) (res *Volume, err error) {
+func (r *VolumeService) Get(ctx context.Context, volumeID string, opts ...option.RequestOption) (res *Volume, err error) {
opts = append(r.Options[:], opts...)
if volumeID == "" {
err = errors.New("missing required volume_id parameter")
@@ -150,51 +150,51 @@ func (r VolumeKind) IsKnown() bool {
return false
}
-type ComputeVolumeListResponse struct {
- Items []Volume `json:"items,required"`
- JSON computeVolumeListResponseJSON `json:"-"`
+type VolumeListResponse struct {
+ Items []Volume `json:"items,required"`
+ JSON volumeListResponseJSON `json:"-"`
}
-// computeVolumeListResponseJSON contains the JSON metadata for the struct
-// [ComputeVolumeListResponse]
-type computeVolumeListResponseJSON struct {
+// volumeListResponseJSON contains the JSON metadata for the struct
+// [VolumeListResponse]
+type volumeListResponseJSON struct {
Items apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *ComputeVolumeListResponse) UnmarshalJSON(data []byte) (err error) {
+func (r *VolumeListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r computeVolumeListResponseJSON) RawJSON() string {
+func (r volumeListResponseJSON) RawJSON() string {
return r.raw
}
-type ComputeVolumeNewParams struct {
+type VolumeNewParams struct {
Size param.Field[int64] `json:"size,required"`
VMID param.Field[string] `json:"vm_id,required"`
// Storage type.
Type param.Field[StorageType] `json:"type"`
}
-func (r ComputeVolumeNewParams) MarshalJSON() (data []byte, err error) {
+func (r VolumeNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-type ComputeVolumeUpdateParams struct {
+type VolumeUpdateParams struct {
Size param.Field[int64] `json:"size,required"`
VMID param.Field[string] `json:"vm_id,required"`
}
-func (r ComputeVolumeUpdateParams) MarshalJSON() (data []byte, err error) {
+func (r VolumeUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-type ComputeVolumeDeleteParams struct {
+type VolumeDeleteParams struct {
VMID param.Field[string] `json:"vm_id,required"`
}
-func (r ComputeVolumeDeleteParams) MarshalJSON() (data []byte, err error) {
+func (r VolumeDeleteParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
diff --git a/volumes/computevolume_test.go b/volumes/volume_test.go
similarity index 88%
rename from volumes/computevolume_test.go
rename to volumes/volume_test.go
index f1a918f..6de5c81 100644
--- a/volumes/computevolume_test.go
+++ b/volumes/volume_test.go
@@ -14,7 +14,7 @@ import (
"github.com/nirvana-labs/nirvana-go/volumes"
)
-func TestComputeVolumeNewWithOptionalParams(t *testing.T) {
+func TestVolumeNewWithOptionalParams(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -26,7 +26,7 @@ func TestComputeVolumeNewWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.Compute.Volumes.New(context.TODO(), volumes.ComputeVolumeNewParams{
+ _, err := client.Compute.Volumes.New(context.TODO(), volumes.VolumeNewParams{
Size: nirvana.F(int64(100)),
VMID: nirvana.F("vm_id"),
Type: nirvana.F(volumes.StorageTypeNvme),
@@ -40,7 +40,7 @@ func TestComputeVolumeNewWithOptionalParams(t *testing.T) {
}
}
-func TestComputeVolumeUpdate(t *testing.T) {
+func TestVolumeUpdate(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -55,7 +55,7 @@ func TestComputeVolumeUpdate(t *testing.T) {
_, err := client.Compute.Volumes.Update(
context.TODO(),
"volume_id",
- volumes.ComputeVolumeUpdateParams{
+ volumes.VolumeUpdateParams{
Size: nirvana.F(int64(100)),
VMID: nirvana.F("vm_id"),
},
@@ -69,7 +69,7 @@ func TestComputeVolumeUpdate(t *testing.T) {
}
}
-func TestComputeVolumeList(t *testing.T) {
+func TestVolumeList(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -91,7 +91,7 @@ func TestComputeVolumeList(t *testing.T) {
}
}
-func TestComputeVolumeDelete(t *testing.T) {
+func TestVolumeDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -106,7 +106,7 @@ func TestComputeVolumeDelete(t *testing.T) {
_, err := client.Compute.Volumes.Delete(
context.TODO(),
"volume_id",
- volumes.ComputeVolumeDeleteParams{
+ volumes.VolumeDeleteParams{
VMID: nirvana.F("vm_id"),
},
)
@@ -119,7 +119,7 @@ func TestComputeVolumeDelete(t *testing.T) {
}
}
-func TestComputeVolumeGet(t *testing.T) {
+func TestVolumeGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
diff --git a/vpcs/networkingvpc.go b/vpcs/vpc.go
similarity index 78%
rename from vpcs/networkingvpc.go
rename to vpcs/vpc.go
index 9d310d5..060de4f 100644
--- a/vpcs/networkingvpc.go
+++ b/vpcs/vpc.go
@@ -17,27 +17,27 @@ import (
"github.com/nirvana-labs/nirvana-go/shared"
)
-// NetworkingVPCService contains methods and other services that help with
-// interacting with the Nirvana Labs API.
+// VPCService 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 [NewNetworkingVPCService] method instead.
-type NetworkingVPCService struct {
+// the [NewVPCService] method instead.
+type VPCService struct {
Options []option.RequestOption
}
-// NewNetworkingVPCService 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 NewNetworkingVPCService(opts ...option.RequestOption) (r *NetworkingVPCService) {
- r = &NetworkingVPCService{}
+// NewVPCService 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 NewVPCService(opts ...option.RequestOption) (r *VPCService) {
+ r = &VPCService{}
r.Options = opts
return
}
// Create a VPC
-func (r *NetworkingVPCService) New(ctx context.Context, body NetworkingVPCNewParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
+func (r *VPCService) New(ctx context.Context, body VPCNewParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
path := "networking/vpcs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
@@ -45,7 +45,7 @@ func (r *NetworkingVPCService) New(ctx context.Context, body NetworkingVPCNewPar
}
// List all VPCs
-func (r *NetworkingVPCService) List(ctx context.Context, opts ...option.RequestOption) (res *VPCList, err error) {
+func (r *VPCService) List(ctx context.Context, opts ...option.RequestOption) (res *VPCList, err error) {
opts = append(r.Options[:], opts...)
path := "networking/vpcs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
@@ -53,7 +53,7 @@ func (r *NetworkingVPCService) List(ctx context.Context, opts ...option.RequestO
}
// Delete a VPC
-func (r *NetworkingVPCService) Delete(ctx context.Context, vpcID string, opts ...option.RequestOption) (res *operations.Operation, err error) {
+func (r *VPCService) Delete(ctx context.Context, vpcID string, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
if vpcID == "" {
err = errors.New("missing required vpc_id parameter")
@@ -65,7 +65,7 @@ func (r *NetworkingVPCService) Delete(ctx context.Context, vpcID string, opts ..
}
// Get details about a VPC
-func (r *NetworkingVPCService) Get(ctx context.Context, vpcID string, opts ...option.RequestOption) (res *VPC, err error) {
+func (r *VPCService) Get(ctx context.Context, vpcID string, opts ...option.RequestOption) (res *VPC, err error) {
opts = append(r.Options[:], opts...)
if vpcID == "" {
err = errors.New("missing required vpc_id parameter")
@@ -161,12 +161,12 @@ func (r vpcListJSON) RawJSON() string {
return r.raw
}
-type NetworkingVPCNewParams struct {
+type VPCNewParams struct {
Name param.Field[string] `json:"name,required"`
Region param.Field[shared.RegionName] `json:"region,required"`
SubnetName param.Field[string] `json:"subnet_name,required"`
}
-func (r NetworkingVPCNewParams) MarshalJSON() (data []byte, err error) {
+func (r VPCNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
diff --git a/vpcs/networkingvpc_test.go b/vpcs/vpc_test.go
similarity index 90%
rename from vpcs/networkingvpc_test.go
rename to vpcs/vpc_test.go
index 87d7e79..218a83d 100644
--- a/vpcs/networkingvpc_test.go
+++ b/vpcs/vpc_test.go
@@ -15,7 +15,7 @@ import (
"github.com/nirvana-labs/nirvana-go/vpcs"
)
-func TestNetworkingVPCNew(t *testing.T) {
+func TestVPCNew(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -27,7 +27,7 @@ func TestNetworkingVPCNew(t *testing.T) {
option.WithBaseURL(baseURL),
option.WithAuthToken("My Auth Token"),
)
- _, err := client.Networking.VPCs.New(context.TODO(), vpcs.NetworkingVPCNewParams{
+ _, err := client.Networking.VPCs.New(context.TODO(), vpcs.VPCNewParams{
Name: nirvana.F("my-vpc"),
Region: nirvana.F(shared.RegionNameAmsterdam),
SubnetName: nirvana.F("my-subnet"),
@@ -41,7 +41,7 @@ func TestNetworkingVPCNew(t *testing.T) {
}
}
-func TestNetworkingVPCList(t *testing.T) {
+func TestVPCList(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -63,7 +63,7 @@ func TestNetworkingVPCList(t *testing.T) {
}
}
-func TestNetworkingVPCDelete(t *testing.T) {
+func TestVPCDelete(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -85,7 +85,7 @@ func TestNetworkingVPCDelete(t *testing.T) {
}
}
-func TestNetworkingVPCGet(t *testing.T) {
+func TestVPCGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL