Package: bcs-oi-api
Business Critical Services Operational Insights API SDKSDK for the Business Critical Services (BCS) Operations Insights (OI) APIExamplefrombcs_oi_apiimportBCSOIAPIfrombcs_oi_api.modelsimportDevice,SecurityAdvisory,SecurityAdvisoryBulletin,SecurityAdvisoryOutcomebcs_oi_api=BCSOIAPI(client_id='client id',client_secret='client secret',region='us')# Getting a generator for all discovered devicesdevices=bcs_oi_api.get_output(model=Device)# Building a dictionary with as key the device_id and the value the Device object for lookupsdevices_dict={device.device_id:devicefordeviceindevices}# Getting a generator for all the Security Advisoriessecurity_advisories=bcs_oi_api.get_output(model=SecurityAdvisory)# Getting a generator for all the Security Advisory Bulletinssecurity_advisory_bulletins=bcs_oi_api.get_output(model=SecurityAdvisoryBulletin)# Building a dictionary with as key the id of the bulletin and as value the bulletin itself for lookupssecurity_advisory_bulletins_dict={bulletin.security_advisory_cold_id:bulletinforbulletininsecurity_advisory_bulletins}# Listing devices which are vulnerable to security advisories with a critical impact ratingforadvisoryinsecurity_advisories:ifadvisory.match_confidence==SecurityAdvisoryOutcome.VULNERABLEand\security_advisory_bulletins_dict[advisory.security_advisory_cold_id].security_impact_rating=='Critical':print(f"Device\"{devices_dict[advisory.device_id].device_name}\"is vulnerable to "f"\"{security_advisory_bulletins_dict[advisory.security_advisory_cold_id].bulletin_title}\"")Filtering & Masking Example# Filtering - Inventory Devicesfrombcs_oi_apiimportBCSOIAPIfrombcs_oi_api.modelsimportDeviceFilter,Device,UIRDetailsFilter,UIRDetailsbcs_oi_api=BCSOIAPI(client_id='client id',client_secret='client secret',region='us')filter_params={"productFamily":["Cisco ASR 9000 Series Aggregation Services Routers","Cisco Catalyst 3850 Series Switches","Cisco ASR 1000 Series Aggregation Services Routers",],}filter_parameter=DeviceFilter.parse_obj(filter_params)inventory_devices=bcs_oi_api.get_output(model=Device,filter_=filter_parameter)forinventory_deviceininventory_devices:print(inventory_device)# Masking - UIR Detailsfilter_params={"unidentifiedDeviceName":["site2-asr-1"],"unidentifiedDeviceStatus":["Recurring"],}fields="unidentifiedDeviceName,unidentifiedDevicePlatform"filter_parameter=UIRDetailsFilter.parse_obj(filter_params)uir_details=bcs_oi_api.get_output(model=UIRDetails,filter_=filter_parameter,fields=fields)foruir_detailinuir_details:print(uir_detail)# In the uir_detail response, only specified fields would be accessible.print(f"Unidentified Device Name :{uir_detail.unidentified_device_name}")print(f"Unidentified Device Platform :{uir_detail.unidentified_device_platform}")InstallationInstalling and upgrading is easy:Install via PIP$ pip install bcs-oi-apiUpgrading to the latest Version$ pip install bcs-oi-api --upgradeQuestions, Support & Discussionbcs-oi-api is acommunity developedandcommunity supportedproject. Feedback, thoughts, questions, issues can be submitted using the issues page.Contributionbcs-oi-api is acommunity developedproject. Code contributions are welcome via PRs!Business Cricital Services Operations Insights APIIssuesCopyright (c) 2018-2021 Cisco and/or its affiliates.