@@ -952,6 +952,72 @@ class EventNotificationsV1 extends BaseService {
952952 return this . createRequest ( parameters ) ;
953953 }
954954
955+ /**
956+ * List all predefined templates.
957+ *
958+ * List all predefined templates.
959+ *
960+ * @param {Object } params - The parameters to send to the service.
961+ * @param {string } params.instanceId - Unique identifier for IBM Cloud Event Notifications instance.
962+ * @param {string } params.source - Source type.
963+ * @param {string } params.type - Destination type.
964+ * @param {number } [params.limit] - Page limit for paginated results.
965+ * @param {number } [params.offset] - offset for paginated results.
966+ * @param {string } [params.search] - Search string for filtering results.
967+ * @param {OutgoingHttpHeaders } [params.headers] - Custom request headers
968+ * @returns {Promise<EventNotificationsV1.Response<EventNotificationsV1.PredefinedTemplatesList>> }
969+ */
970+ public listPreDefinedTemplates (
971+ params : EventNotificationsV1 . ListPreDefinedTemplatesParams
972+ ) : Promise < EventNotificationsV1 . Response < EventNotificationsV1 . PredefinedTemplatesList > > {
973+ const _params = { ...params } ;
974+ const _requiredParams = [ 'instanceId' , 'source' , 'type' ] ;
975+ const _validParams = [ 'instanceId' , 'source' , 'type' , 'limit' , 'offset' , 'search' , 'headers' ] ;
976+ const _validationErrors = validateParams ( _params , _requiredParams , _validParams ) ;
977+ if ( _validationErrors ) {
978+ return Promise . reject ( _validationErrors ) ;
979+ }
980+
981+ const query = {
982+ 'source' : _params . source ,
983+ 'type' : _params . type ,
984+ 'limit' : _params . limit ,
985+ 'offset' : _params . offset ,
986+ 'search' : _params . search ,
987+ } ;
988+
989+ const path = {
990+ 'instance_id' : _params . instanceId ,
991+ } ;
992+
993+ const sdkHeaders = getSdkHeaders (
994+ EventNotificationsV1 . DEFAULT_SERVICE_NAME ,
995+ 'v1' ,
996+ 'listPreDefinedTemplates'
997+ ) ;
998+
999+ const parameters = {
1000+ options : {
1001+ url : '/v1/instances/{instance_id}/pre_defined_templates' ,
1002+ method : 'GET' ,
1003+ qs : query ,
1004+ path,
1005+ } ,
1006+ defaultOptions : extend ( true , { } , this . baseOptions , {
1007+ headers : extend (
1008+ true ,
1009+ sdkHeaders ,
1010+ {
1011+ 'Accept' : 'application/json' ,
1012+ } ,
1013+ _params . headers
1014+ ) ,
1015+ } ) ,
1016+ } ;
1017+
1018+ return this . createRequest ( parameters ) ;
1019+ }
1020+
9551021 /**
9561022 * Get details of a Template.
9571023 *
@@ -1119,6 +1185,60 @@ class EventNotificationsV1 extends BaseService {
11191185
11201186 return this . createRequest ( parameters ) ;
11211187 }
1188+
1189+ /**
1190+ * Get details of a Predefined Template.
1191+ *
1192+ * Get details of a Predefined Template.
1193+ *
1194+ * @param {Object } params - The parameters to send to the service.
1195+ * @param {string } params.instanceId - Unique identifier for IBM Cloud Event Notifications instance.
1196+ * @param {string } params.id - Unique identifier for Template.
1197+ * @param {OutgoingHttpHeaders } [params.headers] - Custom request headers
1198+ * @returns {Promise<EventNotificationsV1.Response<EventNotificationsV1.GetPredefinedTemplate>> }
1199+ */
1200+ public getPreDefinedTemplate (
1201+ params : EventNotificationsV1 . GetPreDefinedTemplateParams
1202+ ) : Promise < EventNotificationsV1 . Response < EventNotificationsV1 . GetPredefinedTemplate > > {
1203+ const _params = { ...params } ;
1204+ const _requiredParams = [ 'instanceId' , 'id' ] ;
1205+ const _validParams = [ 'instanceId' , 'id' , 'headers' ] ;
1206+ const _validationErrors = validateParams ( _params , _requiredParams , _validParams ) ;
1207+ if ( _validationErrors ) {
1208+ return Promise . reject ( _validationErrors ) ;
1209+ }
1210+
1211+ const path = {
1212+ 'instance_id' : _params . instanceId ,
1213+ 'id' : _params . id ,
1214+ } ;
1215+
1216+ const sdkHeaders = getSdkHeaders (
1217+ EventNotificationsV1 . DEFAULT_SERVICE_NAME ,
1218+ 'v1' ,
1219+ 'getPreDefinedTemplate'
1220+ ) ;
1221+
1222+ const parameters = {
1223+ options : {
1224+ url : '/v1/instances/{instance_id}/pre_defined_templates/{id}' ,
1225+ method : 'GET' ,
1226+ path,
1227+ } ,
1228+ defaultOptions : extend ( true , { } , this . baseOptions , {
1229+ headers : extend (
1230+ true ,
1231+ sdkHeaders ,
1232+ {
1233+ 'Accept' : 'application/json' ,
1234+ } ,
1235+ _params . headers
1236+ ) ,
1237+ } ) ,
1238+ } ;
1239+
1240+ return this . createRequest ( parameters ) ;
1241+ }
11221242 /*************************
11231243 * destinations
11241244 ************************/
@@ -3382,6 +3502,23 @@ namespace EventNotificationsV1 {
33823502 headers ?: OutgoingHttpHeaders ;
33833503 }
33843504
3505+ /** Parameters for the `listPreDefinedTemplates` operation. */
3506+ export interface ListPreDefinedTemplatesParams {
3507+ /** Unique identifier for IBM Cloud Event Notifications instance. */
3508+ instanceId : string ;
3509+ /** Source type. */
3510+ source : string ;
3511+ /** Destination type. */
3512+ type : string ;
3513+ /** Page limit for paginated results. */
3514+ limit ?: number ;
3515+ /** offset for paginated results. */
3516+ offset ?: number ;
3517+ /** Search string for filtering results. */
3518+ search ?: string ;
3519+ headers ?: OutgoingHttpHeaders ;
3520+ }
3521+
33853522 /** Parameters for the `getTemplate` operation. */
33863523 export interface GetTemplateParams {
33873524 /** Unique identifier for IBM Cloud Event Notifications instance. */
@@ -3416,6 +3553,15 @@ namespace EventNotificationsV1 {
34163553 headers ?: OutgoingHttpHeaders ;
34173554 }
34183555
3556+ /** Parameters for the `getPreDefinedTemplate` operation. */
3557+ export interface GetPreDefinedTemplateParams {
3558+ /** Unique identifier for IBM Cloud Event Notifications instance. */
3559+ instanceId : string ;
3560+ /** Unique identifier for Template. */
3561+ id : string ;
3562+ headers ?: OutgoingHttpHeaders ;
3563+ }
3564+
34193565 /** Parameters for the `createDestination` operation. */
34203566 export interface CreateDestinationParams {
34213567 /** Unique identifier for IBM Cloud Event Notifications instance. */
@@ -4069,6 +4215,24 @@ namespace EventNotificationsV1 {
40694215 expression ?: string ;
40704216 }
40714217
4218+ /** Template object. */
4219+ export interface GetPredefinedTemplate {
4220+ /** Template ID. */
4221+ id : string ;
4222+ /** Template name. */
4223+ name : string ;
4224+ /** Template description. */
4225+ description : string ;
4226+ /** The type of template. */
4227+ type : string ;
4228+ /** The type of source. */
4229+ source ?: string ;
4230+ /** Updated at. */
4231+ updated_at : string ;
4232+ /** Payload describing a Predefined template configuration. */
4233+ params : PredefinedTemplateConfig ;
4234+ }
4235+
40724236 /** Payload describing histogram. */
40734237 export interface Histrogram {
40744238 /** List of buckets. */
@@ -4253,6 +4417,46 @@ namespace EventNotificationsV1 {
42534417 href : string ;
42544418 }
42554419
4420+ /** Predefined Template object. */
4421+ export interface PredefinedTemplate {
4422+ /** Template ID. */
4423+ id : string ;
4424+ /** Template name. */
4425+ name : string ;
4426+ /** Template description. */
4427+ description : string ;
4428+ /** The type of source. */
4429+ source : string ;
4430+ /** The type of template. */
4431+ type : string ;
4432+ /** Updated at. */
4433+ updated_at : string ;
4434+ }
4435+
4436+ /** Payload describing a Predefined template configuration. */
4437+ export interface PredefinedTemplateConfig {
4438+ /** Template body(Base64 encoded). */
4439+ body : string ;
4440+ }
4441+
4442+ /** Payload describing a pre-defined templates list request. */
4443+ export interface PredefinedTemplatesList {
4444+ /** Total number of pre-defined templates. */
4445+ total_count : number ;
4446+ /** Current offset. */
4447+ offset : number ;
4448+ /** limit to show templates. */
4449+ limit : number ;
4450+ /** List of pre-defined templates. */
4451+ templates : PredefinedTemplate [ ] ;
4452+ /** Response having URL of the page. */
4453+ first ?: PageHrefResponse ;
4454+ /** Response having URL of the page. */
4455+ previous ?: PageHrefResponse ;
4456+ /** Response having URL of the page. */
4457+ next ?: PageHrefResponse ;
4458+ }
4459+
42564460 /** Rule object. */
42574461 export interface Rules {
42584462 /** Whether the rule is enabled or not. */
@@ -5619,6 +5823,90 @@ namespace EventNotificationsV1 {
56195823 }
56205824 }
56215825
5826+ /**
5827+ * PreDefinedTemplatesPager can be used to simplify the use of listPreDefinedTemplates().
5828+ */
5829+ export class PreDefinedTemplatesPager {
5830+ protected _hasNext : boolean ;
5831+
5832+ protected pageContext : any ;
5833+
5834+ protected client : EventNotificationsV1 ;
5835+
5836+ protected params : EventNotificationsV1 . ListPreDefinedTemplatesParams ;
5837+
5838+ /**
5839+ * Construct a PreDefinedTemplatesPager object.
5840+ *
5841+ * @param {EventNotificationsV1 } client - The service client instance used to invoke listPreDefinedTemplates()
5842+ * @param {Object } params - The parameters to be passed to listPreDefinedTemplates()
5843+ * @constructor
5844+ * @returns {PreDefinedTemplatesPager }
5845+ */
5846+ constructor (
5847+ client : EventNotificationsV1 ,
5848+ params : EventNotificationsV1 . ListPreDefinedTemplatesParams
5849+ ) {
5850+ if ( params && params . offset ) {
5851+ throw new Error ( `the params.offset field should not be set` ) ;
5852+ }
5853+
5854+ this . _hasNext = true ;
5855+ this . pageContext = { next : undefined } ;
5856+ this . client = client ;
5857+ this . params = JSON . parse ( JSON . stringify ( params || { } ) ) ;
5858+ }
5859+
5860+ /**
5861+ * Returns true if there are potentially more results to be retrieved by invoking getNext().
5862+ * @returns {boolean }
5863+ */
5864+ public hasNext ( ) : boolean {
5865+ return this . _hasNext ;
5866+ }
5867+
5868+ /**
5869+ * Returns the next page of results by invoking listPreDefinedTemplates().
5870+ * @returns {Promise<EventNotificationsV1.PredefinedTemplate[]> }
5871+ */
5872+ public async getNext ( ) : Promise < EventNotificationsV1 . PredefinedTemplate [ ] > {
5873+ if ( ! this . hasNext ( ) ) {
5874+ throw new Error ( 'No more results available' ) ;
5875+ }
5876+
5877+ if ( this . pageContext . next ) {
5878+ this . params . offset = this . pageContext . next ;
5879+ }
5880+ const response = await this . client . listPreDefinedTemplates ( this . params ) ;
5881+ const { result } = response ;
5882+
5883+ let next = null ;
5884+ if ( result && result . next ) {
5885+ if ( result . next . href ) {
5886+ next = getQueryParam ( result . next . href , 'offset' ) ;
5887+ }
5888+ }
5889+ this . pageContext . next = next ;
5890+ if ( ! this . pageContext . next ) {
5891+ this . _hasNext = false ;
5892+ }
5893+ return result . templates ;
5894+ }
5895+
5896+ /**
5897+ * Returns all results by invoking listPreDefinedTemplates() repeatedly until all pages of results have been retrieved.
5898+ * @returns {Promise<EventNotificationsV1.PredefinedTemplate[]> }
5899+ */
5900+ public async getAll ( ) : Promise < EventNotificationsV1 . PredefinedTemplate [ ] > {
5901+ const results : PredefinedTemplate [ ] = [ ] ;
5902+ while ( this . hasNext ( ) ) {
5903+ const nextPage = await this . getNext ( ) ;
5904+ results . push ( ...nextPage ) ;
5905+ }
5906+ return results ;
5907+ }
5908+ }
5909+
56225910 /**
56235911 * DestinationsPager can be used to simplify the use of listDestinations().
56245912 */
0 commit comments