Skip to main content

Business Critical Services Operational Insights API SDK

Project description

Business Critical Services Operational Insights API SDK

SDK for the Business Critical Services (BCS) Operations Insights (OI) API

Example

from bcs_oi_api import BCSOIAPI
from bcs_oi_api.models import Device, SecurityAdvisory, SecurityAdvisoryBulletin, SecurityAdvisoryOutcome

bcs_oi_api = BCSOIAPI(
    client_id='client id',
    client_secret='client secret',
    region='us'
)

# Getting a generator for all discovered devices
devices = bcs_oi_api.get_output(model=Device)

# Building a dictionary with as key the device_id and the value the Device object for lookups
devices_dict = {device.device_id: device for device in devices}

# Getting a generator for all the Security Advisories
security_advisories = bcs_oi_api.get_output(model=SecurityAdvisory)

# Getting a generator for all the Security Advisory Bulletins
security_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 lookups
security_advisory_bulletins_dict = {bulletin.security_advisory_cold_id: bulletin for bulletin in
                                    security_advisory_bulletins}

# Listing devices which are vulnerable to security advisories with a critical impact rating
for advisory in security_advisories:
    if advisory.match_confidence == SecurityAdvisoryOutcome.VULNERABLE and \
            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 Devices

from bcs_oi_api import BCSOIAPI
from bcs_oi_api.models import DeviceFilter, Device, UIRDetailsFilter, UIRDetails

bcs_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)
for inventory_device in inventory_devices:
    print(inventory_device)


# Masking - UIR Details

filter_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)

for uir_detail in uir_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}")

Installation

Installing and upgrading is easy:

Install via PIP

$ pip install bcs-oi-api

Upgrading to the latest Version

$ pip install bcs-oi-api --upgrade

Questions, Support & Discussion

bcs-oi-api is a community developed and community supported project. Feedback, thoughts, questions, issues can be submitted using the issues page.

Contribution

bcs-oi-api is a community developed project. Code contributions are welcome via PRs!

Copyright (c) 2018-2021 Cisco and/or its affiliates.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bcs-oi-api-1.1.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

bcs_oi_api-1.1.1-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file bcs-oi-api-1.1.1.tar.gz.

File metadata

  • Download URL: bcs-oi-api-1.1.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for bcs-oi-api-1.1.1.tar.gz
Algorithm Hash digest
SHA256 b3d0899b9d213885abb2f84b0c8afb0a1ccb3e8f645466f4d131795cdd6b5209
MD5 3d5859587a96b8389070102dba001d4f
BLAKE2b-256 e59b9c6a83fc7c91b8c4d05db1fd6139fbfd7d6ab535f6c831558ea9492794a6

See more details on using hashes here.

File details

Details for the file bcs_oi_api-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: bcs_oi_api-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for bcs_oi_api-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4e5fb450d9515de4ed1f91f6f362cf337b66ccc5b306859afe8104980208a190
MD5 3c6ebebea64984a7b4a1209b97ff577b
BLAKE2b-256 4191d5dcf018b6d4630453b473613b382ad76ce9368022f7c0e0e13bde98bb29

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page