- Notifications
You must be signed in to change notification settings - Fork13
Cisco Identity Services Engine Platform SDK for Python
License
CiscoISE/ciscoisesdk
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
ciscoisesdk is acommunity developed Python library for working with the Identity Services Engine APIs.Our goal is to make working with Cisco Identity Services Engine in Python anative andnatural experience!
fromciscoisesdkimportIdentityServicesEngineAPIfromciscoisesdk.exceptionsimportApiError# Create a IdentityServicesEngineAPI connection object;# it uses ISE custom URL, username, and password, with ISE API version 3.3_patch_1# and its API Gateway enabled,# verify=True to verify the server's TLS certificate# with debug logs disabled# and without using the CSRF tokenapi=IdentityServicesEngineAPI(username='admin',password='C1sco12345',uses_api_gateway=True,base_url='https://198.18.133.27',version='3.3_patch_1',verify=True,debug=False,uses_csrf_token=False)# NOTE: This collection assumes that the ERS APIs and OpenAPIs are enabled.# Get allowed protocols (first page)search_result=api.allowed_protocols.get_all().response.SearchResultifsearch_resultandsearch_result.resources:forresourceinsearch_result.resources:resource_detail=api.allowed_protocols.get_by_id(resource.id ).response.AllowedProtocolsprint("Id {}\nName {}\nallowChap {}\n".format(resource_detail.id,resource_detail.name,resource_detail.allowChap))print("----------")# Handle pagination with a generatorallowed_protols_gen=api.allowed_protocols.get_all_generator()forallowed_protocols_page_respinallowed_protols_gen:allowed_protols_result=allowed_protocols_page_resp.response.SearchResultforresourceinallowed_protols_result.resources:resource_detail=api.allowed_protocols.get_by_id(resource.id ).response.AllowedProtocolsprint("Id {}\nName {}\nallowChap {}\n".format(resource_detail.id,resource_detail.name,resource_detail.allowChap))# Create network devicetry:network_device_response=api.network_device.create(name='ISE_EST_Local_Host_19',network_device_iplist=[{"ipaddress":"127.35.0.1","mask":32}])print("Created, new Location {}".format(network_device_response.headers.Location))exceptApiErrorase:print(e)# Filter network devicedevice_list_response=api.network_device.get_all(filter='name.EQ.ISE_EST_Local_Host_19')device_responses=device_list_response.response.SearchResult.resourcesiflen(device_responses)>0:device_response=device_responses[0]# Get network device detaildevice_response_detail=api.network_device.get_by_id(device_response.id).response.NetworkDevice# Advance usage example using Custom Caller functions## Define a Custom caller named function## Call them with:## get_created_result(network_device_response.headers.Location)defget_created_result(location):returnapi.custom_caller.call_api('GET',location)## Define the get_created_result function## under the custom_caller wrapper.## Call them with:## api.custom_caller.get_created_result(network_device_response.headers.Location)defsetup_custom():api.custom_caller.add_api('get_created_result',lambdalocation:api.custom_caller.call_api('GET',location) )# Add the custom API calls to the connection object under the custom_caller wrappersetup_custom()# Call the newly added functionscreated_device_1=get_created_result(network_device_response.headers.Location)created_device_2=api.custom_caller.get_created_result(network_device_response.headers.Location)print(created_device_1.response==created_device_2.response)iflen(device_responses)>0:device_response=device_responses[0]# Delete network devicedelete_device=api.network_device.delete_by_id(device_response.id)
Installing and upgrading ciscoisesdk is easy:
Install via PIP
$ pip install ciscoisesdk
Upgrading to the latest Version
$ pip install ciscoisesdk --upgrade
The following table shows the supported versions.
Cisco ISE version | Python "ciscoisesdk" version |
---|---|
3.1.0 | 1.2.0 |
3.1_Patch_1 | 2.0.12 |
3.2_beta | 2.1.2 |
3.3_patch_1 | 2.3.1 |
If your SDK is older please consider updating it first.
Excellent documentation is now available at:https://ciscoisesdk.readthedocs.io
Check out theQuickstart to dive in and begin using ciscoisesdk.
Please see thereleases page for release notes on the incremental functionality and bug fixes incorporated into the published releases.
ciscoisesdk is acommunity developed andcommunity supported project. If you experience any issues using this package, please report them using theissues page.
ciscoisesdk is a community development projects. Feedback, thoughts, ideas, and code contributions are welcome! Please see theContributing guide for more information.
This library is inspired by thewebexteamssdk library
All notable changes to this project will be documented in theCHANGELOG file.
The development team may make additional name changes as the library evolves with the ISE APIs.
Copyright (c) 2021 Cisco and/or its affiliates.
About
Cisco Identity Services Engine Platform SDK for Python