Skip to content

Commit 93a0285

Browse files
feat(api): Updated python-sdk to adopt Code Engine API specification changes
1 parent c10a036 commit 93a0285

File tree

8 files changed

+1670
-396
lines changed

8 files changed

+1670
-396
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test-unit:
2727

2828
test-int:
2929
./test/integration/prepare-integration-tests.sh
30-
python3 -m pytest --ignore test/integration/test_code_engine_v2.py test/integration
30+
python3 -m pytest -v --ignore test/integration/test_code_engine_v2.py test/integration
3131

3232
test-examples:
3333
python3 -m pytest example

README.md

Lines changed: 192 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
[![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)
33
-->
4-
# Python SDK for IBM Cloud Code Engine 4.22.0
4+
# Python SDK for IBM Cloud Code Engine 5.0.0
55

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

@@ -21,6 +21,7 @@ Python client library to interact with the [IBM Cloud Code Engine API](https://c
2121

2222
- [Overview](#overview)
2323
- [Prerequisites](#prerequisites)
24+
- [Breaking Changes (March 2026)](#breaking-changes-march-2026)
2425
- [Installation](#installation)
2526
- [Using the SDK](#using-the-sdk)
2627
- [Questions](#questions)
@@ -38,8 +39,8 @@ IBM Cloud services:
3839

3940
Service Name | Imported Class Name
4041
--- | ---
41-
[IBM Cloud Code Engine V2](https://cloud.ibm.com/apidocs/codeengine/codeengine-v4.22.0) | CodeEngineV2
42-
[IBM Cloud Code Engine V1](https://cloud.ibm.com/apidocs/codeengine/codeengine-v4.22.0) | IbmCloudCodeEngineV1
42+
[IBM Cloud Code Engine V2](https://cloud.ibm.com/apidocs/codeengine/codeengine-v5.0.0) | CodeEngineV2
43+
[IBM Cloud Code Engine V1](https://cloud.ibm.com/apidocs/codeengine/codeengine-v5.0.0) | IbmCloudCodeEngineV1
4344

4445
## Prerequisites
4546

@@ -49,18 +50,204 @@ Service Name | Imported Class Name
4950
* An IAM API key to allow the SDK to access your account. Create one [here](https://cloud.ibm.com/iam/apikeys).
5051
* Python 3.9 or above.
5152

53+
## Breaking Changes (March 2026)
54+
55+
- **Service method renames (pluralization)**
56+
Update list methods and their `operation_id`s accordingly:
57+
58+
```python
59+
# before
60+
ce.list_allowed_outbound_destination(project_id, limit=100, start=token)
61+
62+
# after
63+
ce.list_allowed_outbound_destinations(project_id, limit=100, start=token)
64+
```
65+
66+
```python
67+
# before
68+
ce.list_persistent_data_store(project_id, limit=100, start=token)
69+
70+
# after
71+
ce.list_persistent_data_stores(project_id, limit=100, start=token)
72+
```
73+
74+
- **Pager class renames**
75+
Use the new pluralized pager classes and doc tag strings:
76+
77+
```python
78+
# before
79+
pager = ibm_code_engine_sdk.code_engine_v2.AllowedOutboundDestinationPager(ce, project_id, limit=100)
80+
81+
# after
82+
pager = ibm_code_engine_sdk.code_engine_v2.AllowedOutboundDestinationsPager(ce, project_id, limit=100)
83+
```
84+
85+
```python
86+
# before
87+
pager = ibm_code_engine_sdk.code_engine_v2.PersistentDataStorePager(ce, project_id, limit=100)
88+
89+
# after
90+
pager = ibm_code_engine_sdk.code_engine_v2.PersistentDataStoresPager(ce, project_id, limit=100)
91+
```
92+
93+
- **Allowed outbound destinations: new type & fields; constructor shape changes**
94+
- New type supported: `"private_path_service_gateway"` (in addition to `"cidr_block"`). Update any branching/validation on `type`.
95+
- New optional fields on `AllowedOutboundDestination` and subclasses:
96+
- `name`, `status`, `status_details`
97+
- Private Path specific: `private_path_service_gateway_crn`, `isolation_policy`
98+
- Base classes `AllowedOutboundDestination`, `AllowedOutboundDestinationPatch`, `AllowedOutboundDestinationPrototype`, `AllowedOutboundStatusDetails` are now **abstract** with expanded subclass sets. Instantiate the specific subclass instead, as before, but note the extended list.
99+
100+
- **Creation prototypes changed**
101+
- `AllowedOutboundDestinationPrototype` now **requires** `name`.
102+
- **CIDR prototype constructor order changed**:
103+
104+
```python
105+
from ibm_code_engine_sdk.code_engine_v2 import AllowedOutboundDestinationPrototypeCidrBlockDataPrototype
106+
# before: (type, cidr_block, name)
107+
# after: (type, name, cidr_block)
108+
cidr_proto = AllowedOutboundDestinationPrototypeCidrBlockDataPrototype(
109+
type="cidr_block",
110+
name="allow-egress",
111+
cidr_block="10.0.0.0/24",
112+
)
113+
```
114+
- **New prototype for Private Path service**:
115+
116+
```python
117+
from ibm_code_engine_sdk.code_engine_v2 import (
118+
AllowedOutboundDestinationPrototypePrivatePathServiceGatewayDataPrototype as PPSGProto
119+
)
120+
ppsg_proto = PPSGProto(
121+
type="private_path_service_gateway",
122+
name="pps-to-service-x",
123+
private_path_service_gateway_crn="<pps_gateway_crn>",
124+
isolation_policy="shared", # optional: "shared" | "dedicated"
125+
)
126+
```
127+
128+
- **Patch models changed (do not send `type`)**
129+
- Remove `type` from CIDR patch payloads; field and serialization removed:
130+
131+
```python
132+
from ibm_code_engine_sdk.code_engine_v2 import AllowedOutboundDestinationPatchCidrBlockDataPatch
133+
134+
patch = AllowedOutboundDestinationPatchCidrBlockDataPatch(cidr_block="10.0.1.0/24")
135+
```
136+
137+
- New patch model for Private Path destinations:
138+
139+
```python
140+
from ibm_code_engine_sdk.code_engine_v2 import AllowedOutboundDestinationPatchPrivatePathServiceGatewayDataPatch
141+
142+
pp_patch = AllowedOutboundDestinationPatchPrivatePathServiceGatewayDataPatch(
143+
isolation_policy="dedicated" # "shared" | "dedicated"
144+
)
145+
```
146+
147+
- **Probe model: `type` is now required**
148+
When constructing `Probe`, set the protocol explicitly:
149+
150+
```python
151+
from ibm_code_engine_sdk.code_engine_v2 import Probe
152+
153+
# before (omitted `type`)
154+
# after (required)
155+
probe = Probe(
156+
type="http", # "http" or "tcp"
157+
initial_delay=5,
158+
timeout=2,
159+
)
160+
```
161+
162+
- **Secret model: `format` is now required**
163+
If you build `Secret` instances (e.g., in replace flows), you must set `format`:
164+
165+
```python
166+
from ibm_code_engine_sdk.code_engine_v2 import Secret
167+
168+
secret = Secret(
169+
entity_tag=etag,
170+
format="generic", # set the appropriate format value
171+
name="my-secret",
172+
data={"key": "value"},
173+
)
174+
```
175+
176+
- **Previously-optional fields are now required in several response models (affects re-use of response as request)**
177+
These fields are validated as required in model deserialization; if you reuse response objects to send updates, you must provide them:
178+
179+
- `App`: `computed_env_variables`, `run_service_account`, `run_volume_mounts`
180+
- `AppRevision`: `computed_env_variables`, `run_service_account`, `run_volume_mounts`
181+
- `Build`: `run_build_params`
182+
- `BuildRun`: `run_build_params`, `service_account`, `source_type`, `strategy_size`, `strategy_type`
183+
- `Function`: `computed_env_variables`
184+
- `FunctionRuntimeList`: `function_runtimes`
185+
- `Job`: `computed_env_variables`, `run_service_account`, `run_volume_mounts`
186+
- `JobRun`: `computed_env_variables`
187+
188+
**Example (BuildRun)**
189+
190+
```python
191+
from ibm_code_engine_sdk.code_engine_v2 import BuildRun, BuildParam
192+
193+
build_run = BuildRun(
194+
build_name="my-build",
195+
name="run-1",
196+
run_build_params=[BuildParam(name="ARG1", value="v")],
197+
service_account="default",
198+
source_type="git",
199+
strategy_size="small",
200+
strategy_type="buildpacks",
201+
source_url="https://github.com/org/repo",
202+
)
203+
```
204+
205+
- **Allowed outbound destination CIDR model loosened & enriched**
206+
- `entity_tag` and `name` are no longer required at construction time; they may be absent in incoming JSON.
207+
- New status fields added (`status`, `status_details`). Update your parsing/logic if you inspect readiness.
208+
209+
- **New status details and helper models (if you consume detailed status)**
210+
- `AllowedOutboundStatusDetails` base plus:
211+
- `AllowedOutboundStatusDetailsPrivatePathServiceGatewayStatusDetails`
212+
- Helper models:
213+
- `EndpointGatewayDetails`
214+
- `PrivatePathServiceGatewayDetails`
215+
If you serialize/deserialize status detail trees, include these types.
216+
217+
- **Volume mount doc clarifications (no code changes)**
218+
- `read_only` description now explicitly applies to mounts of type `'persistent_data_store'`.
219+
- Name generation references `reference` (was `ref` in docstring).
220+
221+
- **Storage data enum expansion & doc update**
222+
- `StorageData`/`StorageDataObjectStorageData` now enumerate more `bucket_location` values (regional/zone shorthands). If you validate these values client-side, include the new options.
223+
- `StorageDataObjectStorageData` doc now specifies key/value constraints.
224+
225+
> **Migration checklist**
226+
>
227+
> - [ ] Rename `list_allowed_outbound_destination``list_allowed_outbound_destinations`.
228+
> - [ ] Rename `list_persistent_data_store``list_persistent_data_stores`.
229+
> - [ ] Switch pagers to pluralized classes.
230+
> - [ ] Update API `version` upper bound if you set it.
231+
> - [ ] For outbound destination **create**:
232+
> - [ ] Provide `name` in prototypes.
233+
> - [ ] For CIDR prototype, adjust constructor order to `(type, name, cidr_block)`.
234+
> - [ ] Use new Private Path prototype when needed.
235+
> - [ ] For outbound destination **patch**: remove `type`; use CIDR/Private Path specific patch models.
236+
> - [ ] Set required fields now enforced in models (`Probe.type`, `Secret.format`, and the required lists/fields in `App`, `Build`, `BuildRun`, `Function`, `Job`, `JobRun`, etc.).
237+
> - [ ] Include handling for new enum values: `private_path_service_gateway`, `status` values (`ready|failed|deploying`), and `isolation_policy` (`shared|dedicated`).
238+
52239
## Installation
53240

54241
To install, use `pip` or `easy_install`:
55242

56243
```bash
57-
pip install --upgrade "ibm_code_engine_sdk>=4.22.0"
244+
pip install --upgrade "ibm_code_engine_sdk>=5.0.0"
58245
```
59246

60247
or
61248

62249
```bash
63-
easy_install --upgrade "ibm_code_engine_sdk>=4.22.0"
250+
easy_install --upgrade "ibm_code_engine_sdk>=5.0.0"
64251
```
65252

66253
## Using the SDK

examples/test_code_engine_v2_examples.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# (C) Copyright IBM Corp. 2025.
2+
# (C) Copyright IBM Corp. 2026.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222
import pytest
2323
from ibm_code_engine_sdk.code_engine_v2 import *
2424

25-
version = '2025-08-27'
25+
version = '2026-02-23'
2626

2727
#
2828
# This file provides an example of how to use the Code Engine service.
@@ -147,17 +147,17 @@ def test_get_project_example(self):
147147
pytest.fail(str(e))
148148

149149
@needscredentials
150-
def test_list_allowed_outbound_destination_example(self):
150+
def test_list_allowed_outbound_destinations_example(self):
151151
"""
152-
list_allowed_outbound_destination request example
152+
list_allowed_outbound_destinations request example
153153
"""
154154
try:
155-
print('\nlist_allowed_outbound_destination() result:')
155+
print('\nlist_allowed_outbound_destinations() result:')
156156

157-
# begin-list_allowed_outbound_destination
157+
# begin-list_allowed_outbound_destinations
158158

159159
all_results = []
160-
pager = AllowedOutboundDestinationPager(
160+
pager = AllowedOutboundDestinationsPager(
161161
client=code_engine_service,
162162
project_id='15314cc3-85b4-4338-903f-c28cdee6d005',
163163
limit=100,
@@ -169,7 +169,7 @@ def test_list_allowed_outbound_destination_example(self):
169169

170170
print(json.dumps(all_results, indent=2))
171171

172-
# end-list_allowed_outbound_destination
172+
# end-list_allowed_outbound_destinations
173173
except ApiException as e:
174174
pytest.fail(str(e))
175175

@@ -185,8 +185,8 @@ def test_create_allowed_outbound_destination_example(self):
185185

186186
allowed_outbound_destination_prototype_model = {
187187
'type': 'cidr_block',
188+
'name': 'allow-all',
188189
'cidr_block': 'testString',
189-
'name': 'testString',
190190
}
191191

192192
response = code_engine_service.create_allowed_outbound_destination(
@@ -1334,17 +1334,17 @@ def test_replace_secret_example(self):
13341334
pytest.fail(str(e))
13351335

13361336
@needscredentials
1337-
def test_list_persistent_data_store_example(self):
1337+
def test_list_persistent_data_stores_example(self):
13381338
"""
1339-
list_persistent_data_store request example
1339+
list_persistent_data_stores request example
13401340
"""
13411341
try:
1342-
print('\nlist_persistent_data_store() result:')
1342+
print('\nlist_persistent_data_stores() result:')
13431343

1344-
# begin-list_persistent_data_store
1344+
# begin-list_persistent_data_stores
13451345

13461346
all_results = []
1347-
pager = PersistentDataStorePager(
1347+
pager = PersistentDataStoresPager(
13481348
client=code_engine_service,
13491349
project_id='15314cc3-85b4-4338-903f-c28cdee6d005',
13501350
limit=100,
@@ -1356,7 +1356,7 @@ def test_list_persistent_data_store_example(self):
13561356

13571357
print(json.dumps(all_results, indent=2))
13581358

1359-
# end-list_persistent_data_store
1359+
# end-list_persistent_data_stores
13601360
except ApiException as e:
13611361
pytest.fail(str(e))
13621362

0 commit comments

Comments
 (0)