Skip to content

Python SDK for use with the Cisco Partner Experience Cloud for Success Tracks API

License

Notifications You must be signed in to change notification settings

CiscoDevNet/px-cloud-python-sdk

Repository files navigation

Partner Experience Cloud API - Python SDK

A Python package enabling simple access to the PX Cloud REST API.

About PX Cloud

Partner Experience (PX) Cloud for Success Tracks is the Cisco partner's digital experience where they can connect with Cisco and their customers. It aims to transform customer-partner relationships by providing business and technology insights, such as customer lifecycle journeys, access to customer CX Cloud dashboards, partner offers, and more.

More info: PX Cloud

About the PX Cloud REST API

The PX Cloud REST API enables partner applications to integrate PX Cloud portal data and functionality via an easy-to-use REST interface. With this API, partners can access customer life-cycle data and develop innovative, customized services, adding unique value to their customers' business networks.

Available customer data include: organization details, contract information, Success Track analytics, and hardware asset reports.

More info: PX Cloud API

Requirements.

Python >=3.6

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/CiscoDevNet/px-cloud-python-sdk.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/CiscoDevNet/px-cloud-python-sdk.git)

Then import the package you need:

import pxcloud_api_client

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import pxcloud_api_client

Getting Started

Please follow the installation procedure and then run the following:

