Skip to content

Commit 72a5974

Browse files
authored
fix: adds COS destination support
1 parent 081633c commit 72a5974

File tree

4 files changed

+167
-6
lines changed

4 files changed

+167
-6
lines changed

.secrets.baseline

Lines changed: 5 additions & 5 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": "2023-04-10T04:19:35Z",
6+
"generated_at": "2023-04-18T10:53:48Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -102,15 +102,15 @@
102102
"hashed_secret": "52ff58378da9dd5f3352434d0d26c680750acf56",
103103
"is_secret": false,
104104
"is_verified": false,
105-
"line_number": 648,
105+
"line_number": 649,
106106
"type": "Secret Keyword",
107107
"verified_result": null
108108
},
109109
{
110110
"hashed_secret": "d4c3d66fd0c38547a3c7a4c6bdc29c36911bc030",
111111
"is_secret": false,
112112
"is_verified": false,
113-
"line_number": 1115,
113+
"line_number": 1143,
114114
"type": "Secret Keyword",
115115
"verified_result": null
116116
}
@@ -120,15 +120,15 @@
120120
"hashed_secret": "0cc20f91828bed53ddb6294968b7f9abd631a3ba",
121121
"is_secret": false,
122122
"is_verified": false,
123-
"line_number": 1082,
123+
"line_number": 1112,
124124
"type": "Secret Keyword",
125125
"verified_result": null
126126
},
127127
{
128128
"hashed_secret": "d4c3d66fd0c38547a3c7a4c6bdc29c36911bc030",
129129
"is_secret": false,
130130
"is_verified": false,
131-
"line_number": 1132,
131+
"line_number": 1162,
132132
"type": "Secret Keyword",
133133
"verified_result": null
134134
}

event-notifications/v1.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2135,6 +2135,7 @@ namespace EventNotificationsV1 {
21352135
PUSH_SAFARI = 'push_safari',
21362136
MSTEAMS = 'msteams',
21372137
SERVICENOW = 'servicenow',
2138+
IBMCOS = 'ibmcos',
21382139
}
21392140
}
21402141

