Skip to content

Commit 76ba1e7

Browse files
committed
feat: support for code engine templates
Signed-off-by: nitish <[email protected]>
1 parent e91f80e commit 76ba1e7

File tree

4 files changed

+204
-14
lines changed

4 files changed

+204
-14
lines changed

.secrets.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "package-lock.json|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-07-23T12:55:03Z",
6+
"generated_at": "2025-07-31T11:23:27Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -144,15 +144,15 @@
144144
"hashed_secret": "0cc20f91828bed53ddb6294968b7f9abd631a3ba",
145145
"is_secret": false,
146146
"is_verified": false,
147-
"line_number": 1453,
147+
"line_number": 1509,
148148
"type": "Secret Keyword",
149149
"verified_result": null
150150
},
151151
{
152152
"hashed_secret": "3235b7f8d626cde63611d2e9ec43473f4e844c67",
153153
"is_secret": false,
154154
"is_verified": false,
155-
"line_number": 3043,
155+
"line_number": 3149,
156156
"type": "Base64 High Entropy String",
157157
"verified_result": null
158158
}

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,29 @@ try {
687687
```
688688
For EventStreams template supported template type value: event_streams.notification
689689

690+
#### CodeEngine Template
691+
```js
692+
const templateConfigModel = {
693+
body: <template-body>,
694+
};
695+
let createTemplateParams = {
696+
instanceId: <instance-id>,
697+
name: <template-name>,
698+
type: <template-type>,
699+
templateConfigModel,
700+
description: <template-description>,
701+
};
702+
703+
let createTemplateResult;
704+
try {
705+
createTemplateResult = await eventNotificationsService.createTemplate(createTemplateParams);
706+
console.log(JSON.stringify(createTemplateResult.result, null, 2));
707+
} catch (err) {
708+
console.warn(err);
709+
}
710+
```
711+
For CodeEngine template supported template type value: ibmceapp.notification and ibmcejob.notification
712+
690713
### List Templates
691714
```js
692715
const params = {
@@ -868,6 +891,29 @@ try {
868891
```
869892
For Event Streams template supported template type value: event_streams.notification
870893

894+
#### Update CodeEngine Template
895+
```js
896+
const templateConfigModel = {
897+
params: {
898+
body: <template-body>,
899+
},
900+
};
901+
let replaceTemplateParams = {
902+
instanceId: <instance-id>,
903+
name: <template-name>,
904+
type: <template-type>,
905+
templateConfigModel,
906+
description: <template-description>,s
907+
};
908+
let replaceTemplateResult;
909+
try {
910+
replaceTemplateResult = await eventNotificationsService.replaceTemplate(replaceTemplateParams);
911+
} catch (err) {
912+
console.warn(err);
913+
}
914+
```
915+
For Code Engine template supported template type value: ibmceapp.notification and ibmcejob.notification
916+
871917
### Delete Template
872918
```js
873919
const params = {
@@ -1517,6 +1563,8 @@ Find [event_notifications_v1.env.hide](https://github.com/IBM/event-notification
15171563
- `EVENT_NOTIFICATIONS_EVENT_STREAMS_CRN` - Event Streams instance CRN
15181564
- `EVENT_NOTIFICATIONS_EVENT_STREAMS_TOPIC` - Event Streams instance Topic name
15191565
- `EVENT_NOTIFICATIONS_EVENT_STREAMS_ENDPOINT` - Event streams end point
1566+
- `EVENT_NOTIFICATIONS_CODE_ENGINE_APP_TEMPLATE_BODY` - base 64 encoded json body for Code Engine Application
1567+
- `EVENT_NOTIFICATIONS_CODE_ENGINE_JOB_TEMPLATE_BODY` - base 64 encoded json body for Code Engine Job
15201568
15211569
## Questions
15221570

event-notifications/v1.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5214,6 +5214,13 @@ namespace EventNotificationsV1 {
52145214
sensitive_headers?: string[];
52155215
}
52165216

5217+
/** The attributes for a Code Engine response. */
5218+
export interface SubscriptionAttributesCodeEngineAttributesResponse
5219+
extends SubscriptionAttributes {
5220+
/** Code Engine template id. */
5221+
template_id_notification?: string;
5222+
}
5223+
52175224
/** The attributes reponse for an email destination. */
52185225
export interface SubscriptionAttributesCustomEmailAttributesResponse
52195226
extends SubscriptionAttributes {
@@ -5326,6 +5333,13 @@ namespace EventNotificationsV1 {
53265333
add_notification_payload: boolean;
53275334
}
53285335

5336+
/** The attributes for a Code Engine subscription. */
5337+
export interface SubscriptionCreateAttributesCodeEngineAttributes
5338+
extends SubscriptionCreateAttributes {
5339+
/** code engine template id. */
5340+
template_id_notification?: string;
5341+
}
5342+
53295343
/** The attributes for an email notification. */
53305344
export interface SubscriptionCreateAttributesCustomEmailAttributes
53315345
extends SubscriptionCreateAttributes {
@@ -5428,6 +5442,13 @@ namespace EventNotificationsV1 {
54285442
template_id_notification?: string;
54295443
}
54305444

5445+
/** The attributes for a Code Engine subscription. */
5446+
export interface SubscriptionUpdateAttributesCodeEngineAttributes
5447+
extends SubscriptionUpdateAttributes {
5448+
/** code engine template id. */
5449+
template_id_notification?: string;
5450+
}
5451+
54315452
/** The attributes for an email notification. */
54325453
export interface SubscriptionUpdateAttributesCustomEmailUpdateAttributes
54335454
extends SubscriptionUpdateAttributes {
@@ -5544,6 +5565,19 @@ namespace EventNotificationsV1 {
55445565
template_id_notification?: string;
55455566
}
55465567

5568+
/** Payload describing a code engine application template configuration. */
5569+
export interface TemplateConfigOneOfCodeEngineApplicationTemplateConfig
5570+
extends TemplateConfigOneOf {
5571+
/** Template body(Base64 encoded). */
5572+
body: string;
5573+
}
5574+
5575+
/** Payload describing a code engine Job template configuration. */
5576+
export interface TemplateConfigOneOfCodeEngineJobTemplateConfig extends TemplateConfigOneOf {
5577+
/** Template body(Base64 encoded). */
5578+
body: string;
5579+
}
5580+
55475581
/** Payload describing an email template configuration. */
55485582
export interface TemplateConfigOneOfEmailTemplateConfig extends TemplateConfigOneOf {
55495583
/** Template body(Base64 encoded). */

test/integration/event-notifications.v1.test.js

Lines changed: 119 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ let eventStreamsTemplateBody = '';
119119
let eventStreamsCRN = '';
120120
let eventStreamsTopic = '';
121121
let eventStreamsEndPoint = '';
122+
let codeEngineApplicationTemplateID = '';
123+
let codeEngineJobTemplateID = '';
124+
let codeEngineAppTemplateBody = '';
125+
let codeEngineJobTemplateBody = '';
122126

123127
describe('EventNotificationsV1_integration', () => {
124128
jest.setTimeout(timeout);
@@ -165,6 +169,8 @@ describe('EventNotificationsV1_integration', () => {
165169
eventStreamsCRN = config.eventStreamsCrn;
166170
eventStreamsTopic = config.eventStreamsTopic;
167171
eventStreamsEndPoint = config.eventStreamsEndpoint;
172+
codeEngineAppTemplateBody = config.codeEngineAppTemplateBody;
173+
codeEngineJobTemplateBody = config.codeEngineJobTemplateBody;
168174

169175
eventNotificationsService.enableRetries();
170176
});
@@ -1243,6 +1249,56 @@ describe('EventNotificationsV1_integration', () => {
12431249
expect(createTemplateResult.result.name).toBe(name);
12441250
expect(createTemplateResult.result.description).toBe(description);
12451251
eventStreamsTemplateID = createTemplateResult.result.id;
1252+
1253+
const codeEngineAppTemplateConfigModel = {
1254+
body: codeEngineAppTemplateBody,
1255+
};
1256+
1257+
name = 'codeengine app template name';
1258+
description = 'codeengine app template description';
1259+
type = 'ibmceapp.notification';
1260+
createTemplateParams = {
1261+
instanceId,
1262+
name,
1263+
type,
1264+
params: codeEngineAppTemplateConfigModel,
1265+
description,
1266+
};
1267+
1268+
createTemplateResult = await eventNotificationsService.createTemplate(createTemplateParams);
1269+
expect(createTemplateResult).toBeDefined();
1270+
expect(createTemplateResult.status).toBe(201);
1271+
expect(createTemplateResult.result).toBeDefined();
1272+
1273+
expect(createTemplateResult.result.type).toBe(type);
1274+
expect(createTemplateResult.result.name).toBe(name);
1275+
expect(createTemplateResult.result.description).toBe(description);
1276+
codeEngineApplicationTemplateID = createTemplateResult.result.id;
1277+
1278+
const codeEngineJobTemplateConfigModel = {
1279+
body: codeEngineJobTemplateBody,
1280+
};
1281+
1282+
name = 'codeengine job template name';
1283+
description = 'codeengine job template description';
1284+
type = 'ibmcejob.notification';
1285+
createTemplateParams = {
1286+
instanceId,
1287+
name,
1288+
type,
1289+
params: codeEngineJobTemplateConfigModel,
1290+
description,
1291+
};
1292+
1293+
createTemplateResult = await eventNotificationsService.createTemplate(createTemplateParams);
1294+
expect(createTemplateResult).toBeDefined();
1295+
expect(createTemplateResult.status).toBe(201);
1296+
expect(createTemplateResult.result).toBeDefined();
1297+
1298+
expect(createTemplateResult.result.type).toBe(type);
1299+
expect(createTemplateResult.result.name).toBe(name);
1300+
expect(createTemplateResult.result.description).toBe(description);
1301+
codeEngineJobTemplateID = createTemplateResult.result.id;
12461302
});
12471303

12481304
test('listDestinations()', async () => {
@@ -1915,6 +1971,31 @@ describe('EventNotificationsV1_integration', () => {
19151971
expect(replaceTemplateResult.result.name).toBe(name);
19161972
expect(replaceTemplateResult.result.description).toBe(description);
19171973

1974+
const eventStreamsTemplateConfigModel = {
1975+
body: eventStreamsTemplateBody,
1976+
};
1977+
1978+
name = 'eventstreams template name update';
1979+
description = 'eventstreams template description update';
1980+
type = 'event_streams.notification';
1981+
replaceTemplateParams = {
1982+
instanceId,
1983+
id: eventStreamsTemplateID,
1984+
name,
1985+
type,
1986+
params: eventStreamsTemplateConfigModel,
1987+
description,
1988+
};
1989+
1990+
replaceTemplateResult = await eventNotificationsService.replaceTemplate(replaceTemplateParams);
1991+
expect(replaceTemplateResult).toBeDefined();
1992+
expect(replaceTemplateResult.status).toBe(200);
1993+
expect(replaceTemplateResult.result).toBeDefined();
1994+
1995+
expect(replaceTemplateResult.result.type).toBe(type);
1996+
expect(replaceTemplateResult.result.name).toBe(name);
1997+
expect(replaceTemplateResult.result.description).toBe(description);
1998+
19181999
const pagerdutyTemplateConfigModel = {
19192000
body: pagerdutyTemplateBody,
19202001
};
@@ -1940,19 +2021,44 @@ describe('EventNotificationsV1_integration', () => {
19402021
expect(replaceTemplateResult.result.name).toBe(name);
19412022
expect(replaceTemplateResult.result.description).toBe(description);
19422023

1943-
const eventStreamsTemplateConfigModel = {
1944-
body: eventStreamsTemplateBody,
2024+
const codeEngineAppTemplateConfigModel = {
2025+
body: codeEngineAppTemplateBody,
19452026
};
19462027

1947-
name = 'eventstreams template name update';
1948-
description = 'eventstreams template description update';
1949-
type = 'event_streams.notification';
2028+
name = 'codeengine app template name update';
2029+
description = 'codeengine app template description update';
2030+
type = 'ibmceapp.notification';
19502031
replaceTemplateParams = {
19512032
instanceId,
1952-
id: eventStreamsTemplateID,
2033+
id: codeEngineApplicationTemplateID,
19532034
name,
19542035
type,
1955-
params: eventStreamsTemplateConfigModel,
2036+
params: codeEngineAppTemplateConfigModel,
2037+
description,
2038+
};
2039+
2040+
replaceTemplateResult = await eventNotificationsService.replaceTemplate(replaceTemplateParams);
2041+
expect(replaceTemplateResult).toBeDefined();
2042+
expect(replaceTemplateResult.status).toBe(200);
2043+
expect(replaceTemplateResult.result).toBeDefined();
2044+
2045+
expect(replaceTemplateResult.result.type).toBe(type);
2046+
expect(replaceTemplateResult.result.name).toBe(name);
2047+
expect(replaceTemplateResult.result.description).toBe(description);
2048+
2049+
const codeEngineJobTemplateConfigModel = {
2050+
body: codeEngineJobTemplateBody,
2051+
};
2052+
2053+
name = 'codeengine job template name update';
2054+
description = 'codeengine job template description update';
2055+
type = 'ibmcejob.notification';
2056+
replaceTemplateParams = {
2057+
instanceId,
2058+
id: codeEngineJobTemplateID,
2059+
name,
2060+
type,
2061+
params: codeEngineJobTemplateConfigModel,
19562062
description,
19572063
};
19582064

@@ -2213,7 +2319,7 @@ describe('EventNotificationsV1_integration', () => {
22132319

22142320
// code engine
22152321
const subscriptionCECreateAttributesModel = {
2216-
signing_enabled: false,
2322+
template_id_notification: codeEngineApplicationTemplateID,
22172323
};
22182324

22192325
name = 'subscription_code_engine';
@@ -2326,7 +2432,7 @@ describe('EventNotificationsV1_integration', () => {
23262432

23272433
// code engine
23282434
const subscriptionCEJobCreateAttributesModel = {
2329-
signing_enabled: false,
2435+
template_id_notification: codeEngineJobTemplateID,
23302436
};
23312437

23322438
name = 'subscription_code_engine_job';
@@ -2728,7 +2834,7 @@ describe('EventNotificationsV1_integration', () => {
27282834
expect(fcmRes.result.description).toBe(description);
27292835

27302836
const subscriptionCEUpdateAttributesModel = {
2731-
signing_enabled: true,
2837+
template_id_notification: codeEngineApplicationTemplateID,
27322838
};
27332839

27342840
name = 'code_engine_sub_updated';
@@ -2850,7 +2956,7 @@ describe('EventNotificationsV1_integration', () => {
28502956
expect(resCustomSMS.result.description).toBe(descriptionCustomSMS);
28512957

28522958
const subscriptionCEJobUpdateAttributesModel = {
2853-
signing_enabled: true,
2959+
template_id_notification: codeEngineJobTemplateID,
28542960
};
28552961

28562962
name = 'code_engine_job_sub_updated';
@@ -3546,6 +3652,8 @@ describe('EventNotificationsV1_integration', () => {
35463652
webhookTemplateID,
35473653
pagerdutyTemplateID,
35483654
eventStreamsTemplateID,
3655+
codeEngineApplicationTemplateID,
3656+
codeEngineJobTemplateID,
35493657
];
35503658

35513659
for (let i = 0; i < templates.length; i += 1) {

0 commit comments

Comments
 (0)