Skip to content

Commit 5f46e36

Browse files
feat: Neil/kernel 1017 profile pagination query parameter
1 parent 0d39945 commit 5f46e36

File tree

8 files changed

+43
-16
lines changed

8 files changed

+43
-16
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 101
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ea5c9cb25c29fa5a8758bbf8732eb306783bb6f13b4df29bf1ad5ad3cb32da1e.yml
3-
openapi_spec_hash: 597031840469b011f5cf22a4d8b9d750
4-
config_hash: 147340811dd6fbb9c2d80515a7e31f9a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-fc4a441d80d9a26574ef8af390a0c76265f5d4190daf90a04b6b353b128bbd97.yml
3+
openapi_spec_hash: 192987649d3797c3a80e6ef201667b64
4+
config_hash: 8af430e19f4af86c05f2987241cae72f

api.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,11 @@ Methods:
192192

193193
# Profiles
194194

195-
Types:
196-
197-
- <code><a href="./src/resources/profiles.ts">ProfileListResponse</a></code>
198-
199195
Methods:
200196

201197
- <code title="post /profiles">client.profiles.<a href="./src/resources/profiles.ts">create</a>({ ...params }) -> Profile</code>
202198
- <code title="get /profiles/{id_or_name}">client.profiles.<a href="./src/resources/profiles.ts">retrieve</a>(idOrName) -> Profile</code>
203-
- <code title="get /profiles">client.profiles.<a href="./src/resources/profiles.ts">list</a>() -> ProfileListResponse</code>
199+
- <code title="get /profiles">client.profiles.<a href="./src/resources/profiles.ts">list</a>({ ...params }) -> ProfilesOffsetPagination</code>
204200
- <code title="delete /profiles/{id_or_name}">client.profiles.<a href="./src/resources/profiles.ts">delete</a>(idOrName) -> void</code>
205201
- <code title="get /profiles/{id_or_name}/download">client.profiles.<a href="./src/resources/profiles.ts">download</a>(idOrName) -> Response</code>
206202

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ import {
8888
InvocationUpdateResponse,
8989
Invocations,
9090
} from './resources/invocations';
91-
import { ProfileCreateParams, ProfileListResponse, Profiles } from './resources/profiles';
91+
import { ProfileCreateParams, ProfileListParams, Profiles } from './resources/profiles';
9292
import {
9393
Proxies,
9494
ProxyCheckResponse,
@@ -985,8 +985,8 @@ export declare namespace Kernel {
985985

986986
export {
987987
Profiles as Profiles,
988-
type ProfileListResponse as ProfileListResponse,
989988
type ProfileCreateParams as ProfileCreateParams,
989+
type ProfileListParams as ProfileListParams,
990990
};
991991

992992
export { Auth as Auth };

src/resources/browsers/browsers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ export class Browsers extends APIResource {
209209

210210
export type BrowserListResponsesOffsetPagination = OffsetPagination<BrowserListResponse>;
211211

212+
export type ProfilesOffsetPagination = OffsetPagination<Profile>;
213+
212214
/**
213215
* @deprecated DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles
214216
* instead.

src/resources/browsers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export {
1414
type BrowserListParams,
1515
type BrowserDeleteParams,
1616
type BrowserLoadExtensionsParams,
17+
type ProfilesOffsetPagination,
1718
type BrowserListResponsesOffsetPagination,
1819
} from './browsers';
1920
export {

src/resources/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export {
3333
type BrowserListParams,
3434
type BrowserDeleteParams,
3535
type BrowserLoadExtensionsParams,
36+
type ProfilesOffsetPagination,
3637
type BrowserListResponsesOffsetPagination,
3738
} from './browsers/browsers';
3839
export {
@@ -92,7 +93,7 @@ export {
9293
type InvocationFollowParams,
9394
type InvocationListResponsesOffsetPagination,
9495
} from './invocations';
95-
export { Profiles, type ProfileListResponse, type ProfileCreateParams } from './profiles';
96+
export { Profiles, type ProfileCreateParams, type ProfileListParams } from './profiles';
9697
export {
9798
Proxies,
9899
type ProxyCreateResponse,

src/resources/profiles.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import { APIResource } from '../core/resource';
44
import * as BrowsersAPI from './browsers/browsers';
5+
import { ProfilesOffsetPagination } from './browsers/browsers';
56
import { APIPromise } from '../core/api-promise';
7+
import { OffsetPagination, type OffsetPaginationParams, PagePromise } from '../core/pagination';
68
import { buildHeaders } from '../internal/headers';
79
import { RequestOptions } from '../internal/request-options';
810
import { path } from '../internal/utils/path';
@@ -26,8 +28,11 @@ export class Profiles extends APIResource {
2628
/**
2729
* List profiles with optional filtering and pagination.
2830
*/
29-
list(options?: RequestOptions): APIPromise<ProfileListResponse> {
30-
return this._client.get('/profiles', options);
31+
list(
32+
query: ProfileListParams | null | undefined = {},
33+
options?: RequestOptions,
34+
): PagePromise<ProfilesOffsetPagination, BrowsersAPI.Profile> {
35+
return this._client.getAPIList('/profiles', OffsetPagination<BrowsersAPI.Profile>, { query, ...options });
3136
}
3237

3338
/**
@@ -53,15 +58,22 @@ export class Profiles extends APIResource {
5358
}
5459
}
5560

56-
export type ProfileListResponse = Array<BrowsersAPI.Profile>;
57-
5861
export interface ProfileCreateParams {
5962
/**
6063
* Optional name of the profile. Must be unique within the organization.
6164
*/
6265
name?: string;
6366
}
6467

68+
export interface ProfileListParams extends OffsetPaginationParams {
69+
/**
70+
* Search profiles by name or ID.
71+
*/
72+
query?: string;
73+
}
74+
6575
export declare namespace Profiles {
66-
export { type ProfileListResponse as ProfileListResponse, type ProfileCreateParams as ProfileCreateParams };
76+
export { type ProfileCreateParams as ProfileCreateParams, type ProfileListParams as ProfileListParams };
6777
}
78+
79+
export { type ProfilesOffsetPagination };

tests/api-resources/profiles.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ describe('resource profiles', () => {
4444
expect(dataAndResponse.response).toBe(rawResponse);
4545
});
4646

47+
// Mock server tests are disabled
48+
test.skip('list: request options and params are passed correctly', async () => {
49+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
50+
await expect(
51+
client.profiles.list(
52+
{
53+
limit: 1,
54+
offset: 0,
55+
query: 'query',
56+
},
57+
{ path: '/_stainless_unknown_path' },
58+
),
59+
).rejects.toThrow(Kernel.NotFoundError);
60+
});
61+
4762
// Mock server tests are disabled
4863
test.skip('delete', async () => {
4964
const responsePromise = client.profiles.delete('id_or_name');

0 commit comments

Comments
 (0)