Skip to content

Commit ffc3dc1

Browse files
Jason PetersonGitHub Enterprise
authored andcommitted
feat(api): SDK update 20240124-163103 (#61)
* feat(api): SDK update 20240124-163103
1 parent 10a962c commit ffc3dc1

File tree

7 files changed

+1653
-126
lines changed

7 files changed

+1653
-126
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,7 @@ test/integration/code-engine.v2.test.js
9393

9494
# ignore the generated SSH and TLS keys and certs
9595
test/integration/domain*
96-
test/integration/sshkey*
96+
test/integration/sshkey*
97+
98+
# API repo (pulled from Github)
99+
api

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ before_install:
2323
- echo "CODE_ENGINE_AUTH_TYPE=iam" >> code_engine_v2.env
2424
- echo "CODE_ENGINE_APIKEY=$CE_API_KEY" >> code_engine_v2.env
2525
- echo "CODE_ENGINE_AUTH_URL=$IAM_ENDPOINT" >> code_engine_v2.env
26+
- echo "CODE_ENGINE_DOMAIN_MAPPING_NAME=api-unit-test-tls.e2e-board.info" >> code_engine_v2.env
27+
- echo "CODE_ENGINE_TLS_KEY_FILE_PATH=api/test/integration/tls-files/demohero.key" >> code_engine_v2.env
28+
- echo "CODE_ENGINE_TLS_CERT_FILE_PATH=api/test/integration/tls-files/demohero.crt" >> code_engine_v2.env
2629

2730
script:
2831
- npm run build

code-engine/v2.ts

Lines changed: 708 additions & 66 deletions
Large diffs are not rendered by default.

examples/code-engine.v2.test.js

Lines changed: 159 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @jest-environment node
33
*/
44
/**
5-
* (C) Copyright IBM Corp. 2023.
5+
* (C) Copyright IBM Corp. 2024.
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
@@ -1179,6 +1179,138 @@ describe('CodeEngineV2', () => {
11791179
// end-replace_secret
11801180
});
11811181

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+
11821314
test('deleteProject request example', async () => {
11831315
consoleLogMock.mockImplementation((output) => {
11841316
originalLog(output);
@@ -1438,4 +1570,30 @@ describe('CodeEngineV2', () => {
14381570

14391571
// end-delete_secret
14401572
});
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+
});
14411599
});

test/integration/prepare-integration-tests.sh

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
#!/bin/bash
2+
##################################################
3+
# Licensed Materials - Property of IBM
4+
# IBM Cloud Code Engine, 5900-AB0
5+
# © Copyright IBM Corp. 2020, 2023
6+
# US Government Users Restricted Rights - Use, duplication or
7+
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
8+
##################################################
9+
10+
set -e
11+
112
# Create two new self-signed certificates using openssl
213
# The certs are used to verify TLS secret creations and updates
314
echo "Creating dummy certificates to verify TLS secrets ..."
@@ -11,4 +22,30 @@ echo ""
1122
echo "Creating dummy SSH keys to verify SSH secrets ..."
1223
openssl ecparam -name prime256v1 -genkey -noout -out ./test/integration/sshkey.pem
1324
echo "Creating dummy certificates to verify SSH secrets [done]"
14-
echo ""
25+
echo ""
26+
27+
28+
function get_repo {
29+
if [ ! -d "$apiDirectory" ]; then
30+
printf "Cloning github.ibm.com/coligo/api...\n"
31+
git clone https://github.ibm.com/coligo/api.git "$apiDirectory"
32+
else
33+
printf "github.ibm.com/coligo/api already cloned, getting latest...\n"
34+
cd "$apiDirectory"
35+
if [[ $(git status --porcelain) ]]; then
36+
printf "Local working tree contains changes... stashing them\n"
37+
git stash
38+
fi
39+
git checkout main
40+
git pull
41+
cd "$rootDirectory"
42+
fi
43+
}
44+
45+
echo ""
46+
echo "----------------------------------"
47+
echo "Getting test dependencies ..."
48+
echo "----------------------------------"
49+
rootDirectory=$(pwd)
50+
apiDirectory=$rootDirectory/api
51+
get_repo

0 commit comments

Comments
 (0)