Skip to main content

Simple library to use Spectrum OneClick API.

Project description

oneclick-client

This is a simple library for working with the Spectrum OneClick API. The basic working methods are implemented, the response can be returned in json, like a python dict, or in xml, like a bs4 object. You can also use xml or json in requests, passing them as text.


Installation

pip install oneclick-client

Launch examples

See example.py for more working examples.

# import
from oneclick_client import spectrum as sp

# initialization
api = sp.SpectrumClient(server='https://192.168.0.1:8888',
                        user='spectrum',
                        password='spectrum',
                        verify=False,
                        timeout=5)

# get devices, output in json (python dict)
devices = api.get(out_format='json',
                    app='devices',
                    params={
                        'throttlesize': 10000,
                        'landscape': '0x1000000',
                        'attr': ['0x129e7', '0x129fa', '0x1006e']
                    })

# create service
model = api.post(out_format='json',
                    app='model',
                    params={
                        'landscapeid': '0x1000000',
                        'mtypeid': '0x1046f',
                        'attr': ['0x12a51', '0x1006e'],
                        'val': ['7', 'test_srv'],
                    })
mh = model['create-model-response']['model']['@mh']

# update service name, output in xml (bs4 obj)
update = api.put(app=f"model/{mh}",
                    params={
                        'attr': '0x1006e',
                        'val': 'test_srv_update',
                    })

# request with data in xml and output in json (python dict)
xml_request = """<!-- xml body request GET ALL ASA MODELS -->
<rs:model-request throttlesize="10000"
xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd ">
<rs:target-models>
    <rs:models-search>
        <rs:search-criteria
            xmlns="http://www.ca.com/spectrum/restful/schema/filter">
        <filtered-models>
        <is-derived-from>
            <attribute id="AttributeID.MTYPE_HANDLE">
            <value>0x2101ea</value> <!-- CiscoASA -->
            </attribute>
        </is-derived-from>
        </filtered-models>
    </rs:search-criteria>
    </rs:models-search>
</rs:target-models>
    <rs:requested-attribute id="0x1006e" /> <!-- Device Name -->
    <rs:requested-attribute id="0x10000" /> <!-- Model Type Name -->
    <rs:requested-attribute id="0x10032" /> <!-- Manufacturer -->
    <rs:requested-attribute id="0x129fa" /> <!-- Model Handle -->
    <rs:requested-attribute id="0x1027f" /> <!-- IP Address -->
    <rs:requested-attribute id="0x10004" /> <!-- Contact status -->
    <rs:requested-attribute id="0x110df" /> <!-- MAC Address -->
    <rs:requested-attribute id="0x82002d" /> <!-- Last verified unix timestamp  -->
</rs:model-request>"""

asa_models = api.post(out_format='json', app='models', data=xml_request)

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

oneclick_client-1.0.3.tar.gz (3.8 kB view details)

Uploaded Source

File details

Details for the file oneclick_client-1.0.3.tar.gz.

File metadata

  • Download URL: oneclick_client-1.0.3.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for oneclick_client-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a082b0980ff3ca51a0b96f3ddcdd01bf244891bb564f69f4242b31e4176133af
MD5 d5e1fd65fd8a2c01fd70e20a2a42ac89
BLAKE2b-256 37acd909b3974ca5fdffb26defc8fa9608150da77ed9ed831a225b8560e71184

See more details on using hashes here.

Supported by

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