Skip to content

Commit 641e11b

Browse files
feat(api): Updated python-sdk to adopt Code Engine API specification changes
1 parent e6e044d commit 641e11b

File tree

7 files changed

+278
-48
lines changed

7 files changed

+278
-48
lines changed

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.4.1
5+
# Python SDK for IBM Cloud Code Engine 4.9.0
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.4.1) | CodeEngineV2
43-
[IBM Cloud Code Engine V1](https://cloud.ibm.com/apidocs/codeengine/codeengine-v4.4.1) | IbmCloudCodeEngineV1
42+
[IBM Cloud Code Engine V2](https://cloud.ibm.com/apidocs/codeengine/codeengine-v4.9.0) | CodeEngineV2
43+
[IBM Cloud Code Engine V1](https://cloud.ibm.com/apidocs/codeengine/codeengine-v4.9.0) | 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.4.1"
58+
pip install --upgrade "ibm_code_engine_sdk>=4.9.0"
5959
```
6060

6161
or
6262

6363
```bash
64-
easy_install --upgrade "ibm_code_engine_sdk>=4.4.1"
64+
easy_install --upgrade "ibm_code_engine_sdk>=4.9.0"
6565
```
6666

6767
## Using the SDK

examples/test_code_engine_v2_examples.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# (C) Copyright IBM Corp. 2024.
2+
# (C) Copyright IBM Corp. 2025.
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 = '2024-11-18'
25+
version = '2025-01-10'
2626

2727
#
2828
# This file provides an example of how to use the Code Engine service.

ibm_code_engine_sdk/code_engine_v2.py

Lines changed: 199 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding: utf-8
22

3-
# (C) Copyright IBM Corp. 2024.
3+
# (C) Copyright IBM Corp. 2025.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -56,7 +56,7 @@ def new_instance(
5656

5757
:param str version: (optional) The API version, in format `YYYY-MM-DD`. For
5858
the API behavior documented here, specify any date between `2021-03-31` and
59-
`2024-11-18`.
59+
`2025-01-10`.
6060
"""
6161
authenticator = get_authenticator_from_environment(service_name)
6262
service = cls(
@@ -80,7 +80,7 @@ def __init__(
8080

8181
:param str version: (optional) The API version, in format `YYYY-MM-DD`. For
8282
the API behavior documented here, specify any date between `2021-03-31` and
83-
`2024-11-18`.
83+
`2025-01-10`.
8484
"""
8585
BaseService.__init__(self, service_url=self.DEFAULT_SERVICE_URL, authenticator=authenticator)
8686
self.version = version
@@ -7154,6 +7154,26 @@ class StatusEnum(str, Enum):
71547154
READY = 'ready'
71557155
FAILED = 'failed'
71567156

7157+
class StrategySizeEnum(str, Enum):
7158+
"""
7159+
Optional size for the build, which determines the amount of resources used. Build
7160+
sizes are `small`, `medium`, `large`, `xlarge`, `xxlarge`.
7161+
"""
7162+
7163+
SMALL = 'small'
7164+
MEDIUM = 'medium'
7165+
LARGE = 'large'
7166+
XLARGE = 'xlarge'
7167+
XXLARGE = 'xxlarge'
7168+
7169+
class StrategyTypeEnum(str, Enum):
7170+
"""
7171+
The strategy to use for building the image.
7172+
"""
7173+
7174+
DOCKERFILE = 'dockerfile'
7175+
BUILDPACKS = 'buildpacks'
7176+
71577177

71587178
class BuildList:
71597179
"""
@@ -7456,6 +7476,26 @@ class SourceTypeEnum(str, Enum):
74567476
LOCAL = 'local'
74577477
GIT = 'git'
74587478

7479+
class StrategySizeEnum(str, Enum):
7480+
"""
7481+
Optional size for the build, which determines the amount of resources used. Build
7482+
sizes are `small`, `medium`, `large`, `xlarge`, `xxlarge`.
7483+
"""
7484+
7485+
SMALL = 'small'
7486+
MEDIUM = 'medium'
7487+
LARGE = 'large'
7488+
XLARGE = 'xlarge'
7489+
XXLARGE = 'xxlarge'
7490+
7491+
class StrategyTypeEnum(str, Enum):
7492+
"""
7493+
The strategy to use for building the image.
7494+
"""
7495+
7496+
DOCKERFILE = 'dockerfile'
7497+
BUILDPACKS = 'buildpacks'
7498+
74597499

74607500
class BuildRun:
74617501
"""
@@ -7791,6 +7831,26 @@ class StatusEnum(str, Enum):
77917831
PENDING = 'pending'
77927832
FAILED = 'failed'
77937833

7834+
class StrategySizeEnum(str, Enum):
7835+
"""
7836+
Optional size for the build, which determines the amount of resources used. Build
7837+
sizes are `small`, `medium`, `large`, `xlarge`, `xxlarge`.
7838+
"""
7839+
7840+
SMALL = 'small'
7841+
MEDIUM = 'medium'
7842+
LARGE = 'large'
7843+
XLARGE = 'xlarge'
7844+
XXLARGE = 'xxlarge'
7845+
7846+
class StrategyTypeEnum(str, Enum):
7847+
"""
7848+
The strategy to use for building the image.
7849+
"""
7850+
7851+
DOCKERFILE = 'dockerfile'
7852+
BUILDPACKS = 'buildpacks'
7853+
77947854

77957855
class BuildRunList:
77967856
"""
@@ -10198,6 +10258,106 @@ class ReasonEnum(str, Enum):
1019810258
NO_CODE_BUNDLE = 'no_code_bundle'
1019910259

1020010260

10261+
class IndexDetails:
10262+
"""
10263+
IndexDetails.
10264+
10265+
:param str finished_at: (optional) The timestamp when the job run index finished
10266+
processing.
10267+
:param str last_failure_reason: (optional) Reason why latest retry of the job
10268+
run index failed. Possible values include but are not limited to `OOMKilled`,
10269+
`ContainerExitedCode1` or `ExceededEphemeralStorage`.
10270+
:param int retries: (optional) Number of retries of this job run index.
10271+
:param str started_at: (optional) The timestamp when the job run index started
10272+
processing.
10273+
:param str status: (optional) Current status of the job run index.
10274+
"""
10275+
10276+
def __init__(
10277+
self,
10278+
*,
10279+
finished_at: Optional[str] = None,
10280+
last_failure_reason: Optional[str] = None,
10281+
retries: Optional[int] = None,
10282+
started_at: Optional[str] = None,
10283+
status: Optional[str] = None,
10284+
) -> None:
10285+
"""
10286+
Initialize a IndexDetails object.
10287+
10288+
"""
10289+
self.finished_at = finished_at
10290+
self.last_failure_reason = last_failure_reason
10291+
self.retries = retries
10292+
self.started_at = started_at
10293+
self.status = status
10294+
10295+
@classmethod
10296+
def from_dict(cls, _dict: Dict) -> 'IndexDetails':
10297+
"""Initialize a IndexDetails object from a json dictionary."""
10298+
args = {}
10299+
if (finished_at := _dict.get('finished_at')) is not None:
10300+
args['finished_at'] = finished_at
10301+
if (last_failure_reason := _dict.get('last_failure_reason')) is not None:
10302+
args['last_failure_reason'] = last_failure_reason
10303+
if (retries := _dict.get('retries')) is not None:
10304+
args['retries'] = retries
10305+
if (started_at := _dict.get('started_at')) is not None:
10306+
args['started_at'] = started_at
10307+
if (status := _dict.get('status')) is not None:
10308+
args['status'] = status
10309+
return cls(**args)
10310+
10311+
@classmethod
10312+
def _from_dict(cls, _dict):
10313+
"""Initialize a IndexDetails object from a json dictionary."""
10314+
return cls.from_dict(_dict)
10315+
10316+
def to_dict(self) -> Dict:
10317+
"""Return a json dictionary representing this model."""
10318+
_dict = {}
10319+
if hasattr(self, 'finished_at') and getattr(self, 'finished_at') is not None:
10320+
_dict['finished_at'] = getattr(self, 'finished_at')
10321+
if hasattr(self, 'last_failure_reason') and getattr(self, 'last_failure_reason') is not None:
10322+
_dict['last_failure_reason'] = getattr(self, 'last_failure_reason')
10323+
if hasattr(self, 'retries') and getattr(self, 'retries') is not None:
10324+
_dict['retries'] = getattr(self, 'retries')
10325+
if hasattr(self, 'started_at') and getattr(self, 'started_at') is not None:
10326+
_dict['started_at'] = getattr(self, 'started_at')
10327+
if hasattr(self, 'status') and getattr(self, 'status') is not None:
10328+
_dict['status'] = getattr(self, 'status')
10329+
return _dict
10330+
10331+
def _to_dict(self):
10332+
"""Return a json dictionary representing this model."""
10333+
return self.to_dict()
10334+
10335+
def __str__(self) -> str:
10336+
"""Return a `str` version of this IndexDetails object."""
10337+
return json.dumps(self.to_dict(), indent=2)
10338+
10339+
def __eq__(self, other: 'IndexDetails') -> bool:
10340+
"""Return `true` when self and other are equal, false otherwise."""
10341+
if not isinstance(other, self.__class__):
10342+
return False
10343+
return self.__dict__ == other.__dict__
10344+
10345+
def __ne__(self, other: 'IndexDetails') -> bool:
10346+
"""Return `true` when self and other are not equal, false otherwise."""
10347+
return not self == other
10348+
10349+
class StatusEnum(str, Enum):
10350+
"""
10351+
Current status of the job run index.
10352+
"""
10353+
10354+
PENDING = 'pending'
10355+
RUNNING = 'running'
10356+
SUCCEEDED = 'succeeded'
10357+
FAILED = 'failed'
10358+
UNKNOWN = 'unknown'
10359+
10360+
1020110361
class Job:
1020210362
"""
1020310363
Job is the response model for job resources.
@@ -11587,6 +11747,7 @@ class JobRunStatus:
1158711747
:param str completion_time: (optional) Time the job run completed.
1158811748
:param int failed: (optional) Number of failed job run instances.
1158911749
:param str failed_indices: (optional) List of job run indices that failed.
11750+
:param dict indices_details: (optional) Detailed process information per index.
1159011751
:param int pending: (optional) Number of pending job run instances.
1159111752
:param str pending_indices: (optional) List of job run indices that are pending.
1159211753
:param int requested: (optional) Number of requested job run instances.
@@ -11604,6 +11765,7 @@ def __init__(
1160411765
completion_time: Optional[str] = None,
1160511766
failed: Optional[int] = None,
1160611767
failed_indices: Optional[str] = None,
11768+
indices_details: Optional[dict] = None,
1160711769
pending: Optional[int] = None,
1160811770
pending_indices: Optional[str] = None,
1160911771
requested: Optional[int] = None,
@@ -11617,10 +11779,13 @@ def __init__(
1161711779
"""
1161811780
Initialize a JobRunStatus object.
1161911781

11782+
:param dict indices_details: (optional) Detailed process information per
11783+
index.
1162011784
"""
1162111785
self.completion_time = completion_time
1162211786
self.failed = failed
1162311787
self.failed_indices = failed_indices
11788+
self.indices_details = indices_details
1162411789
self.pending = pending
1162511790
self.pending_indices = pending_indices
1162611791
self.requested = requested
@@ -11641,6 +11806,8 @@ def from_dict(cls, _dict: Dict) -> 'JobRunStatus':
1164111806
args['failed'] = failed
1164211807
if (failed_indices := _dict.get('failed_indices')) is not None:
1164311808
args['failed_indices'] = failed_indices
11809+
if (indices_details := _dict.get('indices_details')) is not None:
11810+
args['indices_details'] = {k: IndexDetails.from_dict(v) for k, v in indices_details.items()}
1164411811
if (pending := _dict.get('pending')) is not None:
1164511812
args['pending'] = pending
1164611813
if (pending_indices := _dict.get('pending_indices')) is not None:
@@ -11675,6 +11842,14 @@ def to_dict(self) -> Dict:
1167511842
_dict['failed'] = getattr(self, 'failed')
1167611843
if hasattr(self, 'failed_indices') and getattr(self, 'failed_indices') is not None:
1167711844
_dict['failed_indices'] = getattr(self, 'failed_indices')
11845+
if hasattr(self, 'indices_details') and self.indices_details is not None:
11846+
indices_details_map = {}
11847+
for k, v in self.indices_details.items():
11848+
if isinstance(v, dict):
11849+
indices_details_map[k] = v
11850+
else:
11851+
indices_details_map[k] = v.to_dict()
11852+
_dict['indices_details'] = indices_details_map
1167811853
if hasattr(self, 'pending') and getattr(self, 'pending') is not None:
1167911854
_dict['pending'] = getattr(self, 'pending')
1168011855
if hasattr(self, 'pending_indices') and getattr(self, 'pending_indices') is not None:
@@ -13121,6 +13296,21 @@ class FormatEnum(str, Enum):
1312113296
SERVICE_OPERATOR = 'service_operator'
1312213297
OTHER = 'other'
1312313298

13299+
class ResourceTypeEnum(str, Enum):
13300+
"""
13301+
The type of the secret.
13302+
"""
13303+
13304+
SECRET_V2 = 'secret_v2'
13305+
SECRET_AUTH_SSH_V2 = 'secret_auth_ssh_v2'
13306+
SECRET_BASIC_AUTH_V2 = 'secret_basic_auth_v2'
13307+
SECRET_GENERIC_V2 = 'secret_generic_v2'
13308+
SECRET_OPERATOR_V2 = 'secret_operator_v2'
13309+
SECRET_OTHER_V2 = 'secret_other_v2'
13310+
SECRET_REGISTRY_V2 = 'secret_registry_v2'
13311+
SECRET_SERVICE_ACCESS_V2 = 'secret_service_access_v2'
13312+
SECRET_TLS_V2 = 'secret_tls_v2'
13313+
1312413314

1312513315
class SecretData:
1312613316
"""
@@ -13929,7 +14119,7 @@ class AllowedOutboundDestinationPatchCidrBlockDataPatch(AllowedOutboundDestinati
1392914119

1393014120
:param str type: (optional) Specify the type of the allowed outbound
1393114121
destination. Allowed types are: 'cidr_block'.
13932-
:param str cidr_block: (optional) The IP address range.
14122+
:param str cidr_block: (optional) The IPv4 address range.
1393314123
"""
1393414124

1393514125
def __init__(
@@ -13943,7 +14133,7 @@ def __init__(
1394314133

1394414134
:param str type: (optional) Specify the type of the allowed outbound
1394514135
destination. Allowed types are: 'cidr_block'.
13946-
:param str cidr_block: (optional) The IP address range.
14136+
:param str cidr_block: (optional) The IPv4 address range.
1394714137
"""
1394814138
# pylint: disable=super-init-not-called
1394914139
self.type = type
@@ -14006,7 +14196,7 @@ class AllowedOutboundDestinationPrototypeCidrBlockDataPrototype(AllowedOutboundD
1400614196

1400714197
:param str type: Specify the type of the allowed outbound destination. Allowed
1400814198
types are: 'cidr_block'.
14009-
:param str cidr_block: The IP address range.
14199+
:param str cidr_block: The IPv4 address range.
1401014200
:param str name: The name of the CIDR block.
1401114201
"""
1401214202

@@ -14021,7 +14211,7 @@ def __init__(
1402114211

1402214212
:param str type: Specify the type of the allowed outbound destination.
1402314213
Allowed types are: 'cidr_block'.
14024-
:param str cidr_block: The IP address range.
14214+
:param str cidr_block: The IPv4 address range.
1402514215
:param str name: The name of the CIDR block.
1402614216
"""
1402714217
# pylint: disable=super-init-not-called
@@ -14104,7 +14294,7 @@ class AllowedOutboundDestinationCidrBlockData(AllowedOutboundDestination):
1410414294
used to achieve optimistic locking.
1410514295
:param str type: Specify the type of the allowed outbound destination. Allowed
1410614296
types are: 'cidr_block'.
14107-
:param str cidr_block: The IP address range.
14297+
:param str cidr_block: The IPv4 address range.
1410814298
:param str name: The name of the CIDR block.
1410914299
"""
1411014300

@@ -14122,7 +14312,7 @@ def __init__(
1412214312
which is used to achieve optimistic locking.
1412314313
:param str type: Specify the type of the allowed outbound destination.
1412414314
Allowed types are: 'cidr_block'.
14125-
:param str cidr_block: The IP address range.
14315+
:param str cidr_block: The IPv4 address range.
1412614316
:param str name: The name of the CIDR block.
1412714317
"""
1412814318
# pylint: disable=super-init-not-called

0 commit comments

Comments
 (0)