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 py_spectrum
Launch examples
See example.py for more working examples.
# import
from py_spectrum 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
Release history Release notifications | RSS feed
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-0.9a0.tar.gz
(3.7 kB
view details)
File details
Details for the file oneclick_client-0.9a0.tar.gz.
File metadata
- Download URL: oneclick_client-0.9a0.tar.gz
- Upload date:
- Size: 3.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68cf035ca8e47d3fbcaba3f932d43175b2fed44d521d36ecc794913c36c383a9
|
|
| MD5 |
1da5ece884542bd64893b43a3bd48444
|
|
| BLAKE2b-256 |
99e1492be8e234a1c3aac4ebc42037a604d965addd75c3fc00f51826f5b188af
|