Skip to content

Commit fa0e013

Browse files
committed
refactor(cbc): rename config→configuration in public API; drop unused NNV
Address review feedback on PR #333: - Rename the business-config vocabulary to match the CBC API's own `configuration` wording: ConfigObject→ConfigurationObject, ConfigData→ConfigurationData, ConfigEntity→ConfigurationEntity (and the internal ConfigurationObjectEntity/Entry/List), get_config_object→ get_configuration_object, and the config_object_id / config_objects fields and parameters. Test identifiers renamed to match. - CBCConfig and CBCConfigError keep the short form — they are SDK client configuration (create_client overrides / setup errors), not CBC's managed business configuration. - Drop the NNV model and the ConsumptionVersion.ref_content field it backed: parsed from the API response but never read anywhere. 63 unit tests pass; integration tests verified against a live CBC tenant.
1 parent 08ce6b9 commit fa0e013

10 files changed

Lines changed: 184 additions & 163 deletions

File tree

‎src/sap_cloud_sdk/cbc/__init__.py‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
config = cbc_client.get_configuration()
1919
2020
# Access entity data
21-
payment = config.get_config_object("payment-config")
21+
payment = config.get_configuration_object("payment-config")
2222
if payment:
2323
for row in payment.get_entity_data("payment-mode").as_list():
2424
print(row)
@@ -47,13 +47,12 @@
4747
)
4848
from sap_cloud_sdk.cbc._models import (
4949
ApiError,
50-
ConfigData,
51-
ConfigEntity,
52-
ConfigObject,
50+
ConfigurationData,
51+
ConfigurationEntity,
52+
ConfigurationObject,
5353
ConsumptionVersion,
5454
ConsumptionVersions,
5555
EntityData,
56-
NNV,
5756
)
5857

5958

@@ -75,13 +74,12 @@
7574
# models — consumption versions
7675
"ConsumptionVersion",
7776
"ConsumptionVersions",
78-
"NNV",
7977
# models — entities
8078
"EntityData",
81-
"ConfigEntity",
82-
"ConfigObject",
79+
"ConfigurationEntity",
80+
"ConfigurationObject",
8381
# models — configuration
84-
"ConfigData",
82+
"ConfigurationData",
8583
# models — api error
8684
"ApiError",
8785
]

‎src/sap_cloud_sdk/cbc/_models.py‎

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,18 @@ class _FrozenModel(BaseModel):
2424
# ---------------------------------------------------------------------------
2525

2626

27-
class NNV(_FrozenModel):
28-
"""Namespace-Name-Version tuple identifying a reference content version."""
29-
30-
namespace: str
31-
name: str
32-
version: str
33-
34-
def __str__(self) -> str:
35-
return f"{self.namespace}.{self.name}.{self.version}"
36-
37-
3827
class ConsumptionVersion(_FrozenModel):
3928
"""A snapshot of the business configuration for an app tenant at a point in time.
4029
4130
Attributes:
4231
version: Version identifier.
4332
created_date: Creation timestamp.
4433
modified_date: Last modification timestamp.
45-
ref_content: Reference content NNV this version is based on, if applicable.
4634
"""
4735

4836
version: str
4937
created_date: datetime | None = Field(default=None, alias="createdDate")
5038
modified_date: datetime | None = Field(default=None, alias="modifiedDate")
51-
ref_content: NNV | None = Field(default=None, alias="referenceContentDetails")
5239

5340

5441
class ConsumptionVersions(_FrozenModel):
@@ -85,7 +72,7 @@ def latest(self) -> ConsumptionVersion | None:
8572
# ---------------------------------------------------------------------------
8673

8774

88-
class ConfigObjectEntity(_FrozenModel):
75+
class ConfigurationObjectEntity(_FrozenModel):
8976
"""One entity listed under a config object by the ``configurationObjects`` API.
9077
9178
Attributes:
@@ -96,26 +83,26 @@ class ConfigObjectEntity(_FrozenModel):
9683
entity_id: str = Field(alias="entityId")
9784

9885

99-
class ConfigObjectEntry(_FrozenModel):
86+
class ConfigurationObjectEntry(_FrozenModel):
10087
"""One config object and its entities as returned by the API.
10188
10289
Attributes:
103-
config_object_id: Authored config object identifier (e.g. ``"payment-config"``).
90+
configuration_object_id: Authored config object identifier (e.g. ``"payment-config"``).
10491
entities: Entities belonging to this config object.
10592
"""
10693

107-
config_object_id: str = Field(alias="configurationObjectId")
108-
entities: list[ConfigObjectEntity]
94+
configuration_object_id: str = Field(alias="configurationObjectId")
95+
entities: list[ConfigurationObjectEntity]
10996

11097

111-
class ConfigObjectList(_FrozenModel):
98+
class ConfigurationObjectList(_FrozenModel):
11299
"""Config objects for a consumption version, already grouped by the API.
113100
114101
Attributes:
115-
items: List of :class:`ConfigObjectEntry` objects.
102+
items: List of :class:`ConfigurationObjectEntry` objects.
116103
"""
117104

118-
items: list[ConfigObjectEntry]
105+
items: list[ConfigurationObjectEntry]
119106

120107

121108
class EntityData:
@@ -172,7 +159,7 @@ def __repr__(self) -> str:
172159

173160

174161
@dataclass
175-
class ConfigEntity:
162+
class ConfigurationEntity:
176163
"""A single entity within a config object.
177164
178165
Attributes:
@@ -185,16 +172,16 @@ class ConfigEntity:
185172

