Skip to content

Commit 3bce4a1

Browse files
committed
SDK regeneration
1 parent f67a4ff commit 3bce4a1

File tree

7 files changed

+256
-194
lines changed

7 files changed

+256
-194
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ List endpoints are paginated. The SDK provides an iterator so that you can simpl
7070
import { TrueFoundryClient } from "truefoundry-sdk";
7171

7272
const client = new TrueFoundryClient({ environment: "YOUR_BASE_URL", apiKey: "YOUR_API_KEY" });
73-
const response = await client.v1.artifacts.list();
73+
const response = await client.v1.clusters.list();
7474
for await (const item of response) {
7575
console.log(item);
7676
}
7777

7878
// Or you can manually iterate page-by-page
79-
const page = await client.v1.artifacts.list();
79+
const page = await client.v1.clusters.list();
8080
while (page.hasNextPage()) {
8181
page = page.getNextPage();
8282
}

reference.md

+39-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## V1 Clusters
44

5-
<details><summary><code>client.v1.clusters.<a href="/src/api/resources/v1/resources/clusters/client/Client.ts">list</a>({ ...params }) -> TrueFoundry.ListClustersResponse</code></summary>
5+
<details><summary><code>client.v1.clusters.<a href="/src/api/resources/v1/resources/clusters/client/Client.ts">list</a>({ ...params }) -> core.Page<TrueFoundry.Cluster></code></summary>
66
<dl>
77
<dd>
88

@@ -30,7 +30,16 @@ Retrieves a list of all latest Clusters. Pagination is available based on query
3030
<dd>
3131

3232
```typescript
33-
await client.v1.clusters.list();
33+
const response = await client.v1.clusters.list();
34+
for await (const item of response) {
35+
console.log(item);
36+
}
37+
38+
// Or you can manually iterate page-by-page
39+
const page = await client.v1.clusters.list();
40+
while (page.hasNextPage()) {
41+
page = page.getNextPage();
42+
}
3443
```
3544

3645
</dd>
@@ -269,7 +278,7 @@ await client.v1.clusters.delete("id");
269278

270279
## V1 Environments
271280

272-
<details><summary><code>client.v1.environments.<a href="/src/api/resources/v1/resources/environments/client/Client.ts">list</a>({ ...params }) -> TrueFoundry.ListEnvironmentsResponse</code></summary>
281+
<details><summary><code>client.v1.environments.<a href="/src/api/resources/v1/resources/environments/client/Client.ts">list</a>({ ...params }) -> core.Page<TrueFoundry.Environment></code></summary>
273282
<dl>
274283
<dd>
275284

@@ -297,10 +306,22 @@ List environments, if no environments are found, default environments are create
297306
<dd>
298307

299308
```typescript
300-
await client.v1.environments.list({
309+
const response = await client.v1.environments.list({
310+
limit: 10,
311+
offset: 0,
312+
});
313+
for await (const item of response) {
314+
console.log(item);
315+
}
316+
317+
// Or you can manually iterate page-by-page
318+
const page = await client.v1.environments.list({
301319
limit: 10,
302320
offset: 0,
303321
});
322+
while (page.hasNextPage()) {
323+
page = page.getNextPage();
324+
}
304325
```
305326

306327
</dd>
@@ -534,7 +555,7 @@ await client.v1.environments.delete("id");
534555

535556
## V1 Workspaces
536557

537-
<details><summary><code>client.v1.workspaces.<a href="/src/api/resources/v1/resources/workspaces/client/Client.ts">list</a>({ ...params }) -> TrueFoundry.ListWorkspacesResponse</code></summary>
558+
<details><summary><code>client.v1.workspaces.<a href="/src/api/resources/v1/resources/workspaces/client/Client.ts">list</a>({ ...params }) -> core.Page<TrueFoundry.Workspace></code></summary>
538559
<dl>
539560
<dd>
540561

@@ -562,10 +583,22 @@ List workspaces associated with the user. Optional filters include clusterId, fq
562583
<dd>
563584

