Skip to content

Commit 1eb86f5

Browse files
release: 0.7.0 (#70)
* chore(internal): codegen related update (#69) * codegen metadata * codegen metadata * feat(api): api update (#71) * release: 0.7.0 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent 90b66ca commit 1eb86f5

10 files changed

+411
-18
lines changed

.release-please-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.6.0"
2+
".": "0.7.0"
33
}

.stats.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 14
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/riza%2Friza-api-00b3e89b997ff405b283aa320524d82ac961a9766eb1d23b8f315a4f850ae97d.yml
1+
configured_endpoints: 15
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/riza%2Friza-api-53d443fce326642ac4579e178d39bd12a49ed8230f1264bda8da4c805d4ae71f.yml

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## 0.7.0 (2025-01-23)
4+
5+
Full Changelog: [v0.6.0...v0.7.0](https://github.com/riza-io/riza-api-go/compare/v0.6.0...v0.7.0)
6+
7+
### Features
8+
9+
* **api:** api update ([#71](https://github.com/riza-io/riza-api-go/issues/71)) ([6ee7e40](https://github.com/riza-io/riza-api-go/commit/6ee7e409be7d31d82b196ebd19ad034343e55c8f))
10+
11+
12+
### Chores
13+
14+
* **internal:** codegen related update ([#69](https://github.com/riza-io/riza-api-go/issues/69)) ([45d5b2c](https://github.com/riza-io/riza-api-go/commit/45d5b2c6adf566245bb3336cae9f6551ff3be5f0))
15+
316
## 0.6.0 (2025-01-16)
417

518
Full Changelog: [v0.5.0...v0.6.0](https://github.com/riza-io/riza-api-go/compare/v0.5.0...v0.6.0)

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Or to pin the version:
2424
<!-- x-release-please-start-version -->
2525

2626
```sh
27-
go get -u 'github.com/riza-io/riza-api-go@v0.6.0'
27+
go get -u 'github.com/riza-io/riza-api-go@v0.7.0'
2828
```
2929

3030
<!-- x-release-please-end -->

api.md

+2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ Methods:
3131
Response Types:
3232

3333
- <a href="https://pkg.go.dev/github.com/riza-io/riza-api-go">riza</a>.<a href="https://pkg.go.dev/github.com/riza-io/riza-api-go#CommandExecResponse">CommandExecResponse</a>
34+
- <a href="https://pkg.go.dev/github.com/riza-io/riza-api-go">riza</a>.<a href="https://pkg.go.dev/github.com/riza-io/riza-api-go#CommandExecFuncResponse">CommandExecFuncResponse</a>
3435

3536
Methods:
3637

3738
- <code title="post /v1/execute">client.Command.<a href="https://pkg.go.dev/github.com/riza-io/riza-api-go#CommandService.Exec">Exec</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/riza-io/riza-api-go">riza</a>.<a href="https://pkg.go.dev/github.com/riza-io/riza-api-go#CommandExecParams">CommandExecParams</a>) (<a href="https://pkg.go.dev/github.com/riza-io/riza-api-go">riza</a>.<a href="https://pkg.go.dev/github.com/riza-io/riza-api-go#CommandExecResponse">CommandExecResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
39+
- <code title="post /v1/execute-function">client.Command.<a href="https://pkg.go.dev/github.com/riza-io/riza-api-go#CommandService.ExecFunc">ExecFunc</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/riza-io/riza-api-go">riza</a>.<a href="https://pkg.go.dev/github.com/riza-io/riza-api-go#CommandExecFuncParams">CommandExecFuncParams</a>) (<a href="https://pkg.go.dev/github.com/riza-io/riza-api-go">riza</a>.<a href="https://pkg.go.dev/github.com/riza-io/riza-api-go#CommandExecFuncResponse">CommandExecFuncResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
3840

3941
# Runtimes
4042

command.go

+224
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ func (r *CommandService) Exec(ctx context.Context, body CommandExecParams, opts
4141
return
4242
}
4343

44+
// Run a function in a secure, isolated environment. Define a function named
45+
// `execute`. The function will be passed `input` as an object.
46+
func (r *CommandService) ExecFunc(ctx context.Context, body CommandExecFuncParams, opts ...option.RequestOption) (res *CommandExecFuncResponse, err error) {
47+
opts = append(r.Options[:], opts...)
48+
path := "v1/execute-function"
49+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
50+
return
51+
}
52+
4453
type CommandExecResponse struct {
4554
// The exit code returned by the script. Will often be '0' on success and non-zero
4655
// on failure.
@@ -70,6 +79,84 @@ func (r commandExecResponseJSON) RawJSON() string {
7079
return r.raw
7180
}
7281

82+
type CommandExecFuncResponse struct {
83+
Execution CommandExecFuncResponseExecution `json:"execution"`
84+
Output interface{} `json:"output"`
85+
// The status of the output. "valid" means your function executed successfully and
86+
// returned a valid JSON-serializable object, or void. "json_serialization_error"
87+
// means your function executed successfully, but returned a nonserializable
88+
// object. "error" means your function failed to execute.
89+
OutputStatus CommandExecFuncResponseOutputStatus `json:"output_status"`
90+
JSON commandExecFuncResponseJSON `json:"-"`
91+
}
92+
93+
// commandExecFuncResponseJSON contains the JSON metadata for the struct
94+
// [CommandExecFuncResponse]
95+
type commandExecFuncResponseJSON struct {
96+
Execution apijson.Field
97+
Output apijson.Field
98+
OutputStatus apijson.Field
99+
raw string
100+
ExtraFields map[string]apijson.Field
101+
}
102+
103+
func (r *CommandExecFuncResponse) UnmarshalJSON(data []byte) (err error) {
104+
return apijson.UnmarshalRoot(data, r)
105+
}
106+
107+
func (r commandExecFuncResponseJSON) RawJSON() string {
108+
return r.raw
109+
}
110+
111+
type CommandExecFuncResponseExecution struct {
112+
// The exit code returned by the script. Will often be '0' on success and non-zero
113+
// on failure.
114+
ExitCode int64 `json:"exit_code"`
115+
// The contents of 'stderr' after executing the script.
116+
Stderr string `json:"stderr"`
117+
// The contents of 'stdout' after executing the script.
118+
Stdout string `json:"stdout"`
119+
JSON commandExecFuncResponseExecutionJSON `json:"-"`
120+
}
121+
122+
// commandExecFuncResponseExecutionJSON contains the JSON metadata for the struct
123+
// [CommandExecFuncResponseExecution]
124+
type commandExecFuncResponseExecutionJSON struct {
125+
ExitCode apijson.Field
126+
Stderr apijson.Field
127+
Stdout apijson.Field
128+
raw string
129+
ExtraFields map[string]apijson.Field
130+
}
131+
132+
func (r *CommandExecFuncResponseExecution) UnmarshalJSON(data []byte) (err error) {
133+
return apijson.UnmarshalRoot(data, r)
134+
}
135+
136+
func (r commandExecFuncResponseExecutionJSON) RawJSON() string {
137+
return r.raw
138+
}
139+
140+
// The status of the output. "valid" means your function executed successfully and
141+
// returned a valid JSON-serializable object, or void. "json_serialization_error"
142+
// means your function executed successfully, but returned a nonserializable
143+
// object. "error" means your function failed to execute.
144+
type CommandExecFuncResponseOutputStatus string
145+
146+
const (
147+
CommandExecFuncResponseOutputStatusError CommandExecFuncResponseOutputStatus = "error"
148+
CommandExecFuncResponseOutputStatusJsonSerializationError CommandExecFuncResponseOutputStatus = "json_serialization_error"
149+
CommandExecFuncResponseOutputStatusValid CommandExecFuncResponseOutputStatus = "valid"
150+
)
151+
152+
func (r CommandExecFuncResponseOutputStatus) IsKnown() bool {
153+
switch r {
154+
case CommandExecFuncResponseOutputStatusError, CommandExecFuncResponseOutputStatusJsonSerializationError, CommandExecFuncResponseOutputStatusValid:
155+
return true
156+
}
157+
return false
158+
}
159+
73160
type CommandExecParams struct {
74161
// The code to execute.
75162
Code param.Field[string] `json:"code,required"`
@@ -210,3 +297,140 @@ type CommandExecParamsLimits struct {
210297
func (r CommandExecParamsLimits) MarshalJSON() (data []byte, err error) {
211298
return apijson.MarshalRoot(r)
212299
}
300+
301+
type CommandExecFuncParams struct {
302+
// The function to execute. Your code must define a function named 'execute' and
303+
// return a JSON-serializable value.
304+
Code param.Field[string] `json:"code,required"`
305+
// The interpreter to use when executing code.
306+
Language param.Field[CommandExecFuncParamsLanguage] `json:"language,required"`
307+
// Set of key-value pairs to add to the script's execution environment.
308+
Env param.Field[map[string]string] `json:"env"`
309+
// List of input files.
310+
Files param.Field[[]CommandExecFuncParamsFile] `json:"files"`
311+
// Configuration for HTTP requests and authentication.
312+
HTTP param.Field[CommandExecFuncParamsHTTP] `json:"http"`
313+
Input param.Field[interface{}] `json:"input"`
314+
// Configuration for execution environment limits.
315+
Limits param.Field[CommandExecFuncParamsLimits] `json:"limits"`
316+
// The ID of the runtime revision to use when executing code.
317+
RuntimeRevisionID param.Field[string] `json:"runtime_revision_id"`
318+
}
319+
320+
func (r CommandExecFuncParams) MarshalJSON() (data []byte, err error) {
321+
return apijson.MarshalRoot(r)
322+
}
323+
324+
// The interpreter to use when executing code.
325+
type CommandExecFuncParamsLanguage string
326+
327+
const (
328+
CommandExecFuncParamsLanguagePython CommandExecFuncParamsLanguage = "python"
329+
CommandExecFuncParamsLanguageJavascript CommandExecFuncParamsLanguage = "javascript"
330+
CommandExecFuncParamsLanguageTypescript CommandExecFuncParamsLanguage = "typescript"
331+
CommandExecFuncParamsLanguageRuby CommandExecFuncParamsLanguage = "ruby"
332+
CommandExecFuncParamsLanguagePhp CommandExecFuncParamsLanguage = "php"
333+
)
334+
335+
func (r CommandExecFuncParamsLanguage) IsKnown() bool {
336+
switch r {
337+
case CommandExecFuncParamsLanguagePython, CommandExecFuncParamsLanguageJavascript, CommandExecFuncParamsLanguageTypescript, CommandExecFuncParamsLanguageRuby, CommandExecFuncParamsLanguagePhp:
338+
return true
339+
}
340+
return false
341+
}
342+
343+
type CommandExecFuncParamsFile struct {
344+
// The contents of the file.
345+
Contents param.Field[string] `json:"contents"`
346+
// The relative path of the file.
347+
Path param.Field[string] `json:"path"`
348+
}
349+
350+
func (r CommandExecFuncParamsFile) MarshalJSON() (data []byte, err error) {
351+
return apijson.MarshalRoot(r)
352+
}
353+
354+
// Configuration for HTTP requests and authentication.
355+
type CommandExecFuncParamsHTTP struct {
356+
// List of allowed HTTP hosts and associated authentication.
357+
Allow param.Field[[]CommandExecFuncParamsHTTPAllow] `json:"allow"`
358+
}
359+
360+
func (r CommandExecFuncParamsHTTP) MarshalJSON() (data []byte, err error) {
361+
return apijson.MarshalRoot(r)
362+
}
363+
364+
// List of allowed HTTP hosts and associated authentication.
365+
type CommandExecFuncParamsHTTPAllow struct {
366+
// Authentication configuration for outbound requests to this host.
367+
Auth param.Field[CommandExecFuncParamsHTTPAllowAuth] `json:"auth"`
368+
// The hostname to allow.
369+
Host param.Field[string] `json:"host"`
370+
}
371+
372+
func (r CommandExecFuncParamsHTTPAllow) MarshalJSON() (data []byte, err error) {
373+
return apijson.MarshalRoot(r)
374+
}
375+
376+
// Authentication configuration for outbound requests to this host.
377+
type CommandExecFuncParamsHTTPAllowAuth struct {
378+
Basic param.Field[CommandExecFuncParamsHTTPAllowAuthBasic] `json:"basic"`
379+
// Configuration to add an 'Authorization' header using the 'Bearer' scheme.
380+
Bearer param.Field[CommandExecFuncParamsHTTPAllowAuthBearer] `json:"bearer"`
381+
Header param.Field[CommandExecFuncParamsHTTPAllowAuthHeader] `json:"header"`
382+
Query param.Field[CommandExecFuncParamsHTTPAllowAuthQuery] `json:"query"`
383+
}
384+
385+
func (r CommandExecFuncParamsHTTPAllowAuth) MarshalJSON() (data []byte, err error) {
386+
return apijson.MarshalRoot(r)
387+
}
388+
389+
type CommandExecFuncParamsHTTPAllowAuthBasic struct {
390+
Password param.Field[string] `json:"password"`
391+
UserID param.Field[string] `json:"user_id"`
392+
}
393+
394+
func (r CommandExecFuncParamsHTTPAllowAuthBasic) MarshalJSON() (data []byte, err error) {
395+
return apijson.MarshalRoot(r)
396+
}
397+
398+
// Configuration to add an 'Authorization' header using the 'Bearer' scheme.
399+
type CommandExecFuncParamsHTTPAllowAuthBearer struct {
400+
// The token to set, e.g. 'Authorization: Bearer <token>'.
401+
Token param.Field[string] `json:"token"`
402+
}
403+
404+
func (r CommandExecFuncParamsHTTPAllowAuthBearer) MarshalJSON() (data []byte, err error) {
405+
return apijson.MarshalRoot(r)
406+
}
407+
408+
type CommandExecFuncParamsHTTPAllowAuthHeader struct {
409+
Name param.Field[string] `json:"name"`
410+
Value param.Field[string] `json:"value"`
411+
}
412+
413+
func (r CommandExecFuncParamsHTTPAllowAuthHeader) MarshalJSON() (data []byte, err error) {
414+
return apijson.MarshalRoot(r)
415+
}
416+
417+
type CommandExecFuncParamsHTTPAllowAuthQuery struct {
418+
Key param.Field[string] `json:"key"`
419+
Value param.Field[string] `json:"value"`
420+
}
421+
422+
func (r CommandExecFuncParamsHTTPAllowAuthQuery) MarshalJSON() (data []byte, err error) {
423+
return apijson.MarshalRoot(r)
424+
}
425+
426+
// Configuration for execution environment limits.
427+
type CommandExecFuncParamsLimits struct {
428+
// The maximum time allowed for execution (in seconds). Default is 30.
429+
ExecutionTimeout param.Field[int64] `json:"execution_timeout"`
430+
// The maximum memory allowed for execution (in MiB). Default is 128.
431+
MemorySize param.Field[int64] `json:"memory_size"`
432+
}
433+
434+
func (r CommandExecFuncParamsLimits) MarshalJSON() (data []byte, err error) {
435+
return apijson.MarshalRoot(r)
436+
}

command_test.go

+62
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,65 @@ func TestCommandExecWithOptionalParams(t *testing.T) {
7474
t.Fatalf("err should be nil: %s", err.Error())
7575
}
7676
}
77+
78+
func TestCommandExecFuncWithOptionalParams(t *testing.T) {
79+
baseURL := "http://localhost:4010"
80+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
81+
baseURL = envURL
82+
}
83+
if !testutil.CheckTestServer(t, baseURL) {
84+
return
85+
}
86+
client := riza.NewClient(
87+
option.WithBaseURL(baseURL),
88+
option.WithAPIKey("My API Key"),
89+
)
90+
_, err := client.Command.ExecFunc(context.TODO(), riza.CommandExecFuncParams{
91+
Code: riza.F("def execute(input): return { \"name\": \"John\", \"executed\": True }"),
92+
Language: riza.F(riza.CommandExecFuncParamsLanguagePython),
93+
Env: riza.F(map[string]string{
94+
"foo": "string",
95+
}),
96+
Files: riza.F([]riza.CommandExecFuncParamsFile{{
97+
Contents: riza.F("contents"),
98+
Path: riza.F("path"),
99+
}}),
100+
HTTP: riza.F(riza.CommandExecFuncParamsHTTP{
101+
Allow: riza.F([]riza.CommandExecFuncParamsHTTPAllow{{
102+
Auth: riza.F(riza.CommandExecFuncParamsHTTPAllowAuth{
103+
Basic: riza.F(riza.CommandExecFuncParamsHTTPAllowAuthBasic{
104+
Password: riza.F("password"),
105+
UserID: riza.F("user_id"),
106+
}),
107+
Bearer: riza.F(riza.CommandExecFuncParamsHTTPAllowAuthBearer{
108+
Token: riza.F("token"),
109+
}),
110+
Header: riza.F(riza.CommandExecFuncParamsHTTPAllowAuthHeader{
111+
Name: riza.F("name"),
112+
Value: riza.F("value"),
113+
}),
114+
Query: riza.F(riza.CommandExecFuncParamsHTTPAllowAuthQuery{
115+
Key: riza.F("key"),
116+
Value: riza.F("value"),
117+
}),
118+
}),
119+
Host: riza.F("host"),
120+
}}),
121+
}),
122+
Input: riza.F[any](map[string]interface{}{
123+
"name": "John",
124+
}),
125+
Limits: riza.F(riza.CommandExecFuncParamsLimits{
126+
ExecutionTimeout: riza.F(int64(0)),
127+
MemorySize: riza.F(int64(0)),
128+
}),
129+
RuntimeRevisionID: riza.F("runtime_revision_id"),
130+
})
131+
if err != nil {
132+
var apierr *riza.Error
133+
if errors.As(err, &apierr) {
134+
t.Log(string(apierr.DumpRequest(true)))
135+
}
136+
t.Fatalf("err should be nil: %s", err.Error())
137+
}
138+
}

0 commit comments

Comments
 (0)