Skip to content

Commit e3bbaa8

Browse files
feat(api): Updated python-sdk to adopt Code Engine API specification changes
1 parent 20cc46a commit e3bbaa8

File tree

11 files changed

+3657
-1611
lines changed

11 files changed

+3657
-1611
lines changed

.github/pull_request_template.md

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Unit and Integration Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
jobs:
12+
unit-and-integration-tests:
13+
runs-on: ibm-x86-64-medium
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: '3.13'
19+
cache: 'pip'
20+
- name: Run Unit tests
21+
run: make ci
22+
- name: Checkout API for latest domain mapping certs
23+
uses: actions/checkout@v4
24+
with:
25+
repository: 'coligo/api'
26+
ref: 'main'
27+
path: "api"
28+
token: ${{ secrets.DEVOPS_GITHUB_TOKEN }}
29+
- name: Run Integration tests
30+
env:
31+
CE_API_HOST: ${{ vars.CE_API_HOST }}
32+
CE_API_KEY: ${{ secrets.CE_API_KEY }}
33+
CE_DOMAIN_MAPPING_NAME: ${{ vars.CE_DOMAIN_MAPPING_NAME }}
34+
COS_ACCESS_KEY_ID: ${{ secrets.COS_ACCESS_KEY_ID }}
35+
COS_SECRET_ACCESS_KEY: ${{ secrets.COS_SECRET_ACCESS_KEY }}
36+
IAM_ENDPOINT: ${{ vars.IAM_ENDPOINT }}
37+
run: |
38+
# create an .env file that is pulled in while executing the v2 integration tests
39+
echo "CODE_ENGINE_URL=https://$CE_API_HOST/v2" > code_engine_v2.env
40+
echo "CODE_ENGINE_AUTH_TYPE=iam" >> code_engine_v2.env
41+
echo "CODE_ENGINE_APIKEY=$CE_API_KEY" >> code_engine_v2.env
42+
echo "CODE_ENGINE_AUTH_URL=$IAM_ENDPOINT" >> code_engine_v2.env
43+
echo "CODE_ENGINE_DOMAIN_MAPPING_NAME=$CE_DOMAIN_MAPPING_NAME" >> code_engine_v2.env
44+
echo "CODE_ENGINE_TLS_KEY_FILE_PATH=api/test/integration/tls-files/demohero.key" >> code_engine_v2.env
45+
echo "CODE_ENGINE_TLS_CERT_FILE_PATH=api/test/integration/tls-files/demohero.crt" >> code_engine_v2.env
46+
make test-int
47+
48+
49+
50+

.metadata

Lines changed: 0 additions & 9 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
44
-->
5-
# Python SDK for IBM Cloud Code Engine 4.20.0
5+
# Python SDK for IBM Cloud Code Engine 4.21.1
66

