22
33import { APIResource } from '../../../core/resource' ;
44import { APIPromise } from '../../../core/api-promise' ;
5- import { Page , PagePromise } from '../../../core/pagination' ;
5+ import { CursorPage , type CursorPageParams , Page , PagePromise } from '../../../core/pagination' ;
66import { RequestOptions } from '../../../internal/request-options' ;
77import { path } from '../../../internal/utils/path' ;
88
@@ -44,21 +44,24 @@ export class Permissions extends APIResource {
4444 *
4545 * @example
4646 * ```ts
47- * const permission =
48- * await client.fineTuning.checkpoints.permissions.retrieve(
49- * 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
50- * );
47+ * // Automatically fetches more pages as needed.
48+ * for await (const permissionRetrieveResponse of client.fineTuning.checkpoints.permissions.retrieve(
49+ * 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
50+ * )) {
51+ * // ...
52+ * }
5153 * ```
5254 */
5355 retrieve (
5456 fineTunedModelCheckpoint : string ,
5557 query : PermissionRetrieveParams | null | undefined = { } ,
5658 options ?: RequestOptions ,
57- ) : APIPromise < PermissionRetrieveResponse > {
58- return this . _client . get ( path `/fine_tuning/checkpoints/${ fineTunedModelCheckpoint } /permissions` , {
59- query,
60- ...options ,
61- } ) ;
59+ ) : PagePromise < PermissionRetrieveResponsesPage , PermissionRetrieveResponse > {
60+ return this . _client . getAPIList (
61+ path `/fine_tuning/checkpoints/${ fineTunedModelCheckpoint } /permissions` ,
62+ CursorPage < PermissionRetrieveResponse > ,
63+ { query, ...options } ,
64+ ) ;
6265 }
6366
6467 /**
@@ -95,6 +98,8 @@ export class Permissions extends APIResource {
9598// Note: no pagination actually occurs yet, this is for forwards-compatibility.
9699export type PermissionCreateResponsesPage = Page < PermissionCreateResponse > ;
97100
101+ export type PermissionRetrieveResponsesPage = CursorPage < PermissionRetrieveResponse > ;
102+
98103/**
99104 * The `checkpoint.permission` object represents a permission for a fine-tuned
100105 * model checkpoint.
@@ -121,44 +126,30 @@ export interface PermissionCreateResponse {
121126 project_id : string ;
122127}
123128
129+ /**
130+ * The `checkpoint.permission` object represents a permission for a fine-tuned
131+ * model checkpoint.
132+ */
124133export interface PermissionRetrieveResponse {
125- data : Array < PermissionRetrieveResponse . Data > ;
126-
127- has_more : boolean ;
128-
129- object : 'list' ;
130-
131- first_id ?: string | null ;
132-
133- last_id ?: string | null ;
134- }
135-
136- export namespace PermissionRetrieveResponse {
137134 /**
138- * The `checkpoint.permission` object represents a permission for a fine-tuned
139- * model checkpoint.
135+ * The permission identifier, which can be referenced in the API endpoints.
140136 */
141- export interface Data {
142- /**
143- * The permission identifier, which can be referenced in the API endpoints.
144- */
145- id : string ;
137+ id : string ;
146138
147- /**
148- * The Unix timestamp (in seconds) for when the permission was created.
149- */
150- created_at : number ;
139+ /**
140+ * The Unix timestamp (in seconds) for when the permission was created.
141+ */
142+ created_at : number ;
151143
152- /**
153- * The object type, which is always "checkpoint.permission".
154- */
155- object : 'checkpoint.permission' ;
144+ /**
145+ * The object type, which is always "checkpoint.permission".
146+ */
147+ object : 'checkpoint.permission' ;
156148
157- /**
158- * The project identifier that the permission is for.
159- */
160- project_id : string ;
161- }
149+ /**
150+ * The project identifier that the permission is for.
151+ */
152+ project_id : string ;
162153}
163154
164155export interface PermissionDeleteResponse {
@@ -185,17 +176,7 @@ export interface PermissionCreateParams {
185176 project_ids : Array < string > ;
186177}
187178
188- export interface PermissionRetrieveParams {
189- /**
190- * Identifier for the last permission ID from the previous pagination request.
191- */
192- after ?: string ;
193-
194- /**
195- * Number of permissions to retrieve.
196- */
197- limit ?: number ;
198-
179+ export interface PermissionRetrieveParams extends CursorPageParams {
199180 /**
200181 * The order in which to retrieve permissions.
201182 */
@@ -220,6 +201,7 @@ export declare namespace Permissions {
220201 type PermissionRetrieveResponse as PermissionRetrieveResponse ,
221202 type PermissionDeleteResponse as PermissionDeleteResponse ,
222203 type PermissionCreateResponsesPage as PermissionCreateResponsesPage ,
204+ type PermissionRetrieveResponsesPage as PermissionRetrieveResponsesPage ,
223205 type PermissionCreateParams as PermissionCreateParams ,
224206 type PermissionRetrieveParams as PermissionRetrieveParams ,
225207 type PermissionDeleteParams as PermissionDeleteParams ,
0 commit comments