Skip to content

Commit 10cda97

Browse files
authored
Merge pull request #14 from stainless-api/release-please--branches--main--changes--next
release: 0.2.0
2 parents 4474d89 + dd3a53b commit 10cda97

31 files changed

+559
-582
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
name: CI
22
on:
33
push:
4-
branches:
5-
- main
6-
pull_request:
7-
branches:
8-
- main
9-
- next
4+
branches-ignore:
5+
- 'generated'
6+
- 'codegen/**'
7+
- 'integrated/**'
8+
- 'stl-preview-head/**'
9+
- 'stl-preview-base/**'
1010

1111
jobs:
1212
lint:
13+
timeout-minutes: 10
1314
name: lint
14-
runs-on: ubuntu-latest
15+
runs-on: ${{ github.repository == 'stainless-sdks/stainless-v0-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
16+
1517
steps:
1618
- uses: actions/checkout@v4
1719

@@ -23,8 +25,9 @@ jobs:
2325
- name: Run lints
2426
run: ./scripts/lint
2527
test:
28+
timeout-minutes: 10
2629
name: test
27-
runs-on: ubuntu-latest
30+
runs-on: ${{ github.repository == 'stainless-sdks/stainless-v0-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
2831
steps:
2932
- uses: actions/checkout@v4
3033

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.1"
2+
".": "0.2.0"
33
}

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 11
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-6cc6dbcccc2b281f55ced484ddf562c7615d5facb27db5599575e253d9a9a47c.yml
3-
openapi_spec_hash: d74c662cb71cffec14b86f666f53f7c4
4-
config_hash: bf9f13a248e3d2f6cb014c313f9870a3
1+
configured_endpoints: 10
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/stainless%2Fstainless-v0-c9f598f79a7265337b04e831c4c36bfd8216901c74a5e6d14a38e30d33ec731b.yml
3+
openapi_spec_hash: 458ba78d4ac13aea449822777e9194a5
4+
config_hash: 8817e4ad583190fe8c46f5044c5dca03

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
# Changelog
22

3+
## 0.2.0 (2025-04-24)
4+
5+
Full Changelog: [v0.1.1...v0.2.0](https://github.com/stainless-api/stainless-api-go/compare/v0.1.1...v0.2.0)
6+
7+
### Features
8+
9+
* add typescript ([1631f7a](https://github.com/stainless-api/stainless-api-go/commit/1631f7ad568491a66ed0b7e5821879cd5645cb21))
10+
* **api:** configs ([675c5b1](https://github.com/stainless-api/stainless-api-go/commit/675c5b10c1cffd923f32261fa1cb06e1134b1775))
11+
* **api:** fix enum name conflict maybe ([f21813c](https://github.com/stainless-api/stainless-api-go/commit/f21813cad5d2237595d1389bbe25747649055da7))
12+
* **api:** manual updates ([f9b7e82](https://github.com/stainless-api/stainless-api-go/commit/f9b7e82bda7ad171be29985d013ce47781a8b6b0))
13+
* **api:** manual updates ([4b28524](https://github.com/stainless-api/stainless-api-go/commit/4b285245767a00f24bda90c3088279d7d3b1a1e7))
14+
* **api:** manual updates ([59ac5d0](https://github.com/stainless-api/stainless-api-go/commit/59ac5d095d4677f1722b76a9fc1c7531a424512a))
15+
* **api:** manual updates ([88c1005](https://github.com/stainless-api/stainless-api-go/commit/88c10052262103a1b01809a0b9d43892f72c8657))
16+
* **api:** manual updates ([c6af2bc](https://github.com/stainless-api/stainless-api-go/commit/c6af2bc172620f147bdb7b78b02b015c9c647150))
17+
* **api:** manual updates ([ee18ef8](https://github.com/stainless-api/stainless-api-go/commit/ee18ef80f20bfe06e6c2c4eb665d82f3bfd9143f))
18+
* **api:** manual updates ([b52a583](https://github.com/stainless-api/stainless-api-go/commit/b52a58329e8013cb34e4add568bc6b2f877c2628))
19+
* **api:** manual updates ([03ae282](https://github.com/stainless-api/stainless-api-go/commit/03ae28279f75772025d2641212969db6409b11a5))
20+
* **api:** parent build id ([ef14ee0](https://github.com/stainless-api/stainless-api-go/commit/ef14ee06c9ca5b16e10d2bdc6dce19d327cc1355))
21+
* **api:** remove discriminator thing ([40f8bc0](https://github.com/stainless-api/stainless-api-go/commit/40f8bc0dd275031d0f7bc9a90e5a610676edda6e))
22+
* **api:** use correct hashes ([e118e5a](https://github.com/stainless-api/stainless-api-go/commit/e118e5a173e468eb037b0e12e25d7e4e62cba6e9))
23+
* change list endpoint ([8a34e45](https://github.com/stainless-api/stainless-api-go/commit/8a34e451abf01b2748a339990944f93b33787ddf))
24+
* **client:** support more time formats ([dde7235](https://github.com/stainless-api/stainless-api-go/commit/dde72351a8cfbf8271984e9fda80b630d3fdf161))
25+
26+
27+
### Bug Fixes
28+
29+
* **client:** time format encoding fix ([67abcf1](https://github.com/stainless-api/stainless-api-go/commit/67abcf1ace98c409d908e09f3d033cbfcf4a32e0))
30+
31+
32+
### Chores
33+
34+
* **ci:** add timeout thresholds for CI jobs ([d6b6255](https://github.com/stainless-api/stainless-api-go/commit/d6b625593d4244a7a5ef5f98dbec567e5befb0de))
35+
* **ci:** only use depot for staging repos ([2275406](https://github.com/stainless-api/stainless-api-go/commit/22754063ee707b8b0527f7b72b736180c48ecbc7))
36+
* **internal:** codegen related update ([d0aa369](https://github.com/stainless-api/stainless-api-go/commit/d0aa3690b2c934f19a9d3d0f60d0f1167fb1eb9c))
37+
* **readme:** improve formatting ([cc1106d](https://github.com/stainless-api/stainless-api-go/commit/cc1106df35a95fb7719589acc66c42c6bf2ff8cc))
38+
* **utils:** add internal resp to param utility ([d69809f](https://github.com/stainless-api/stainless-api-go/commit/d69809f2f39bd1717bae31887079edac00ccabcc))
39+
340
## 0.1.1 (2025-04-18)
441

542
Full Changelog: [v0.1.0-alpha.2...v0.1.1](https://github.com/stainless-api/stainless-api-go/compare/v0.1.0-alpha.2...v0.1.1)

README.md

Lines changed: 85 additions & 42 deletions
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/stainless-api/stainless-api-go@v0.1.1'
27+
go get -u 'github.com/stainless-api/stainless-api-go@v0.2.0'
2828
```
2929

3030
<!-- x-release-please-end -->
@@ -52,11 +52,16 @@ func main() {
5252
client := stainlessv0.NewClient(
5353
option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("STAINLESS_V0_API_KEY")
5454
)
55-
openAPI, err := client.OpenAPI.Get(context.TODO())
55+
buildObject, err := client.Builds.New(context.TODO(), stainlessv0.BuildNewParams{
56+
Project: "project",
57+
Revision: stainlessv0.BuildNewParamsRevisionUnion{
58+
OfString: stainlessv0.String("string"),
59+
},
60+
})
5661
if err != nil {
5762
panic(err.Error())
5863
}
59-
fmt.Printf("%+v\n", openAPI)
64+
fmt.Printf("%+v\n", buildObject.ID)
6065
}
6166

6267
```
@@ -66,29 +71,18 @@ func main() {
6671
The stainlessv0 library uses the [`omitzero`](https://tip.golang.org/doc/go1.24#encodingjsonpkgencodingjson)
6772
semantics from the Go 1.24+ `encoding/json` release for request fields.
6873

69-
Required primitive fields (`int64`, `string`, etc.) feature the tag <code>\`json:...,required\`</code>. These
74+
Required primitive fields (`int64`, `string`, etc.) feature the tag <code>\`json:"...,required"\`</code>. These
7075
fields are always serialized, even their zero values.
7176

72-
Optional primitive types are wrapped in a `param.Opt[T]`. Use the provided constructors set `param.Opt[T]` fields such as `stainlessv0.String(string)`, `stainlessv0.Int(int64)`, etc.
73-
74-
Optional primitives, maps, slices and structs and string enums (represented as `string`) always feature the
75-
tag <code>\`json:"...,omitzero"\`</code>. Their zero values are considered omitted.
76-
77-
Any non-nil slice of length zero will serialize as an empty JSON array, `"[]"`. Similarly, any non-nil map with length zero with serialize as an empty JSON object, `"{}"`.
78-
79-
To send `null` instead of an `param.Opt[T]`, use `param.NullOpt[T]()`.
80-
To send `null` instead of a struct, use `param.NullObj[T]()`, where `T` is a struct.
81-
To send a custom value instead of a struct, use `param.OverrideObj[T](value)`.
77+
Optional primitive types are wrapped in a `param.Opt[T]`. These fields can be set with the provided constructors, `stainlessv0.String(string)`, `stainlessv0.Int(int64)`, etc.
8278

83-
To override request structs contain a `.WithExtraFields(map[string]any)` method which can be used to
84-
send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching
85-
key, so only use with trusted data.
79+
Any `param.Opt[T]`, map, slice, struct or string enum uses the
80+
tag <code>\`json:"...,omitzero"\`</code>. Its zero value is considered omitted.
8681

8782
```go
8883
params := stainlessv0.ExampleParams{
89-
ID: "id_xxx", // required property
90-
Name: stainlessv0.String("..."), // optional property
91-
Description: param.NullOpt[string](), // explicit null property
84+
ID: "id_xxx", // required property
85+
Name: stainlessv0.String("..."), // optional property
9286

9387
Point: stainlessv0.Point{
9488
X: 0, // required field will serialize as 0
@@ -98,7 +92,23 @@ params := stainlessv0.ExampleParams{
9892

9993
Origin: stainlessv0.Origin{}, // the zero value of [Origin] is considered omitted
10094
}
95+
```
96+
97+
To send `null` instead of a `param.Opt[T]`, use `param.NullOpt[T]()`.
98+
To send `null` instead of a struct `T`, use `param.NullObj[T]()`.
99+
100+
```go
101+
params.Description = param.NullOpt[string]() // explicit null string property
102+
params.Point = param.NullObj[Point]() // explicit null struct property
103+
```
104+
105+
Request structs contain a `.WithExtraFields(map[string]any)` method which can send non-conforming
106+
fields in the request body. Extra fields overwrite any struct fields with a matching
107+
key. For security reasons, only use `WithExtraFields` with trusted data.
108+
109+
To send a custom value instead of a struct, use `param.OverrideObj[T](value)`.
101110

111+
```go
102112
// In cases where the API specifies a given type,
103113
// but you want to send something else, use [WithExtraFields]:
104114
params.WithExtraFields(map[string]any{
@@ -110,7 +120,7 @@ custom := param.OverrideObj[stainlessv0.FooParams](12)
110120
```
111121

112122
When available, use the `.IsPresent()` method to check if an optional parameter is not omitted or `null`.
113-
Otherwise, the `param.IsOmitted(any)` function can confirm the presence of any `omitzero` field.
123+
The `param.IsOmitted(any)` function can confirm the presence of any `omitzero` field.
114124

115125
### Request unions
116126

@@ -144,34 +154,38 @@ if address := animal.GetOwner().GetAddress(); address != nil {
144154

145155
### Response objects
146156

147-
All fields in response structs are value types (not pointers or wrappers).
148-
149-
If a given field is `null`, not present, or invalid, the corresponding field
150-
will simply be its zero value. To handle optional fields, see the `IsPresent()` method
151-
below.
152-
153-
All response structs also include a special `JSON` field, containing more detailed
154-
information about each property, which you can use like so:
157+
All fields in response structs are ordinary value types (not pointers or wrappers).
158+
Response structs also include a special `JSON` field containing metadata about
159+
each property.
155160

156161
```go
157162
type Animal struct {
158163
Name string `json:"name,nullable"`
159164
Owners int `json:"owners"`
160165
Age int `json:"age"`
161166
JSON struct {
162-
Name resp.Field
163-
Owner resp.Field
164-
Age resp.Field
167+
Name resp.Field
168+
Owner resp.Field
169+
Age resp.Field
170+
ExtraFields map[string]resp.Field
165171
} `json:"-"`
166172
}
173+
```
174+
175+
To handle optional data, use the `IsPresent()` method on the JSON field.
176+
If a field is `null`, not present, or invalid, the corresponding field
177+
will simply be its zero value.
178+
179+
```go
180+
raw := `{"owners": 1, "name": null}`
167181

168182
var res Animal
169-
json.Unmarshal([]byte(`{"name": null, "owners": 0}`), &res)
183+
json.Unmarshal([]byte(raw), &res)
170184

171185
// Use the IsPresent() method to handle optional fields
172-
res.Owners // 0
186+
res.Owners // 1
173187
res.JSON.Owners.IsPresent() // true
174-
res.JSON.Owners.Raw() // "0"
188+
res.JSON.Owners.Raw() // "1"
175189

176190
res.Age // 0
177191
res.JSON.Age.IsPresent() // false
@@ -244,7 +258,7 @@ client := stainlessv0.NewClient(
244258
option.WithHeader("X-Some-Header", "custom_header_info"),
245259
)
246260

247-
client.OpenAPI.Get(context.TODO(), ...,
261+
client.Builds.New(context.TODO(), ...,
248262
// Override the header
249263
option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
250264
// Add an undocumented field to the request body, using sjson syntax
@@ -273,14 +287,19 @@ When the API returns a non-success status code, we return an error with type
273287
To handle errors, we recommend that you use the `errors.As` pattern:
274288

275289
```go
276-
_, err := client.OpenAPI.Get(context.TODO())
290+
_, err := client.Builds.New(context.TODO(), stainlessv0.BuildNewParams{
291+
Project: "project",
292+
Revision: stainlessv0.BuildNewParamsRevisionUnion{
293+
OfString: stainlessv0.String("string"),
294+
},
295+
})
277296
if err != nil {
278297
var apierr *stainlessv0.Error
279298
if errors.As(err, &apierr) {
280299
println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request
281300
println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
282301
}
283-
panic(err.Error()) // GET "/v0/openapi": 400 Bad Request { ... }
302+
panic(err.Error()) // GET "/v0/builds": 400 Bad Request { ... }
284303
}
285304
```
286305

@@ -298,8 +317,14 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`.
298317
// This sets the timeout for the request, including all the retries.
299318
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
300319
defer cancel()
301-
client.OpenAPI.Get(
320+
client.Builds.New(
302321
ctx,
322+
stainlessv0.BuildNewParams{
323+
Project: "project",
324+
Revision: stainlessv0.BuildNewParamsRevisionUnion{
325+
OfString: stainlessv0.String("string"),
326+
},
327+
},
303328
// This sets the per-retry timeout
304329
option.WithRequestTimeout(20*time.Second),
305330
)
@@ -333,7 +358,16 @@ client := stainlessv0.NewClient(
333358
)
334359

335360
// Override per-request:
336-
client.OpenAPI.Get(context.TODO(), option.WithMaxRetries(5))
361+
client.Builds.New(
362+
context.TODO(),
363+
stainlessv0.BuildNewParams{
364+
Project: "project",
365+
Revision: stainlessv0.BuildNewParamsRevisionUnion{
366+
OfString: stainlessv0.String("string"),
367+
},
368+
},
369+
option.WithMaxRetries(5),
370+
)
337371
```
338372

339373
### Accessing raw response data (e.g. response headers)
@@ -344,11 +378,20 @@ you need to examine response headers, status codes, or other details.
344378
```go
345379
// Create a variable to store the HTTP response
346380
var response *http.Response
347-
openAPI, err := client.OpenAPI.Get(context.TODO(), option.WithResponseInto(&response))
381+
buildObject, err := client.Builds.New(
382+
context.TODO(),
383+
stainlessv0.BuildNewParams{
384+
Project: "project",
385+
Revision: stainlessv0.BuildNewParamsRevisionUnion{
386+
OfString: stainlessv0.String("string"),
387+
},
388+
},
389+
option.WithResponseInto(&response),
390+
)
348391
if err != nil {
349392
// handle error
350393
}
351-
fmt.Printf("%+v\n", openAPI)
394+
fmt.Printf("%+v\n", buildObject)
352395

353396
fmt.Printf("Status Code: %d\n", response.StatusCode)
354397
fmt.Printf("Headers: %+#v\n", response.Header)

0 commit comments

Comments
 (0)