@@ -23,6 +23,7 @@ import { DowntimeResponseData } from "../models/DowntimeResponseData";
23
23
import { DowntimeUpdateRequest } from "../models/DowntimeUpdateRequest" ;
24
24
import { ListDowntimesResponse } from "../models/ListDowntimesResponse" ;
25
25
import { MonitorDowntimeMatchResponse } from "../models/MonitorDowntimeMatchResponse" ;
26
+ import { MonitorDowntimeMatchResponseData } from "../models/MonitorDowntimeMatchResponseData" ;
26
27
27
28
export class DowntimesApiRequestFactory extends BaseAPIRequestFactory {
28
29
public async cancelDowntime (
@@ -201,6 +202,8 @@ export class DowntimesApiRequestFactory extends BaseAPIRequestFactory {
201
202
202
203
public async listMonitorDowntimes (
203
204
monitorId : number ,
205
+ pageOffset ?: number ,
206
+ pageLimit ?: number ,
204
207
_options ?: Configuration
205
208
) : Promise < RequestContext > {
206
209
const _config = _options || this . configuration ;
@@ -224,6 +227,20 @@ export class DowntimesApiRequestFactory extends BaseAPIRequestFactory {
224
227
requestContext . setHeaderParam ( "Accept" , "application/json" ) ;
225
228
requestContext . setHttpConfig ( _config . httpConfig ) ;
226
229
230
+ // Query Params
231
+ if ( pageOffset !== undefined ) {
232
+ requestContext . setQueryParam (
233
+ "page[offset]" ,
234
+ ObjectSerializer . serialize ( pageOffset , "number" , "int64" )
235
+ ) ;
236
+ }
237
+ if ( pageLimit !== undefined ) {
238
+ requestContext . setQueryParam (
239
+ "page[limit]" ,
240
+ ObjectSerializer . serialize ( pageLimit , "number" , "int64" )
241
+ ) ;
242
+ }
243
+
227
244
// Apply auth methods
228
245
applySecurityAuthentication ( _config , requestContext , [
229
246
"AuthZ" ,
@@ -708,6 +725,16 @@ export interface DowntimesApiListMonitorDowntimesRequest {
708
725
* @type number
709
726
*/
710
727
monitorId : number ;
728
+ /**
729
+ * Specific offset to use as the beginning of the returned page.
730
+ * @type number
731
+ */
732
+ pageOffset ?: number ;
733
+ /**
734
+ * Maximum number of downtimes in the response.
735
+ * @type number
736
+ */
737
+ pageLimit ?: number ;
711
738
}
712
739
713
740
export interface DowntimesApiUpdateDowntimeRequest {
@@ -884,6 +911,8 @@ export class DowntimesApi {
884
911
) : Promise < MonitorDowntimeMatchResponse > {
885
912
const requestContextPromise = this . requestFactory . listMonitorDowntimes (
886
913
param . monitorId ,
914
+ param . pageOffset ,
915
+ param . pageLimit ,
887
916
options
888
917
) ;
889
918
return requestContextPromise . then ( ( requestContext ) => {
@@ -895,6 +924,51 @@ export class DowntimesApi {
895
924
} ) ;
896
925
}
897
926
927
+ /**
928
+ * Provide a paginated version of listMonitorDowntimes returning a generator with all the items.
929
+ */
930
+ public async * listMonitorDowntimesWithPagination (
931
+ param : DowntimesApiListMonitorDowntimesRequest ,
932
+ options ?: Configuration
933
+ ) : AsyncGenerator < MonitorDowntimeMatchResponseData > {
934
+ let pageSize = 30 ;
935
+ if ( param . pageLimit !== undefined ) {
936
+ pageSize = param . pageLimit ;
937
+ }
938
+ param . pageLimit = pageSize ;
939
+ while ( true ) {
940
+ const requestContext = await this . requestFactory . listMonitorDowntimes (
941
+ param . monitorId ,
942
+ param . pageOffset ,
943
+ param . pageLimit ,
944
+ options
945
+ ) ;
946
+ const responseContext = await this . configuration . httpApi . send (
947
+ requestContext
948
+ ) ;
949
+
950
+ const response = await this . responseProcessor . listMonitorDowntimes (
951
+ responseContext
952
+ ) ;
953
+ const responseData = response . data ;
954
+ if ( responseData === undefined ) {
955
+ break ;
956
+ }
957
+ const results = responseData ;
958
+ for ( const item of results ) {
959
+ yield item ;
960
+ }
961
+ if ( results . length < pageSize ) {
962
+ break ;
963
+ }
964
+ if ( param . pageOffset === undefined ) {
965
+ param . pageOffset = pageSize ;
966
+ } else {
967
+ param . pageOffset = param . pageOffset + pageSize ;
968
+ }
969
+ }
970
+ }
971
+
898
972
/**
899
973
* Update a downtime by `downtime_id`.
900
974
* @param param The request object
0 commit comments