Skip to main content

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.

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 vaildates 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 during normal code execution.

Methods

This module currently supports the four methods used by Device42 as well as HEAD, which verifies the remote server is listening.

  • delete(api=)
  • get(api=)
  • head
  • post(data, api=)
  • put(data, api=)

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


Download files

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

Source Distribution

iupy_device42api-0.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iupy_device42api-0.1.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file iupy_device42api-0.1.1.tar.gz.

File metadata

  • Download URL: iupy_device42api-0.1.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for iupy_device42api-0.1.1.tar.gz
Algorithm Hash digest
SHA256 47734686e014377c770b7951bde366d09eda8a47348b477817d5680e217b6915
MD5 03d7bf2ff391b2633bb3c3d38ef9486d
BLAKE2b-256 ea4f1b15716cb25cc2f852c7f87e21cc539c12c0c6a3bee14a41846c9a1ca3bd

See more details on using hashes here.

File details

Details for the file iupy_device42api-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for iupy_device42api-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 55030f585f2081b3e56abb1c7669fe073e84d65e4bf209c316c180cab0497b16
MD5 218d4787d6a5653c8e1ee35c793f7fbf
BLAKE2b-256 7e835118759e1ce77689e63b970690dd289e2d5243ed3c45464fc4a4f334d086

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