Powertrain File Service API Client
Bases: BasePowertrainAPIClient
Powertrain FileService API Client.
Source code in reportconnectors/api_client/powertrain/file_service/__init__.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 | |
download_raw_data_file(file_id)
Downloads the raw data file content for the given file_id.
It uses the /Files/{file_id}/Download endpoint to download the file content.
Downloaded data is a base64 encoded string that is decoded to the original file content (CSV) and name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_id
|
int
|
Raw data file identifier |
required |
Returns:
| Type | Description |
|---|---|
CsvRawDataFile
|
CsvFile object with raw data file content and name. |
Source code in reportconnectors/api_client/powertrain/file_service/__init__.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
download_raw_data_from_url(url, file_name=None)
Downloads the raw data file content directly from provided URL.
The URL is a part of 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 |
|---|---|
CsvRawDataFile
|
CsvFile object with raw data file content and name. |
Source code in reportconnectors/api_client/powertrain/file_service/__init__.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
get_raw_data_files_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 provided the 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 |
|---|---|
RawDataFilesAttributesResponse
|
Response object that list the attributes of found raw data files. |
Source code in reportconnectors/api_client/powertrain/file_service/__init__.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |