06-14-2019 09:57 AM - edited 07-31-2019 09:54 AM
The Cisco Intersight Universal API Calls module for Python provides a set of functions that simplify creation, retrieval, modification, and deletion of resources on Cisco Intersight. Any available API types listed in the Cisco Intersight API Reference library can be accessed, including those which do not yet have a specific module in the Intersight SDK for Python.
The Cisco Intersight Universal API Calls module can be found on the Cisco DevNet Code Exchange here or directly from GitHub at https://github.com/ugo-emekauwa/intersight-universal-api-calls.
pip install git+https://github.com/CiscoUcs/intersight-python.git
key_id = "5c89885075646127773ec143/5c82fc477577712d3088eb2f/5c8987b17577712d302eaaff"
key = "C:\\Keys\\Key1\\SecretKey.txt"
The Cisco Intersight Universal API Calls module contains six functions for creating, retrieving, modifying, and deleting resources. The following is a list of the functions and sample commands for each:
iu_get() - Performs a universal or generic GET on objects under any available Intersight API type.
adapters = "adapter/ConfigPolicies"
iu_get(adapters)
iu_get_moid() - Performs a universal or generic GET on a specified object under any available Intersight API type.
adapters = "adapter/ConfigPolicies"
adapter1_moid = "5c8987b17564777d30212345"
iu_get_moid(adapters,adapter1_moid)
iu_delete_moid() - Performs a universal or generic DELETE on a specified object under any available Intersight API type.
adapters = "adapter/ConfigPolicies"
adapter1_moid = "5c8987b17564777d30212345"
iu_delete_moid(adapters,adapter1_moid)
iu_post() - Performs a universal or generic POST of an object under any available Intersight API type.
adapters = "adapter/ConfigPolicies"
adapter2_body = {
'Name': 'Adapter_Policy2',
'Settings': [
{
'ObjectType': 'adapter.AdapterConfig',
'EthSettings': {'ObjectType': 'adapter.EthSettings', 'LldpEnabled': True},
'FcSettings': {'ObjectType': 'adapter.FcSettings', 'FipEnabled': True},
'SlotId': '1'
}
]
}
iu_post(adapters,adapter2_body)
iu_post_moid() - Performs a universal or generic POST on a specified object under any available Intersight API type.
adapters = "adapter/ConfigPolicies"
adapter2_moid = "5c8987b17564777d30252537"
adapter2_body_update1 = {
'Settings': [
{
'EthSettings': {'ObjectType': 'adapter.EthSettings', 'LldpEnabled': False},
'FcSettings': {'ObjectType': 'adapter.FcSettings', 'FipEnabled': False},
'SlotId': '1'
}
]
}
iu_post_moid(adapters,adapter2_moid,adapter2_body_update1)
iu_patch_moid() - Performs a universal or generic PATCH on a specified object under any available Intersight API type.
adapters = "adapter/ConfigPolicies"
adapter2_moid = "5c8987b17564777d30252537"
adapter2_body_update2 = {'Name': 'Adapter_Policy2_Updated'}
iu_patch_moid(adapters,adapter2_moid,adapter2_body_update2)
_______________________________________________
Ugo Emekauwa
Developer / Technical Solutions Architect
dCloud DCV, DCoE
uemekauw@cisco.com
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: