Powertrain Report API Client
The Powertrain Report API Client is a Python client designed to interact with the Powertrain Report API. This client is built on top of the base Powertrain API client, which provides methods to manage authentication and other common tasks.
The Powertrain Report API Client provides methods to access all available endpoints in the Report API. This API is a collection of endpoints from other microservices that provide all data related to analytics and reporting.
The Report API should be the only one you need to interact with to get all the data you need for analytics and reporting related activities.
Bases: BasePowertrainAPIClient
Powertrain Report API Client.
Source code in reportconnectors/api_client/powertrain/report/__init__.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 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 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | |
download_file_from_url(url, file_name=None)
Downloads the raw data file content directly from the provided URL.
The URL is a part of the response from the get_raw_data_files_attributes method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL to download the raw data file content. |
required |
file_name
|
Optional[str]
|
Optional file name to use for the downloaded file. If not provided, the file name from the URL is used. |
None
|
Returns:
| Type | Description |
|---|---|
FileRawData
|
CsvFile object with the raw data file content and name. |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | |
get_aggregated_timeseries_results(asset_id, start_date, end_date, symbolic_name)
Gets the list of aggregated timeseries for given asset id and time range.
The aggregation resolution depends on the requested time range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
int
|
Asset identifier |
required |
start_date
|
DateType
|
Start Date |
required |
end_date
|
DateType
|
End |
required |
symbolic_name
|
Union[str, List[str]]
|
List of symbolic names or a single symbolic name. |
required |
Returns:
| Type | Description |
|---|---|
ListOfTimeseriesAggregatedResults
|
List of aggregated timeseries. |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
get_analytic_algorithm_results(asset_id, start_date, end_date, algorithm_name, use_all_retentions=False)
Gets the algorithm(s) results for a given asset in the provided time range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
int
|
Asset identifier |
required |
start_date
|
DateType
|
Start Date |
required |
end_date
|
DateType
|
End Date |
required |
algorithm_name
|
Union[str, Sequence[str]]
|
Name of the algorithm, as given in type definitions. It might be a single name, or collection of names. |
required |
use_all_retentions
|
bool
|
If True, it will return all data for the algorithm, otherwise only the results. It can be used to get the latest CI model in the response. |
False
|
Returns:
| Type | Description |
|---|---|
AnalyticsAlgorithmResults
|
Algorithm results data model. |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
get_analytic_algorithms_overview(asset_id, start_date, end_date)
Gets the overview list of analytics algorithms for the given asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
int
|
Asset ID |
required |
start_date
|
DateType
|
Start date |
required |
end_date
|
DateType
|
End date |
required |
Returns:
| Type | Description |
|---|---|
AnalyticsAlgorithmsOverview
|
Analytics Algorithm overview |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
get_asset_details(asset_id)
Get asset details which include master data and asset properties
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Union[int, List[int]]
|
Asset ID or list of Asset IDs. |
required |
Returns:
List of ReportAssetDetail objects
Source code in reportconnectors/api_client/powertrain/report/__init__.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
get_asset_group(name_filter='', site_ids=None, organizations_ids=None, asset_group_ids=None, countries=None, country_codes=None, fleets_only=False, include_assets=False, refresh_data=False)
Gets the asset group list based on the provided filters. Args: name_filter: Filter asset groups by their name. site_ids: List of site IDs to filter by. organizations_ids: List of organization IDs to filter by. asset_group_ids: List of asset group IDs to filter by. countries: List of country names to filter by. country_codes: List of country codes to filter by. fleets_only: If True, only fleets are returned. include_assets: If True, assets are included in the response. refresh_data: If True, it gets data from external sources and updates it in the pt api Returns: ListReportAssetGroups
Source code in reportconnectors/api_client/powertrain/report/__init__.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | |
get_assets_structure(asset_ids)
Gets organization structure for a list of assets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_ids
|
List[int]
|
List of asset IDs |
required |
Returns:
| Type | Description |
|---|---|
ListOfOrganizationAssetStructure
|
Response with a list of ReportAssetStructure objects |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
get_bearing_info(bearing, manufacturer=None)
Gets the bearing info based on the provided bearing type and optional manufacturer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bearing
|
str
|
Bearing identifier |
required |
manufacturer
|
Optional[str]
|
Manufacturer name. If not provided, then the all matching results are returned. |
None
|
Returns:
| Type | Description |
|---|---|
ListOfBearingInfos
|
List of matching bearing info data |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
get_capabilities(asset_id, capability_code, organization_id=None, check_subscription=False)
Gets the list of capabilities for specified assets and organization
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
organization_id
|
Optional[int]
|
Organization Identifier |
None
|
asset_id
|
Union[List[int], int]
|
Asset identifier or list of asset identifiers. |
required |
capability_code
|
Union[str, List[str]]
|
Capability code or list of capability codes to filter by |
required |
check_subscription
|
bool
|
If True, it will check if the user has a subscription for the capability. |
False
|
Source code in reportconnectors/api_client/powertrain/report/__init__.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
get_condition_index_results(asset_id, start_date, end_date)
Gets the condition index results for a given asset in the provided timerange.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
int
|
Asset identifier |
required |
start_date
|
DateType
|
Start Date |
required |
end_date
|
DateType
|
End Date |
required |
Returns:
| Type | Description |
|---|---|
AnalyticsConditionDetails
|
List of ConditionDetails results |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | |
get_event_comments(event_id)
Gets the event-related comments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_id
|
int
|
Identifier of the event |
required |
Returns:
| Type | Description |
|---|---|
ListOfEventComments
|
Asset properties. |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | |
get_file_attributes(asset_id, start_date, end_date)
Gets the list of raw data file attributes that describe the raw data files available for a given asset(s) in the provided time range.
It uses the /Report/Asset/RawData endpoint for the requested asset_id and time range.
The returned raw data file objects don't contain the file content, but only the download URL.
If you want to download the file content, you have two options:
- Run the
.get_file()method on theRawDataFileAttributesresponse element. - Use the client method
.download_raw_data_file(file_id)to get the file content and name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Union[int, List[int]]
|
Asset identifier or list of asset identifiers |
required |
start_date
|
DateType
|
Start Date |
required |
end_date
|
DateType
|
End Date |
required |
Returns:
| Type | Description |
|---|---|
ListOfFileAttributes
|
Response object that contains the list of the found raw data files attributes. |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | |
get_full_timeseries_results(asset_id, start_date, end_date, symbolic_name)
Gets the list of raw timeseries for given asset id and time range.
Note
Maximum timerange you can ask for in a single request depends on the asset type. It's 30 days for SmartSensor assets, and 1 day for Drive assets. If you want to overcome that, it has to be done above this client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
int
|
Asset identifier |
required |
start_date
|
DateType
|
Start Date |
required |
end_date
|
DateType
|
End |
required |
symbolic_name
|
Union[str, List[str]]
|
List of symbolic names or a single symbolic name. |
required |
Returns:
| Type | Description |
|---|---|
ListOfTimeseriesFullResults
|
List of aggregated timeseries. |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
get_sensor_details(sensor_id)
Gets the sensor details based on the provided sensor identifier(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sensor_id
|
Union[int, List[int]]
|
Sensor identifier or list of sensor identifiers. |
required |
Returns:
| Type | Description |
|---|---|
ListOfSensorDetails
|
List of the Sensor Details |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | |
get_timeseries_config(asset_id)
Gets the timeseries config for a given asset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
int
|
Asset ID |
required |
Returns:
| Type | Description |
|---|---|
ListOfTimeseriesConfigs
|
Timeseries config |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
get_unit_conversions()
Gets all unit conversion data in a single response.
Returns:
| Type | Description |
|---|---|
ListOfUnitConversions
|
All unit conversion data in a single response. |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
437 438 439 440 441 442 443 444 445 446 447 448 | |
search_for_assets(page_number=1, page_size=1000, refresh_data=False, name_filter='', organization_id=None, site_id=None, asset_type=None)
Gets all assets of the organizations and/or sites the user has access to. At least an organization or site must be specified. If both are specified, then the superset is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
refresh_data
|
bool
|
If True, it gets data from external sources and updates it in the Organization microservice database. Default is False. |
False
|
page_number
|
int
|
Page number of the paged results starting from 1. Default 1 |
1
|
page_size
|
int
|
Page size of the paged results. Default 1000 |
1000
|
organization_id
|
Union[int, List[int], None]
|
Organization ID or list of organization IDs for the query. |
None
|
site_id
|
Union[int, List[int], None]
|
Site ID or list of site IDs for the query. |
None
|
asset_type
|
Union[str, List[str], None]
|
Asset Type or list of asset types for the query. |
None
|
name_filter
|
str
|
Filter assets by their name, asset serial number. |
''
|
Returns:
| Type | Description |
|---|---|
ListOfOrganizationAssetDetails
|
ReportAssetSearch results |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
search_for_events(asset_id, start_date, end_date, use_cursor=False, page_size=100, **kwargs)
Returns the events for the given asset ids and date range.
It's based on the Event/Search endpoint.
It also allows filtering events by severity, status, cause, existence of comments, binary logger, data loggers, parameter backup, and message text.
Results are paginated with a default page size of 100.
However, if you set use_cursor=True, it will fetch all the events,
by using the cursor returned in the response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Union[int, Sequence[int]]
|
Asset identifier or list of asset identifiers. |
required |
start_date
|
DateType
|
Start date of the search. |
required |
end_date
|
DateType
|
End date of the search. |
required |
use_cursor
|
bool
|
If True, it will fetch all the events using the cursor returned in the response. Otherwise,
it will fetch only the first page with the results. Default: |
False
|
page_size
|
int
|
Number of events per page. Default: |
100
|
Other Parameters:
| Name | Type | Description |
|---|---|---|
severity_codes |
List[str]
|
List of severity codes to filter the events |
status_codes |
List[str]
|
List of status codes to filter the events |
cause_codes |
List[str]
|
List of cause codes to filter the events |
has_comments |
bool
|
If True, it will filter the events that have comments |
has_binary_logger |
bool
|
If True, it will filter the events that have binary logger |
has_data_loggers |
bool
|
If True, it will filter the events that have data loggers |
has_parameter_backup |
bool
|
If True, it will filter the events that have parameter backup |
message_text_contains |
str
|
Text to search in the message text |
cursor |
str
|
Cursor that points to a specific results page |
Returns:
| Type | Description |
|---|---|
EventsResponse
|
EventSearchResponse object with the list of events and the next cursor. |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | |
search_for_organizations(refresh_data=False, page_number=1, page_size=1000, name_filter='', only_favorites=False)
Gets all organizations matching the specified filter that the user has access to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
refresh_data
|
bool
|
If True, it gets data from external sources and updates it in the Organization microservice database. Default is False. |
False
|
page_number
|
int
|
Page number of the paged results starting from 1. Default 1 |
1
|
page_size
|
int
|
Page size of the paged results. Default 1000 |
1000
|
name_filter
|
str
|
Filter organizations by their name. |
''
|
only_favorites
|
bool
|
If True, only favorites are returned. |
False
|
Returns:
| Type | Description |
|---|---|
ListOfOrganizationDetails
|
ReportOrganizationSearch results |
Source code in reportconnectors/api_client/powertrain/report/__init__.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
search_for_sites(organization_id, refresh_data=False, page_number=1, page_size=1000)
Get all sites for the specified organizations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
refresh_data
|
bool
|
If True, it gets data from external sources and updates it in the Organization microservice database. Default is False. |
False
|
page_number
|
int
|
Page number of the paged results starting from 1. Default 1 |
1
|
page_size
|
int
|
Page size of the paged results. Default 1000 |
1000
|
organization_id
|
Union[int, List[int]]
|
Organization ID or list of organization IDs. |
required |
Returns: ListOfReportSites
Source code in reportconnectors/api_client/powertrain/report/__init__.py
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 | |