Ian Underwood's Device42 API
Project description
iupy-device42api
Ian Underwood's Device42 API
About
This is a minimally functioning package that provides a python interface to instances of Device42.
The module provides a single point to connect to Device42 using either a username and password, or a client key and secret key.
When keys are used for authentication, it becomes possible to request and use a bearer token for the remainder of the operations. Tokens are issued for a fixed amount of time and need to be renewed before they expire, or be rerequested when they do. The first goal of this module is to implement and manage token acquisition without any special requirements from the end user.
NOTE: This is a stupid-early version of the module.
Usage
The module uses a python class to provide all the primary methods needed to access a Device42 system.
Connect & Disconnect
connect()
The connect function opens and validates connectivity to a specified URL.
- url (Required) - This is the D42 target
- ssl_verify (Optional) - Set to true if SSL verification is desired for an https destination.
- client_key - When using key authentication, this is the client key returned from Device42.
- secret_key - When using key authentication, this is the secret key returned from Device42.
- username - Used to access Device42 with a username.
- password - Used to access Device42 with a password.
Do note that if all the variables are sent, the client_key and server_key will be used as the connection method.
import iupy_device42api
d42 = iupy_device42api.Device42API()
connect = d42.connect(url='https://device42.local',
client_key='clientkey',
secret_key='secretkey')
if connect:
print("Connected to D42 successfully!')
d42.disconnect()
else:
print("Connection to D42 failed!')
del d42
disconnect()
The disconnect function effectively clears out any active tokens that Device42 is using with the script. This prevents any tokens from remaining active after normal code execution. This is particularly useful if the token timeout uses a long period (default is 10 minutes).
Methods
This module currently supports the four methods used by Device42 as well as HEAD, which verifies the remote server is listening. The api and data arguments are positional.
- delete(api)
- get(api)
- head
- post(api, data)
- put(api, data)
Each function returns a response object as one would expect from the requests module. The functions post and put include a mandatory data argument.
Testing
Module tests, located in the testing folder, require the module to be installed as well as a test_creds.py file which contains variables used for the testing environment. This file needs to be in the executing directory.
Since this repository exists on GitHub, an example test_creds.py.example file is provided.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iupy_device42api-0.1.2.tar.gz.
File metadata
- Download URL: iupy_device42api-0.1.2.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ea289702eb6af7d12e992e1dc207f5d9b09b3a6f890a869b14d3b804aafe778
|
|
| MD5 |
dfd4f2cab76e8a2c08c93367a2c6bdd8
|
|
| BLAKE2b-256 |
9596a9f63eb9426fce39f950c74a03a2d3f0253f370379a5f583935b53cffe46
|
File details
Details for the file iupy_device42api-0.1.2-py3-none-any.whl.
File metadata
- Download URL: iupy_device42api-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
517710a2e1bd06ec8f7c27815de4127fa08332a036d53e93c2a2dac244c687af
|
|
| MD5 |
4af168aa383d06a97b6d9c0a5eef520a
|
|
| BLAKE2b-256 |
2c2bd7effd713215044a66f3237dd6a744a0447779f92cc7a3e2b15ffb7e9df9
|