@@ -2375,7 +2376,9 @@ namespace EventNotificationsV1 {
23752376
name: string;
23762377
/** Destination description. */
23772378
description: string;
2378-
/** Destination type Email/SMS/Webhook/FCM/Slack/MSTeams/PagerDuty/IBMCloudFunctions/IBMCodeEngine/ServiceNow. */
2379+
/** Destination type
2380+
* Email/SMS/Webhook/FCM/Slack/MSTeams/PagerDuty/IBMCloudFunctions/IBMCodeEngine/ServiceNow/IBMCloudObjectStorage.
2381+
*/
23792382
type: string;
23802383
/** Payload describing a destination configuration. */
23812384
config?: DestinationConfig;
@@ -2971,6 +2974,17 @@ namespace EventNotificationsV1 {
29712974
api_key?: string;
29722975
}
29732976

2977+
/** Payload describing a Cloud Object Storage destination configuration. */
2978+
export interface DestinationConfigOneOfIBMCloudObjectStorageDestinationConfig
2979+
extends DestinationConfigOneOf {
2980+
/** Bucket Name for Cloud Object Storage. */
2981+
bucket_name: string;
2982+
/** Instance Id of Cloud Object Storage. */
2983+
instance_id: string;
2984+
/** End Point of Cloud Object Storage. */
2985+
endpoint: string;
2986+
}
2987+
29742988
/** Payload describing an iOS destination configuration. */
29752989
export interface DestinationConfigOneOfIOSDestinationConfig extends DestinationConfigOneOf {
29762990
/** Authentication type (p8 or p12). */

examples/event-notifications.v1.test.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ let destinationId10 = '';
6464
let destinationId11 = '';
6565
let destinationId12 = '';
6666
let destinationId13 = '';
67+
let destinationId14 = '';
6768
let subscriptionId = '';
6869
let subscriptionId1 = '';
6970
let subscriptionId2 = '';
@@ -834,6 +835,33 @@ describe('EventNotificationsV1', () => {
834835
} catch (err) {
835836
console.warn(err);
836837
}
838+
839+
const cosdestinationConfigModel = {
840+
params: {
841+
bucket_name: 'encosbucket',
842+
instance_id: 'e8a6b5a3-3ff4-xxxx-xxxx-ea86a4d4a3b6',
843+
endpoint: 'https://s3.us-west.cloud-object-storage.test.appdomain.cloud',
844+
},
845+
};
846+
847+
name = 'COS_destination';
848+
description = 'COS Destination';
849+
type = 'ibmcos';
850+
params = {
851+
instanceId,
852+
name,
853+
type,
854+
description,
855+
config: cosdestinationConfigModel,
856+
};
857+
858+
try {
859+
res = await eventNotificationsService.createDestination(params);
860+
console.log(JSON.stringify(res.result, null, 2));
861+
destinationId14 = res.result.id;
862+
} catch (err) {
863+
console.warn(err);
864+
}
837865
// end-create_destination
838866
});
839867

@@ -1258,6 +1286,31 @@ describe('EventNotificationsV1', () => {
12581286
config: destinationCEConfigModel,
12591287
};
12601288

1289+
try {
1290+
res = await eventNotificationsService.updateDestination(params);
1291+
console.log(JSON.stringify(res.result, null, 2));
1292+
} catch (err) {
1293+
console.warn(err);
1294+
}
1295+
1296+
const destinationConfigModelCOS = {
1297+
params: {
1298+
bucket_name: 'encosbucket',
1299+
instance_id: 'e8a6b5a3-xxxx-xxxx-ad88-ea86a4d4a3b6',
1300+
endpoint: 'https://s3.us-west.cloud-object-storage.test.appdomain.cloud',
1301+
},
1302+
};
1303+
1304+
name = 'COS_destination_update';
1305+
description = 'COS Destination_update';
1306+
params = {
1307+
instanceId,
1308+
id: destinationId14,
1309+
name,
1310+
description,
1311+
config: destinationConfigModelCOS,
1312+
};
1313+
12611314
try {
12621315
res = await eventNotificationsService.updateDestination(params);
12631316
console.log(JSON.stringify(res.result, null, 2));
@@ -1832,6 +1885,7 @@ describe('EventNotificationsV1', () => {
18321885
destinationId11,
18331886
destinationId12,
18341887
destinationId13,
1888+
destinationId14,
18351889
];
18361890

18371891
for (let i = 0; i < destinations.length; i += 1) {

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

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ let destinationId10 = '';
5151
let destinationId11 = '';
5252
let destinationId12 = '';
5353
let destinationId13 = '';
54+
let destinationId14 = '';
5455

5556
let subscriptionId = '';
5657
let subscriptionId1 = '';
@@ -66,6 +67,7 @@ let subscriptionId10 = '';
6667
let subscriptionId11 = '';
6768
let subscriptionId12 = '';
6869
let subscriptionId13 = '';
70+
let subscriptionId14 = '';
6971
let fcmServerKey = '';
7072
let fcmSenderId = '';
7173
let safariCertificatePath = '';
@@ -821,6 +823,34 @@ describe('EventNotificationsV1_integration', () => {
821823
expect(ceRes.result.description).toBe(description);
822824
destinationId13 = ceRes.result.id;
823825

826+
const cosdestinationConfigModel = {
827+
params: {
828+
bucket_name: 'cloud-object-storage-cos-standard-gxi',
829+
instance_id: 'ee55ab3b-b8ef-41e3-af59-2e1291740fea',
830+
endpoint: 'https://s3.us-east.cloud-object-storage.appdomain.cloud',
831+
},
832+
};
833+
name = 'COS_destination';
834+
description = 'COS Destination';
835+
type = 'ibmcos';
836+
params = {
837+
instanceId,
838+
name,
839+
type,
840+
description,
841+
config: cosdestinationConfigModel,
842+
};
843+
844+
const cosRes = await eventNotificationsService.createDestination(params);
845+
expect(cosRes).toBeDefined();
846+
expect(cosRes.status).toBe(201);
847+
expect(cosRes.result).toBeDefined();
848+
849+
expect(cosRes.result.type).toBe(type);
850+
expect(cosRes.result.name).toBe(name);
851+
expect(cosRes.result.description).toBe(description);
852+
destinationId14 = cosRes.result.id;
853+
824854
//
825855
// The following status codes aren't covered by tests.
826856
// Please provide integration tests for these too.
@@ -1236,6 +1266,32 @@ describe('EventNotificationsV1_integration', () => {
12361266
expect(ceRes.result.name).toBe(name);
12371267
expect(ceRes.result.description).toBe(description);
12381268

1269+
const destinationConfigModelCOS = {
1270+
params: {
1271+
bucket_name: 'cloud-object-storage-cos-standard-gxi',
1272+
instance_id: 'ee55ab3b-b8ef-41e3-af59-2e1291740fea',
1273+
endpoint: 'https://s3.us-east.cloud-object-storage.appdomain.cloud',
1274+
},
1275+
};
1276+
1277+
name = 'COS_destination_update';
1278+
description = 'COS Destination_update';
1279+
1280+
params = {
1281+
instanceId,
1282+
id: destinationId14,
1283+
name,
1284+
description,
1285+
config: destinationConfigModelCOS,
1286+
};
1287+
1288+
const cosRes = await eventNotificationsService.updateDestination(params);
1289+
expect(cosRes).toBeDefined();
1290+
expect(cosRes.status).toBe(200);
1291+
expect(cosRes.result).toBeDefined();
1292+
expect(cosRes.result.name).toBe(name);
1293+
expect(cosRes.result.description).toBe(description);
1294+
12391295
//
12401296
// The following status codes aren't covered by tests.
12411297
// Please provide integration tests for these too.
@@ -1550,6 +1606,24 @@ describe('EventNotificationsV1_integration', () => {
15501606
expect(ceRes.result.name).toBe(name);
15511607
expect(ceRes.result.description).toBe(description);
15521608
subscriptionId13 = ceRes.result.id;
1609+
1610+
name = 'COS subscription';
1611+
description = 'Subscription for the COS destination';
1612+
params = {
1613+
instanceId,
1614+
name,
1615+
destinationId: destinationId14,
1616+
topicId,
1617+
description,
1618+
};
1619+
1620+
const cosRes = await eventNotificationsService.createSubscription(params);
1621+
expect(cosRes).toBeDefined();
1622+
expect(cosRes.status).toBe(201);
1623+
expect(cosRes.result).toBeDefined();
1624+
expect(cosRes.result.name).toBe(name);
1625+
expect(cosRes.result.description).toBe(description);
1626+
subscriptionId14 = cosRes.result.id;
15531627
//
15541628
// The following status codes aren't covered by tests.
15551629
// Please provide integration tests for these too.
@@ -1904,6 +1978,23 @@ describe('EventNotificationsV1_integration', () => {
19041978
expect(ceRes.result).toBeDefined();
19051979
expect(ceRes.result.name).toBe(name);
19061980
expect(ceRes.result.description).toBe(description);
1981+
1982+
name = 'COS Subscription update';
1983+
description = 'Subscription for the COS destination update';
1984+
params = {
1985+
instanceId,
1986+
name,
1987+
id: subscriptionId14,
1988+
description,
1989+
};
1990+
1991+
const cosRes = await eventNotificationsService.updateSubscription(params);
1992+
expect(cosRes).toBeDefined();
1993+
expect(cosRes.status).toBe(200);
1994+
expect(cosRes.result).toBeDefined();
1995+
expect(cosRes.result.name).toBe(name);
1996+
expect(cosRes.result.description).toBe(description);
1997+
19071998
// The following status codes aren't covered by tests.
19081999
// Please provide integration tests for these too.
19092000
//
@@ -2185,6 +2276,7 @@ describe('EventNotificationsV1_integration', () => {
21852276
subscriptionId11,
21862277
subscriptionId12,
21872278
subscriptionId13,
2279+
subscriptionId14,
21882280
];
21892281

21902282
for (let i = 0; i < subscriptions.length; i += 1) {
@@ -2262,6 +2354,7 @@ describe('EventNotificationsV1_integration', () => {
22622354
destinationId11,
22632355
destinationId12,
22642356
destinationId13,
2357+
destinationId14,
22652358
];
22662359

22672360
for (let i = 0; i < destinations.length; i += 1) {

0 commit comments

Comments
 (0)