@@ -27,9 +27,9 @@ const client = new Stainless({
2727 environment: ' staging' , // defaults to 'production'
2828});
2929
30- const buildObject = await client .builds .create ({ project: ' project ' , revision: ' string ' });
30+ const build = await client .builds .create ({ project: ' stainless ' , revision: ' main ' });
3131
32- console .log (buildObject .id );
32+ console .log (build .id );
3333```
3434
3535### Request & Response types
@@ -45,8 +45,8 @@ const client = new Stainless({
4545 environment: ' staging' , // defaults to 'production'
4646});
4747
48- const params: Stainless .BuildCreateParams = { project: ' project ' , revision: ' string ' };
49- const buildObject : Stainless .BuildObject = await client .builds .create (params );
48+ const params: Stainless .BuildCreateParams = { project: ' stainless ' , revision: ' main ' };
49+ const build : Stainless .Build = await client .builds .create (params );
5050```
5151
5252Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -59,17 +59,15 @@ a subclass of `APIError` will be thrown:
5959
6060<!-- prettier-ignore -->
6161``` ts
62- const buildObject = await client .builds
63- .create ({ project: ' project' , revision: ' string' })
64- .catch (async (err ) => {
65- if (err instanceof Stainless .APIError ) {
66- console .log (err .status ); // 400
67- console .log (err .name ); // BadRequestError
68- console .log (err .headers ); // {server: 'nginx', ...}
69- } else {
70- throw err ;
71- }
72- });
62+ const build = await client .builds .create ({ project: ' stainless' , revision: ' main' }).catch (async (err ) => {
63+ if (err instanceof Stainless .APIError ) {
64+ console .log (err .status ); // 400
65+ console .log (err .name ); // BadRequestError
66+ console .log (err .headers ); // {server: 'nginx', ...}
67+ } else {
68+ throw err ;
69+ }
70+ });
7371```
7472
7573Error codes are as follows:
@@ -101,7 +99,7 @@ const client = new Stainless({
10199});
102100
103101// Or, configure per-request:
104- await client .builds .create ({ project: ' project ' , revision: ' string ' }, {
102+ await client .builds .create ({ project: ' stainless ' , revision: ' main ' }, {
105103 maxRetries: 5 ,
106104});
107105```
@@ -118,7 +116,7 @@ const client = new Stainless({
118116});
119117
120118// Override per-request:
121- await client .builds .create ({ project: ' project ' , revision: ' string ' }, {
119+ await client .builds .create ({ project: ' stainless ' , revision: ' main ' }, {
122120 timeout: 5 * 1000 ,
123121});
124122```
@@ -133,22 +131,22 @@ List methods in the Stainless API are paginated.
133131You can use the ` for await … of ` syntax to iterate through items across all pages:
134132
135133``` ts
136- async function fetchAllBuildObjects (params ) {
137- const allBuildObjects = [];
134+ async function fetchAllBuilds (params ) {
135+ const allBuilds = [];
138136 // Automatically fetches more pages as needed.
139- for await (const buildObject of client .builds .list ({ project: ' project ' })) {
140- allBuildObjects .push (buildObject );
137+ for await (const build of client .builds .list ({ project: ' stainless ' })) {
138+ allBuilds .push (build );
141139 }
142- return allBuildObjects ;
140+ return allBuilds ;
143141}
144142```
145143
146144Alternatively, you can request a single page at a time:
147145
148146``` ts
149- let page = await client .builds .list ({ project: ' project ' });
150- for (const buildObject of page .data ) {
151- console .log (buildObject );
147+ let page = await client .builds .list ({ project: ' stainless ' });
148+ for (const build of page .data ) {
149+ console .log (build );
152150}
153151
154152// Convenience methods are provided for manually paginating:
@@ -172,15 +170,15 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
172170``` ts
173171const client = new Stainless ();
174172
175- const response = await client .builds .create ({ project: ' project ' , revision: ' string ' }).asResponse ();
173+ const response = await client .builds .create ({ project: ' stainless ' , revision: ' main ' }).asResponse ();
176174console .log (response .headers .get (' X-My-Header' ));
177175console .log (response .statusText ); // access the underlying Response object
178176
179- const { data : buildObject , response : raw } = await client .builds
180- .create ({ project: ' project ' , revision: ' string ' })
177+ const { data : build , response : raw } = await client .builds
178+ .create ({ project: ' stainless ' , revision: ' main ' })
181179 .withResponse ();
182180console .log (raw .headers .get (' X-My-Header' ));
183- console .log (buildObject .id );
181+ console .log (build .id );
184182```
185183
186184### Logging
0 commit comments