186173

187174
@dataclass
188-
class ConfigObject:
175+
class ConfigurationObject:
189176
"""A configuration object and its entities.
190177
191178
Attributes:
192-
config_object_id: Authored config object identifier (e.g. ``"payment-config"``).
179+
configuration_object_id: Authored config object identifier (e.g. ``"payment-config"``).
193180
entities: Entity data for all entities in this config object.
194181
"""
195182

196-
config_object_id: str
197-
entities: list[ConfigEntity]
183+
configuration_object_id: str
184+
entities: list[ConfigurationEntity]
198185

199186
def get_entity_data(self, entity_id: str) -> EntityData | None:
200187
"""Return the data for the entity with the given ID.
@@ -210,50 +197,52 @@ def get_entity_data(self, entity_id: str) -> EntityData | None:
210197

211198

212199
@dataclass
213-
class ConfigData:
200+
class ConfigurationData:
214201
"""Complete business configuration — all config objects for one consumption version.
215202
216203
Attributes:
217204
consumption_version: Version this data was fetched from.
218205
app_tenant_id: Application tenant this data belongs to.
219-
config_objects: Configuration objects and their entity data.
206+
configuration_objects: Configuration objects and their entity data.
220207
"""
221208

222209
consumption_version: str
223210
app_tenant_id: str
224-
config_objects: list[ConfigObject]
211+
configuration_objects: list[ConfigurationObject]
225212

226-
def get_config_object(self, config_object_id: str) -> ConfigObject | None:
213+
def get_configuration_object(
214+
self, configuration_object_id: str
215+
) -> ConfigurationObject | None:
227216
"""Return the config object with the given ID.
228217
229218
Args:
230-
config_object_id: Authored config object identifier.
219+
configuration_object_id: Authored config object identifier.
231220
232221
Returns:
233-
Matching :class:`ConfigObject`, or ``None`` if not found.
222+
Matching :class:`ConfigurationObject`, or ``None`` if not found.
234223
"""
235224
return next(
236225
(
237226
co
238-
for co in self.config_objects
239-
if co.config_object_id == config_object_id
227+
for co in self.configuration_objects
228+
if co.configuration_object_id == configuration_object_id
240229
),
241230
None,
242231
)
243232

244233
def get_entity_data(
245-
self, config_object_id: str, entity_id: str
234+
self, configuration_object_id: str, entity_id: str
246235
) -> EntityData | None:
247236
"""Return the data for the given config object and entity IDs.
248237
249238
Args:
250-
config_object_id: Authored config object identifier.
239+
configuration_object_id: Authored config object identifier.
251240
entity_id: Authored entity identifier.
252241
253242
Returns:
254243
:class:`EntityData` for the matching entity, or ``None`` if not found.
255244
"""
256-
co = self.get_config_object(config_object_id)
245+
co = self.get_configuration_object(configuration_object_id)
257246
return co.get_entity_data(entity_id) if co is not None else None
258247

259248

‎src/sap_cloud_sdk/cbc/client.py‎

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838

3939
from sap_cloud_sdk.cbc._models import (
4040
ApiError,
41-
ConfigData,
42-
ConfigEntity,
43-
ConfigObject,
44-
ConfigObjectList,
41+
ConfigurationData,
42+
ConfigurationEntity,
43+
ConfigurationObject,
44+
ConfigurationObjectList,
4545
ConsumptionVersions,
4646
EntityData,
4747
)
@@ -261,7 +261,7 @@ def _get_consumption_versions(
261261

262262
def _get_configuration_objects(
263263
self, base_url: str, app_tenant_id: str, consumption_version: str
264-
) -> ConfigObjectList:
264+
) -> ConfigurationObjectList:
265265
"""Return the config objects (with their entities) for the given version.
266266
267267
The API returns config objects already grouped with their child entities,
@@ -273,7 +273,7 @@ def _get_configuration_objects(
273273
consumption_version: Consumption version ID.
274274
275275
Returns:
276-
:class:`ConfigObjectList` containing config objects and their entities.
276+
:class:`ConfigurationObjectList` containing config objects and their entities.
277277
278278
Raises:
279279
CBCClientError: On 4xx responses.
@@ -285,13 +285,13 @@ def _get_configuration_objects(
285285
f"/consumptionVersions/{consumption_version}/configurationObjects"
286286
f"?appTenantId={app_tenant_id}",
287287
)
288-
return ConfigObjectList.model_validate(self._request("GET", url).json())
288+
return ConfigurationObjectList.model_validate(self._request("GET", url).json())
289289

290290
@record_metrics(Module.CBC, Operation.CBC_GET_CONFIGURATION)
291291
def get_configuration(
292292
self,
293293
consumption_version: str | None = None,
294-
) -> ConfigData:
294+
) -> ConfigurationData:
295295
"""Return the full business configuration for the configured tenant.
296296
297297
Fetches the config objects and the data for every entity they contain, for
@@ -304,7 +304,7 @@ def get_configuration(
304304
latest version is resolved via :meth:`get_consumption_versions`.
305305
306306
Returns:
307-
:class:`ConfigData` containing all entity data for the version.
307+
:class:`ConfigurationData` containing all entity data for the version.
308308
309309
Raises:
310310
CBCClientError: On 4xx responses, or when no consumption version exists
@@ -326,32 +326,32 @@ def get_configuration(
326326
co_list = self._get_configuration_objects(
327327
base_url, app_tenant_id, consumption_version
328328
)
329-
config_objects = [
330-
ConfigObject(
331-
config_object_id=entry.config_object_id,
329+
configuration_objects = [
330+
ConfigurationObject(
331+
configuration_object_id=entry.configuration_object_id,
332332
entities=[
333333
self._fetch_entity_data(
334334
base_url,
335335
app_tenant_id,
336336
consumption_version,
337-
entry.config_object_id,
337+
entry.configuration_object_id,
338338
entity.entity_id,
339339
)
340340
for entity in entry.entities
341341
],
342342
)
343343
for entry in co_list.items
344344
]
345-
return ConfigData(
345+
return ConfigurationData(
346346
consumption_version=consumption_version,
347347
app_tenant_id=app_tenant_id,
348-
config_objects=config_objects,
348+
configuration_objects=configuration_objects,
349349
)
350350

351351
@record_metrics(Module.CBC, Operation.CBC_GET_ENTITY_DATA)
352352
def get_entity_data(
353353
self,
354-
config_object_id: str,
354+
configuration_object_id: str,
355355
entity_id: str,
356356
consumption_version: str | None = None,
357357
) -> EntityData:
@@ -362,7 +362,7 @@ def get_entity_data(
362362
config object.
363363
364364
Args:
365-
config_object_id: Authored config object identifier (e.g. ``"payment-config"``).
365+
configuration_object_id: Authored config object identifier (e.g. ``"payment-config"``).
366366
entity_id: Authored entity identifier (e.g. ``"payment-mode"``).
367367
consumption_version: Consumption version ID. When ``None``, the
368368
latest version is resolved via :meth:`get_consumption_versions`.
@@ -387,21 +387,25 @@ def get_entity_data(
387387
)
388388
consumption_version = latest.version
389389
return self._fetch_entity_data(
390-
base_url, app_tenant_id, consumption_version, config_object_id, entity_id
390+
base_url,
391+
app_tenant_id,
392+
consumption_version,
393+
configuration_object_id,
394+
entity_id,
391395
).data
392396

393397
def _fetch_entity_data(
394398
self,
395399
base_url: str,
396400
app_tenant_id: str,
397401
consumption_version: str,
398-
config_object_id: str,
402+
configuration_object_id: str,
399403
entity_id: str,
400-
) -> ConfigEntity:
404+
) -> ConfigurationEntity:
401405
url = self._configurations_url(
402406
base_url,
403407
f"/consumptionVersions/{consumption_version}/configurationObjects"
404-
f"/{config_object_id}/entities/{entity_id}/data"
408+
f"/{configuration_object_id}/entities/{entity_id}/data"
405409
f"?appTenantId={app_tenant_id}",
406410
)
407411
body = self._request("GET", url).json()
@@ -414,7 +418,7 @@ def _fetch_entity_data(
414418
# ARRAY / UNSPECIFIED / absent — items may be absent or empty.
415419
raw_data = content.get("items", [])
416420

417-
return ConfigEntity(entity_id=entity_id, data=EntityData(raw_data))
421+
return ConfigurationEntity(entity_id=entity_id, data=EntityData(raw_data))
418422

419423
def _configurations_url(self, base_url: str, path: str = "") -> str:
420424
base = base_url.rstrip("/")

0 commit comments

Comments
 (0)