COMcheckClient¶
The primary interface for interacting with the COMcheck Web API.
COMcheckClient
¶
High-level client for the COMcheck Web API.
Provides user-friendly methods that accept Pydantic models as inputs
and return either :class:~comcheck_api.types.core_types.ComBuilding
models, primitives, or raw dicts depending on the operation.
Can be used as a context manager to ensure the underlying HTTP connection is closed::
with COMcheckClient(api_key="your-key") as client:
project = client.get_project("123")
Example
Initialize COMcheck client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
Optional[str]
|
Optional API key for authentication. Can be set later with set_api_key() |
None
|
Source code in comcheck_api/client/comcheck_client.py
set_api_key
¶
Set the API key and initialize the API service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_key
|
str
|
API key for authentication |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If API key is not provided |
Source code in comcheck_api/client/comcheck_client.py
get_project
¶
Fetch a single project by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_id
|
str
|
The project ID to retrieve. |
required |
mode
|
Literal['python', 'json']
|
|
'python'
|
Returns:
| Type | Description |
|---|---|
Optional[Union[ComBuilding, Dict[str, Any]]]
|
The project as a |
Source code in comcheck_api/client/comcheck_client.py
list_projects
¶
Get a list of all projects.
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
API response data as list of project dictionaries |
update_project
¶
Update a project by ID.
The existing project is fetched first to preserve server-assigned IDs
and the userProject reference. Envelope component IDs that are
None (auto-generated by Pydantic) are stripped before submission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_id
|
str
|
The project ID to update. |
required |
project_data
|
ComBuilding
|
A |
required |
mode
|
Literal['python', 'json']
|
|
'python'
|
Returns:
| Type | Description |
|---|---|
ComBuilding | dict[str, Any] | None
|
The refreshed project after the update, in the requested format. |
Raises:
| Type | Description |
|---|---|
COMCheckProjectNotFoundError
|
If the project does not exist. |
Source code in comcheck_api/client/comcheck_client.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | |
start_run_simulation
¶
Start a compliance simulation run for a project.
If project_id is supplied the project is persisted via
:meth:update_project before the simulation is launched.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
ComBuilding
|
The project data to simulate. |
required |
project_id
|
Optional[int]
|
Optional server-side project ID. When given, the project is saved before the simulation starts. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
The simulation session ID that can be passed to |
str
|
meth: |
Raises:
| Type | Description |
|---|---|
COMCheckSimulationError
|
If the API returns no session data. |
Source code in comcheck_api/client/comcheck_client.py
get_simulation_status
¶
Get the status of a running or completed simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
str
|
The session ID returned by :meth: |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A dict containing |
Dict[str, Any]
|
|
Dict[str, Any]
|
class: |
Dict[str, Any]
|
values are |
Raises:
| Type | Description |
|---|---|
COMCheckSimulationError
|
If the status cannot be retrieved. |
Source code in comcheck_api/client/comcheck_client.py
get_simulation_result
¶
Get the result metrics of a completed simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
str
|
The session ID returned by :meth: |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
A dict containing |
Dict[str, Any]
|
|
Dict[str, Any]
|
|
Raises:
| Type | Description |
|---|---|
COMCheckSimulationError
|
If the result cannot be retrieved. |