@@ -43,84 +43,91 @@ export class TracingProjects {
43
43
public async list (
44
44
request : TrueFoundry . v1 . TracingProjectsListRequest = { } ,
45
45
requestOptions ?: TracingProjects . RequestOptions ,
46
- ) : Promise < TrueFoundry . ListTracingProjectsResponse > {
47
- const { ml_repo_id : mlRepoId , fqn, name, offset, limit } = request ;
48
- const _queryParams : Record < string , string | string [ ] | object | object [ ] | null > = { } ;
49
- if ( mlRepoId != null ) {
50
- _queryParams [ "ml_repo_id" ] = mlRepoId . toString ( ) ;
51
- }
52
-
53
- if ( fqn != null ) {
54
- _queryParams [ "fqn" ] = fqn ;
55
- }
56
-
57
- if ( name != null ) {
58
- _queryParams [ "name" ] = name ;
59
- }
60
-
61
- if ( offset != null ) {
62
- _queryParams [ "offset" ] = offset . toString ( ) ;
63
- }
64
-
65
- if ( limit != null ) {
66
- _queryParams [ "limit" ] = limit . toString ( ) ;
67
- }
68
-
69
- const _response = await ( this . _options . fetcher ?? core . fetcher ) ( {
70
- url : urlJoin (
71
- ( await core . Supplier . get ( this . _options . baseUrl ) ) ??
72
- ( await core . Supplier . get ( this . _options . environment ) ) ,
73
- "api/ml/v1/tracing-projects" ,
74
- ) ,
75
- method : "GET" ,
76
- headers : {
77
- Authorization : await this . _getAuthorizationHeader ( ) ,
78
- "X-Fern-Language" : "JavaScript" ,
79
- "X-Fern-SDK-Name" : "truefoundry-sdk" ,
80
- "X-Fern-SDK-Version" : "0.0.0" ,
81
- "User-Agent" : "truefoundry-sdk/0.0.0" ,
82
- "X-Fern-Runtime" : core . RUNTIME . type ,
83
- "X-Fern-Runtime-Version" : core . RUNTIME . version ,
84
- ...requestOptions ?. headers ,
85
- } ,
86
- contentType : "application/json" ,
87
- queryParameters : _queryParams ,
88
- requestType : "json" ,
89
- timeoutMs : requestOptions ?. timeoutInSeconds != null ? requestOptions . timeoutInSeconds * 1000 : 60000 ,
90
- maxRetries : requestOptions ?. maxRetries ,
91
- abortSignal : requestOptions ?. abortSignal ,
92
- } ) ;
93
- if ( _response . ok ) {
94
- return _response . body as TrueFoundry . ListTracingProjectsResponse ;
95
- }
96
-
97
- if ( _response . error . reason === "status-code" ) {
98
- switch ( _response . error . statusCode ) {
99
- case 422 :
100
- throw new TrueFoundry . UnprocessableEntityError ( _response . error . body as unknown ) ;
101
- default :
46
+ ) : Promise < core . Page < TrueFoundry . TracingProject > > {
47
+ const list = async (
48
+ request : TrueFoundry . v1 . TracingProjectsListRequest ,
49
+ ) : Promise < TrueFoundry . ListTracingProjectsResponse > => {
50
+ const { ml_repo_id : mlRepoId , fqn, name, offset, limit } = request ;
51
+ const _queryParams : Record < string , string | string [ ] | object | object [ ] | null > = { } ;
52
+ if ( mlRepoId != null ) {
53
+ _queryParams [ "ml_repo_id" ] = mlRepoId . toString ( ) ;
54
+ }
55
+ if ( fqn != null ) {
56
+ _queryParams [ "fqn" ] = fqn ;
57
+ }
58
+ if ( name != null ) {
59
+ _queryParams [ "name" ] = name ;
60
+ }
61
+ if ( offset != null ) {
62
+ _queryParams [ "offset" ] = offset . toString ( ) ;
63
+ }
64
+ if ( limit != null ) {
65
+ _queryParams [ "limit" ] = limit . toString ( ) ;
66
+ }
67
+ const _response = await ( this . _options . fetcher ?? core . fetcher ) ( {
68
+ url : urlJoin (
69
+ ( await core . Supplier . get ( this . _options . baseUrl ) ) ??
70
+ ( await core . Supplier . get ( this . _options . environment ) ) ,
71
+ "api/ml/v1/tracing-projects" ,
72
+ ) ,
73
+ method : "GET" ,
74
+ headers : {
75
+ Authorization : await this . _getAuthorizationHeader ( ) ,
76
+ "X-Fern-Language" : "JavaScript" ,
77
+ "X-Fern-SDK-Name" : "truefoundry-sdk" ,
78
+ "X-Fern-SDK-Version" : "0.0.0" ,
79
+ "User-Agent" : "truefoundry-sdk/0.0.0" ,
80
+ "X-Fern-Runtime" : core . RUNTIME . type ,
81
+ "X-Fern-Runtime-Version" : core . RUNTIME . version ,
82
+ ...requestOptions ?. headers ,
83
+ } ,
84
+ contentType : "application/json" ,
85
+ queryParameters : _queryParams ,
86
+ requestType : "json" ,
87
+ timeoutMs : requestOptions ?. timeoutInSeconds != null ? requestOptions . timeoutInSeconds * 1000 : 60000 ,
88
+ maxRetries : requestOptions ?. maxRetries ,
89
+ abortSignal : requestOptions ?. abortSignal ,
90
+ } ) ;
91
+ if ( _response . ok ) {
92
+ return _response . body as TrueFoundry . ListTracingProjectsResponse ;
93
+ }
94
+ if ( _response . error . reason === "status-code" ) {
95
+ switch ( _response . error . statusCode ) {
96
+ case 422 :
97
+ throw new TrueFoundry . UnprocessableEntityError ( _response . error . body as unknown ) ;
98
+ default :
99
+ throw new errors . TrueFoundryError ( {
100
+ statusCode : _response . error . statusCode ,
101
+ body : _response . error . body ,
102
+ } ) ;
103
+ }
104
+ }
105
+ switch ( _response . error . reason ) {
106
+ case "non-json" :
102
107
throw new errors . TrueFoundryError ( {
103
108
statusCode : _response . error . statusCode ,
104
- body : _response . error . body ,
109
+ body : _response . error . rawBody ,
110
+ } ) ;
111
+ case "timeout" :
112
+ throw new errors . TrueFoundryTimeoutError (
113
+ "Timeout exceeded when calling GET /api/ml/v1/tracing-projects." ,
114
+ ) ;
115
+ case "unknown" :
116
+ throw new errors . TrueFoundryError ( {
117
+ message : _response . error . errorMessage ,
105
118
} ) ;
106
119
}
107
- }
108
-
109
- switch ( _response . error . reason ) {
110
- case "non-json" :
111
- throw new errors . TrueFoundryError ( {
112
- statusCode : _response . error . statusCode ,
113
- body : _response . error . rawBody ,
114
- } ) ;
115
- case "timeout" :
116
- throw new errors . TrueFoundryTimeoutError (
117
- "Timeout exceeded when calling GET /api/ml/v1/tracing-projects." ,
118
- ) ;
119
- case "unknown" :
120
- throw new errors . TrueFoundryError ( {
121
- message : _response . error . errorMessage ,
122
- } ) ;
123
- }
120
+ } ;
121
+ let _offset = request ?. offset != null ? request ?. offset : 0 ;
122
+ return new core . Pageable < TrueFoundry . ListTracingProjectsResponse , TrueFoundry . TracingProject > ( {
123
+ response : await list ( request ) ,
124
+ hasNextPage : ( response ) => ( response ?. data ?? [ ] ) . length > 0 ,
125
+ getItems : ( response ) => response ?. data ?? [ ] ,
126
+ loadPage : ( response ) => {
127
+ _offset += response ?. data != null ? response . data . length : 1 ;
128
+ return list ( core . setObjectProperty ( request , "offset" , _offset ) ) ;
129
+ } ,
130
+ } ) ;
124
131
}
125
132
126
133
/**
0 commit comments