Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.3.0"
".": "0.4.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 18
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-5058541cc0e298a6fc3e9cda1af0e32586d1f39c5666946e15f546c1aedc18ea.yml
openapi_spec_hash: 7f572ac0c7f9dc4f5fc7d9883a53d6c7
config_hash: 35db4c99791f175865381f13a8ad6075
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fhypeman-ce51f144a3d2de556750203edbaa5bfeefe874660737c35a4fc37dfb30057dd5.yml
openapi_spec_hash: 27663b6503056317abcb578ac7b67c06
config_hash: b4e65d240d7bca1ba6162ee2098c8ac2
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.4.0 (2025-11-26)

Full Changelog: [v0.3.0...v0.4.0](https://github.com/onkernel/hypeman-go/compare/v0.3.0...v0.4.0)

### Features

* Generate log streaming ([f444c22](https://github.com/onkernel/hypeman-go/commit/f444c22bd9eb0ad06e66b3ca167171ddec2836e4))

## 0.3.0 (2025-11-26)

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

```sh
go get -u 'github.com/onkernel/hypeman-go@v0.3.0'
go get -u 'github.com/onkernel/hypeman-go@v0.4.0'
```

<!-- x-release-please-end -->
Expand Down
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ Methods:
- <code title="get /instances/{id}">client.Instances.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#InstanceService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#Instance">Instance</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /instances">client.Instances.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#InstanceService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) ([]<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#Instance">Instance</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /instances/{id}">client.Instances.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#InstanceService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) <a href="https://pkg.go.dev/builtin#error">error</a></code>
- <code title="get /instances/{id}/logs">client.Instances.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#InstanceService.Logs">Logs</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/onkernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#InstanceLogsParams">InstanceLogsParams</a>) (<a href="https://pkg.go.dev/builtin#string">string</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /instances/{id}/standby">client.Instances.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#InstanceService.PutInStandby">PutInStandby</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#Instance">Instance</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /instances/{id}/restore">client.Instances.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#InstanceService.RestoreFromStandby">RestoreFromStandby</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#Instance">Instance</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /instances/{id}/logs">client.Instances.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#InstanceService.StreamLogs">StreamLogs</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/onkernel/hypeman-go">hypeman</a>.<a href="https://pkg.go.dev/github.com/onkernel/hypeman-go#InstanceStreamLogsParams">InstanceStreamLogsParams</a>) (<a href="https://pkg.go.dev/builtin#string">string</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

## Volumes

Expand Down
8 changes: 4 additions & 4 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ func TestContextDeadlineStreaming(t *testing.T) {
},
}),
)
stream := client.Instances.StreamLogsStreaming(
stream := client.Instances.LogsStreaming(
deadlineCtx,
"id",
hypeman.InstanceStreamLogsParams{},
hypeman.InstanceLogsParams{},
)
for stream.Next() {
_ = stream.Current()
Expand Down Expand Up @@ -320,10 +320,10 @@ func TestContextDeadlineStreamingWithRequestTimeout(t *testing.T) {
},
}),
)
stream := client.Instances.StreamLogsStreaming(
stream := client.Instances.LogsStreaming(
context.Background(),
"id",
hypeman.InstanceStreamLogsParams{},
hypeman.InstanceLogsParams{},
option.WithRequestTimeout((100 * time.Millisecond)),
)
for stream.Next() {
Expand Down
45 changes: 23 additions & 22 deletions instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,25 @@ func (r *InstanceService) Delete(ctx context.Context, id string, opts ...option.
return
}

// Streams instance console logs as Server-Sent Events. Returns the last N lines
// (controlled by `tail` parameter), then optionally continues streaming new lines
// if `follow=true`.
func (r *InstanceService) LogsStreaming(ctx context.Context, id string, query InstanceLogsParams, opts ...option.RequestOption) (stream *ssestream.Stream[string]) {
var (
raw *http.Response
err error
)
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "text/event-stream")}, opts...)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("instances/%s/logs", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &raw, opts...)
return ssestream.NewStream[string](ssestream.NewDecoder(raw), err)
}

// Put instance in standby (pause, snapshot, delete VMM)
func (r *InstanceService) PutInStandby(ctx context.Context, id string, opts ...option.RequestOption) (res *Instance, err error) {
opts = slices.Concat(r.Options, opts)
Expand All @@ -106,23 +125,6 @@ func (r *InstanceService) RestoreFromStandby(ctx context.Context, id string, opt
return
}

// Stream instance logs (SSE)
func (r *InstanceService) StreamLogsStreaming(ctx context.Context, id string, query InstanceStreamLogsParams, opts ...option.RequestOption) (stream *ssestream.Stream[string]) {
var (
raw *http.Response
err error
)
opts = slices.Concat(r.Options, opts)
opts = append([]option.RequestOption{option.WithHeader("Accept", "text/event-stream")}, opts...)
if id == "" {
err = errors.New("missing required id parameter")
return
}
path := fmt.Sprintf("instances/%s/logs", id)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &raw, opts...)
return ssestream.NewStream[string](ssestream.NewDecoder(raw), err)
}

type Instance struct {
// Auto-generated unique identifier (CUID2 format)
ID string `json:"id,required"`
Expand Down Expand Up @@ -278,17 +280,16 @@ func (r *InstanceNewParamsNetwork) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}

type InstanceStreamLogsParams struct {
// Follow logs (stream with SSE)
type InstanceLogsParams struct {
// Continue streaming new lines after initial output
Follow param.Opt[bool] `query:"follow,omitzero" json:"-"`
// Number of lines to return from end
Tail param.Opt[int64] `query:"tail,omitzero" json:"-"`
paramObj
}

// URLQuery serializes [InstanceStreamLogsParams]'s query parameters as
// `url.Values`.
func (r InstanceStreamLogsParams) URLQuery() (v url.Values, err error) {
// URLQuery serializes [InstanceLogsParams]'s query parameters as `url.Values`.
func (r InstanceLogsParams) URLQuery() (v url.Values, err error) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
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.3.0" // x-release-please-version
const PackageVersion = "0.4.0" // x-release-please-version