intersight-rest
Cisco has released their new Intersight platform for managing UCS Server and Hyperflex Hyperconverged infrastructure from a SaaS based interface. With high security standards, forming and signing the RESTful API calls to Intersight can be a challenge, so this package was written to do all of that work for you. All you need to provide is your Public/Private keys generated from the Intersight interface, as well at the API endpoint you'd like to target. Optionally you can add in query parameters for GET requests, and a body for POST/PATCH opterations.
Overview:
intersight_call(**options);
| Option | Format | Value |
|---|---|---|
| http_method | <String> | HTTP Verb [ GET | POST | PATCH | DELETE ] |
| resource_path | <String> | Resource Path from https://intersight.com/apidocs |
| query_params | <Dict> | Query Parameters from Resource Path GET |
| body | <Dict> | Body Parameters from Resource Path POST |
| moid | <String> | MOID of Object to be Modified |
| name | <String> | Name of Object to be Modified (See Notes) |
| proxy | <String> | Proxy Server Address [ proto://<address>:<port> ] |
1 name will be ignored if moid is set.
2 name is case sensitive.
More information about Intersight is available at: https://intersight.com
Details on the RESTful API and documentation: https://intersight.com/apidocs
PIP Installation:
$ pip install intersight-rest
Usage:
# Import "intersight_rest" Package
import intersight_rest as isREST
# Import JSON Package
import json
# Load Public/Private Keys
isREST.set_private_key(open("./keys/private_key.pem", "r") .read())
isREST.set_public_key(open("./keys/public_key.txt", "r") .read())
# Select Resource Path from https://www.intersight.com/apidocs
resource_path = '/ntp/Policies'
# GET EXAMPLE
#-- Set GET Options --#
options = {
"http_method": "get",
"resource_path": resource_path,
"query_params": query_params
}
#-- Send GET Request --#
results = isREST.intersight_call(**options)
print("Status Code: " + str(results.status_code))
print(json.dumps(results.json(), indent=4))
#-- NOTE: intersight_call Returns a "requests.Response" Object --#
# GET "query_params" Examples
#-- Example query_params returning the top 1 result(s) --#
query_params = {
"$top": 1
}
#-- Example query_params showing filter by "Name" key --#
query_params = {
"$filter": "Name eq 'Test-NTP'"
}
#-- Example query_params showing filter by "Description" key --#
query_params = {
"$filter": "Description eq 'pool.ntp.org'"
}
#-- Example query_params showing advanced Tag filder by key & value --#
query_params = {
"$filter": "Tags/any(t: t/Key eq 'loc' and t/Value eq 'California')"
}
# POST EXAMPLE
#-- Assemble POST Body --#
post_body = {
"Name": "Test-NTP",
"Description": "Test NTP Policy",
"NtpServers": ["8.8.8.8"]
}
#-- Set POST Options --#
options = {
"http_method": "post",
"resource_path": resource_path,
"body": post_body
}
#-- Send POST Request --#
results = isREST.intersight_call(**options)
print("Status Code: " + str(results.status_code))
print(json.dumps(results.json(), indent=4))
#-- NOTE: intersight_call Returns a "requests.Response" Object --#
# PATCH EXAMPLE
#-- Assemble PATCH Body --#
patch_body = {
"NtpServers": ["10.10.10.10"]
}
#-- Option #1: PATCH by Object MOID --#
#-- Set Object MOID to be Modified --#
patch_moid = "6b1727fa686c873463b8163e"
#-- Set PATCH Options --#
options = {
"http_method": "patch",
"resource_path": resource_path,
"body": patch_body,
"moid": patch_moid
}
#-- Option #2: PATCH by Object NAME --#
#-- Set Object NAME to be Modified --#
patch_name = "Test-NTP"
#-- Set PATCH Options --#
options = {
"http_method": "patch",
"resource_path": resource_path,
"body": patch_body,
"name": patch_name
}
#-- Send PATCH Request --#
results = isREST.intersight_call(**options)
print("Status Code: " + str(results.status_code))
print(json.dumps(results.json(), indent=4))
#-- NOTE: intersight_call Returns a "requests.Response" Object --#
# DELETE EXAMPLE
#-- Option #1: DELETE by Object MOID --#
#-- Set Object MOID to be Deleted --#
delete_moid = "6b1727fa686c873463b8163e"
#-- Set DELETE Options --#
options = {
"http_method": "delete",
"moid": delete_moid
}
#-- Option #2: DELETE by Object Name --#
#-- Set Object NAME to be Deleted --#
delete_name = "Test-NTP"
#-- Set DELETE Options --#
options = {
"http_method": "delete",
"name": delete_name
}
#-- Send DELETE Request --#
results = isREST.intersight_call(**options)
print("Status Code: " + str(results.status_code))
#-- NOTE: intersight_call Returns a "requests.Response" Object --#
See package source for more details...
*Copyright (c) 2018 Cisco and/or its affiliates.
Metadata
Release files for intersight-rest 1.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| intersight-rest-1.1.7.tar.gz | 6.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| intersight_rest-1.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.8 kB
Release files / intersight-rest-1.1.7.tar.gz
| Download URL | intersight-rest-1.1.7.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ff12c647bc5616a83406ba6deba6cc2f3be2f8396f274267a0651925b197171
|
|
BLAKE2b-256 checksum How to use checksums |
bfe366e74f7e33ef7eadb80566b1a8aebd9b8e18891f3c18b8978d996063cdb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.2
|
Release files / intersight_rest-1.1.7-py3-none-any.whl
| Download URL | intersight_rest-1.1.7-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c285875b7e7757ee90448f7fa64a145fbdcea081f2410b1b640ee15065ad38da
|
|
BLAKE2b-256 checksum How to use checksums |
4a3fc514bc43427283559e5e5d937a6138ac7c1253253472c2adc43e118a0dd8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.2
|
Security for intersight-rest 1.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.