diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 000572e..b069996 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.13" + ".": "0.1.0-alpha.14" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index a3eeb48..baf4dec 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 21 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nirvana-labs%2Fnirvana-d34ebbf790173255bdedff7e5d4fe32a6b217c0dd51dee295603872843065848.yml +configured_endpoints: 22 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nirvana-labs%2Fnirvana-6e3dd3baf6a65944d5c5468740fb292207576dfa404bcff24a77d4b6ad6d4a82.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b872a7..7171307 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.1.0-alpha.14 (2025-01-27) + +Full Changelog: [v0.1.0-alpha.13...v0.1.0-alpha.14](https://github.com/nirvana-labs/nirvana-go/compare/v0.1.0-alpha.13...v0.1.0-alpha.14) + +### Features + +* **api:** api update ([#51](https://github.com/nirvana-labs/nirvana-go/issues/51)) ([8b35f6b](https://github.com/nirvana-labs/nirvana-go/commit/8b35f6b040cc32f244ecdb568539cfb1510f9d41)) +* **api:** api update ([#53](https://github.com/nirvana-labs/nirvana-go/issues/53)) ([a054ca1](https://github.com/nirvana-labs/nirvana-go/commit/a054ca1e8e2ddc9735f9668737cc04885a0ecbe7)) +* **api:** api update ([#54](https://github.com/nirvana-labs/nirvana-go/issues/54)) ([68cbeb0](https://github.com/nirvana-labs/nirvana-go/commit/68cbeb067e1a12c41091d2ea257125a2ded56968)) +* **api:** api update ([#55](https://github.com/nirvana-labs/nirvana-go/issues/55)) ([41770b7](https://github.com/nirvana-labs/nirvana-go/commit/41770b75c7a252d05934f0f9de57045340a64e82)) +* **api:** api update ([#56](https://github.com/nirvana-labs/nirvana-go/issues/56)) ([65af2e1](https://github.com/nirvana-labs/nirvana-go/commit/65af2e10b17a6a54e404bc1b62dc50a9fb0b8320)) +* **api:** api update ([#57](https://github.com/nirvana-labs/nirvana-go/issues/57)) ([3a5fb4d](https://github.com/nirvana-labs/nirvana-go/commit/3a5fb4dd59a349b8c65c570412ce9c0a48b61863)) +* **api:** api update ([#58](https://github.com/nirvana-labs/nirvana-go/issues/58)) ([0a3ae46](https://github.com/nirvana-labs/nirvana-go/commit/0a3ae46604201fd59738d5d97ee069a9e03e33fd)) + ## 0.1.0-alpha.13 (2025-01-24) Full Changelog: [v0.1.0-alpha.12...v0.1.0-alpha.13](https://github.com/nirvana-labs/nirvana-go/compare/v0.1.0-alpha.12...v0.1.0-alpha.13) diff --git a/README.md b/README.md index 6a266cc..2d2b1a5 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Or to pin the version: ```sh -go get -u 'github.com/nirvana-labs/nirvana-go@v0.1.0-alpha.13' +go get -u 'github.com/nirvana-labs/nirvana-go@v0.1.0-alpha.14' ``` @@ -43,32 +43,32 @@ import ( "fmt" "github.com/nirvana-labs/nirvana-go" + "github.com/nirvana-labs/nirvana-go/compute" "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{ + operation, err := client.Compute.VMs.New(context.TODO(), compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }) @@ -164,7 +164,7 @@ client := nirvana.NewClient( option.WithHeader("X-Some-Header", "custom_header_info"), ) -client.VMs.New(context.TODO(), ..., +client.Compute.VMs.New(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,23 +193,23 @@ 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{ +_, err := client.Compute.VMs.New(context.TODO(), compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }) @@ -219,7 +219,7 @@ if err != nil { 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 "/compute/vms": 400 Bad Request { ... } } ``` @@ -237,25 +237,25 @@ 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.Compute.VMs.New( ctx, - vms.VMNewParams{ - BootVolume: nirvana.F(vms.VMNewParamsBootVolume{ + compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }, @@ -292,25 +292,25 @@ client := nirvana.NewClient( ) // Override per-request: -client.VMs.New( +client.Compute.VMs.New( context.TODO(), - vms.VMNewParams{ - BootVolume: nirvana.F(vms.VMNewParamsBootVolume{ + compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }, diff --git a/api.md b/api.md index dba02fb..3192cd3 100644 --- a/api.md +++ b/api.md @@ -7,96 +7,103 @@ - shared.RegionName - shared.ResourceStatus -# VMs - -Params Types: - -- vms.CPUParam -- vms.RamParam -- vms.SSHKeyParam +# Operations Response Types: -- vms.CPU -- vms.OSImage -- vms.Ram -- vms.VM -- vms.VMList +- operations.Operation 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) +- client.Operations.List(ctx context.Context) ([]operations.Operation, error) +- client.Operations.Get(ctx context.Context, operationID string) (operations.Operation, error) -## OSImages +# Compute -Methods: +## VMs -- client.VMs.OSImages.List(ctx context.Context) ([]vms.OSImage, error) +Params Types: -# VPCs +- compute.CPUParam +- compute.RamParam +- compute.SSHKeyParam Response Types: -- vpcs.Subnet -- vpcs.VPC -- vpcs.VPCList +- compute.CPU +- compute.OSImage +- compute.Ram +- compute.VM +- compute.VMList + +Methods: + +- client.Compute.VMs.New(ctx context.Context, body compute.VMNewParams) (operations.Operation, error) +- client.Compute.VMs.Update(ctx context.Context, vmID string, body compute.VMUpdateParams) (operations.Operation, error) +- client.Compute.VMs.List(ctx context.Context) (compute.VMList, error) +- client.Compute.VMs.Delete(ctx context.Context, vmID string) (operations.Operation, error) +- client.Compute.VMs.Get(ctx context.Context, vmID string) (compute.VM, error) + +### 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) ([]compute.OSImage, error) -# FirewallRules +## Volumes Params Types: -- firewall_rules.FirewallRuleEndpointParam +- compute.StorageType Response Types: -- firewall_rules.FirewallRule -- firewall_rules.FirewallRuleEndpoint -- firewall_rules.FirewallRuleList +- compute.StorageType +- compute.Volume +- compute.VolumeKind +- compute.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) - -# Volumes +- client.Compute.Volumes.New(ctx context.Context, body compute.VolumeNewParams) (operations.Operation, error) +- client.Compute.Volumes.Update(ctx context.Context, volumeID string, body compute.VolumeUpdateParams) (operations.Operation, error) +- client.Compute.Volumes.List(ctx context.Context) (compute.VolumeListResponse, error) +- client.Compute.Volumes.Delete(ctx context.Context, volumeID string, body compute.VolumeDeleteParams) (operations.Operation, error) +- client.Compute.Volumes.Get(ctx context.Context, volumeID string) (compute.Volume, error) -Params Types: +# Networking -- volumes.StorageType +## VPCs Response Types: -- volumes.StorageType -- volumes.Volume +- networking.Subnet +- networking.VPC +- networking.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.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 networking.VPCNewParams) (operations.Operation, error) +- client.Networking.VPCs.List(ctx context.Context) (networking.VPCList, error) +- client.Networking.VPCs.Delete(ctx context.Context, vpcID string) (operations.Operation, error) +- client.Networking.VPCs.Get(ctx context.Context, vpcID string) (networking.VPC, error) -# Operations +## FirewallRules + +Params Types: + +- networking.FirewallRuleEndpointParam Response Types: -- operations.Operation +- networking.FirewallRule +- networking.FirewallRuleEndpoint +- networking.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 networking.FirewallRuleNewParams) (operations.Operation, error) +- client.Networking.FirewallRules.Update(ctx context.Context, vpcID string, firewallRuleID string, body networking.FirewallRuleUpdateParams) (operations.Operation, error) +- client.Networking.FirewallRules.List(ctx context.Context, vpcID string) (networking.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) (networking.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..7c508fc 100644 --- a/client_test.go +++ b/client_test.go @@ -11,10 +11,10 @@ import ( "time" "github.com/nirvana-labs/nirvana-go" + "github.com/nirvana-labs/nirvana-go/compute" "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,23 +39,23 @@ func TestUserAgentHeader(t *testing.T) { }, }), ) - client.VMs.New(context.Background(), vms.VMNewParams{ - BootVolume: nirvana.F(vms.VMNewParamsBootVolume{ + client.Compute.VMs.New(context.Background(), compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }) @@ -81,23 +81,23 @@ func TestRetryAfter(t *testing.T) { }, }), ) - res, err := client.VMs.New(context.Background(), vms.VMNewParams{ - BootVolume: nirvana.F(vms.VMNewParamsBootVolume{ + res, err := client.Compute.VMs.New(context.Background(), compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }) @@ -134,23 +134,23 @@ 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{ + res, err := client.Compute.VMs.New(context.Background(), compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }) @@ -182,23 +182,23 @@ 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{ + res, err := client.Compute.VMs.New(context.Background(), compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }) @@ -229,23 +229,23 @@ func TestRetryAfterMs(t *testing.T) { }, }), ) - res, err := client.VMs.New(context.Background(), vms.VMNewParams{ - BootVolume: nirvana.F(vms.VMNewParamsBootVolume{ + res, err := client.Compute.VMs.New(context.Background(), compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }) @@ -270,23 +270,23 @@ 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{ + res, err := client.Compute.VMs.New(cancelCtx, compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }) @@ -308,23 +308,23 @@ 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{ + res, err := client.Compute.VMs.New(cancelCtx, compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }) @@ -352,23 +352,23 @@ func TestContextDeadline(t *testing.T) { }, }), ) - res, err := client.VMs.New(deadlineCtx, vms.VMNewParams{ - BootVolume: nirvana.F(vms.VMNewParamsBootVolume{ + res, err := client.Compute.VMs.New(deadlineCtx, compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }) diff --git a/vms/aliases.go b/compute/aliases.go similarity index 99% rename from vms/aliases.go rename to compute/aliases.go index ff146e6..7f0e6ef 100644 --- a/vms/aliases.go +++ b/compute/aliases.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package vms +package compute import ( "github.com/nirvana-labs/nirvana-go/internal/apierror" 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/vms/vm.go b/compute/vm.go similarity index 93% rename from vms/vm.go rename to compute/vm.go index 5a10c75..01d8d52 100644 --- a/vms/vm.go +++ b/compute/vm.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package vms +package compute import ( "context" @@ -14,7 +14,6 @@ import ( "github.com/nirvana-labs/nirvana-go/operations" "github.com/nirvana-labs/nirvana-go/option" "github.com/nirvana-labs/nirvana-go/shared" - "github.com/nirvana-labs/nirvana-go/volumes" ) // VMService contains methods and other services that help with interacting with @@ -25,7 +24,7 @@ import ( // the [NewVMService] method instead. type VMService struct { Options []option.RequestOption - OSImages *OSImageService + OSImages *VMOSImageService } // NewVMService generates a new service that applies the given options to each @@ -34,14 +33,14 @@ type VMService struct { func NewVMService(opts ...option.RequestOption) (r *VMService) { r = &VMService{} r.Options = opts - r.OSImages = NewOSImageService(opts...) + r.OSImages = NewVMOSImageService(opts...) return } // 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 +52,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 +60,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 +72,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 +84,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 } @@ -189,11 +188,11 @@ func (r SSHKeyParam) MarshalJSON() (data []byte, err error) { type VM struct { ID string `json:"id,required"` // Volume details. - BootVolume volumes.Volume `json:"boot_volume,required"` + BootVolume Volume `json:"boot_volume,required"` // CPU details. - CPUConfig CPU `json:"cpu_config,required"` - CreatedAt string `json:"created_at,required"` - DataVolumes []volumes.Volume `json:"data_volumes,required"` + CPUConfig CPU `json:"cpu_config,required"` + CreatedAt string `json:"created_at,required"` + DataVolumes []Volume `json:"data_volumes,required"` // RAM details. MemConfig Ram `json:"mem_config,required"` Name string `json:"name,required"` @@ -287,7 +286,7 @@ func (r VMNewParamsBootVolume) MarshalJSON() (data []byte, err error) { type VMNewParamsDataVolume struct { Size param.Field[int64] `json:"size,required"` // Storage type. - Type param.Field[volumes.StorageType] `json:"type"` + Type param.Field[StorageType] `json:"type"` } func (r VMNewParamsDataVolume) MarshalJSON() (data []byte, err error) { @@ -321,7 +320,7 @@ func (r VMUpdateParamsBootVolume) MarshalJSON() (data []byte, err error) { type VMUpdateParamsDataVolume struct { Size param.Field[int64] `json:"size,required"` // Storage type. - Type param.Field[volumes.StorageType] `json:"type"` + Type param.Field[StorageType] `json:"type"` } func (r VMUpdateParamsDataVolume) MarshalJSON() (data []byte, err error) { diff --git a/vms/vm_test.go b/compute/vm_test.go similarity index 80% rename from vms/vm_test.go rename to compute/vm_test.go index ae25ed3..50fda83 100644 --- a/vms/vm_test.go +++ b/compute/vm_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package vms_test +package compute_test import ( "context" @@ -9,11 +9,10 @@ import ( "testing" "github.com/nirvana-labs/nirvana-go" + "github.com/nirvana-labs/nirvana-go/compute" "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" - "github.com/nirvana-labs/nirvana-go/volumes" ) func TestVMNewWithOptionalParams(t *testing.T) { @@ -28,28 +27,28 @@ func TestVMNewWithOptionalParams(t *testing.T) { option.WithBaseURL(baseURL), option.WithAuthToken("My Auth Token"), ) - _, err := client.VMs.New(context.TODO(), vms.VMNewParams{ - BootVolume: nirvana.F(vms.VMNewParamsBootVolume{ + _, err := client.Compute.VMs.New(context.TODO(), compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), - DataVolumes: nirvana.F([]vms.VMNewParamsDataVolume{{ + DataVolumes: nirvana.F([]compute.VMNewParamsDataVolume{{ Size: nirvana.F(int64(100)), - Type: nirvana.F(volumes.StorageTypeNvme), + Type: nirvana.F(compute.StorageTypeNvme), }}), SubnetID: nirvana.F("123e4567-e89b-12d3-a456-426614174000"), }) @@ -74,21 +73,21 @@ 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{ - BootVolume: nirvana.F(vms.VMUpdateParamsBootVolume{ + compute.VMUpdateParams{ + BootVolume: nirvana.F(compute.VMUpdateParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.CPUParam{ Cores: nirvana.F(int64(2)), }), - DataVolumes: nirvana.F([]vms.VMUpdateParamsDataVolume{{ + DataVolumes: nirvana.F([]compute.VMUpdateParamsDataVolume{{ Size: nirvana.F(int64(100)), - Type: nirvana.F(volumes.StorageTypeNvme), + Type: nirvana.F(compute.StorageTypeNvme), }}), - Ram: nirvana.F(vms.RamParam{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), }, @@ -114,7 +113,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 +135,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 +157,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/vms/osimage.go b/compute/vmosimage.go similarity index 50% rename from vms/osimage.go rename to compute/vmosimage.go index 1256b72..4229306 100644 --- a/vms/osimage.go +++ b/compute/vmosimage.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package vms +package compute import ( "context" @@ -10,29 +10,29 @@ import ( "github.com/nirvana-labs/nirvana-go/option" ) -// OSImageService contains methods and other services that help with interacting +// VMOSImageService 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 [NewOSImageService] method instead. -type OSImageService struct { +// the [NewVMOSImageService] method instead. +type VMOSImageService struct { Options []option.RequestOption } -// NewOSImageService 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 NewOSImageService(opts ...option.RequestOption) (r *OSImageService) { - r = &OSImageService{} +// NewVMOSImageService 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 NewVMOSImageService(opts ...option.RequestOption) (r *VMOSImageService) { + r = &VMOSImageService{} r.Options = opts return } // List all OS Images -func (r *OSImageService) List(ctx context.Context, opts ...option.RequestOption) (res *[]OSImage, err error) { +func (r *VMOSImageService) 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/compute/vmosimage_test.go similarity index 85% rename from vms/osimage_test.go rename to compute/vmosimage_test.go index f2eb926..fb4ae74 100644 --- a/vms/osimage_test.go +++ b/compute/vmosimage_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package vms_test +package compute_test import ( "context" @@ -13,7 +13,7 @@ import ( "github.com/nirvana-labs/nirvana-go/option" ) -func TestOSImageList(t *testing.T) { +func TestVMOSImageList(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -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/volumes/volume.go b/compute/volume.go similarity index 75% rename from volumes/volume.go rename to compute/volume.go index d884380..80b8dbb 100644 --- a/volumes/volume.go +++ b/compute/volume.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package volumes +package compute import ( "context" @@ -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,11 +49,19 @@ 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 } +// List all volumes +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...) + return +} + // Delete a Volume. Boot or data volumes can be deleted. func (r *VolumeService) Delete(ctx context.Context, volumeID string, body VolumeDeleteParams, opts ...option.RequestOption) (res *operations.Operation, err error) { opts = append(r.Options[:], opts...) @@ -61,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 } @@ -73,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 } @@ -97,7 +105,9 @@ func (r StorageType) IsKnown() bool { type Volume struct { ID string `json:"id,required"` CreatedAt string `json:"created_at,required"` - Size int64 `json:"size,required"` + // Volume kind. + Kind VolumeKind `json:"kind,required"` + Size int64 `json:"size,required"` // Storage type. Type StorageType `json:"type,required"` UpdatedAt string `json:"updated_at,required"` @@ -108,6 +118,7 @@ type Volume struct { type volumeJSON struct { ID apijson.Field CreatedAt apijson.Field + Kind apijson.Field Size apijson.Field Type apijson.Field UpdatedAt apijson.Field @@ -123,6 +134,43 @@ func (r volumeJSON) RawJSON() string { return r.raw } +// Volume kind. +type VolumeKind string + +const ( + VolumeKindBoot VolumeKind = "boot" + VolumeKindData VolumeKind = "data" +) + +func (r VolumeKind) IsKnown() bool { + switch r { + case VolumeKindBoot, VolumeKindData: + return true + } + return false +} + +type VolumeListResponse struct { + Items []Volume `json:"items,required"` + JSON volumeListResponseJSON `json:"-"` +} + +// volumeListResponseJSON contains the JSON metadata for the struct +// [VolumeListResponse] +type volumeListResponseJSON struct { + Items apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VolumeListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r volumeListResponseJSON) RawJSON() string { + return r.raw +} + type VolumeNewParams struct { Size param.Field[int64] `json:"size,required"` VMID param.Field[string] `json:"vm_id,required"` diff --git a/volumes/volume_test.go b/compute/volume_test.go similarity index 72% rename from volumes/volume_test.go rename to compute/volume_test.go index 434231e..bb6ed06 100644 --- a/volumes/volume_test.go +++ b/compute/volume_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package volumes_test +package compute_test import ( "context" @@ -9,9 +9,9 @@ import ( "testing" "github.com/nirvana-labs/nirvana-go" + "github.com/nirvana-labs/nirvana-go/compute" "github.com/nirvana-labs/nirvana-go/internal/testutil" "github.com/nirvana-labs/nirvana-go/option" - "github.com/nirvana-labs/nirvana-go/volumes" ) func TestVolumeNewWithOptionalParams(t *testing.T) { @@ -26,10 +26,10 @@ 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(), compute.VolumeNewParams{ Size: nirvana.F(int64(100)), VMID: nirvana.F("vm_id"), - Type: nirvana.F(volumes.StorageTypeNvme), + Type: nirvana.F(compute.StorageTypeNvme), }) if err != nil { var apierr *nirvana.Error @@ -52,10 +52,10 @@ 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{ + compute.VolumeUpdateParams{ Size: nirvana.F(int64(100)), VMID: nirvana.F("vm_id"), }, @@ -69,6 +69,28 @@ func TestVolumeUpdate(t *testing.T) { } } +func TestVolumeList(t *testing.T) { + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := nirvana.NewClient( + option.WithBaseURL(baseURL), + option.WithAuthToken("My Auth Token"), + ) + _, err := client.Compute.Volumes.List(context.TODO()) + if err != nil { + var apierr *nirvana.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + func TestVolumeDelete(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { @@ -81,10 +103,10 @@ 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{ + compute.VolumeDeleteParams{ VMID: nirvana.F("vm_id"), }, ) @@ -109,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/firewall_rules/aliases.go b/firewall_rules/aliases.go deleted file mode 100644 index dcceda7..0000000 --- a/firewall_rules/aliases.go +++ /dev/null @@ -1,79 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package firewall_rules - -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/internal/version.go b/internal/version.go index 805f4ff..5f0be5b 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.1.0-alpha.13" // x-release-please-version +const PackageVersion = "0.1.0-alpha.14" // x-release-please-version diff --git a/vpcs/aliases.go b/networking/aliases.go similarity index 99% rename from vpcs/aliases.go rename to networking/aliases.go index 5d19c18..bd25d5d 100644 --- a/vpcs/aliases.go +++ b/networking/aliases.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package vpcs +package networking import ( "github.com/nirvana-labs/nirvana-go/internal/apierror" diff --git a/firewall_rules/firewallrule.go b/networking/firewallrule.go similarity index 95% rename from firewall_rules/firewallrule.go rename to networking/firewallrule.go index 443dff4..c599f31 100644 --- a/firewall_rules/firewallrule.go +++ b/networking/firewallrule.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package firewall_rules +package networking import ( "context" @@ -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/networking/firewallrule_test.go similarity index 82% rename from firewall_rules/firewallrule_test.go rename to networking/firewallrule_test.go index 6f36b7f..40a3a22 100644 --- a/firewall_rules/firewallrule_test.go +++ b/networking/firewallrule_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package firewall_rules_test +package networking_test import ( "context" @@ -9,8 +9,8 @@ import ( "testing" "github.com/nirvana-labs/nirvana-go" - "github.com/nirvana-labs/nirvana-go/firewall_rules" "github.com/nirvana-labs/nirvana-go/internal/testutil" + "github.com/nirvana-labs/nirvana-go/networking" "github.com/nirvana-labs/nirvana-go/option" ) @@ -26,17 +26,17 @@ 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{ - Destination: nirvana.F(firewall_rules.FirewallRuleEndpointParam{ + networking.FirewallRuleNewParams{ + Destination: nirvana.F(networking.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("tcp"), - Source: nirvana.F(firewall_rules.FirewallRuleEndpointParam{ + Source: nirvana.F(networking.FirewallRuleEndpointParam{ Address: nirvana.F("0.0.0.0/0"), Ports: nirvana.F([]string{"22", "80", "443"}), }), @@ -63,18 +63,18 @@ 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", - firewall_rules.FirewallRuleUpdateParams{ - Destination: nirvana.F(firewall_rules.FirewallRuleEndpointParam{ + networking.FirewallRuleUpdateParams{ + Destination: nirvana.F(networking.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.FirewallRuleUpdateParamsProtocolTcp), - Source: nirvana.F(firewall_rules.FirewallRuleEndpointParam{ + Protocol: nirvana.F(networking.FirewallRuleUpdateParamsProtocolTcp), + Source: nirvana.F(networking.FirewallRuleEndpointParam{ Address: nirvana.F("0.0.0.0/0"), Ports: nirvana.F([]string{"22", "80", "443"}), }), @@ -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/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/vpcs/vpc.go b/networking/vpc.go similarity index 88% rename from vpcs/vpc.go rename to networking/vpc.go index fdc1e04..228cc4c 100644 --- a/vpcs/vpc.go +++ b/networking/vpc.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package vpcs +package networking import ( "context" @@ -8,7 +8,6 @@ import ( "fmt" "net/http" - "github.com/nirvana-labs/nirvana-go/firewall_rules" "github.com/nirvana-labs/nirvana-go/internal/apijson" "github.com/nirvana-labs/nirvana-go/internal/param" "github.com/nirvana-labs/nirvana-go/internal/requestconfig" @@ -39,7 +38,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 +46,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 +58,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 +70,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 } @@ -107,12 +106,12 @@ func (r subnetJSON) RawJSON() string { // VPC details. type VPC struct { - ID string `json:"id,required"` - CreatedAt string `json:"created_at,required"` - FirewallRules []firewall_rules.FirewallRule `json:"firewall_rules,required"` - Name string `json:"name,required"` - Region shared.RegionName `json:"region,required"` - Status shared.ResourceStatus `json:"status,required"` + ID string `json:"id,required"` + CreatedAt string `json:"created_at,required"` + FirewallRules []FirewallRule `json:"firewall_rules,required"` + Name string `json:"name,required"` + Region shared.RegionName `json:"region,required"` + Status shared.ResourceStatus `json:"status,required"` // Subnet details. Subnet Subnet `json:"subnet,required"` UpdatedAt string `json:"updated_at,required"` diff --git a/vpcs/vpc_test.go b/networking/vpc_test.go similarity index 87% rename from vpcs/vpc_test.go rename to networking/vpc_test.go index e10f318..943796a 100644 --- a/vpcs/vpc_test.go +++ b/networking/vpc_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -package vpcs_test +package networking_test import ( "context" @@ -10,9 +10,9 @@ import ( "github.com/nirvana-labs/nirvana-go" "github.com/nirvana-labs/nirvana-go/internal/testutil" + "github.com/nirvana-labs/nirvana-go/networking" "github.com/nirvana-labs/nirvana-go/option" "github.com/nirvana-labs/nirvana-go/shared" - "github.com/nirvana-labs/nirvana-go/vpcs" ) func TestVPCNew(t *testing.T) { @@ -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(), networking.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) { diff --git a/operations/operation.go b/operations/operation.go index 7eaf7a7..1ec0890 100644 --- a/operations/operation.go +++ b/operations/operation.go @@ -88,10 +88,10 @@ func (r operationJSON) RawJSON() string { type OperationKind string const ( - OperationKindVM OperationKind = "VM" - OperationKindVolume OperationKind = "VOLUME" - OperationKindVPC OperationKind = "VPC" - OperationKindFirewallRule OperationKind = "FIREWALL_RULE" + OperationKindVM OperationKind = "vm" + OperationKindVolume OperationKind = "volume" + OperationKindVPC OperationKind = "vpc" + OperationKindFirewallRule OperationKind = "firewall_rule" ) func (r OperationKind) IsKnown() bool { @@ -105,11 +105,11 @@ func (r OperationKind) IsKnown() bool { type OperationStatus string const ( - OperationStatusPending OperationStatus = "PENDING" - OperationStatusRunning OperationStatus = "RUNNING" - OperationStatusDone OperationStatus = "DONE" - OperationStatusFailed OperationStatus = "FAILED" - OperationStatusUnknown OperationStatus = "UNKNOWN" + OperationStatusPending OperationStatus = "pending" + OperationStatusRunning OperationStatus = "running" + OperationStatusDone OperationStatus = "done" + OperationStatusFailed OperationStatus = "failed" + OperationStatusUnknown OperationStatus = "unknown" ) func (r OperationStatus) IsKnown() bool { @@ -123,9 +123,9 @@ func (r OperationStatus) IsKnown() bool { type OperationType string const ( - OperationTypeCreate OperationType = "CREATE" - OperationTypeUpdate OperationType = "UPDATE" - OperationTypeDelete OperationType = "DELETE" + OperationTypeCreate OperationType = "create" + OperationTypeUpdate OperationType = "update" + OperationTypeDelete OperationType = "delete" ) func (r OperationType) IsKnown() bool { 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..0593757 100644 --- a/usage_test.go +++ b/usage_test.go @@ -8,10 +8,10 @@ import ( "testing" "github.com/nirvana-labs/nirvana-go" + "github.com/nirvana-labs/nirvana-go/compute" "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,23 +26,23 @@ 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{ + operation, err := client.Compute.VMs.New(context.TODO(), compute.VMNewParams{ + BootVolume: nirvana.F(compute.VMNewParamsBootVolume{ Size: nirvana.F(int64(100)), }), - CPU: nirvana.F(vms.CPUParam{ + CPU: nirvana.F(compute.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{ + Ram: nirvana.F(compute.RamParam{ Size: nirvana.F(int64(2)), }), Region: nirvana.F(shared.RegionNameAmsterdam), SourceAddress: nirvana.F("0.0.0.0/0"), - SSHKey: nirvana.F(vms.SSHKeyParam{ + SSHKey: nirvana.F(compute.SSHKeyParam{ PublicKey: nirvana.F("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC1234567890"), }), }) diff --git a/volumes/aliases.go b/volumes/aliases.go deleted file mode 100644 index 5458c55..0000000 --- a/volumes/aliases.go +++ /dev/null @@ -1,79 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package volumes - -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