-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCIVisibilityPipelinesApi.ts
772 lines (715 loc) · 24.7 KB
/
CIVisibilityPipelinesApi.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
import {
BaseAPIRequestFactory,
RequiredError,
} from "../../datadog-api-client-common/baseapi";
import {
Configuration,
applySecurityAuthentication,
} from "../../datadog-api-client-common/configuration";
import {
RequestContext,
HttpMethod,
ResponseContext,
} from "../../datadog-api-client-common/http/http";
import { logger } from "../../../logger";
import { ObjectSerializer } from "../models/ObjectSerializer";
import { ApiException } from "../../datadog-api-client-common/exception";
import { APIErrorResponse } from "../models/APIErrorResponse";
import { CIAppCreatePipelineEventRequest } from "../models/CIAppCreatePipelineEventRequest";
import { CIAppPipelineEvent } from "../models/CIAppPipelineEvent";
import { CIAppPipelineEventsRequest } from "../models/CIAppPipelineEventsRequest";
import { CIAppPipelineEventsResponse } from "../models/CIAppPipelineEventsResponse";
import { CIAppPipelinesAggregateRequest } from "../models/CIAppPipelinesAggregateRequest";
import { CIAppPipelinesAnalyticsAggregateResponse } from "../models/CIAppPipelinesAnalyticsAggregateResponse";
import { CIAppQueryPageOptions } from "../models/CIAppQueryPageOptions";
import { CIAppSort } from "../models/CIAppSort";
import { HTTPCIAppErrors } from "../models/HTTPCIAppErrors";
export class CIVisibilityPipelinesApiRequestFactory extends BaseAPIRequestFactory {
public async aggregateCIAppPipelineEvents(
body: CIAppPipelinesAggregateRequest,
_options?: Configuration
): Promise<RequestContext> {
const _config = _options || this.configuration;
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new RequiredError("body", "aggregateCIAppPipelineEvents");
}
// Path Params
const localVarPath = "/api/v2/ci/pipelines/analytics/aggregate";
// Make Request Context
const requestContext = _config
.getServer("v2.CIVisibilityPipelinesApi.aggregateCIAppPipelineEvents")
.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json",
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(body, "CIAppPipelinesAggregateRequest", ""),
contentType
);
requestContext.setBody(serializedBody);
// Apply auth methods
applySecurityAuthentication(_config, requestContext, [
"AuthZ",
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
}
public async createCIAppPipelineEvent(
body: CIAppCreatePipelineEventRequest,
_options?: Configuration
): Promise<RequestContext> {
const _config = _options || this.configuration;
logger.warn("Using unstable operation 'createCIAppPipelineEvent'");
if (!_config.unstableOperations["v2.createCIAppPipelineEvent"]) {
throw new Error(
"Unstable operation 'createCIAppPipelineEvent' is disabled"
);
}
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new RequiredError("body", "createCIAppPipelineEvent");
}
// Path Params
const localVarPath = "/api/v2/ci/pipeline";
// Make Request Context
const requestContext = _config
.getServer("v2.CIVisibilityPipelinesApi.createCIAppPipelineEvent")
.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json",
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(body, "CIAppCreatePipelineEventRequest", ""),
contentType
);
requestContext.setBody(serializedBody);
// Apply auth methods
applySecurityAuthentication(_config, requestContext, ["apiKeyAuth"]);
return requestContext;
}
public async listCIAppPipelineEvents(
filterQuery?: string,
filterFrom?: Date,
filterTo?: Date,
sort?: CIAppSort,
pageCursor?: string,
pageLimit?: number,
_options?: Configuration
): Promise<RequestContext> {
const _config = _options || this.configuration;
// Path Params
const localVarPath = "/api/v2/ci/pipelines/events";
// Make Request Context
const requestContext = _config
.getServer("v2.CIVisibilityPipelinesApi.listCIAppPipelineEvents")
.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Query Params
if (filterQuery !== undefined) {
requestContext.setQueryParam(
"filter[query]",
ObjectSerializer.serialize(filterQuery, "string", "")
);
}
if (filterFrom !== undefined) {
requestContext.setQueryParam(
"filter[from]",
ObjectSerializer.serialize(filterFrom, "Date", "date-time")
);
}
if (filterTo !== undefined) {
requestContext.setQueryParam(
"filter[to]",
ObjectSerializer.serialize(filterTo, "Date", "date-time")
);
}
if (sort !== undefined) {
requestContext.setQueryParam(
"sort",
ObjectSerializer.serialize(sort, "CIAppSort", "")
);
}
if (pageCursor !== undefined) {
requestContext.setQueryParam(
"page[cursor]",
ObjectSerializer.serialize(pageCursor, "string", "")
);
}
if (pageLimit !== undefined) {
requestContext.setQueryParam(
"page[limit]",
ObjectSerializer.serialize(pageLimit, "number", "int32")
);
}
// Apply auth methods
applySecurityAuthentication(_config, requestContext, [
"AuthZ",
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
}
public async searchCIAppPipelineEvents(
body?: CIAppPipelineEventsRequest,
_options?: Configuration
): Promise<RequestContext> {
const _config = _options || this.configuration;
// Path Params
const localVarPath = "/api/v2/ci/pipelines/events/search";
// Make Request Context
const requestContext = _config
.getServer("v2.CIVisibilityPipelinesApi.searchCIAppPipelineEvents")
.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json",
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(body, "CIAppPipelineEventsRequest", ""),
contentType
);
requestContext.setBody(serializedBody);
// Apply auth methods
applySecurityAuthentication(_config, requestContext, [
"AuthZ",
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
}
}
export class CIVisibilityPipelinesApiResponseProcessor {
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to aggregateCIAppPipelineEvents
* @throws ApiException if the response code was not in [200, 299]
*/
public async aggregateCIAppPipelineEvents(
response: ResponseContext
): Promise<CIAppPipelinesAnalyticsAggregateResponse> {
const contentType = ObjectSerializer.normalizeMediaType(
response.headers["content-type"]
);
if (response.httpStatusCode == 200) {
const body: CIAppPipelinesAnalyticsAggregateResponse =
ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"CIAppPipelinesAnalyticsAggregateResponse"
) as CIAppPipelinesAnalyticsAggregateResponse;
return body;
}
if (
response.httpStatusCode == 400 ||
response.httpStatusCode == 403 ||
response.httpStatusCode == 429
) {
const bodyText = ObjectSerializer.parse(
await response.body.text(),
contentType
);
let body: APIErrorResponse;
try {
body = ObjectSerializer.deserialize(
bodyText,
"APIErrorResponse"
) as APIErrorResponse;
} catch (error) {
logger.info(`Got error deserializing error: ${error}`);
throw new ApiException<APIErrorResponse>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: CIAppPipelinesAnalyticsAggregateResponse =
ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"CIAppPipelinesAnalyticsAggregateResponse",
""
) as CIAppPipelinesAnalyticsAggregateResponse;
return body;
}
const body = (await response.body.text()) || "";
throw new ApiException<string>(
response.httpStatusCode,
'Unknown API Status Code!\nBody: "' + body + '"'
);
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to createCIAppPipelineEvent
* @throws ApiException if the response code was not in [200, 299]
*/
public async createCIAppPipelineEvent(
response: ResponseContext
): Promise<any> {
const contentType = ObjectSerializer.normalizeMediaType(
response.headers["content-type"]
);
if (response.httpStatusCode == 202) {
const body: any = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"any"
) as any;
return body;
}
if (
response.httpStatusCode == 400 ||
response.httpStatusCode == 401 ||
response.httpStatusCode == 403 ||
response.httpStatusCode == 408 ||
response.httpStatusCode == 413 ||
response.httpStatusCode == 429 ||
response.httpStatusCode == 500 ||
response.httpStatusCode == 503
) {
const bodyText = ObjectSerializer.parse(
await response.body.text(),
contentType
);
let body: HTTPCIAppErrors;
try {
body = ObjectSerializer.deserialize(
bodyText,
"HTTPCIAppErrors"
) as HTTPCIAppErrors;
} catch (error) {
logger.info(`Got error deserializing error: ${error}`);
throw new ApiException<HTTPCIAppErrors>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<HTTPCIAppErrors>(response.httpStatusCode, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: any = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"any",
""
) as any;
return body;
}
const body = (await response.body.text()) || "";
throw new ApiException<string>(
response.httpStatusCode,
'Unknown API Status Code!\nBody: "' + body + '"'
);
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to listCIAppPipelineEvents
* @throws ApiException if the response code was not in [200, 299]
*/
public async listCIAppPipelineEvents(
response: ResponseContext
): Promise<CIAppPipelineEventsResponse> {
const contentType = ObjectSerializer.normalizeMediaType(
response.headers["content-type"]
);
if (response.httpStatusCode == 200) {
const body: CIAppPipelineEventsResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"CIAppPipelineEventsResponse"
) as CIAppPipelineEventsResponse;
return body;
}
if (
response.httpStatusCode == 400 ||
response.httpStatusCode == 403 ||
response.httpStatusCode == 429
) {
const bodyText = ObjectSerializer.parse(
await response.body.text(),
contentType
);
let body: APIErrorResponse;
try {
body = ObjectSerializer.deserialize(
bodyText,
"APIErrorResponse"
) as APIErrorResponse;
} catch (error) {
logger.info(`Got error deserializing error: ${error}`);
throw new ApiException<APIErrorResponse>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: CIAppPipelineEventsResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"CIAppPipelineEventsResponse",
""
) as CIAppPipelineEventsResponse;
return body;
}
const body = (await response.body.text()) || "";
throw new ApiException<string>(
response.httpStatusCode,
'Unknown API Status Code!\nBody: "' + body + '"'
);
}
/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to searchCIAppPipelineEvents
* @throws ApiException if the response code was not in [200, 299]
*/
public async searchCIAppPipelineEvents(
response: ResponseContext
): Promise<CIAppPipelineEventsResponse> {
const contentType = ObjectSerializer.normalizeMediaType(
response.headers["content-type"]
);
if (response.httpStatusCode == 200) {
const body: CIAppPipelineEventsResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"CIAppPipelineEventsResponse"
) as CIAppPipelineEventsResponse;
return body;
}
if (
response.httpStatusCode == 400 ||
response.httpStatusCode == 403 ||
response.httpStatusCode == 429
) {
const bodyText = ObjectSerializer.parse(
await response.body.text(),
contentType
);
let body: APIErrorResponse;
try {
body = ObjectSerializer.deserialize(
bodyText,
"APIErrorResponse"
) as APIErrorResponse;
} catch (error) {
logger.info(`Got error deserializing error: ${error}`);
throw new ApiException<APIErrorResponse>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: CIAppPipelineEventsResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"CIAppPipelineEventsResponse",
""
) as CIAppPipelineEventsResponse;
return body;
}
const body = (await response.body.text()) || "";
throw new ApiException<string>(
response.httpStatusCode,
'Unknown API Status Code!\nBody: "' + body + '"'
);
}
}
export interface CIVisibilityPipelinesApiAggregateCIAppPipelineEventsRequest {
/**
* @type CIAppPipelinesAggregateRequest
*/
body: CIAppPipelinesAggregateRequest;
}
export interface CIVisibilityPipelinesApiCreateCIAppPipelineEventRequest {
/**
* @type CIAppCreatePipelineEventRequest
*/
body: CIAppCreatePipelineEventRequest;
}
export interface CIVisibilityPipelinesApiListCIAppPipelineEventsRequest {
/**
* Search query following log syntax.
* @type string
*/
filterQuery?: string;
/**
* Minimum timestamp for requested events.
* @type Date
*/
filterFrom?: Date;
/**
* Maximum timestamp for requested events.
* @type Date
*/
filterTo?: Date;
/**
* Order of events in results.
* @type CIAppSort
*/
sort?: CIAppSort;
/**
* List following results with a cursor provided in the previous query.
* @type string
*/
pageCursor?: string;
/**
* Maximum number of events in the response.
* @type number
*/
pageLimit?: number;
}
export interface CIVisibilityPipelinesApiSearchCIAppPipelineEventsRequest {
/**
* @type CIAppPipelineEventsRequest
*/
body?: CIAppPipelineEventsRequest;
}
export class CIVisibilityPipelinesApi {
private requestFactory: CIVisibilityPipelinesApiRequestFactory;
private responseProcessor: CIVisibilityPipelinesApiResponseProcessor;
private configuration: Configuration;
public constructor(
configuration: Configuration,
requestFactory?: CIVisibilityPipelinesApiRequestFactory,
responseProcessor?: CIVisibilityPipelinesApiResponseProcessor
) {
this.configuration = configuration;
this.requestFactory =
requestFactory ||
new CIVisibilityPipelinesApiRequestFactory(configuration);
this.responseProcessor =
responseProcessor || new CIVisibilityPipelinesApiResponseProcessor();
}
/**
* Use this API endpoint to aggregate CI Visibility pipeline events into buckets of computed metrics and timeseries.
* @param param The request object
*/
public aggregateCIAppPipelineEvents(
param: CIVisibilityPipelinesApiAggregateCIAppPipelineEventsRequest,
options?: Configuration
): Promise<CIAppPipelinesAnalyticsAggregateResponse> {
const requestContextPromise =
this.requestFactory.aggregateCIAppPipelineEvents(param.body, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.aggregateCIAppPipelineEvents(
responseContext
);
});
});
}
/**
* Send your pipeline event to your Datadog platform over HTTP. For details about how pipeline executions are modeled and what execution types we support, see [Pipeline Data Model And Execution Types](https://docs.datadoghq.com/continuous_integration/guides/pipeline_data_model/).
*
* Pipeline events can be submitted with a timestamp that is up to 18 hours in the past.
* @param param The request object
*/
public createCIAppPipelineEvent(
param: CIVisibilityPipelinesApiCreateCIAppPipelineEventRequest,
options?: Configuration
): Promise<any> {
const requestContextPromise = this.requestFactory.createCIAppPipelineEvent(
param.body,
options
);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.createCIAppPipelineEvent(
responseContext
);
});
});
}
/**
* List endpoint returns CI Visibility pipeline events that match a [search query](https://docs.datadoghq.com/continuous_integration/explorer/search_syntax/).
* [Results are paginated similarly to logs](https://docs.datadoghq.com/logs/guide/collect-multiple-logs-with-pagination).
*
* Use this endpoint to see your latest pipeline events.
* @param param The request object
*/
public listCIAppPipelineEvents(
param: CIVisibilityPipelinesApiListCIAppPipelineEventsRequest = {},
options?: Configuration
): Promise<CIAppPipelineEventsResponse> {
const requestContextPromise = this.requestFactory.listCIAppPipelineEvents(
param.filterQuery,
param.filterFrom,
param.filterTo,
param.sort,
param.pageCursor,
param.pageLimit,
options
);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.listCIAppPipelineEvents(
responseContext
);
});
});
}
/**
* Provide a paginated version of listCIAppPipelineEvents returning a generator with all the items.
*/
public async *listCIAppPipelineEventsWithPagination(
param: CIVisibilityPipelinesApiListCIAppPipelineEventsRequest = {},
options?: Configuration
): AsyncGenerator<CIAppPipelineEvent> {
let pageSize = 10;
if (param.pageLimit !== undefined) {
pageSize = param.pageLimit;
}
param.pageLimit = pageSize;
while (true) {
const requestContext = await this.requestFactory.listCIAppPipelineEvents(
param.filterQuery,
param.filterFrom,
param.filterTo,
param.sort,
param.pageCursor,
param.pageLimit,
options
);
const responseContext = await this.configuration.httpApi.send(
requestContext
);
const response = await this.responseProcessor.listCIAppPipelineEvents(
responseContext
);
const responseData = response.data;
if (responseData === undefined) {
break;
}
const results = responseData;
for (const item of results) {
yield item;
}
if (results.length < pageSize) {
break;
}
const cursorMeta = response.meta;
if (cursorMeta === undefined) {
break;
}
const cursorMetaPage = cursorMeta.page;
if (cursorMetaPage === undefined) {
break;
}
const cursorMetaPageAfter = cursorMetaPage.after;
if (cursorMetaPageAfter === undefined) {
break;
}
param.pageCursor = cursorMetaPageAfter;
}
}
/**
* List endpoint returns CI Visibility pipeline events that match a [search query](https://docs.datadoghq.com/continuous_integration/explorer/search_syntax/).
* [Results are paginated similarly to logs](https://docs.datadoghq.com/logs/guide/collect-multiple-logs-with-pagination).
*
* Use this endpoint to build complex events filtering and search.
* @param param The request object
*/
public searchCIAppPipelineEvents(
param: CIVisibilityPipelinesApiSearchCIAppPipelineEventsRequest = {},
options?: Configuration
): Promise<CIAppPipelineEventsResponse> {
const requestContextPromise = this.requestFactory.searchCIAppPipelineEvents(
param.body,
options
);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.searchCIAppPipelineEvents(
responseContext
);
});
});
}
/**
* Provide a paginated version of searchCIAppPipelineEvents returning a generator with all the items.
*/
public async *searchCIAppPipelineEventsWithPagination(
param: CIVisibilityPipelinesApiSearchCIAppPipelineEventsRequest = {},
options?: Configuration
): AsyncGenerator<CIAppPipelineEvent> {
let pageSize = 10;
if (param.body === undefined) {
param.body = new CIAppPipelineEventsRequest();
}
if (param.body.page === undefined) {
param.body.page = new CIAppQueryPageOptions();
}
if (param.body.page.limit !== undefined) {
pageSize = param.body.page.limit;
}
param.body.page.limit = pageSize;
while (true) {
const requestContext =
await this.requestFactory.searchCIAppPipelineEvents(
param.body,
options
);
const responseContext = await this.configuration.httpApi.send(
requestContext
);
const response = await this.responseProcessor.searchCIAppPipelineEvents(
responseContext
);
const responseData = response.data;
if (responseData === undefined) {
break;
}
const results = responseData;
for (const item of results) {
yield item;
}
if (results.length < pageSize) {
break;
}
const cursorMeta = response.meta;
if (cursorMeta === undefined) {
break;
}
const cursorMetaPage = cursorMeta.page;
if (cursorMetaPage === undefined) {
break;
}
const cursorMetaPageAfter = cursorMetaPage.after;
if (cursorMetaPageAfter === undefined) {
break;
}
param.body.page.cursor = cursorMetaPageAfter;
}
}
}