|
2 | 2 | * @jest-environment node
|
3 | 3 | */
|
4 | 4 | /**
|
5 |
| - * (C) Copyright IBM Corp. 2023. |
| 5 | + * (C) Copyright IBM Corp. 2024. |
6 | 6 | *
|
7 | 7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
8 | 8 | * you may not use this file except in compliance with the License.
|
@@ -1179,6 +1179,138 @@ describe('CodeEngineV2', () => {
|
1179 | 1179 | // end-replace_secret
|
1180 | 1180 | });
|
1181 | 1181 |
|
| 1182 | + test('listDomainMappings request example', async () => { |
| 1183 | + consoleLogMock.mockImplementation((output) => { |
| 1184 | + originalLog(output); |
| 1185 | + }); |
| 1186 | + consoleWarnMock.mockImplementation((output) => { |
| 1187 | + // if an error occurs, display the message and then fail the test |
| 1188 | + originalWarn(output); |
| 1189 | + expect(true).toBeFalsy(); |
| 1190 | + }); |
| 1191 | + |
| 1192 | + originalLog('listDomainMappings() result:'); |
| 1193 | + // begin-list_domain_mappings |
| 1194 | + |
| 1195 | + const params = { |
| 1196 | + projectId: '15314cc3-85b4-4338-903f-c28cdee6d005', |
| 1197 | + limit: 100, |
| 1198 | + }; |
| 1199 | + |
| 1200 | + const allResults = []; |
| 1201 | + try { |
| 1202 | + const pager = new CodeEngineV2.DomainMappingsPager(codeEngineService, params); |
| 1203 | + while (pager.hasNext()) { |
| 1204 | + const nextPage = await pager.getNext(); |
| 1205 | + expect(nextPage).not.toBeNull(); |
| 1206 | + allResults.push(...nextPage); |
| 1207 | + } |
| 1208 | + console.log(JSON.stringify(allResults, null, 2)); |
| 1209 | + } catch (err) { |
| 1210 | + console.warn(err); |
| 1211 | + } |
| 1212 | + |
| 1213 | + // end-list_domain_mappings |
| 1214 | + }); |
| 1215 | + |
| 1216 | + test('createDomainMapping request example', async () => { |
| 1217 | + consoleLogMock.mockImplementation((output) => { |
| 1218 | + originalLog(output); |
| 1219 | + }); |
| 1220 | + consoleWarnMock.mockImplementation((output) => { |
| 1221 | + // if an error occurs, display the message and then fail the test |
| 1222 | + originalWarn(output); |
| 1223 | + expect(true).toBeFalsy(); |
| 1224 | + }); |
| 1225 | + |
| 1226 | + originalLog('createDomainMapping() result:'); |
| 1227 | + // begin-create_domain_mapping |
| 1228 | + |
| 1229 | + // Request models needed by this operation. |
| 1230 | + |
| 1231 | + // ComponentRef |
| 1232 | + const componentRefModel = { |
| 1233 | + name: 'my-app-1', |
| 1234 | + resource_type: 'app_v2', |
| 1235 | + }; |
| 1236 | + |
| 1237 | + const params = { |
| 1238 | + projectId: '15314cc3-85b4-4338-903f-c28cdee6d005', |
| 1239 | + component: componentRefModel, |
| 1240 | + name: 'www.example.com', |
| 1241 | + tlsSecret: 'my-tls-secret', |
| 1242 | + }; |
| 1243 | + |
| 1244 | + let res; |
| 1245 | + try { |
| 1246 | + res = await codeEngineService.createDomainMapping(params); |
| 1247 | + console.log(JSON.stringify(res.result, null, 2)); |
| 1248 | + } catch (err) { |
| 1249 | + console.warn(err); |
| 1250 | + } |
| 1251 | + |
| 1252 | + // end-create_domain_mapping |
| 1253 | + }); |
| 1254 | + |
| 1255 | + test('getDomainMapping request example', async () => { |
| 1256 | + consoleLogMock.mockImplementation((output) => { |
| 1257 | + originalLog(output); |
| 1258 | + }); |
| 1259 | + consoleWarnMock.mockImplementation((output) => { |
| 1260 | + // if an error occurs, display the message and then fail the test |
| 1261 | + originalWarn(output); |
| 1262 | + expect(true).toBeFalsy(); |
| 1263 | + }); |
| 1264 | + |
| 1265 | + originalLog('getDomainMapping() result:'); |
| 1266 | + // begin-get_domain_mapping |
| 1267 | + |
| 1268 | + const params = { |
| 1269 | + projectId: '15314cc3-85b4-4338-903f-c28cdee6d005', |
| 1270 | + name: 'www.example.com', |
| 1271 | + }; |
| 1272 | + |
| 1273 | + let res; |
| 1274 | + try { |
| 1275 | + res = await codeEngineService.getDomainMapping(params); |
| 1276 | + console.log(JSON.stringify(res.result, null, 2)); |
| 1277 | + } catch (err) { |
| 1278 | + console.warn(err); |
| 1279 | + } |
| 1280 | + |
| 1281 | + // end-get_domain_mapping |
| 1282 | + }); |
| 1283 | + |
| 1284 | + test('updateDomainMapping request example', async () => { |
| 1285 | + consoleLogMock.mockImplementation((output) => { |
| 1286 | + originalLog(output); |
| 1287 | + }); |
| 1288 | + consoleWarnMock.mockImplementation((output) => { |
| 1289 | + // if an error occurs, display the message and then fail the test |
| 1290 | + originalWarn(output); |
| 1291 | + expect(true).toBeFalsy(); |
| 1292 | + }); |
| 1293 | + |
| 1294 | + originalLog('updateDomainMapping() result:'); |
| 1295 | + // begin-update_domain_mapping |
| 1296 | + |
| 1297 | + const params = { |
| 1298 | + projectId: '15314cc3-85b4-4338-903f-c28cdee6d005', |
| 1299 | + name: 'www.example.com', |
| 1300 | + ifMatch: 'testString', |
| 1301 | + }; |
| 1302 | + |
| 1303 | + let res; |
| 1304 | + try { |
| 1305 | + res = await codeEngineService.updateDomainMapping(params); |
| 1306 | + console.log(JSON.stringify(res.result, null, 2)); |
| 1307 | + } catch (err) { |
| 1308 | + console.warn(err); |
| 1309 | + } |
| 1310 | + |
| 1311 | + // end-update_domain_mapping |
| 1312 | + }); |
| 1313 | + |
1182 | 1314 | test('deleteProject request example', async () => {
|
1183 | 1315 | consoleLogMock.mockImplementation((output) => {
|
1184 | 1316 | originalLog(output);
|
@@ -1438,4 +1570,30 @@ describe('CodeEngineV2', () => {
|
1438 | 1570 |
|
1439 | 1571 | // end-delete_secret
|
1440 | 1572 | });
|
| 1573 | + |
| 1574 | + test('deleteDomainMapping request example', async () => { |
| 1575 | + consoleLogMock.mockImplementation((output) => { |
| 1576 | + originalLog(output); |
| 1577 | + }); |
| 1578 | + consoleWarnMock.mockImplementation((output) => { |
| 1579 | + // if an error occurs, display the message and then fail the test |
| 1580 | + originalWarn(output); |
| 1581 | + expect(true).toBeFalsy(); |
| 1582 | + }); |
| 1583 | + |
| 1584 | + // begin-delete_domain_mapping |
| 1585 | + |
| 1586 | + const params = { |
| 1587 | + projectId: '15314cc3-85b4-4338-903f-c28cdee6d005', |
| 1588 | + name: 'www.example.com', |
| 1589 | + }; |
| 1590 | + |
| 1591 | + try { |
| 1592 | + await codeEngineService.deleteDomainMapping(params); |
| 1593 | + } catch (err) { |
| 1594 | + console.warn(err); |
| 1595 | + } |
| 1596 | + |
| 1597 | + // end-delete_domain_mapping |
| 1598 | + }); |
1441 | 1599 | });
|
0 commit comments