Skip to content

Commit 4203ce6

Browse files
feat(api): update via SDK Studio
1 parent 17ea405 commit 4203ce6

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 10
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-3edc7a0eef4a0d4495782efbdb0d9b777a55aee058dab119f90de56019441326.yml
33
openapi_spec_hash: dff0b1efa1c1614cf770ed8327cefab2
4-
config_hash: f33cc77a9c01e879ad127194c897a988
4+
config_hash: cb04a4d88ee9f530b303ca57ff7090b3

README.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ const client = new Kernel({
5555
});
5656

5757
async function main() {
58-
const params: Kernel.BrowserCreateParams = { invocation_id: 'REPLACE_ME' };
58+
const params: Kernel.BrowserCreateParams = {
59+
invocation_id: 'REPLACE_ME',
60+
persistence: { id: 'browser-for-user-1234' },
61+
};
5962
const browser: Kernel.BrowserCreateResponse = await client.browsers.create(params);
6063
}
6164

@@ -117,15 +120,17 @@ a subclass of `APIError` will be thrown:
117120
<!-- prettier-ignore -->
118121
```ts
119122
async function main() {
120-
const browser = await client.browsers.create({ invocation_id: 'REPLACE_ME' }).catch(async (err) => {
121-
if (err instanceof Kernel.APIError) {
122-
console.log(err.status); // 400
123-
console.log(err.name); // BadRequestError
124-
console.log(err.headers); // {server: 'nginx', ...}
125-
} else {
126-
throw err;
127-
}
128-
});
123+
const browser = await client.browsers
124+
.create({ invocation_id: 'REPLACE_ME', persistence: { id: 'browser-for-user-1234' } })
125+
.catch(async (err) => {
126+
if (err instanceof Kernel.APIError) {
127+
console.log(err.status); // 400
128+
console.log(err.name); // BadRequestError
129+
console.log(err.headers); // {server: 'nginx', ...}
130+
} else {
131+
throw err;
132+
}
133+
});
129134
}
130135

131136
main();
@@ -160,7 +165,7 @@ const client = new Kernel({
160165
});
161166

162167
// Or, configure per-request:
163-
await client.browsers.create({ invocation_id: 'REPLACE_ME' }, {
168+
await client.browsers.create({ invocation_id: 'REPLACE_ME', persistence: { id: 'browser-for-user-1234' } }, {
164169
maxRetries: 5,
165170
});
166171
```
@@ -177,7 +182,7 @@ const client = new Kernel({
177182
});
178183

179184
// Override per-request:
180-
await client.browsers.create({ invocation_id: 'REPLACE_ME' }, {
185+
await client.browsers.create({ invocation_id: 'REPLACE_ME', persistence: { id: 'browser-for-user-1234' } }, {
181186
timeout: 5 * 1000,
182187
});
183188
```
@@ -200,12 +205,14 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
200205
```ts
201206
const client = new Kernel();
202207

203-
const response = await client.browsers.create({ invocation_id: 'REPLACE_ME' }).asResponse();
208+
const response = await client.browsers
209+
.create({ invocation_id: 'REPLACE_ME', persistence: { id: 'browser-for-user-1234' } })
210+
.asResponse();
204211
console.log(response.headers.get('X-My-Header'));
205212
console.log(response.statusText); // access the underlying Response object
206213

207214
const { data: browser, response: raw } = await client.browsers
208-
.create({ invocation_id: 'REPLACE_ME' })
215+
.create({ invocation_id: 'REPLACE_ME', persistence: { id: 'browser-for-user-1234' } })
209216
.withResponse();
210217
console.log(raw.headers.get('X-My-Header'));
211218
console.log(browser.session_id);

0 commit comments

Comments
 (0)