ALM API Client
Bases: BaseAPIClient
Motion Asset Lifecycle Management (ALM) API Client.
It uses the CIAM API client as a base class to handle authentication.
So far it only supports the endpoints needed for the PM Kit maintenance plan.
Notes
There is a special method to get the PM Kit maintenance plan for an asset. It queries the asset details, recommended maintenance services and service events in parallel and then creates a PM Kit maintenance plan object from the data.
Source code in reportconnectors/api_client/alm/__init__.py
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 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 | |
is_logged
property
Checks if the client is logged in.
__init__(url, ciam_url, **kwargs)
Initializes the ALM API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
ALM API URL |
required |
ciam_url
|
str
|
CIAM API URL |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
timeout |
float
|
Timeout for the API requests. Default: |
proxies |
Dict[str, str]
|
Proxy settings. Default: |
cert_path |
Union[str, bool]
|
Path to the certificate file or |
Source code in reportconnectors/api_client/alm/__init__.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
authenticate(client_id, client_secret, password, username, **kwargs)
Authenticates the client.
Because the ALM service uses CIAM as an authentication provider, the validation of logged status is done through the CIAM API client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client_id
|
str
|
Client ID |
required |
client_secret
|
str
|
Client secret |
required |
password
|
str
|
User password |
required |
username
|
str
|
Username |
required |
Other Parameters:
| Name | Type | Description |
|---|---|---|
token_url |
str
|
Authentication token URL. If not provided, it is taken from the CIAM API client |
timeout |
float
|
Timeout for the authentication process. Default: |
Returns:
| Type | Description |
|---|---|
bool
|
True if the client is successfully authenticated and the access token is obtained and set. |
bool
|
Otherwise, it returns False. |
Source code in reportconnectors/api_client/alm/__init__.py
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 | |
get_asset_base_data(asset_id)
Gets the asset base data response for an asset identified by the serial number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
str
|
Asset serial number |
required |
Returns:
| Type | Description |
|---|---|
AlmAssetBaseData
|
Asset base data. |
Source code in reportconnectors/api_client/alm/__init__.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
get_asset_core_details(asset_id=None, serial_number=None, device_type=None, strict_mode=False)
Gets the asset core details for the asset identified by either asset_id or serial_number. If both asset_id and serial_number are provided, asset_id has priority.
If device_type is provided, it filters the results based on the device type.
Notes
This can be useful when there are multiple assets with the same serial number but different device types. For example, in case of MV drives, there is another asset (LV drive) with the same serial number. To filter out the LV drive, the device_type="MvDrive" parameter can be used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Optional[str]
|
Asset identifier in the ALM system |
None
|
serial_number
|
Optional[str]
|
Asset serial number |
None
|
device_type
|
Optional[AlmDeviceType]
|
Device type to filter the results (optional). |
None
|
strict_mode
|
bool
|
If True, then the device type must match exactly. Otherwise, if there is only one asset with the given serial number, it is returned regardless of the device type. Default: False |
False
|
Returns:
| Type | Description |
|---|---|
AlmCoreAssetData
|
Asset core details data. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither asset_id nor serial_number is provided |
ValueError
|
If the asset with the given parameters is not found |
ValueError
|
If multiple assets are found for the given parameters in strict mode |
Source code in reportconnectors/api_client/alm/__init__.py
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 | |
get_asset_details(asset_id)
Gets the asset details for the asset identified by the given asset_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
str
|
Asset identifier in the ALM system |
required |
Returns:
| Type | Description |
|---|---|
AlmAssetDetails
|
Asset details. |
Source code in reportconnectors/api_client/alm/__init__.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
get_asset_id_from_serial_number(serial_number, device_type=None, strict_mode=False)
Gets the ALM asset identifier from based on the asset serial number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
serial_number
|
str
|
Asset serial number |
required |
device_type
|
Optional[AlmDeviceType]
|
Device type to filter the results (optional). |
None
|
strict_mode
|
bool
|
If True, then the device type must match exactly. Otherwise, if there is only one asset with the given serial number, it is returned regardless of the device type. Default: False |
False
|
Notes
Filtering by device type can be useful for MV Drives, where there are multiple assets with the same serial number but different device types. To filter out the LV drive, the device_type="MvDrive" parameter can be used.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
ALM asset identifier. |
Source code in reportconnectors/api_client/alm/__init__.py
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 | |
get_pm_kit_maintenance_plan(serial_number=None, asset_id=None, device_type=None)
Gets the PM Kit maintenance plan for the asset with the given serial number.
It queries the asset details, recommended maintenance services and service events in parallel and then creates a PM Kit maintenance plan object from the data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
serial_number
|
Optional[str]
|
Asset serial number |
None
|
asset_id
|
Optional[str]
|
Asset identifier in the ALM system. |
None
|
device_type
|
Optional[AlmDeviceType]
|
Device type to filter the results (optional). When dealing with MV drives, it is recommended to set this parameter to AlmDeviceType.MV_DRIVE to avoid getting the LV drive data. |
None
|
Returns:
| Type | Description |
|---|---|
PmKitMaintenancePlan
|
PM Kit maintenance plan. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the asset ID is missing for the asset with the given serial number |
Source code in reportconnectors/api_client/alm/__init__.py
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 | |
get_recommended_maintenance_service(asset_id)
Gets the recommended maintenance service data for the asset identified by the given asset_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
str
|
Asset identifier in the ALM system |
required |
Returns:
| Type | Description |
|---|---|
List[AlmRecommendedService]
|
Recommended maintenance service data. |
Source code in reportconnectors/api_client/alm/__init__.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
get_service_events(asset_id)
Gets the service events for the asset identified by the given asset_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
str
|
Asset identifier in the ALM system |
required |
Returns:
| Type | Description |
|---|---|
List[AlmServiceEvent]
|
List of service events. |
Source code in reportconnectors/api_client/alm/__init__.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |