GLP¶
The GLP module provides interfaces for device, subscription, and user management through the HPE GreenLake Platform
Devices¶
devices
¶
Devices
¶
Bases: object
get_all_devices(conn, select=None)
¶
Get a list of devices managed in a workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
select
|
list
|
A comma separated list of select properties to display in the response. The default is that all properties are returned. Example: select=serialNumber,macAddress |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
A list of all devices in the workspace, or an empty list if an error occurs |
Source code in pycentral/glp/devices.py
get_device(conn, limit=DEVICE_GET_LIMIT, offset=0, filter=None, select=None, sort=None)
¶
Get a list of devices managed in a GLP workspace from filter/select and sort inputs.
Rate limits are enforced on this API. 160 requests per minute is supported per workspace. API will result in 429 if this threshold is breached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
limit
|
int
|
Specifies the number of results to be returned. The default value is 2000 |
DEVICE_GET_LIMIT
|
offset
|
int
|
Specifies the zero-based resource offset to start the response from. The default value is 0 |
0
|
filter
|
str
|
Device filters joined by logical operators |
None
|
select
|
list
|
Properties of devices to be displayed in response |
None
|
sort
|
str
|
Sort string expressions |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Response as provided by 'command' function in NewCentralBase |
Source code in pycentral/glp/devices.py
get_device_id(conn, serial)
¶
Get device ID in a GLP workspace based on serial number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
serial
|
str
|
Device serial number |
required |
Returns:
| Type | Description |
|---|---|
tuple(bool, str)
|
Tuple of two elements. First element returns True if device id is found, else False. The second element is a GLP device ID if found, else an error message from the response |
Source code in pycentral/glp/devices.py
get_status(conn, id)
¶
Get status of an async GLP devices request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
id
|
str
|
Transaction ID from async API request |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Response as provided by 'command' function in NewCentralBase |
Source code in pycentral/glp/devices.py
add_devices(conn, network=[], compute=[], storage=[])
¶
Add devices to a workspace in GreenLake Platform (GLP).
Handles coordinating chaining requests if passed more than 5 devices (max per api call). Can use any combination of network, compute, and storage devices. Always returns a 202 response code if basic input validation is met. Currently does not support Async get status handling to confirm operation success.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
network
|
list
|
Network devices as dict objects |
[]
|
compute
|
list
|
Compute devices as dict objects |
[]
|
storage
|
list
|
Storage devices as dict objects |
[]
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of response objects as provided by 'command' function in NewCentralBase |
Source code in pycentral/glp/devices.py
__add_dev(conn, type, inputs)
¶
Helper function for add_devices.
Handles splitting inputs larger than input size and coordinates running the commands to not exceed rate limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
type
|
str
|
One of network, compute, or storage |
required |
inputs
|
list
|
List of 'type' objects in dict format |
required |
Returns:
| Type | Description |
|---|---|
list[dict]
|
Response object(s) as provided by 'command' function in NewCentralBase |
Source code in pycentral/glp/devices.py
add_sub(conn, devices, sub, serial=False, key=False)
¶
Add subscription to device(s).
API endpoint supports five devices per request. Handles chaining multiple requests for greater than five devices supplied. An additional response dict object will be appended to the return list for each additional request required to handle the number of input devices passed to the function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
devices
|
list
|
List of device id(s) or serial numbers |
required |
sub
|
str
|
Subscription id or key |
required |
serial
|
bool
|
Flag to use device serial numbers, default is False |
False
|
key
|
bool
|
Flag to use subscription key, default is False |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of API response objects as provided by 'command' function in NewCentralBase |
Source code in pycentral/glp/devices.py
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 | |
remove_sub(conn, devices, serial=False)
¶
Remove a subscription from a device.
API endpoint supports five devices per request. Handles chaining multiple requests for greater than five devices supplied. An additional response dict object will be appended to the return list for each additional request required to handle the number of input devices passed to the function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
devices
|
list
|
List of device id(s) or serial numbers |
required |
serial
|
bool
|
Flag to use device serial numbers, default is False |
False
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of API response objects as provided by 'command' function in NewCentralBase |
Source code in pycentral/glp/devices.py
assign_devices(conn, devices=None, application=None, region=None, serial=False)
¶
Assign devices to an application by passing one or more device id(s) or serial numbers.
Currently supports assigning and un-assigning devices to and from an application or applying/removing subscriptions to/from devices. Rate limits are enforced on this API. Five requests per minute is supported per workspace. API will result in 429 if this threshold is breached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
devices
|
list
|
List of device id(s) or serial numbers |
None
|
application
|
str
|
Application id |
None
|
region
|
str
|
AHE region of the application the device is provisioned in |
None
|
serial
|
bool
|
Flag to use device serial numbers, default is False |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
API response |
Source code in pycentral/glp/devices.py
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 | |
unassign_devices(conn, devices=None, serial=False)
¶
Unassign devices from an application by passing one or more device id(s) or serial numbers.
Currently supports assigning and un-assigning devices to and from an application or applying/removing subscriptions to/from devices. Rate limits are enforced on this API. Five requests per minute is supported per workspace. API will result in 429 if this threshold is breached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
devices
|
list
|
List of device id(s) or serial numbers |
None
|
serial
|
bool
|
Flag to use device serial numbers, default is False |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
API response |
Source code in pycentral/glp/devices.py
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 | |
Service Manager¶
service_manager
¶
ServiceManager
¶
Bases: object
get_application_id_and_region(conn, application_name, region)
¶
Retrieve the application ID and API region name for a specified application and region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
application_name
|
str
|
name of the application to search for. |
required |
region
|
str
|
The region (UI name) where the application is deployed. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary containing the application ID and API region name if found, otherwise None. |
Source code in pycentral/glp/service_manager.py
get_service_manager_provisions(conn, limit=2000, offset=0)
¶
Retrieve all provisioned services in GLP workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
limit
|
int
|
Specify the maximum number of entries per page. Maximum value accepted is 2000. |
2000
|
offset
|
int
|
Specify pagination offset. Defines how many pages to skip before returning results. Default is 0. |
0
|
Returns:
| Type | Description |
|---|---|
dict
|
API response containing provisioned services. |
Source code in pycentral/glp/service_manager.py
get_service_manager_by_region(conn)
¶
Get the region mapping for the service manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
Returns:
| Type | Description |
|---|---|
dict
|
API response containing service managers by region. |
Source code in pycentral/glp/service_manager.py
get_service_managers(conn, limit=2000, offset=0)
¶
Retrieve all available service managers in GLP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object |
required |
limit (int, optional): Specify the maximum number of entries per page. Maximum value accepted is 2000. offset (int, optional): Specify pagination offset. Defines how many pages to skip before returning results.
Returns:
| Type | Description |
|---|---|
dict
|
API response containing service managers. |
Source code in pycentral/glp/service_manager.py
Subscriptions¶
subscriptions
¶
Subscriptions
¶
Bases: object
get_all_subscriptions(conn, select=None)
¶
Get all subscriptions managed in a workspace.
API will result in 429 if this threshold is breached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object. |
required |
select
|
list
|
A comma separated list of select properties to return in the response. By default, all properties are returned. Example: select=id,key |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
A list of all subscriptions in the workspace, or an empty list if an error occurs. |
Source code in pycentral/glp/subscriptions.py
get_subscription(conn, filter=None, select=None, sort=None, limit=SUB_GET_LIMIT, offset=0)
¶
Get a subscription managed in a workspace.
Rate limits are enforced on this API. 60 requests per minute is supported per workspace. API will result in 429 if this threshold is breached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object. |
required |
filter
|
str
|
Filter expressions consisting of simple comparison operations joined by logical operators. Example: filter=key eq 'MHNBAP0001' and key in 'PAYHAH3YJE6THY, E91A7FDFE04D44C339' |
None
|
select
|
list
|
A comma separated list of select properties to return in the response. By default, all properties are returned. Example: select=id,key |
None
|
sort
|
str
|
A comma separated list of sort expressions. A sort expression is a property name optionally followed by a direction indicator asc or desc. Default is ascending order. Example: sort=key, quote desc |
None
|
limit
|
int
|
Specifies the number of results to be returned. Default is 50. Range: 1-50. |
SUB_GET_LIMIT
|
offset
|
int
|
Specifies the zero-based resource offset to start the response from. Default is 0. |
0
|
Returns:
| Type | Description |
|---|---|
dict
|
API response containing subscriptions. |
Source code in pycentral/glp/subscriptions.py
get_sub_id(conn, key)
¶
Get subscription ID in a GLP workspace based on subscription key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object. |
required |
key
|
str
|
Subscription key. |
required |
Returns:
| Type | Description |
|---|---|
tuple(bool, str)
|
Tuple of two elements. First element returns True if subscription ID is found, else False. The second element is a GLP subscription ID if found, else an error message. |
Source code in pycentral/glp/subscriptions.py
get_status(conn, id)
¶
Get status of an async GLP subscription request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object. |
required |
id
|
str
|
Transaction ID from async API request. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Response as provided by 'command' function in NewCentralBase. |
Source code in pycentral/glp/subscriptions.py
add_subscription(conn, subscriptions=None, limit=0, offset=0)
¶
Add one or more subscriptions to a workspace.
This API provides an asynchronous response and will always return "202 Accepted" if basic input validations are successful. The location header in the response provides the URI to be invoked for fetching progress of the subscription addition task. For details about the status fetch URL, refer to the API Get progress or status of async operations in subscriptions. Rate limits are enforced on this API. 4 requests per minute is supported per workspace. API will result in 429 if this threshold is breached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object. |
required |
subscriptions
|
list
|
List of subscription key objects. Example: [{"key": "string"}] |
None
|
limit
|
int
|
Specifies the number of results to be returned. Default is 0. Range: 1-50. |
0
|
offset
|
int
|
Specifies the zero-based resource offset to start the response from. |
0
|
Returns:
| Type | Description |
|---|---|
dict
|
API response from the add subscription operation. |
Source code in pycentral/glp/subscriptions.py
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 | |
User Management¶
user_management
¶
UserMgmt
¶
Bases: object
get_users(conn, filter=None, limit=300, offset=0)
¶
Retrieve users that match given filters.
All users are returned when no filters are provided. The Get users API can be filtered by: id, username, userStatus, createdAt, updatedAt, lastLogin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object. |
required |
filter
|
str
|
Filter data using a subset of OData 4.0 and return only the subset of resources that match the filter. Examples:
|
None
|
limit
|
int
|
Specify the maximum number of entries per page. Maximum value accepted is 300. Range: 1-300. |
300
|
offset
|
int
|
Specify pagination offset. Defines how many pages to skip before returning results. |
0
|
Returns:
| Type | Description |
|---|---|
dict
|
API response containing users. |
Source code in pycentral/glp/user_management.py
get_user(conn, email=None, id=None)
¶
Get a user from a workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object. |
required |
email
|
str
|
Account username (email address). |
None
|
id
|
str
|
Target user ID. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Response as provided by 'command' function in NewCentralBase. |
Source code in pycentral/glp/user_management.py
get_user_id(conn, email)
¶
Get user ID in a GLP workspace by email.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object. |
required |
email
|
str
|
Account username (email address). |
required |
Returns:
| Type | Description |
|---|---|
tuple(bool, str)
|
Tuple of two elements. First element returns True if user ID is found, else False. The second element is a GLP user ID if found, else an error message. |
Source code in pycentral/glp/user_management.py
delete_user(conn, email=None, user_id=None)
¶
Delete a user from a workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object. |
required |
email
|
str
|
Account username (email address). |
None
|
user_id
|
str
|
Target user ID. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
API response from the delete operation. |
Source code in pycentral/glp/user_management.py
inv_user(conn, email, send_link)
¶
Invite a user to a GLP workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
NewCentralBase
|
pycentral base connection object. |
required |
email
|
str
|
Email address of the user to invite. |
required |
send_link
|
bool
|
Set to True to send welcome email. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Response as provided by 'command' function in NewCentralBase. |