@@ -19,6 +19,7 @@ import { ApiException } from "../../datadog-api-client-common/exception";
19
19
import { APIErrorResponse } from "../models/APIErrorResponse" ;
20
20
import { DowntimeCreateRequest } from "../models/DowntimeCreateRequest" ;
21
21
import { DowntimeResponse } from "../models/DowntimeResponse" ;
22
+ import { DowntimeResponseData } from "../models/DowntimeResponseData" ;
22
23
import { DowntimeUpdateRequest } from "../models/DowntimeUpdateRequest" ;
23
24
import { ListDowntimesResponse } from "../models/ListDowntimesResponse" ;
24
25
import { MonitorDowntimeMatchResponse } from "../models/MonitorDowntimeMatchResponse" ;
@@ -161,6 +162,8 @@ export class DowntimesApiRequestFactory extends BaseAPIRequestFactory {
161
162
public async listDowntimes (
162
163
currentOnly ?: boolean ,
163
164
include ?: string ,
165
+ pageOffset ?: number ,
166
+ pageLimit ?: number ,
164
167
_options ?: Configuration
165
168
) : Promise < RequestContext > {
166
169
const _config = _options || this . configuration ;
@@ -193,6 +196,18 @@ export class DowntimesApiRequestFactory extends BaseAPIRequestFactory {
193
196
ObjectSerializer . serialize ( include , "string" , "" )
194
197
) ;
195
198
}
199
+ if ( pageOffset !== undefined ) {
200
+ requestContext . setQueryParam (
201
+ "page[offset]" ,
202
+ ObjectSerializer . serialize ( pageOffset , "number" , "int64" )
203
+ ) ;
204
+ }
205
+ if ( pageLimit !== undefined ) {
206
+ requestContext . setQueryParam (
207
+ "page[limit]" ,
208
+ ObjectSerializer . serialize ( pageLimit , "number" , "int64" )
209
+ ) ;
210
+ }
196
211
197
212
// Apply auth methods
198
213
applySecurityAuthentication ( _config , requestContext , [
@@ -705,6 +720,16 @@ export interface DowntimesApiListDowntimesRequest {
705
720
* @type string
706
721
*/
707
722
include ?: string ;
723
+ /**
724
+ * Specific offset to use as the beginning of the returned page.
725
+ * @type number
726
+ */
727
+ pageOffset ?: number ;
728
+ /**
729
+ * Maximum number of downtimes in the response.
730
+ * @type number
731
+ */
732
+ pageLimit ?: number ;
708
733
}
709
734
710
735
export interface DowntimesApiListMonitorDowntimesRequest {
@@ -820,6 +845,8 @@ export class DowntimesApi {
820
845
const requestContextPromise = this . requestFactory . listDowntimes (
821
846
param . currentOnly ,
822
847
param . include ,
848
+ param . pageOffset ,
849
+ param . pageLimit ,
823
850
options
824
851
) ;
825
852
return requestContextPromise . then ( ( requestContext ) => {
@@ -831,6 +858,52 @@ export class DowntimesApi {
831
858
} ) ;
832
859
}
833
860
861
+ /**
862
+ * Provide a paginated version of listDowntimes returning a generator with all the items.
863
+ */
864
+ public async * listDowntimesWithPagination (
865
+ param : DowntimesApiListDowntimesRequest = { } ,
866
+ options ?: Configuration
867
+ ) : AsyncGenerator < DowntimeResponseData > {
868
+ let pageSize = 30 ;
869
+ if ( param . pageLimit !== undefined ) {
870
+ pageSize = param . pageLimit ;
871
+ }
872
+ param . pageLimit = pageSize ;
873
+ while ( true ) {
874
+ const requestContext = await this . requestFactory . listDowntimes (
875
+ param . currentOnly ,
876
+ param . include ,
877
+ param . pageOffset ,
878
+ param . pageLimit ,
879
+ options
880
+ ) ;
881
+ const responseContext = await this . configuration . httpApi . send (
882
+ requestContext
883
+ ) ;
884
+
885
+ const response = await this . responseProcessor . listDowntimes (
886
+ responseContext
887
+ ) ;
888
+ const responseData = response . data ;
889
+ if ( responseData === undefined ) {
890
+ break ;
891
+ }
892
+ const results = responseData ;
893
+ for ( const item of results ) {
894
+ yield item ;
895
+ }
896
+ if ( results . length < pageSize ) {
897
+ break ;
898
+ }
899
+ if ( param . pageOffset === undefined ) {
900
+ param . pageOffset = pageSize ;
901
+ } else {
902
+ param . pageOffset = param . pageOffset + pageSize ;
903
+ }
904
+ }
905
+ }
906
+
834
907
/**
835
908
* Get all active downtimes for the specified monitor.
836
909
* @param param The request object
0 commit comments