@@ -28,6 +28,10 @@ else {
2828 FormData = undici . FormData ;
2929}
3030
31+ import { CreateTestUserRequest } from '../model/createTestUserRequest' ;
32+ import { CreateTestUserResponse } from '../model/createTestUserResponse' ;
33+ import { DeleteTestUserRequest } from '../model/deleteTestUserRequest' ;
34+ import { DeleteTestUserResponse } from '../model/deleteTestUserResponse' ;
3135import { GenericApiResponse } from '../model/genericApiResponse' ;
3236import { TestAddMockModelMonitoringDataRequest } from '../model/testAddMockModelMonitoringDataRequest' ;
3337
@@ -150,6 +154,188 @@ export class TestApi {
150154 }
151155
152156
157+ /**
158+ * Create a new user for testing/benchmarking purposes. Users created via this API are marked with `analytics_type = \'test\'`. If name/username/email are not provided, random values are generated.
159+ * @summary Create a test user
160+ * @param createTestUserRequest
161+ */
162+ public async createTestUser ( createTestUserRequest : CreateTestUserRequest , options : { headers : { [ name : string ] : string } } = { headers : { } } ) : Promise < CreateTestUserResponse > {
163+ const localVarPath = this . basePath + '/api/test/users' ;
164+ let localVarQueryParameters : Record < string , string > = { } ;
165+ let localVarHeaderParams : Record < string , string > = {
166+ 'User-Agent' : 'edgeimpulse-api nodejs' ,
167+ 'Content-Type' : 'application/json' ,
168+ ...this . defaultHeaders ,
169+ } ;
170+ const produces = [ 'application/json' ] ;
171+ // give precedence to 'application/json'
172+ if ( produces . indexOf ( 'application/json' ) >= 0 ) {
173+ localVarHeaderParams . Accept = 'application/json' ;
174+ } else {
175+ localVarHeaderParams . Accept = produces . join ( ',' ) ;
176+ }
177+ let localVarFormParams : Record < string , string > | FormData | UndiciFormData | undefined ;
178+
179+ // verify required parameter 'createTestUserRequest' is not null or undefined
180+
181+
182+ if ( createTestUserRequest === null || createTestUserRequest === undefined ) {
183+ throw new Error ( 'Required parameter createTestUserRequest was null or undefined when calling createTestUser.' ) ;
184+ }
185+
186+ localVarHeaderParams = {
187+ ...localVarHeaderParams ,
188+ ...options . headers ,
189+ ...this . opts . extraHeaders ,
190+ } ;
191+
192+ const queryString = Object . entries ( localVarQueryParameters )
193+ . filter ( ( [ , value ] ) => value !== undefined )
194+ . map ( ( [ key , value ] ) => `${ key } =${ encodeURIComponent ( String ( value ) ) } ` )
195+ . join ( '&' ) ;
196+
197+ let localVarUrl = localVarPath + ( queryString ? `?${ queryString } ` : '' ) ;
198+ let localVarRequestOptions : RequestOptionsType = {
199+ method : 'POST' ,
200+ headers : { ...localVarHeaderParams } ,
201+ } ;
202+
203+ localVarRequestOptions . body = JSON . stringify ( ObjectSerializer . serialize ( createTestUserRequest , "CreateTestUserRequest" ) ) ;
204+
205+
206+ let requestOptions = localVarRequestOptions ;
207+ let url = localVarUrl ;
208+ const auth_ApiKeyAuthentication = await this . authentications . ApiKeyAuthentication . applyToRequest ( requestOptions , url ) ;
209+ requestOptions = auth_ApiKeyAuthentication . requestOptions ;
210+ url = auth_ApiKeyAuthentication . url ;
211+
212+ const auth_JWTAuthentication = await this . authentications . JWTAuthentication . applyToRequest ( requestOptions , url ) ;
213+ requestOptions = auth_JWTAuthentication . requestOptions ;
214+ url = auth_JWTAuthentication . url ;
215+
216+ const auth_JWTHttpHeaderAuthentication = await this . authentications . JWTHttpHeaderAuthentication . applyToRequest ( requestOptions , url ) ;
217+ requestOptions = auth_JWTHttpHeaderAuthentication . requestOptions ;
218+ url = auth_JWTHttpHeaderAuthentication . url ;
219+
220+ const auth_OAuth2 = await this . authentications . OAuth2 . applyToRequest ( requestOptions , url ) ;
221+ requestOptions = auth_OAuth2 . requestOptions ;
222+ url = auth_OAuth2 . url ;
223+
224+ const authDefault = await this . authentications . default . applyToRequest ( requestOptions , url ) ;
225+ requestOptions = authDefault . requestOptions ;
226+ url = authDefault . url ;
227+
228+ if ( localVarFormParams ) {
229+ delete requestOptions . headers [ 'Content-Type' ] ;
230+ if ( localVarFormParams instanceof FormData ) {
231+ // FormData: fetch will handle Content-Type automatically.
232+ requestOptions . body = localVarFormParams ;
233+ }
234+ else if ( Object . keys ( localVarFormParams ) . length > 0 ) {
235+ // URL-encoded form
236+ requestOptions . body = new URLSearchParams ( localVarFormParams as Record < string , string > ) . toString ( ) ;
237+ requestOptions . headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded' ;
238+ }
239+ }
240+
241+ const response = await fetch ( url , requestOptions ) ;
242+ return this . handleResponse (
243+ response ,
244+ 'CreateTestUserResponse'
245+ ) ;
246+ }
247+
248+ /**
249+ * Delete a user with `analytics_type = \'test\'` by user ID.
250+ * @summary Delete a test user
251+ * @param deleteTestUserRequest
252+ */
253+ public async deleteTestUser ( deleteTestUserRequest : DeleteTestUserRequest , options : { headers : { [ name : string ] : string } } = { headers : { } } ) : Promise < DeleteTestUserResponse > {
254+ const localVarPath = this . basePath + '/api/test/users' ;
255+ let localVarQueryParameters : Record < string , string > = { } ;
256+ let localVarHeaderParams : Record < string , string > = {
257+ 'User-Agent' : 'edgeimpulse-api nodejs' ,
258+ 'Content-Type' : 'application/json' ,
259+ ...this . defaultHeaders ,
260+ } ;
261+ const produces = [ 'application/json' ] ;
262+ // give precedence to 'application/json'
263+ if ( produces . indexOf ( 'application/json' ) >= 0 ) {
264+ localVarHeaderParams . Accept = 'application/json' ;
265+ } else {
266+ localVarHeaderParams . Accept = produces . join ( ',' ) ;
267+ }
268+ let localVarFormParams : Record < string , string > | FormData | UndiciFormData | undefined ;
269+
270+ // verify required parameter 'deleteTestUserRequest' is not null or undefined
271+
272+
273+ if ( deleteTestUserRequest === null || deleteTestUserRequest === undefined ) {
274+ throw new Error ( 'Required parameter deleteTestUserRequest was null or undefined when calling deleteTestUser.' ) ;
275+ }
276+
277+ localVarHeaderParams = {
278+ ...localVarHeaderParams ,
279+ ...options . headers ,
280+ ...this . opts . extraHeaders ,
281+ } ;
282+
283+ const queryString = Object . entries ( localVarQueryParameters )
284+ . filter ( ( [ , value ] ) => value !== undefined )
285+ . map ( ( [ key , value ] ) => `${ key } =${ encodeURIComponent ( String ( value ) ) } ` )
286+ . join ( '&' ) ;
287+
288+ let localVarUrl = localVarPath + ( queryString ? `?${ queryString } ` : '' ) ;
289+ let localVarRequestOptions : RequestOptionsType = {
290+ method : 'DELETE' ,
291+ headers : { ...localVarHeaderParams } ,
292+ } ;
293+
294+ localVarRequestOptions . body = JSON . stringify ( ObjectSerializer . serialize ( deleteTestUserRequest , "DeleteTestUserRequest" ) ) ;
295+
296+
297+ let requestOptions = localVarRequestOptions ;
298+ let url = localVarUrl ;
299+ const auth_ApiKeyAuthentication = await this . authentications . ApiKeyAuthentication . applyToRequest ( requestOptions , url ) ;
300+ requestOptions = auth_ApiKeyAuthentication . requestOptions ;
301+ url = auth_ApiKeyAuthentication . url ;
302+
303+ const auth_JWTAuthentication = await this . authentications . JWTAuthentication . applyToRequest ( requestOptions , url ) ;
304+ requestOptions = auth_JWTAuthentication . requestOptions ;
305+ url = auth_JWTAuthentication . url ;
306+
307+ const auth_JWTHttpHeaderAuthentication = await this . authentications . JWTHttpHeaderAuthentication . applyToRequest ( requestOptions , url ) ;
308+ requestOptions = auth_JWTHttpHeaderAuthentication . requestOptions ;
309+ url = auth_JWTHttpHeaderAuthentication . url ;
310+
311+ const auth_OAuth2 = await this . authentications . OAuth2 . applyToRequest ( requestOptions , url ) ;
312+ requestOptions = auth_OAuth2 . requestOptions ;
313+ url = auth_OAuth2 . url ;
314+
315+ const authDefault = await this . authentications . default . applyToRequest ( requestOptions , url ) ;
316+ requestOptions = authDefault . requestOptions ;
317+ url = authDefault . url ;
318+
319+ if ( localVarFormParams ) {
320+ delete requestOptions . headers [ 'Content-Type' ] ;
321+ if ( localVarFormParams instanceof FormData ) {
322+ // FormData: fetch will handle Content-Type automatically.
323+ requestOptions . body = localVarFormParams ;
324+ }
325+ else if ( Object . keys ( localVarFormParams ) . length > 0 ) {
326+ // URL-encoded form
327+ requestOptions . body = new URLSearchParams ( localVarFormParams as Record < string , string > ) . toString ( ) ;
328+ requestOptions . headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded' ;
329+ }
330+ }
331+
332+ const response = await fetch ( url , requestOptions ) ;
333+ return this . handleResponse (
334+ response ,
335+ 'DeleteTestUserResponse'
336+ ) ;
337+ }
338+
153339 /**
154340 * Test-only API to insert mock aggregate data for model monitoring.
155341 * @summary Add mock summary data for model monitoring.
0 commit comments