77
Python client library to interact with the [IBM Cloud Code Engine API](https://cloud.ibm.com/apidocs/codeengine).
88

@@ -39,8 +39,8 @@ IBM Cloud services:
3939

4040
Service Name | Imported Class Name
4141
--- | ---
42-
[IBM Cloud Code Engine V2](https://cloud.ibm.com/apidocs/codeengine/codeengine-v4.20.0) | CodeEngineV2
43-
[IBM Cloud Code Engine V1](https://cloud.ibm.com/apidocs/codeengine/codeengine-v4.20.0) | IbmCloudCodeEngineV1
42+
[IBM Cloud Code Engine V2](https://cloud.ibm.com/apidocs/codeengine/codeengine-v4.21.1) | CodeEngineV2
43+
[IBM Cloud Code Engine V1](https://cloud.ibm.com/apidocs/codeengine/codeengine-v4.21.1) | IbmCloudCodeEngineV1
4444

4545
## Prerequisites
4646

@@ -55,13 +55,13 @@ Service Name | Imported Class Name
5555
To install, use `pip` or `easy_install`:
5656

5757
```bash
58-
pip install --upgrade "ibm_code_engine_sdk>=4.20.0"
58+
pip install --upgrade "ibm_code_engine_sdk>=4.21.1"
5959
```
6060

6161
or
6262

6363
```bash
64-
easy_install --upgrade "ibm_code_engine_sdk>=4.20.0"
64+
easy_install --upgrade "ibm_code_engine_sdk>=4.21.1"
6565
```
6666

6767
## Using the SDK

examples/test_code_engine_v2_examples.py

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import pytest
2323
from ibm_code_engine_sdk.code_engine_v2 import *
2424

25-
version = '2025-03-29'
25+
version = '2025-08-27'
2626

2727
#
2828
# This file provides an example of how to use the Code Engine service.
@@ -1333,6 +1333,80 @@ def test_replace_secret_example(self):
13331333
except ApiException as e:
13341334
pytest.fail(str(e))
13351335

1336+
@needscredentials
1337+
def test_list_persistent_data_store_example(self):
1338+
"""
1339+
list_persistent_data_store request example
1340+
"""
1341+
try:
1342+
print('\nlist_persistent_data_store() result:')
1343+
1344+
# begin-list_persistent_data_store
1345+
1346+
all_results = []
1347+
pager = PersistentDataStorePager(
1348+
client=code_engine_service,
1349+
project_id='15314cc3-85b4-4338-903f-c28cdee6d005',
1350+
limit=100,
1351+
)
1352+
while pager.has_next():
1353+
next_page = pager.get_next()
1354+
assert next_page is not None
1355+
all_results.extend(next_page)
1356+
1357+
print(json.dumps(all_results, indent=2))
1358+
1359+
# end-list_persistent_data_store
1360+
except ApiException as e:
1361+
pytest.fail(str(e))
1362+
1363+
@needscredentials
1364+
def test_create_persistent_data_store_example(self):
1365+
"""
1366+
create_persistent_data_store request example
1367+
"""
1368+
try:
1369+
print('\ncreate_persistent_data_store() result:')
1370+
1371+
# begin-create_persistent_data_store
1372+
1373+
response = code_engine_service.create_persistent_data_store(
1374+
project_id='15314cc3-85b4-4338-903f-c28cdee6d005',
1375+
name='my-persistent-data-store',
1376+
storage_type='object_storage',
1377+
)
1378+
persistent_data_store = response.get_result()
1379+
1380+
print(json.dumps(persistent_data_store, indent=2))
1381+
1382+
# end-create_persistent_data_store
1383+
1384+
except ApiException as e:
1385+
pytest.fail(str(e))
1386+
1387+
@needscredentials
1388+
def test_get_persistent_data_store_example(self):
1389+
"""
1390+
get_persistent_data_store request example
1391+
"""
1392+
try:
1393+
print('\nget_persistent_data_store() result:')
1394+
1395+
# begin-get_persistent_data_store
1396+
1397+
response = code_engine_service.get_persistent_data_store(
1398+
project_id='15314cc3-85b4-4338-903f-c28cdee6d005',
1399+
name='my-persistent-data-store',
1400+
)
1401+
persistent_data_store = response.get_result()
1402+
1403+
print(json.dumps(persistent_data_store, indent=2))
1404+
1405+
# end-get_persistent_data_store
1406+
1407+
except ApiException as e:
1408+
pytest.fail(str(e))
1409+
13361410
@needscredentials
13371411
def test_delete_project_example(self):
13381412
"""
@@ -1580,6 +1654,25 @@ def test_delete_secret_example(self):
15801654
except ApiException as e:
15811655
pytest.fail(str(e))
15821656

1657+
@needscredentials
1658+
def test_delete_persistent_data_store_example(self):
1659+
"""
1660+
delete_persistent_data_store request example
1661+
"""
1662+
try:
1663+
# begin-delete_persistent_data_store
1664+
1665+
response = code_engine_service.delete_persistent_data_store(
1666+
project_id='15314cc3-85b4-4338-903f-c28cdee6d005',
1667+
name='my-persistent-data-store',
1668+
)
1669+
1670+
# end-delete_persistent_data_store
1671+
print('\ndelete_persistent_data_store() response status code: ', response.get_status_code())
1672+
1673+
except ApiException as e:
1674+
pytest.fail(str(e))
1675+
15831676

15841677
# endregion
15851678
##############################################################################

0 commit comments

Comments
 (0)