Skip to content

Commit

Permalink
release: 0.1.0-alpha.11 (#37)
Browse files Browse the repository at this point in the history
* feat(api): api update (#36)

* release: 0.1.0-alpha.11

---------

Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
  • Loading branch information
stainless-app[bot] authored Jan 22, 2025
1 parent f3164e9 commit f66cf2a
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.10"
".": "0.1.0-alpha.11"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 17
configured_endpoints: 19
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/nirvana-labs%2Fnirvana-6aab21baffe1788ef3489dedfb817e9425a87edc3955e0b9cf720cca4302d7a3.yml
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.1.0-alpha.11 (2025-01-22)

Full Changelog: [v0.1.0-alpha.10...v0.1.0-alpha.11](https://github.com/nirvana-labs/nirvana-go/compare/v0.1.0-alpha.10...v0.1.0-alpha.11)

### Features

* **api:** api update ([#36](https://github.com/nirvana-labs/nirvana-go/issues/36)) ([e8b94d8](https://github.com/nirvana-labs/nirvana-go/commit/e8b94d8e052561667a48cae15a50ff008c6edddf))

## 0.1.0-alpha.10 (2025-01-22)

Full Changelog: [v0.1.0-alpha.9...v0.1.0-alpha.10](https://github.com/nirvana-labs/nirvana-go/compare/v0.1.0-alpha.9...v0.1.0-alpha.10)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/nirvana-labs/nirvana-go@v0.1.0-alpha.10'
go get -u 'github.com/nirvana-labs/nirvana-go@v0.1.0-alpha.11'
```

<!-- x-release-please-end -->
Expand Down
14 changes: 8 additions & 6 deletions api.md

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions firewall_rules/firewallrule.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (r *FirewallRuleService) Update(ctx context.Context, vpcID string, firewall
}

// List all firewall rules
func (r *FirewallRuleService) List(ctx context.Context, vpcID string, opts ...option.RequestOption) (res *FirewallRuleListResponse, 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")
Expand Down Expand Up @@ -180,24 +180,24 @@ func (r FirewallRuleEndpointParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

type FirewallRuleListResponse struct {
Items []FirewallRule `json:"items,required"`
JSON firewallRuleListResponseJSON `json:"-"`
type FirewallRuleList struct {
Items []FirewallRule `json:"items,required"`
JSON firewallRuleListJSON `json:"-"`
}

// firewallRuleListResponseJSON contains the JSON metadata for the struct
// [FirewallRuleListResponse]
type firewallRuleListResponseJSON struct {
// firewallRuleListJSON contains the JSON metadata for the struct
// [FirewallRuleList]
type firewallRuleListJSON struct {
Items apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *FirewallRuleListResponse) UnmarshalJSON(data []byte) (err error) {
func (r *FirewallRuleList) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r firewallRuleListResponseJSON) RawJSON() string {
func (r firewallRuleListJSON) RawJSON() string {
return r.raw
}

Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "0.1.0-alpha.10" // x-release-please-version
const PackageVersion = "0.1.0-alpha.11" // x-release-please-version
8 changes: 8 additions & 0 deletions operations/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ func NewOperationService(opts ...option.RequestOption) (r *OperationService) {
return
}

// List all operations
func (r *OperationService) List(ctx context.Context, opts ...option.RequestOption) (res *[]Operation, err error) {
opts = append(r.Options[:], opts...)
path := "operations"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}

// Get details about a specific operation
func (r *OperationService) Get(ctx context.Context, operationID string, opts ...option.RequestOption) (res *Operation, err error) {
opts = append(r.Options[:], opts...)
Expand Down
22 changes: 22 additions & 0 deletions operations/operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ import (
"github.com/nirvana-labs/nirvana-go/option"
)

func TestOperationList(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.Operations.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 TestOperationGet(t *testing.T) {
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
Expand Down
16 changes: 8 additions & 8 deletions vms/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,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 *VMListResponse, err error) {
func (r *VMService) List(ctx context.Context, opts ...option.RequestOption) (res *VMList, err error) {
opts = append(r.Options[:], opts...)
path := "vms"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
Expand Down Expand Up @@ -207,23 +207,23 @@ func (r vmJSON) RawJSON() string {
return r.raw
}

type VMListResponse struct {
Items []VM `json:"items,required"`
JSON vmListResponseJSON `json:"-"`
type VMList struct {
Items []VM `json:"items,required"`
JSON vmListJSON `json:"-"`
}

// vmListResponseJSON contains the JSON metadata for the struct [VMListResponse]
type vmListResponseJSON struct {
// vmListJSON contains the JSON metadata for the struct [VMList]
type vmListJSON struct {
Items apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *VMListResponse) UnmarshalJSON(data []byte) (err error) {
func (r *VMList) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r vmListResponseJSON) RawJSON() string {
func (r vmListJSON) RawJSON() string {
return r.raw
}

Expand Down
24 changes: 24 additions & 0 deletions volumes/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ func (r *VolumeService) New(ctx context.Context, vmID string, body VolumeNewPara
return
}

// Update a volume
func (r *VolumeService) Update(ctx context.Context, vmID string, volumeID string, body VolumeUpdateParams, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
if vmID == "" {
err = errors.New("missing required vm_id parameter")
return
}
if volumeID == "" {
err = errors.New("missing required volume_id parameter")
return
}
path := fmt.Sprintf("vms/%s/volumes/%s", vmID, volumeID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &res, opts...)
return
}

// Delete a volume
func (r *VolumeService) Delete(ctx context.Context, vmID string, volumeID string, opts ...option.RequestOption) (res *operations.Operation, err error) {
opts = append(r.Options[:], opts...)
Expand Down Expand Up @@ -112,3 +128,11 @@ type VolumeNewParams struct {
func (r VolumeNewParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}

type VolumeUpdateParams struct {
Size param.Field[int64] `json:"size,required"`
}

func (r VolumeUpdateParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
29 changes: 29 additions & 0 deletions volumes/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,35 @@ func TestVolumeNewWithOptionalParams(t *testing.T) {
}
}

func TestVolumeUpdate(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.Volumes.Update(
context.TODO(),
"vm_id",
"volume_id",
volumes.VolumeUpdateParams{
Size: nirvana.F(int64(100)),
},
)
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 {
Expand Down
16 changes: 8 additions & 8 deletions vpcs/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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 *VPCListResponse, err error) {
func (r *VPCService) List(ctx context.Context, opts ...option.RequestOption) (res *VPCList, err error) {
opts = append(r.Options[:], opts...)
path := "vpcs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
Expand Down Expand Up @@ -141,23 +141,23 @@ func (r vpcJSON) RawJSON() string {
return r.raw
}

type VPCListResponse struct {
Items []VPC `json:"items,required"`
JSON vpcListResponseJSON `json:"-"`
type VPCList struct {
Items []VPC `json:"items,required"`
JSON vpcListJSON `json:"-"`
}

// vpcListResponseJSON contains the JSON metadata for the struct [VPCListResponse]
type vpcListResponseJSON struct {
// vpcListJSON contains the JSON metadata for the struct [VPCList]
type vpcListJSON struct {
Items apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *VPCListResponse) UnmarshalJSON(data []byte) (err error) {
func (r *VPCList) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r vpcListResponseJSON) RawJSON() string {
func (r vpcListJSON) RawJSON() string {
return r.raw
}

Expand Down

0 comments on commit f66cf2a

Please sign in to comment.