codemie-sdk-python 0.1.711__py3-none-any.whl → 0.1.712__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
codemie_sdk/__init__.py CHANGED
@@ -203,6 +203,16 @@ from .models.marketplace_management import (
203
203
  MarketplaceDecisionRequest,
204
204
  )
205
205
  from .services.marketplace_management import MarketplaceManagementService
206
+ from .models.provisioning import (
207
+ ProvisioningProject,
208
+ ProvisioningProjectBlock,
209
+ ProvisioningBudgetRequest,
210
+ ProvisioningBudgetCategory,
211
+ ProvisioningBudgetGroup,
212
+ ProvisioningBudgetResponse,
213
+ ProvisioningBudgetResult,
214
+ )
215
+ from .services.provisioning import ProvisioningService
206
216
 
207
217
  try:
208
218
  __version__ = _pkg_version("codemie-sdk-python")
@@ -347,6 +357,14 @@ __all__ = [
347
357
  "UsageAttributionTableResponse",
348
358
  "UsageAttributionSettingsResponse",
349
359
  "UsageAttributionService",
360
+ "ProvisioningProject",
361
+ "ProvisioningProjectBlock",
362
+ "ProvisioningBudgetRequest",
363
+ "ProvisioningBudgetCategory",
364
+ "ProvisioningBudgetGroup",
365
+ "ProvisioningBudgetResponse",
366
+ "ProvisioningBudgetResult",
367
+ "ProvisioningService",
350
368
  "MarketplaceStatusFilter",
351
369
  "MarketplaceGateResult",
352
370
  "MarketplacePendingOrderBy",
@@ -25,8 +25,11 @@ from .definition import (
25
25
  WorkflowAssistant,
26
26
  WorkflowAssistantTool,
27
27
  WorkflowDefinition,
28
+ WorkflowEndState,
29
+ WorkflowEngineRetryPolicy,
28
30
  WorkflowMCPServer,
29
31
  WorkflowNextState,
32
+ WorkflowPoolConfig,
30
33
  WorkflowRetryPolicy,
31
34
  WorkflowState,
32
35
  WorkflowStateCondition,
@@ -41,9 +44,12 @@ __all__: list[str] = [
41
44
  "WorkflowAssistantTool",
42
45
  "WorkflowBuilder",
43
46
  "WorkflowDefinition",
47
+ "WorkflowEndState",
48
+ "WorkflowEngineRetryPolicy",
44
49
  "WorkflowMCPServer",
45
50
  "WorkflowMode",
46
51
  "WorkflowNextState",
52
+ "WorkflowPoolConfig",
47
53
  "WorkflowRetryPolicy",
48
54
  "WorkflowState",
49
55
  "WorkflowStateCondition",
@@ -29,8 +29,10 @@ from .definition import (
29
29
  CustomWorkflowNode,
30
30
  WorkflowAssistant,
31
31
  WorkflowDefinition,
32
+ WorkflowEngineRetryPolicy,
32
33
  WorkflowMCPServer,
33
34
  WorkflowNextState,
35
+ WorkflowPoolConfig,
34
36
  WorkflowRetryPolicy,
35
37
  WorkflowState,
36
38
  WorkflowTool,
@@ -54,6 +56,7 @@ class _BuilderState:
54
56
  tools: dict[str, WorkflowTool] = field(default_factory=dict)
55
57
  custom_nodes: dict[str, CustomWorkflowNode] = field(default_factory=dict)
56
58
  states: tuple[WorkflowState, ...] = ()
59
+ engine: dict[str, Any] = field(default_factory=dict)
57
60
 
58
61
 
59
62
  class WorkflowBuilder:
@@ -88,6 +91,47 @@ class WorkflowBuilder:
88
91
  def with_icon_url(self, icon_url: str) -> "WorkflowBuilder":
89
92
  return self._replaced(icon_url=icon_url)
90
93
 
94
+ def _with_engine(self, **setting: Any) -> "WorkflowBuilder":
95
+ return self._replaced(engine={**self._state.engine, **setting})
96
+
97
+ def with_max_concurrency(self, value: int) -> "WorkflowBuilder":
98
+ """Accepted up to 100, but the backend runtime clamps it (5 by default)."""
99
+ return self._with_engine(max_concurrency=value)
100
+
101
+ def with_recursion_limit(self, value: int) -> "WorkflowBuilder":
102
+ return self._with_engine(recursion_limit=value)
103
+
104
+ def with_verbose(self, value: bool) -> "WorkflowBuilder":
105
+ return self._with_engine(verbose=value)
106
+
107
+ def with_type(self, value: str) -> "WorkflowBuilder":
108
+ return self._with_engine(type=value)
109
+
110
+ def with_max_nesting_level(self, value: int) -> "WorkflowBuilder":
111
+ return self._with_engine(max_nesting_level=value)
112
+
113
+ def with_pool_config(self, value: WorkflowPoolConfig) -> "WorkflowBuilder":
114
+ return self._with_engine(pool_config=value)
115
+
116
+ def with_retry_policy(self, value: WorkflowEngineRetryPolicy) -> "WorkflowBuilder":
117
+ return self._with_engine(retry_policy=value)
118
+
119
+ def with_summarization_node(self, enabled: bool) -> "WorkflowBuilder":
120
+ return self._with_engine(enable_summarization_node=enabled)
121
+
122
+ def with_summarization_limits(
123
+ self, messages: int | None = None, tokens: int | None = None
124
+ ) -> "WorkflowBuilder":
125
+ """Set only the given before-summarization limits."""
126
+ given = {
127
+ "messages_limit_before_summarization": messages,
128
+ "tokens_limit_before_summarization": tokens,
129
+ }
130
+ return self._with_engine(**{k: v for k, v in given.items() if v is not None})
131
+
132
+ def with_max_iteration_key_output_limit(self, value: int) -> "WorkflowBuilder":
133
+ return self._with_engine(max_iteration_key_output_limit=value)
134
+
91
135
  def add_assistant(
92
136
  self,
93
137
  id: str,
@@ -342,6 +386,7 @@ class WorkflowBuilder:
342
386
  tools=list(self._state.tools.values()),
343
387
  custom_nodes=list(self._state.custom_nodes.values()),
344
388
  states=list(self._state.states),
389
+ **self._state.engine,
345
390
  )
346
391
 
347
392
  def publish(
@@ -19,7 +19,7 @@ the backend classes in
19
19
  ``codemie/src/codemie/core/workflow_models/workflow_models.py``.
20
20
  """
21
21
 
22
- from typing import Callable, Literal
22
+ from typing import Any, Callable, Literal
23
23
 
24
24
  import yaml
25
25
  from pydantic import (
@@ -250,6 +250,75 @@ class WorkflowRetryPolicy(BaseModel):
250
250
  max_attempts: int
251
251
 
252
252
 
253
+ _POOL_DEFAULT_MIN_SIZE = 2
254
+ _POOL_DEFAULT_MAX_SIZE = 5
255
+
256
+
257
+ class WorkflowPoolConfig(BaseModel):
258
+ """Workflow-wide pool settings; unset fields use the platform default.
259
+
260
+ The platform defaults are min_size 2 and max_size 5, and a deployment-wide
261
+ cap (5 by default) limits the pool further. Sizes are checked against the
262
+ defaults, not against the deployment cap.
263
+ """
264
+
265
+ model_config = _MIRRORED_MODEL_CONFIG
266
+
267
+ enabled: bool | None = None
268
+ min_size: int | None = Field(None, ge=1, le=20)
269
+ max_size: int | None = Field(None, ge=1, le=50)
270
+ refill_interval_seconds: int | None = Field(None, ge=5)
271
+
272
+ @model_validator(mode="after")
273
+ def _check_size_order(self) -> "WorkflowPoolConfig":
274
+ min_size = (
275
+ self.min_size if self.min_size is not None else _POOL_DEFAULT_MIN_SIZE
276
+ )
277
+ max_size = (
278
+ self.max_size if self.max_size is not None else _POOL_DEFAULT_MAX_SIZE
279
+ )
280
+ if min_size > max_size:
281
+ raise ValueError(
282
+ f"min_size ({min_size}) must not exceed max_size ({max_size}); "
283
+ f"unset sizes default to {_POOL_DEFAULT_MIN_SIZE} and {_POOL_DEFAULT_MAX_SIZE}"
284
+ )
285
+ return self
286
+
287
+
288
+ class WorkflowEngineRetryPolicy(BaseModel):
289
+ """Workflow-wide retry policy; every field optional like the backend."""
290
+
291
+ model_config = _MIRRORED_MODEL_CONFIG
292
+
293
+ initial_interval: float | None = Field(
294
+ None,
295
+ ge=0,
296
+ le=3_600_000,
297
+ description="Delay before the first retry, in seconds.",
298
+ )
299
+ backoff_factor: float | None = Field(None, ge=1, le=10)
300
+ max_interval: float | None = Field(
301
+ None,
302
+ ge=0,
303
+ le=3_600_000,
304
+ description="Upper bound for the delay between retries, in seconds.",
305
+ )
306
+ max_attempts: int | None = Field(None, ge=1, le=100)
307
+
308
+ @model_validator(mode="after")
309
+ def _check_interval_order(self) -> "WorkflowEngineRetryPolicy":
310
+ if (
311
+ self.initial_interval is not None
312
+ and self.max_interval is not None
313
+ and self.initial_interval > self.max_interval
314
+ ):
315
+ raise ValueError(
316
+ f"initial_interval ({self.initial_interval}) must not exceed "
317
+ f"max_interval ({self.max_interval})"
318
+ )
319
+ return self
320
+
321
+
253
322
  class WorkflowNextState(BaseModel):
254
323
  """Where a state transitions to, and how context/history carry across it."""
255
324
 
@@ -268,6 +337,7 @@ class WorkflowNextState(BaseModel):
268
337
  reset_keys_in_context_store: list[str] | None = None
269
338
  include_in_iterator_context: list[str] = Field(default_factory=lambda: ["*"])
270
339
  append_to_context: bool = False
340
+ override_task: bool | None = None
271
341
 
272
342
  @model_validator(mode="after")
273
343
  def check_exclusive(self) -> "WorkflowNextState":
@@ -280,6 +350,15 @@ class WorkflowNextState(BaseModel):
280
350
  return self
281
351
 
282
352
 
353
+ def WorkflowEndState(*, state_id: str = "end", **settings: Any) -> WorkflowNextState:
354
+ """Next state that ends the workflow; accepts the same settings as WorkflowNextState."""
355
+ if state_id != "end":
356
+ raise ValueError(
357
+ "WorkflowEndState always ends the workflow; state_id must be 'end'"
358
+ )
359
+ return WorkflowNextState(state_id="end", **settings)
360
+
361
+
283
362
  class WorkflowState(BaseModel):
284
363
  """A single node in the workflow graph."""
285
364
 
@@ -338,6 +417,14 @@ class WorkflowDefinition(BaseModel):
338
417
  messages_limit_before_summarization: int | None = Field(None, gt=0)
339
418
  tokens_limit_before_summarization: int | None = Field(None, gt=0)
340
419
  max_iteration_key_output_limit: int | None = Field(None, gt=0)
420
+ # The backend runtime clamps this to its configured maximum (5 by default).
421
+ max_concurrency: int | None = Field(None, ge=1, le=100)
422
+ recursion_limit: int | None = Field(None, ge=1, le=5000)
423
+ verbose: bool | None = None
424
+ type: str | None = None
425
+ max_nesting_level: int | None = Field(None, ge=1)
426
+ pool_config: WorkflowPoolConfig | None = None
427
+ retry_policy: WorkflowEngineRetryPolicy | None = None
341
428
 
342
429
  def to_yaml_config(
343
430
  self, resolve_assistant_name: Callable[[str], str] | None = None
@@ -371,11 +458,19 @@ class WorkflowDefinition(BaseModel):
371
458
  "messages_limit_before_summarization",
372
459
  "tokens_limit_before_summarization",
373
460
  "max_iteration_key_output_limit",
461
+ "max_concurrency",
462
+ "recursion_limit",
463
+ "verbose",
464
+ "type",
465
+ "max_nesting_level",
466
+ "pool_config",
467
+ "retry_policy",
374
468
  )
469
+ values = {name: getattr(self, name) for name in names}
375
470
  return {
376
- name: getattr(self, name)
377
- for name in names
378
- if getattr(self, name) is not None
471
+ name: v.model_dump(exclude_none=True) if isinstance(v, BaseModel) else v
472
+ for name, v in values.items()
473
+ if v is not None
379
474
  }
380
475
 
381
476
  @staticmethod
@@ -33,8 +33,8 @@ from ..services.mcp_configs import MCPConfigsService
33
33
  from ..services.cost_center import CostCenterService
34
34
  from ..services.customer_config_service import CustomerConfigService
35
35
  from ..services.project_budget_groups import ProjectBudgetGroupsService
36
+ from ..services.provisioning import ProvisioningService
36
37
  from ..services.usage_attribution import UsageAttributionService
37
- from ..services.servicenow_integration import ServiceNowIntegrationService
38
38
  from ..services.marketplace_management import MarketplaceManagementService
39
39
  from ..services.export import ExportService
40
40
 
@@ -187,9 +187,6 @@ class CodeMieClient:
187
187
  self.project_budget_groups = ProjectBudgetGroupsService(
188
188
  self._api_domain, _token_source, verify_ssl=self._verify_ssl
189
189
  )
190
- self.servicenow_integration = ServiceNowIntegrationService(
191
- self._api_domain, _token_source, verify_ssl=self._verify_ssl
192
- )
193
190
  self.a2a = A2AService(
194
191
  self._api_domain, _token_source, verify_ssl=self._verify_ssl
195
192
  )
@@ -205,6 +202,9 @@ class CodeMieClient:
205
202
  self.export = ExportService(
206
203
  self._api_domain, _token_source, verify_ssl=self._verify_ssl
207
204
  )
205
+ self.provisioning = ProvisioningService(
206
+ self._api_domain, _token_source, verify_ssl=self._verify_ssl
207
+ )
208
208
 
209
209
  @property
210
210
  def token(self) -> str:
@@ -296,6 +296,7 @@ class Assistant(AssistantBase):
296
296
  )
297
297
  shared: bool = False
298
298
  is_react: bool = False
299
+ hide_tool_outputs: bool = False
299
300
  is_global: bool = False
300
301
  created_date: datetime | None = None
301
302
  updated_date: datetime | None = None
@@ -309,6 +310,7 @@ class Assistant(AssistantBase):
309
310
  display_name: str | None = None
310
311
  mcp_servers: list[MCPServerDetails] = Field(default_factory=list)
311
312
  assistant_ids: list[str] = Field(default_factory=list)
313
+ skill_ids: list[str] | None = None
312
314
  enabled_builtin_subagents: list[str] = Field(default_factory=list)
313
315
  version_count: int | None = None
314
316
  prompt_variables: list[PromptVariable] | None = Field(default=None)
@@ -370,6 +372,7 @@ class AssistantRequestBase(AssistantBase):
370
372
  )
371
373
  shared: bool = False
372
374
  is_react: bool = False
375
+ hide_tool_outputs: bool = False
373
376
  is_global: bool | None = False
374
377
  categories: list[str] = Field(
375
378
  default_factory=list,
@@ -381,6 +384,7 @@ class AssistantRequestBase(AssistantBase):
381
384
  tools_tokens_size_limit: int | None = None
382
385
  mcp_servers: list[MCPServerDetails] = Field(default_factory=list)
383
386
  assistant_ids: list[str] = Field(default_factory=list)
387
+ skill_ids: list[str] | None = None
384
388
  enabled_builtin_subagents: list[str] | None = None
385
389
  prompt_variables: list[PromptVariable] = Field(default_factory=list)
386
390
  skip_integration_validation: bool | None = Field(default=False)
@@ -508,6 +512,7 @@ class AssistantVersion(BaseModel):
508
512
  toolkits: list[ToolKitDetails] = Field(default_factory=list)
509
513
  mcp_servers: list[MCPServerDetails] = Field(default_factory=list)
510
514
  assistant_ids: list[str] = Field(default_factory=list)
515
+ skill_ids: list[str] | None = None
511
516
  prompt_variables: list[PromptVariable] = Field(default_factory=list)
512
517
 
513
518
 
@@ -123,6 +123,7 @@ class AssistantDataItem(BaseModel):
123
123
  context: list[ContextItem | str] | None = None
124
124
  tools: list[ToolItem] | None = None
125
125
  conversation_starters: list[str] = []
126
+ hide_tool_outputs: bool = False
126
127
 
127
128
 
128
129
  class ConversationDetailsData(BaseModel):
@@ -145,6 +146,7 @@ class AssistantDetailsData(BaseModel):
145
146
  context: list[ContextItem | str]
146
147
  tools: list[ToolItem]
147
148
  conversation_starters: list[str]
149
+ hide_tool_outputs: bool = False
148
150
 
149
151
 
150
152
  class ConversationCreateRequest(BaseModel):
@@ -81,8 +81,8 @@ class Integration(BaseModel):
81
81
  setting_type: IntegrationType = Field(default=IntegrationType.USER)
82
82
 
83
83
  @field_serializer("date", "update_date")
84
- def serialize_dt(self, dt: datetime, _info):
85
- return dt.isoformat()
84
+ def serialize_dt(self, dt: datetime | None, _info):
85
+ return dt.isoformat() if dt is not None else None
86
86
 
87
87
 
88
88
  class IntegrationTestRequest(BaseModel):
@@ -0,0 +1,122 @@
1
+ # Copyright 2026 EPAM Systems, Inc. ("EPAM")
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Provisioning API models for the CodeMie SDK.
16
+
17
+ The provisioning routes are callable only by registered provisioning clients. The request
18
+ models are deliberately permissive: the server owns the validation rules, so the SDK sends
19
+ what the caller gives it (including unknown fields) and surfaces the server's verdict as
20
+ an HTTP error.
21
+ """
22
+
23
+ from pydantic import BaseModel, ConfigDict, Field
24
+
25
+
26
+ class ProvisioningProject(BaseModel):
27
+ """A shared project returned by the project lookup."""
28
+
29
+ model_config = ConfigDict(extra="ignore")
30
+
31
+ project_name: str
32
+ display_name: str | None = None
33
+
34
+
35
+ class ProvisioningProjectBlock(BaseModel):
36
+ """Project settings applied together with a budget.
37
+
38
+ Attributes:
39
+ cost_center: Cost center to link the project to while it has no active one.
40
+ admin_emails: People to make project admins; existing admins are never removed.
41
+ """
42
+
43
+ model_config = ConfigDict(extra="allow")
44
+
45
+ cost_center: str | None = None
46
+ admin_emails: list[str] | None = None
47
+
48
+
49
+ class ProvisioningBudgetRequest(BaseModel):
50
+ """Request body for setting or adjusting a project budget.
51
+
52
+ Attributes:
53
+ amounts: Monthly budget in USD per category (``platform``, ``cli``,
54
+ ``premium_models``).
55
+ project: Optional project settings. An empty block is sent as ``{}``; ``None``
56
+ leaves the block out of the body.
57
+ """
58
+
59
+ # Non-finite amounts are sent as the JSON constants NaN / Infinity instead of null,
60
+ # so the server, not the client, rejects them.
61
+ model_config = ConfigDict(extra="allow", ser_json_inf_nan="constants")
62
+
63
+ amounts: dict[str, float]
64
+ project: ProvisioningProjectBlock | None = None
65
+
66
+
67
+ class ProvisioningBudgetCategory(BaseModel):
68
+ """Budget of one spend category in a budget response."""
69
+
70
+ model_config = ConfigDict(extra="ignore")
71
+
72
+ category: str
73
+ max_budget: float
74
+ soft_budget: float
75
+ budget_reset_at: str | None = None
76
+
77
+
78
+ class ProvisioningBudgetGroup(BaseModel):
79
+ """Budget of a project after the call."""
80
+
81
+ model_config = ConfigDict(extra="ignore")
82
+
83
+ total_amount: float
84
+ budget_duration: str
85
+ categories: list[ProvisioningBudgetCategory]
86
+
87
+
88
+ class ProvisioningBudgetResponse(BaseModel):
89
+ """Outcome of a set or adjust call.
90
+
91
+ ``budget`` is always present: the API never answers a set or adjust with a null budget.
92
+ A cancel answers 204 without a body, which :class:`ProvisioningBudgetResult` represents
93
+ with ``budget=None``.
94
+ """
95
+
96
+ model_config = ConfigDict(extra="ignore")
97
+
98
+ project_name: str
99
+ cost_center: str | None = None
100
+ created_project: bool
101
+ created_cost_center: bool
102
+ created_budget: bool
103
+ budget: ProvisioningBudgetGroup
104
+ admins_assigned: list[str] = Field(default_factory=list)
105
+ admins_not_assigned: list[str] = Field(default_factory=list)
106
+
107
+
108
+ class ProvisioningBudgetResult(BaseModel):
109
+ """A budget call's HTTP status together with its parsed body.
110
+
111
+ The status is part of the contract (201 when the call created the budget, 200 when it
112
+ replaced or adjusted one, 204 after a cancel), so it is returned rather than hidden.
113
+
114
+ Attributes:
115
+ status_code: HTTP status of the successful answer.
116
+ budget: Parsed body, or ``None`` when the answer has no body (cancel).
117
+ """
118
+
119
+ model_config = ConfigDict(extra="ignore")
120
+
121
+ status_code: int
122
+ budget: ProvisioningBudgetResponse | None = None
@@ -136,10 +136,14 @@ class AssistantService:
136
136
  Returns:
137
137
  AssistantUpdateResponse with optional validation results
138
138
  """
139
+ payload = request.model_dump(exclude_none=True)
140
+ if "hide_tool_outputs" not in request.model_fields_set:
141
+ # Don't overwrite the stored value with the model default on update.
142
+ payload.pop("hide_tool_outputs", None)
139
143
  return self._api.put(
140
144
  f"/v1/assistants/{assistant_id}",
141
145
  AssistantUpdateResponse,
142
- json_data=request.model_dump(exclude_none=True),
146
+ json_data=payload,
143
147
  )
144
148
 
145
149
  def get_tools(self) -> list[ToolKitDetails]:
@@ -319,7 +323,6 @@ class AssistantService:
319
323
  toolkits=version.toolkits
320
324
  if hasattr(version, "toolkits")
321
325
  else assistant.toolkits,
322
- user_prompts=assistant.user_prompts,
323
326
  shared=assistant.shared,
324
327
  is_react=assistant.is_react,
325
328
  is_global=assistant.is_global,
@@ -330,6 +333,9 @@ class AssistantService:
330
333
  assistant_ids=version.assistant_ids
331
334
  if hasattr(version, "assistant_ids")
332
335
  else assistant.assistant_ids,
336
+ skill_ids=assistant.skill_ids
337
+ if version.skill_ids is None
338
+ else version.skill_ids,
333
339
  )
334
340
  update_resp = self.update(assistant_id, update_req)
335
341
  resp = update_resp.model_dump()
@@ -0,0 +1,211 @@
1
+ # Copyright 2026 EPAM Systems, Inc. ("EPAM")
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Provisioning service for the CodeMie SDK.
16
+
17
+ Wraps the third-party provisioning routes under ``/v1/provisioning``. Only registered
18
+ provisioning clients may call them, each with its own bearer token; any other caller,
19
+ including an admin, is rejected with HTTP 403.
20
+ """
21
+
22
+ import logging
23
+ from urllib.parse import quote
24
+
25
+ import requests
26
+
27
+ from ..models.provisioning import (
28
+ ProvisioningBudgetRequest,
29
+ ProvisioningBudgetResponse,
30
+ ProvisioningBudgetResult,
31
+ ProvisioningProject,
32
+ )
33
+ from ..utils.http import ApiRequestHandler, TokenSource
34
+
35
+ logger = logging.getLogger(__name__)
36
+
37
+ _PROJECTS_URL = "/v1/provisioning/projects"
38
+ _CHANGE_REFERENCE_HEADER = "X-Change-Reference"
39
+
40
+
41
+ class ProvisioningService:
42
+ """Service for the provisioning routes: member project lookup and project budgets.
43
+
44
+ A registered client authenticates with its own token, not the token of the user the
45
+ :class:`CodeMieClient` was created for. Build a service for a client with
46
+ :meth:`with_token`, or construct one directly.
47
+ """
48
+
49
+ def __init__(self, api_domain: str, token: TokenSource, verify_ssl: bool = True):
50
+ """Initialize the ProvisioningService.
51
+
52
+ Args:
53
+ api_domain: Base URL for the CodeMie API
54
+ token: Authentication token of the caller (a provisioning client's token for
55
+ the calls to succeed)
56
+ verify_ssl: Whether to verify SSL certificates
57
+ """
58
+ self._api_domain = api_domain.rstrip("/")
59
+ self._token = token
60
+ self._verify_ssl = verify_ssl
61
+ self._api = ApiRequestHandler(self._api_domain, token, verify_ssl)
62
+
63
+ def with_token(self, token: TokenSource) -> "ProvisioningService":
64
+ """Return a service for the same API that authenticates with another token.
65
+
66
+ Args:
67
+ token: Authentication token, for example the token of a provisioning client
68
+
69
+ Returns:
70
+ A new ProvisioningService; this one is left unchanged
71
+ """
72
+ return ProvisioningService(self._api_domain, token, self._verify_ssl)
73
+
74
+ def list_projects(self, member_emails: list[str]) -> list[ProvisioningProject]:
75
+ """List the shared projects that any of the given people belong to.
76
+
77
+ The result is the distinct union across all emails, sorted by project name,
78
+ without personal projects. Emails with no active user are skipped, and an empty
79
+ list is returned when none match. The emails are sent as given; the server
80
+ rejects an empty list or an invalid email with HTTP 422.
81
+
82
+ Args:
83
+ member_emails: Emails of the people whose projects to list
84
+
85
+ Returns:
86
+ List of ProvisioningProject with the project name and display name
87
+
88
+ Raises:
89
+ HTTPError: If the request fails, for example 403 when the caller is not a
90
+ client holding the read-projects permission
91
+ """
92
+ return self._api.get(
93
+ _PROJECTS_URL,
94
+ response_model=list[ProvisioningProject],
95
+ params={"member_email": member_emails},
96
+ wrap_response=False,
97
+ )
98
+
99
+ def set_budget(
100
+ self,
101
+ project_name: str,
102
+ change_reference: str | None,
103
+ request: ProvisioningBudgetRequest,
104
+ ) -> ProvisioningBudgetResult:
105
+ """Replace the amounts of a project budget, creating the project and budget if missing.
106
+
107
+ A category left out of ``request.amounts`` gets 0 and ``platform`` must be above 0.
108
+ The answer is 201 when the call created the budget and 200 when it replaced one.
109
+
110
+ Args:
111
+ project_name: CodeMie project name, sent as given
112
+ change_reference: The caller's reference for this change, sent as the
113
+ ``X-Change-Reference`` header; ``None`` leaves the header out so the
114
+ server's rejection of a missing reference can be observed
115
+ request: Amounts and optional project block
116
+
117
+ Returns:
118
+ ProvisioningBudgetResult with the HTTP status and the budget after the call
119
+
120
+ Raises:
121
+ HTTPError: If the request is rejected (400, 403, 409, 422) or fails (500, 502)
122
+ """
123
+ return self._send_budget("PUT", project_name, change_reference, request)
124
+
125
+ def adjust_budget(
126
+ self,
127
+ project_name: str,
128
+ change_reference: str | None,
129
+ request: ProvisioningBudgetRequest,
130
+ ) -> ProvisioningBudgetResult:
131
+ """Merge amounts into a project budget: a listed category changes, 0 removes it.
132
+
133
+ A category left out of ``request.amounts`` keeps its amount. The answer is
134
+ always 200 on success.
135
+
136
+ Args:
137
+ project_name: CodeMie project name, sent as given
138
+ change_reference: The caller's reference for this change; ``None`` leaves
139
+ the ``X-Change-Reference`` header out
140
+ request: Amounts and optional project block
141
+
142
+ Returns:
143
+ ProvisioningBudgetResult with the HTTP status and the budget after the call
144
+
145
+ Raises:
146
+ HTTPError: If the request is rejected (400, 403, 409, 422) or fails (500, 502)
147
+ """
148
+ return self._send_budget("PATCH", project_name, change_reference, request)
149
+
150
+ def cancel_budget(
151
+ self, project_name: str, change_reference: str | None
152
+ ) -> ProvisioningBudgetResult:
153
+ """Delete a project budget. A project without a budget is not an error.
154
+
155
+ Args:
156
+ project_name: CodeMie project name, sent as given
157
+ change_reference: The caller's reference for this change; ``None`` leaves
158
+ the ``X-Change-Reference`` header out
159
+
160
+ Returns:
161
+ ProvisioningBudgetResult with status 204 and no body
162
+
163
+ Raises:
164
+ HTTPError: If the request is rejected (403, 404, 409, 422) or fails (500)
165
+ """
166
+ return self._send_budget("DELETE", project_name, change_reference, None)
167
+
168
+ def _send_budget(
169
+ self,
170
+ method: str,
171
+ project_name: str,
172
+ change_reference: str | None,
173
+ request: ProvisioningBudgetRequest | None,
174
+ ) -> ProvisioningBudgetResult:
175
+ """Send a budget call and return the status with the parsed body.
176
+
177
+ The shared request handler parses the body and drops the status, and 201 versus
178
+ 200 is part of the set contract, so these routes are sent directly. The headers
179
+ come from the handler, so the localhost fallback applies, and the call is logged
180
+ the way the handler logs its own calls.
181
+ """
182
+ headers = self._api._get_headers()
183
+ if change_reference is not None:
184
+ headers[_CHANGE_REFERENCE_HEADER] = change_reference
185
+
186
+ endpoint = f"{_PROJECTS_URL}/{quote(project_name, safe='')}/budget"
187
+ logger.debug(f"Making {method} request to {self._api_domain}{endpoint}")
188
+ try:
189
+ response = requests.request(
190
+ method,
191
+ f"{self._api_domain}{endpoint}",
192
+ headers=headers,
193
+ data=(
194
+ request.model_dump_json(exclude_none=True)
195
+ if request is not None
196
+ else None
197
+ ),
198
+ verify=self._verify_ssl,
199
+ )
200
+ response.raise_for_status()
201
+ except Exception as e:
202
+ logger.error(f"Error during {method} request to {endpoint}: {str(e)}")
203
+ raise
204
+ logger.info(f"Successfully processed {method} request to {endpoint}")
205
+
206
+ if response.status_code == 204 or not response.content:
207
+ return ProvisioningBudgetResult(status_code=response.status_code)
208
+ return ProvisioningBudgetResult(
209
+ status_code=response.status_code,
210
+ budget=ProvisioningBudgetResponse.model_validate(response.json()),
211
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codemie-sdk-python
3
- Version: 0.1.711
3
+ Version: 0.1.712
4
4
  Summary: CodeMie SDK for Python
5
5
  License: Apache-2.0
6
6
  Author: CodeMie
@@ -961,6 +961,35 @@ request = WorkflowCreateRequest(
961
961
  )
962
962
  ```
963
963
 
964
+ 6. **Engine settings**
965
+
966
+ Workflow-wide settings are optional; an unset setting means the platform default applies.
967
+ ```python
968
+ from codemie_sdk.builders.workflow import WorkflowEngineRetryPolicy, WorkflowPoolConfig
969
+
970
+ builder = (
971
+ builder.with_max_concurrency(20)
972
+ .with_retry_policy(WorkflowEngineRetryPolicy(max_attempts=3, backoff_factor=2.0))
973
+ .with_pool_config(WorkflowPoolConfig(enabled=True, min_size=2, max_size=10))
974
+ )
975
+ ```
976
+
977
+ | Setter | Bounds |
978
+ |---|---|
979
+ | `with_max_concurrency(n)` | 1-100 (the backend runtime clamps it, 5 by default) |
980
+ | `with_recursion_limit(n)` | 1-5000 |
981
+ | `with_verbose(flag)` | bool |
982
+ | `with_type(name)` | free string |
983
+ | `with_max_nesting_level(n)` | >= 1 |
984
+ | `with_pool_config(WorkflowPoolConfig)` | `min_size` 1-20, `max_size` 1-50, `refill_interval_seconds` >= 5; unset sizes default to 2 and 5 and `min_size` must not exceed `max_size`; the platform also caps pool size per deployment (5 by default) |
985
+ | `with_retry_policy(WorkflowEngineRetryPolicy)` | `initial_interval`/`max_interval` in seconds, 0-3600000, `backoff_factor` 1-10, `max_attempts` 1-100 |
986
+ | `with_summarization_node(flag)` | bool |
987
+ | `with_summarization_limits(messages=, tokens=)` | > 0 |
988
+ | `with_max_iteration_key_output_limit(n)` | > 0 |
989
+
990
+ `WorkflowNextState(override_task=True)` sets `override_task` on a transition. `keep_history` is
991
+ intentionally unsupported: it is deprecated, so use `include_in_llm_history`.
992
+
964
993
  #### Workflow Node Types
965
994
 
966
995
  Every state in a workflow runs one thing: an assistant, a tool, a custom node (such as
@@ -1119,6 +1148,8 @@ builder = (
1119
1148
  )
1120
1149
  )
1121
1150
  ```
1151
+ `WorkflowEndState(output_key="pr")` is shorthand for `WorkflowNextState(state_id="end", output_key="pr")`
1152
+ and accepts the same settings. Condition and switch targets still take the plain `"end"` id.
1122
1153
  Other mapping types are `constant`, `script` and `array_map`. `on_error` can be `fail`, `skip`,
1123
1154
  `default` (use together with `default_output`) or `partial`.
1124
1155
 
@@ -1,35 +1,35 @@
1
- codemie_sdk/__init__.py,sha256=PTg8-npxmVmPWeNisI8rP17GQUEJ5KP2blTeL908wQY,10732
1
+ codemie_sdk/__init__.py,sha256=4JU0B6Z9zKvDipVm6urzw96eASlwmQ1_Yzs-H20-iEg,11283
2
2
  codemie_sdk/auth/__init__.py,sha256=IksEj223xEZtJ-cQ0AT9L0Bs9psIJ8QNzDXrPTUQ3xQ,126
3
3
  codemie_sdk/auth/credentials.py,sha256=hO0X3EQWZSlIm0ABhiJo4fIIndm2blB0JZWMaWvsuTE,7774
4
4
  codemie_sdk/builders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- codemie_sdk/builders/workflow/__init__.py,sha256=kQS-h9EiMiFWByZCElwv-X786AkVWdsa5ynXwoP_4hs,1605
6
- codemie_sdk/builders/workflow/builder.py,sha256=bb_1uUe0AFhWuqe60Dao_1E-INxPwa7bzdwOprquuQg,13818
7
- codemie_sdk/builders/workflow/definition.py,sha256=mo0JqfnWDKjdoswCcKLVidC3GdNyq818RBp1EPjNKI0,15251
5
+ codemie_sdk/builders/workflow/__init__.py,sha256=FNqDrHPclKwjV2tEwQu6Yxpk8JsaSVB6hgS4xh4bkF4,1765
6
+ codemie_sdk/builders/workflow/builder.py,sha256=BZHLbHK35DYacEeGrz_eAxuwign19UwoadZYMMV3lEU,15785
7
+ codemie_sdk/builders/workflow/definition.py,sha256=s82O4_lPz4ui-CeSxEfT1FqJsoSu4aezYm4ean2lBcs,18708
8
8
  codemie_sdk/builders/workflow/publish.py,sha256=wrXFDNX0LpRTULp8zm5DD6hEmAqEwIMxPm0mSs82xjQ,7370
9
9
  codemie_sdk/client/__init__.py,sha256=yf6C39MmrJ6gK9ZHMhBeynKwUUYVSUTQbKxU8-4qpKg,101
10
- codemie_sdk/client/client.py,sha256=crzOjUz1foj9yErTo1bW0JWycYUaJPOWo7PDet3r_4c,10592
10
+ codemie_sdk/client/client.py,sha256=XOPnIiy0wEERBuNlDebg-tdDrN1SQznQIJvnTqnzOj0,10554
11
11
  codemie_sdk/exceptions.py,sha256=uuzvtvYBMzrNGt7Q4k5RVq0Pd8eJ_tR2tLy3pF2ICDs,1148
12
12
  codemie_sdk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  codemie_sdk/models/a2a.py,sha256=93GGBg4vkrlnuGCtakMLgYtrD9U54Dme9Dm5sJGO2bc,1986
14
14
  codemie_sdk/models/activity_event.py,sha256=KDEzzUEfs1J9ALNo4mLP-Rq7jeTM4g-P4A5A7Z4YjzM,1072
15
15
  codemie_sdk/models/admin.py,sha256=2UGaO60ZrHHcDcV9thYBVxDyUCvtfPQhs10WswhGFJs,2298
16
16
  codemie_sdk/models/analytics.py,sha256=B9lLAddL_LylXsoOukiPqbz4HVd2itmuB6iaEbhpKiQ,10194
17
- codemie_sdk/models/assistant.py,sha256=EWrWETnXKOZWItezJ6TdNSxY09JV6VVIcO9mrNJF97k,30414
17
+ codemie_sdk/models/assistant.py,sha256=GV6QSgnQ3PKciC1AfMLio0rDDUZoqGlaNNpRngesY5o,30603
18
18
  codemie_sdk/models/categories.py,sha256=eq7_sw-sevNLeWpjaW3N055Xcgbbevs0Bl_rj--maUk,2303
19
19
  codemie_sdk/models/common.py,sha256=ipNNdQlv4Ct1UyIAknjJbrdjjvv0lZJYK6dnPm8wai4,1170
20
- codemie_sdk/models/conversation.py,sha256=r5gV5BD-Euj4OfeLYn6NBiO-S6uFQtwACVobvFgLUcA,10204
20
+ codemie_sdk/models/conversation.py,sha256=jWqpOdgLeD9FTO1inGt-ARe37idukZmlOb-ZEK3mB6w,10276
21
21
  codemie_sdk/models/cost_center.py,sha256=qny13YLZGFkHfL_vzO85MMKBda-9Z_MwNxZNfMYl7dQ,2629
22
22
  codemie_sdk/models/datasource.py,sha256=jp1Rbx1f0cvgUierU-3ru0xfq7NEpjaB_NBpp7VfCOk,31711
23
23
  codemie_sdk/models/errors.py,sha256=tQXoPUhM2U95NoyTxsSSJws8PQ-Fr3iOQQ8IjJCsx78,11658
24
24
  codemie_sdk/models/file_operation.py,sha256=h5UBCCAbQQGm1EavF0AHn_dNE2t_Cc9be20lv_K5Vo8,722
25
25
  codemie_sdk/models/guardrails.py,sha256=813PRnu9VEF6hoUB-lw5xG_qAZXPic38qL40AwYkSMQ,2114
26
- codemie_sdk/models/integration.py,sha256=yBV28vZ8oN0oNRNHdDPL3UUSJqNga1YodABIfX8dhyI,3522
26
+ codemie_sdk/models/integration.py,sha256=D-SLsLzel0kKj4grUPM6XXu3TtKWjjD8rKttH4gVuYg,3557
27
27
  codemie_sdk/models/llm.py,sha256=ViADvsSAkc85YQyPUkGE3ZvMc5pnHWHO0_rOkLSTfu4,1333
28
28
  codemie_sdk/models/marketplace_management.py,sha256=T51fSW0G8RGyBxMBnT_o5D8E00UQaW_Fcq1nw-RGlZY,6396
29
29
  codemie_sdk/models/mcp_config.py,sha256=lqHEYNWW6MhZEx2tMTryVTfq_wThnmMS7vmWxtPkbYM,3792
30
30
  codemie_sdk/models/mermaid.py,sha256=dhRgX-itvfyrt0LUg5pbSo0CTH5PewiegqcZn3hWggU,675
31
31
  codemie_sdk/models/project.py,sha256=9nMsPNw0mUHud2sAISXrJx2lXz9VKw2Dn-ABq53UgZ8,7600
32
- codemie_sdk/models/servicenow_integration.py,sha256=xE-QYCaEWsN3znEnw9CkGiRCsAlRzv1SME4rky9k-Y0,3531
32
+ codemie_sdk/models/provisioning.py,sha256=hN7veiRThhKQd8tTFPfPBGX1KFfTiwE_T2M00hG9FR8,4006
33
33
  codemie_sdk/models/skill.py,sha256=KE4lsF8TMxIQa_UE0oRDMT6XIEHqKjsDyi0HYKEp1mM,6918
34
34
  codemie_sdk/models/task.py,sha256=YHu5DRnECS2wnqIWZ_YH8Z72p1I4aV3xWFW5joxN_8Q,1442
35
35
  codemie_sdk/models/usage_attribution.py,sha256=uMHmtcTGD65kf6ZWHvNpRGwpV-kAUl1b5S01vq76OV0,4444
@@ -49,7 +49,7 @@ codemie_sdk/services/a2a.py,sha256=vxMistimImheSRWWqOP0hy7aiQnv0NjoQnkUchtm73c,1
49
49
  codemie_sdk/services/activity_event.py,sha256=KoD0DyeqJ0CmQPA4PAXH4uGIAQCgcJbYwDnv-MCckGc,3630
50
50
  codemie_sdk/services/admin.py,sha256=yk1xdBXDjpdW4OMOdBaURkZhAxak9h-TppKyhStLekc,4006
51
51
  codemie_sdk/services/analytics.py,sha256=fLoH6FsXMfulA6vNajYFkGaZaRrZzmTzriEm8IiTz7Y,25444
52
- codemie_sdk/services/assistant.py,sha256=5TJCwrK7eSsrBaT0TsEjRw8mKqXHOoiDLhfVQfVYJBA,32080
52
+ codemie_sdk/services/assistant.py,sha256=O4Z_fNCmujBnN1mKNHk5teB9hNUk6iKSoPCkC_FNSbU,32388
53
53
  codemie_sdk/services/categories.py,sha256=1qd98JCcMNdpbos0O1WpMApT6TurE7OuI7zoYewnwk8,5030
54
54
  codemie_sdk/services/codemie_guardrails.py,sha256=O3yCeIQYG8W7z-sVRR4Cw9UVncqP9lPVNxUSaUZrh7I,2833
55
55
  codemie_sdk/services/conversation.py,sha256=HWedtlrVXvq4xyAgVNzJ9IZSeHMx4Se5fyp8PPIloEQ,14809
@@ -66,7 +66,7 @@ codemie_sdk/services/mcp_configs.py,sha256=bfe0QTrMqE5hEvyUlNMCjTxqL7u0AG7aZloQr
66
66
  codemie_sdk/services/mermaid.py,sha256=7cLykdrJVW576raUbON3yhuWnbGaXl8rX1QfVwbu2JE,2246
67
67
  codemie_sdk/services/project.py,sha256=v58ALdLv4BuxMkZNlkNZPikkXcCIePMoQtmKwdKCgko,14703
68
68
  codemie_sdk/services/project_budget_groups.py,sha256=B7QJt3sh_LV3lfwALZlxUq0SLR30BWafHcS6eHyOh8Y,5471
69
- codemie_sdk/services/servicenow_integration.py,sha256=UiMlyiSxegs4gY604rDlKTDxDymKMDP-GRZ85DRlbl8,3376
69
+ codemie_sdk/services/provisioning.py,sha256=NlgrSOCBML_a8PqcTQbje2OA7Mf_BVTq0Ozpre9h-ko,8362
70
70
  codemie_sdk/services/skill.py,sha256=0mExdeKTMNqkEpKafD0ya1WyLj9CMCFaprkggKYqnQg,13216
71
71
  codemie_sdk/services/task.py,sha256=UaYh__xGF7VKWCJKPrncVjTvx46Gz1AN9XczPVL71oA,1052
72
72
  codemie_sdk/services/usage_attribution.py,sha256=iLjs4trg3Fj_uapLW1PAHgrtkVb2hiTPjRKOvO1vdaY,10782
@@ -83,6 +83,6 @@ codemie_sdk/services/workflow_execution_state.py,sha256=u1xmGvaHjqvQS5ujhyvJ_Ac7
83
83
  codemie_sdk/services/workspace.py,sha256=eLwZ0fhi1BfOesrXaQlTdOll8q7ENP9b_jb5eybKSVw,5038
84
84
  codemie_sdk/utils/__init__.py,sha256=EzK_UrS5KHmAnE73Hci9LaObB5omjVUhIq4svh0gfwo,137
85
85
  codemie_sdk/utils/http.py,sha256=PWejBKa5pwzQ5eLVhdN8lYKEu1B1QtwGTRmZfnGFL6c,14158
86
- codemie_sdk_python-0.1.711.dist-info/METADATA,sha256=C1ZfHmfSJCdtpKaxZQJRJRwV4mw59OLxo7AYDEr2tZw,49750
87
- codemie_sdk_python-0.1.711.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
88
- codemie_sdk_python-0.1.711.dist-info/RECORD,,
86
+ codemie_sdk_python-0.1.712.dist-info/METADATA,sha256=8sgXChkzMhIpoR8bkmFPo4GKkU-99cyeEEroOyxNHH8,51375
87
+ codemie_sdk_python-0.1.712.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
88
+ codemie_sdk_python-0.1.712.dist-info/RECORD,,
@@ -1,103 +0,0 @@
1
- # Copyright 2026 EPAM Systems, Inc. ("EPAM")
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- """ServiceNow integration models for the CodeMie SDK.
16
-
17
- The integration endpoints are callable only by the ServiceNow integration service account.
18
- The request model is deliberately permissive: the server owns the validation rules, so the
19
- SDK sends what the caller gives it and surfaces the server's verdict as an HTTP error.
20
- """
21
-
22
- from enum import Enum
23
-
24
- from pydantic import BaseModel, ConfigDict, Field
25
-
26
-
27
- class ServiceNowBudgetAction(str, Enum):
28
- """Budget action requested by ServiceNow."""
29
-
30
- SET = "set"
31
- ADJUST = "adjust"
32
- CANCEL = "cancel"
33
-
34
-
35
- class ServiceNowProject(BaseModel):
36
- """A shared project returned by the project lookup."""
37
-
38
- model_config = ConfigDict(extra="ignore")
39
-
40
- project_name: str
41
- display_name: str | None = None
42
-
43
-
44
- class ServiceNowBudgetRequest(BaseModel):
45
- """Request body for applying a ServiceNow budget request to a project.
46
-
47
- Attributes:
48
- action: ``set`` replaces the budget, ``adjust`` merges into it, ``cancel`` deletes it.
49
- request_id: ServiceNow request number, used for audit logs and new budget names.
50
- epam_project_code: EPAM project code; names the cost center when it differs from
51
- the CodeMie project name.
52
- codemie_project_name: CodeMie project to manage; the server defaults it to
53
- ``epam_project_code`` when omitted.
54
- admin_emails: People to make project admins (ignored by ``cancel``).
55
- amounts: Monthly budget in USD per category (``platform``, ``cli``,
56
- ``premium_models``); required for ``set`` and ``adjust``.
57
- """
58
-
59
- # Non-finite amounts are sent as the JSON constants NaN / Infinity instead of null,
60
- # so the server, not the client, rejects them.
61
- model_config = ConfigDict(ser_json_inf_nan="constants")
62
-
63
- action: ServiceNowBudgetAction
64
- request_id: str
65
- epam_project_code: str
66
- codemie_project_name: str | None = None
67
- admin_emails: list[str] = Field(default_factory=list)
68
- amounts: dict[str, float] | None = None
69
-
70
-
71
- class ServiceNowBudgetCategory(BaseModel):
72
- """Budget of one spend category in a budget response."""
73
-
74
- model_config = ConfigDict(extra="ignore")
75
-
76
- category: str
77
- max_budget: float
78
- soft_budget: float
79
- budget_reset_at: str | None = None
80
-
81
-
82
- class ServiceNowBudgetGroup(BaseModel):
83
- """Budget of a project after the request, with its categories in a fixed order."""
84
-
85
- model_config = ConfigDict(extra="ignore")
86
-
87
- total_amount: float
88
- budget_duration: str
89
- categories: list[ServiceNowBudgetCategory]
90
-
91
-
92
- class ServiceNowBudgetResponse(BaseModel):
93
- """Outcome of a budget request."""
94
-
95
- model_config = ConfigDict(extra="ignore")
96
-
97
- project_name: str
98
- cost_center: str | None = None
99
- created_project: bool
100
- created_cost_center: bool
101
- budget: ServiceNowBudgetGroup | None = None
102
- admins_assigned: list[str] = Field(default_factory=list)
103
- admins_pending: list[str] = Field(default_factory=list)
@@ -1,90 +0,0 @@
1
- # Copyright 2026 EPAM Systems, Inc. ("EPAM")
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- """ServiceNow integration service for the CodeMie SDK."""
16
-
17
- from ..models.servicenow_integration import (
18
- ServiceNowBudgetRequest,
19
- ServiceNowBudgetResponse,
20
- ServiceNowProject,
21
- )
22
- from ..utils.http import ApiRequestHandler, TokenSource
23
-
24
-
25
- class ServiceNowIntegrationService:
26
- """Service for the ServiceNow integration endpoints.
27
-
28
- Only the ServiceNow integration service account may call these endpoints; any other
29
- caller is rejected with HTTP 403.
30
- """
31
-
32
- def __init__(self, api_domain: str, token: TokenSource, verify_ssl: bool = True):
33
- """Initialize the ServiceNowIntegrationService.
34
-
35
- Args:
36
- api_domain: Base URL for the CodeMie API
37
- token: Authentication token
38
- verify_ssl: Whether to verify SSL certificates
39
- """
40
- self._api = ApiRequestHandler(api_domain, token, verify_ssl)
41
-
42
- def list_projects(self, emails: list[str]) -> list[ServiceNowProject]:
43
- """List the shared projects that any of the given users belong to.
44
-
45
- The result is the distinct union across all emails, ordered by project name.
46
- Emails with no active CodeMie user are skipped, and an empty list is returned
47
- when none match. The emails are sent as given; the server rejects an empty
48
- list or an invalid email with HTTP 422.
49
-
50
- Args:
51
- emails: Requester and approver emails
52
-
53
- Returns:
54
- List of ServiceNowProject with the project name and display name
55
-
56
- Raises:
57
- HTTPError: If the request fails
58
- """
59
- return self._api.get(
60
- "/v1/integrations/servicenow/projects",
61
- response_model=list[ServiceNowProject],
62
- params={"emails": emails},
63
- wrap_response=False,
64
- )
65
-
66
- def submit_budget_request(
67
- self, request: ServiceNowBudgetRequest
68
- ) -> ServiceNowBudgetResponse:
69
- """Apply a ServiceNow budget request to a project.
70
-
71
- ``set`` replaces the project budget, ``adjust`` merges into it and ``cancel``
72
- deletes it. The project (and its cost center) is created when it does not exist,
73
- and every resolvable ``admin_emails`` user becomes a project admin.
74
-
75
- Args:
76
- request: The budget request
77
-
78
- Returns:
79
- ServiceNowBudgetResponse with the resolved project, cost center, the budget
80
- after the request (None after cancel) and the admin assignment outcome
81
-
82
- Raises:
83
- HTTPError: If the request is rejected (400, 403, 404, 409 or 422)
84
- """
85
- return self._api.post(
86
- "/v1/integrations/servicenow/budgets",
87
- response_model=ServiceNowBudgetResponse,
88
- data=request.model_dump_json(exclude_none=True),
89
- wrap_response=False,
90
- )