2
2
3
3
import { APIResource } from '../../../core/resource' ;
4
4
import { APIPromise } from '../../../core/api-promise' ;
5
- import { Page , PagePromise } from '../../../core/pagination' ;
5
+ import { CursorPage , type CursorPageParams , Page , PagePromise } from '../../../core/pagination' ;
6
6
import { RequestOptions } from '../../../internal/request-options' ;
7
7
import { path } from '../../../internal/utils/path' ;
8
8
@@ -44,21 +44,24 @@ export class Permissions extends APIResource {
44
44
*
45
45
* @example
46
46
* ```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
+ * }
51
53
* ```
52
54
*/
53
55
retrieve (
54
56
fineTunedModelCheckpoint : string ,
55
57
query : PermissionRetrieveParams | null | undefined = { } ,
56
58
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
+ ) ;
62
65
}
63
66
64
67
/**
@@ -95,6 +98,8 @@ export class Permissions extends APIResource {
95
98
// Note: no pagination actually occurs yet, this is for forwards-compatibility.
96
99
export type PermissionCreateResponsesPage = Page < PermissionCreateResponse > ;
97
100
101
+ export type PermissionRetrieveResponsesPage = CursorPage < PermissionRetrieveResponse > ;
102
+
98
103
/**
99
104
* The `checkpoint.permission` object represents a permission for a fine-tuned
100
105
* model checkpoint.
@@ -121,44 +126,30 @@ export interface PermissionCreateResponse {
121
126
project_id : string ;
122
127
}
123
128
129
+ /**
130
+ * The `checkpoint.permission` object represents a permission for a fine-tuned
131
+ * model checkpoint.
132
+ */
124
133
export 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 {
137
134
/**
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.
140
136
*/
141
- export interface Data {
142
- /**
143
- * The permission identifier, which can be referenced in the API endpoints.
144
- */
145
- id : string ;
137
+ id : string ;
146
138
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 ;
151
143
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' ;
156
148
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 ;
162
153
}
163
154
164
155
export interface PermissionDeleteResponse {
@@ -185,17 +176,7 @@ export interface PermissionCreateParams {
185
176
project_ids : Array < string > ;
186
177
}
187
178
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 {
199
180
/**
200
181
* The order in which to retrieve permissions.
201
182
*/
@@ -220,6 +201,7 @@ export declare namespace Permissions {
220
201
type PermissionRetrieveResponse as PermissionRetrieveResponse ,
221
202
type PermissionDeleteResponse as PermissionDeleteResponse ,
222
203
type PermissionCreateResponsesPage as PermissionCreateResponsesPage ,
204
+ type PermissionRetrieveResponsesPage as PermissionRetrieveResponsesPage ,
223
205
type PermissionCreateParams as PermissionCreateParams ,
224
206
type PermissionRetrieveParams as PermissionRetrieveParams ,
225
207
type PermissionDeleteParams as PermissionDeleteParams ,
0 commit comments