import time
import pxcloud_api_client
from pprint import pprint
from pxcloud_api_client.api import compliance_api
from pxcloud_api_client.model.asset_violations_response import AssetViolationsResponse
from pxcloud_api_client.model.assets_violations_response import AssetsViolationsResponse
from pxcloud_api_client.model.assets_with_violations_response import AssetsWithViolationsResponse
from pxcloud_api_client.model.error_response import ErrorResponse
from pxcloud_api_client.model.opt_in_response import OptInResponse
from pxcloud_api_client.model.policy_rule_details import PolicyRuleDetails
from pxcloud_api_client.model.suggestions_response import SuggestionsResponse
from pxcloud_api_client.model.violation_summary_response import ViolationSummaryResponse
# Defining the host is optional and defaults to https://api-cx.cisco.com/px
# See configuration.py for a list of all supported configuration parameters.
configuration = pxcloud_api_client.Configuration(
    host = "https://api-cx.cisco.com/px"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure OAuth2 access token for authorization: oAuth2
configuration = pxcloud_api_client.Configuration(
    host = "https://api-cx.cisco.com/px"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'


# Enter a context with an instance of the API client
with pxcloud_api_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = compliance_api.ComplianceApi(api_client)
    success_track_id = "successTrackId_example" # str | 
    source_system_id = "sourceSystemId_example" # str | 
    customer_id = "customerId_example" # str | 
    asset_id = "assetId_example" # str | 
    offset = 1 # int |  (optional) (default to 1)
    max = 10 # int |  (optional) (default to 10)

    try:
        # Get the violations of the asset
        api_response = api_instance.asset_violations(success_track_id, source_system_id, customer_id, asset_id, offset=offset, max=max)
        pprint(api_response)
    except pxcloud_api_client.ApiException as e:
        print("Exception when calling ComplianceApi->asset_violations: %s\n" % e)

Auto Authentication

The auth.py generates the authorization tokens to access the PXCloud.

For more info see example.py which shows the usage of the auth.py.

Documentation for API Endpoints

All URIs are relative to https://api-cx.cisco.com/px/v1

Class Method HTTP request Description
ComplianceApi asset_violations GET /v1/customers/{customerId}/insights/compliance/assetViolations Get the violations of the asset
ComplianceApi assets_with_violations GET /v1/customers/{customerId}/insights/compliance/assetsWithViolations Get the asset summary
ComplianceApi opt_in GET /v1/customers/{customerId}/insights/compliance/optIn optIn status
ComplianceApi policy_rule_details GET /v1/customers/{customerId}/insights/compliance/policyRuleDetails Returns information about the policy the rule belongs to
ComplianceApi suggestions GET /v1/customers/{customerId}/insights/compliance/suggestions Get the Suggestions filtered upon Severity (if given), for summary tab
ComplianceApi violations GET /v1/customers/{customerId}/insights/compliance/violations Get the violation summary of a customer
ComplianceApi violations_assets GET /v1/customers/{customerId}/insights/compliance/violations/assets Get the violation details of impacted assets for the customer, and selected policy Group, Policy and Rule
ContractsApi contract_details GET /v1/contract/details Get the list of contracts Details from flat table. It supports pagination , filtering and sorting
ContractsApi contracts GET /v1/contracts Get the list of customer contracts for a particular partner. It supports pagination with offset and limit parameters , filtering and sorting
CrashRiskApi asset_risk_factors GET /v1/customers/{customerId}/insights/crashRisk/assets/{assetIdBase64}/riskFactors Get risk factors of a device
CrashRiskApi assets GET /v1/customers/{customerId}/insights/crashRisk/assets Get devices which are at risk of crash owned by a customer, sorted by risk score in descending order by default
CrashRiskApi assets_crashed GET /v1/customers/{customerId}/insights/crashRisk/assetsCrashed Get the list of crashed devices for last given time period
CrashRiskApi crash_history GET /v1/customers/{customerId}/insights/crashRisk/asset/{assetIdBase64}/crashHistory Get the device crash-detail - Asset 360(time stamp, reset reason)
CrashRiskApi similar_assets GET /v1/customers/{customerId}/insights/crashRisk/assets/{assetIdBase64}/similarAssets Get similar assets based on the similarity score
CustomerDataApi lifecycle GET /v1/customers/{customerId}/lifecycle Get customer lifecycle
CustomerDataApi report_summary GET /v1/customers/{customerId}/reports/{reportId} Get the report
CustomerDataApi reports POST /v1/customers/{customerId}/reports Request customer data reports as bulk files
CustomersApi customers GET /v1/customers Fetch list of customers paginated for a given partner Id
FaultsApi fault_affected_assets GET /v1/customers/{customerId}/insights/faults/{faultId}/affectedAssets Affected Assets
FaultsApi fault_history GET /v1/customers/{customerId}/insights/faults/{faultId}/affectedAssets/{assetName}/faultHistory Assets Fault History
FaultsApi fault_summary GET /v1/customers/{customerId}/insights/faults/{faultId}/summary Fault summary
FaultsApi faults GET /v1/customers/{customerId}/insights/faults Faults details
InsightsApi software_group_assets GET /v1/customers/{customerId}/insights/software/softwareGroups/assets Asset information in the Software Group
InsightsApi software_group_field_notices GET /v1/customers/{customerId}/insights/software/softwareGroups/suggestions/fieldNotices Software Group - Suggestions Field Notices
InsightsApi software_group_security_advisories GET /v1/customers/{customerId}/insights/software/softwareGroups/suggestions/securityAdvisories Software Group - Suggestions Security Advisories
InsightsApi software_group_suggestions GET /v1/customers/{customerId}/insights/software/softwareGroups/suggestions Software Group Suggestions
InsightsApi software_group_suggestions_bugs GET /v1/customers/{customerId}/insights/software/softwareGroups/suggestions/bugs Software Group - Suggestions Bugs
InsightsApi software_groups GET /v1/customers/{customerId}/insights/software/softwareGroups Software Group Information
PartnerDataApi success_tracks GET /v1/successTracks Success Tracks
PartnerOffersDataApi partner_offers GET /v1/partnerOffers Get Partner Offers
PartnerOffersSessionsDataApi partner_offers_sessions GET /v1/partnerOffersSessions Get Partner Offers Session data
V1ContractsWithCustomersApi contracts_with_customers GET /v1/contractsWithCustomers Get the Outbound Contracts With Customers

Documentation For Models

Documentation For Authorization

The access token authentication request is based on the OAuth client credentials grant flow, which is a single HTTP transaction, not requiring user interaction to complete.

More info: Authentication for PX Cloud API

FAQs and Troubleshooting

For FAQs and Troubleshooting please make use of the official forum cisco communities

Notes for Large OpenAPI documents

If the OpenAPI document is large, imports in pxcloud_api_client.apis and pxcloud_api_client.models may fail with a RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:

Solution 1: Use specific imports for apis and models like:

  • from pxcloud_api_client.api.default_api import DefaultApi
  • from pxcloud_api_client.model.pet import Pet

Solution 2: Before importing the package, adjust the maximum recursion limit as shown below:

import sys
sys.setrecursionlimit(1500)
import pxcloud_api_client
from pxcloud_api_client.apis import *
from pxcloud_api_client.models import *

About

Python SDK for use with the Cisco Partner Experience Cloud for Success Tracks API

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published