564585
```typescript
565-
await client.v1.workspaces.list({
586+
const response = await client.v1.workspaces.list({
566587
limit: 10,
567588
offset: 0,
568589
});
590+
for await (const item of response) {
591+
console.log(item);
592+
}
593+
594+
// Or you can manually iterate page-by-page
595+
const page = await client.v1.workspaces.list({
596+
limit: 10,
597+
offset: 0,
598+
});
599+
while (page.hasNextPage()) {
600+
page = page.getNextPage();
601+
}
569602
```
570603

571604
</dd>

src/api/resources/v1/resources/clusters/client/Client.ts

+68-60
Original file line numberDiff line numberDiff line change
@@ -45,70 +45,78 @@ export class Clusters {
4545
public async list(
4646
request: TrueFoundry.v1.ClustersListRequest = {},
4747
requestOptions?: Clusters.RequestOptions,
48-
): Promise<TrueFoundry.ListClustersResponse> {
49-
const { offset, limit } = request;
50-
const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
51-
if (offset != null) {
52-
_queryParams["offset"] = offset.toString();
53-
}
54-
55-
if (limit != null) {
56-
_queryParams["limit"] = limit.toString();
57-
}
58-
59-
const _response = await (this._options.fetcher ?? core.fetcher)({
60-
url: urlJoin(
61-
(await core.Supplier.get(this._options.baseUrl)) ??
62-
(await core.Supplier.get(this._options.environment)),
63-
"api/svc/v1/clusters",
64-
),
65-
method: "GET",
66-
headers: {
67-
Authorization: await this._getAuthorizationHeader(),
68-
"X-Fern-Language": "JavaScript",
69-
"X-Fern-SDK-Name": "truefoundry-sdk",
70-
"X-Fern-SDK-Version": "0.0.0",
71-
"User-Agent": "truefoundry-sdk/0.0.0",
72-
"X-Fern-Runtime": core.RUNTIME.type,
73-
"X-Fern-Runtime-Version": core.RUNTIME.version,
74-
...requestOptions?.headers,
75-
},
76-
contentType: "application/json",
77-
queryParameters: _queryParams,
78-
requestType: "json",
79-
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
80-
maxRetries: requestOptions?.maxRetries,
81-
abortSignal: requestOptions?.abortSignal,
82-
});
83-
if (_response.ok) {
84-
return _response.body as TrueFoundry.ListClustersResponse;
85-
}
86-
87-
if (_response.error.reason === "status-code") {
88-
switch (_response.error.statusCode) {
89-
case 401:
90-
throw new TrueFoundry.UnauthorizedError(_response.error.body as unknown);
91-
default:
48+
): Promise<core.Page<TrueFoundry.Cluster>> {
49+
const list = async (request: TrueFoundry.v1.ClustersListRequest): Promise<TrueFoundry.ListClustersResponse> => {
50+
const { offset, limit } = request;
51+
const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
52+
if (offset != null) {
53+
_queryParams["offset"] = offset.toString();
54+
}
55+
if (limit != null) {
56+
_queryParams["limit"] = limit.toString();
57+
}
58+
const _response = await (this._options.fetcher ?? core.fetcher)({
59+
url: urlJoin(
60+
(await core.Supplier.get(this._options.baseUrl)) ??
61+
(await core.Supplier.get(this._options.environment)),
62+
"api/svc/v1/clusters",
63+
),
64+
method: "GET",
65+
headers: {
66+
Authorization: await this._getAuthorizationHeader(),
67+
"X-Fern-Language": "JavaScript",
68+
"X-Fern-SDK-Name": "truefoundry-sdk",
69+
"X-Fern-SDK-Version": "0.0.0",
70+
"User-Agent": "truefoundry-sdk/0.0.0",
71+
"X-Fern-Runtime": core.RUNTIME.type,
72+
"X-Fern-Runtime-Version": core.RUNTIME.version,
73+
...requestOptions?.headers,
74+
},
75+
contentType: "application/json",
76+
queryParameters: _queryParams,
77+
requestType: "json",
78+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
79+
maxRetries: requestOptions?.maxRetries,
80+
abortSignal: requestOptions?.abortSignal,
81+
});
82+
if (_response.ok) {
83+
return _response.body as TrueFoundry.ListClustersResponse;
84+
}
85+
if (_response.error.reason === "status-code") {
86+
switch (_response.error.statusCode) {
87+
case 401:
88+
throw new TrueFoundry.UnauthorizedError(_response.error.body as unknown);
89+
default:
90+
throw new errors.TrueFoundryError({
91+
statusCode: _response.error.statusCode,
92+
body: _response.error.body,
93+
});
94+
}
95+
}
96+
switch (_response.error.reason) {
97+
case "non-json":
9298
throw new errors.TrueFoundryError({
9399
statusCode: _response.error.statusCode,
94-
body: _response.error.body,
100+
body: _response.error.rawBody,
101+
});
102+
case "timeout":
103+
throw new errors.TrueFoundryTimeoutError("Timeout exceeded when calling GET /api/svc/v1/clusters.");
104+
case "unknown":
105+
throw new errors.TrueFoundryError({
106+
message: _response.error.errorMessage,
95107
});
96108
}
97-
}
98-
99-
switch (_response.error.reason) {
100-
case "non-json":
101-
throw new errors.TrueFoundryError({
102-
statusCode: _response.error.statusCode,
103-
body: _response.error.rawBody,
104-
});
105-
case "timeout":
106-
throw new errors.TrueFoundryTimeoutError("Timeout exceeded when calling GET /api/svc/v1/clusters.");
107-
case "unknown":
108-
throw new errors.TrueFoundryError({
109-
message: _response.error.errorMessage,
110-
});
111-
}
109+
};
110+
let _offset = request?.offset != null ? request?.offset : 1;
111+
return new core.Pageable<TrueFoundry.ListClustersResponse, TrueFoundry.Cluster>({
112+
response: await list(request),
113+
hasNextPage: (response) => (response?.data ?? []).length > 0,
114+
getItems: (response) => response?.data ?? [],
115+
loadPage: (response) => {
116+
_offset += response?.data != null ? response.data.length : 1;
117+
return list(core.setObjectProperty(request, "offset", _offset));
118+
},
119+
});
112120
}
113121

114122
/**

src/api/resources/v1/resources/environments/client/Client.ts

+67-55
Original file line numberDiff line numberDiff line change
@@ -46,65 +46,77 @@ export class Environments {
4646
public async list(
4747
request: TrueFoundry.v1.EnvironmentsListRequest = {},
4848
requestOptions?: Environments.RequestOptions,
49-
): Promise<TrueFoundry.ListEnvironmentsResponse> {
50-
const { limit, offset } = request;
51-
const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
52-
if (limit != null) {
53-
_queryParams["limit"] = limit.toString();
54-
}
55-
56-
if (offset != null) {
57-
_queryParams["offset"] = offset.toString();
58-
}
59-
60-
const _response = await (this._options.fetcher ?? core.fetcher)({
61-
url: urlJoin(
62-
(await core.Supplier.get(this._options.baseUrl)) ??
63-
(await core.Supplier.get(this._options.environment)),
64-
"api/svc/v1/environments",
65-
),
66-
method: "GET",
67-
headers: {
68-
Authorization: await this._getAuthorizationHeader(),
69-
"X-Fern-Language": "JavaScript",
70-
"X-Fern-SDK-Name": "truefoundry-sdk",
71-
"X-Fern-SDK-Version": "0.0.0",
72-
"User-Agent": "truefoundry-sdk/0.0.0",
73-
"X-Fern-Runtime": core.RUNTIME.type,
74-
"X-Fern-Runtime-Version": core.RUNTIME.version,
75-
...requestOptions?.headers,
76-
},
77-
contentType: "application/json",
78-
queryParameters: _queryParams,
79-
requestType: "json",
80-
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
81-
maxRetries: requestOptions?.maxRetries,
82-
abortSignal: requestOptions?.abortSignal,
83-
});
84-
if (_response.ok) {
85-
return _response.body as TrueFoundry.ListEnvironmentsResponse;
86-
}
87-
88-
if (_response.error.reason === "status-code") {
89-
throw new errors.TrueFoundryError({
90-
statusCode: _response.error.statusCode,
91-
body: _response.error.body,
49+
): Promise<core.Page<TrueFoundry.Environment>> {
50+
const list = async (
51+
request: TrueFoundry.v1.EnvironmentsListRequest,
52+
): Promise<TrueFoundry.ListEnvironmentsResponse> => {
53+
const { limit, offset } = request;
54+
const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
55+
if (limit != null) {
56+
_queryParams["limit"] = limit.toString();
57+
}
58+
if (offset != null) {
59+
_queryParams["offset"] = offset.toString();
60+
}
61+
const _response = await (this._options.fetcher ?? core.fetcher)({
62+
url: urlJoin(
63+
(await core.Supplier.get(this._options.baseUrl)) ??
64+
(await core.Supplier.get(this._options.environment)),
65+
"api/svc/v1/environments",
66+
),
67+
method: "GET",
68+
headers: {
69+
Authorization: await this._getAuthorizationHeader(),
70+
"X-Fern-Language": "JavaScript",
71+
"X-Fern-SDK-Name": "truefoundry-sdk",
72+
"X-Fern-SDK-Version": "0.0.0",
73+
"User-Agent": "truefoundry-sdk/0.0.0",
74+
"X-Fern-Runtime": core.RUNTIME.type,
75+
"X-Fern-Runtime-Version": core.RUNTIME.version,
76+
...requestOptions?.headers,
77+
},
78+
contentType: "application/json",
79+
queryParameters: _queryParams,
80+
requestType: "json",
81+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
82+
maxRetries: requestOptions?.maxRetries,
83+
abortSignal: requestOptions?.abortSignal,
9284
});
93-
}
94-
95-
switch (_response.error.reason) {
96-
case "non-json":
85+
if (_response.ok) {
86+
return _response.body as TrueFoundry.ListEnvironmentsResponse;
87+
}
88+
if (_response.error.reason === "status-code") {
9789
throw new errors.TrueFoundryError({
9890
statusCode: _response.error.statusCode,
99-
body: _response.error.rawBody,
100-
});
101-
case "timeout":
102-
throw new errors.TrueFoundryTimeoutError("Timeout exceeded when calling GET /api/svc/v1/environments.");
103-
case "unknown":
104-
throw new errors.TrueFoundryError({
105-
message: _response.error.errorMessage,
91+
body: _response.error.body,
10692
});
107-
}
93+
}
94+
switch (_response.error.reason) {
95+
case "non-json":
96+
throw new errors.TrueFoundryError({
97+
statusCode: _response.error.statusCode,
98+
body: _response.error.rawBody,
99+
});
100+
case "timeout":
101+
throw new errors.TrueFoundryTimeoutError(
102+
"Timeout exceeded when calling GET /api/svc/v1/environments.",
103+
);
104+
case "unknown":
105+
throw new errors.TrueFoundryError({
106+
message: _response.error.errorMessage,
107+
});
108+
}
109+
};
110+
let _offset = request?.offset != null ? request?.offset : 1;
111+
return new core.Pageable<TrueFoundry.ListEnvironmentsResponse, TrueFoundry.Environment>({
112+
response: await list(request),
113+
hasNextPage: (response) => (response?.data ?? []).length > 0,
114+
getItems: (response) => response?.data ?? [],
115+
loadPage: (response) => {
116+
_offset += response?.data != null ? response.data.length : 1;
117+
return list(core.setObjectProperty(request, "offset", _offset));
118+
},
119+
});
108120
}
109121

110122
/**

0 commit comments

Comments
 (0)