Skip to main content

Python SDK for Matrix42 Enterprise Service Management CMBD

Project description

Python 3 Matrix42 SDK for Enterprise Service Management (ESM) tool

"ERP for Software Asset Management"

matrix42sdk package in my-feed feed in Azure Artifacts Build Status Code style: black GitHub Pull Requests GitHub repo size

The background story

As of July 2020, Matrix42 AG, a German company is offering a Configuration Management Database (CMBD) - basically a competing product to ServiceNOW and many others like Microsoft Intune.

Their Angular based product can be installed on-prem and used as ITIL supporting tool for the company.

It provides a REST API which this Python3+ SDK tries to cover. Unfortunately, Swagger support is currently not available which has led me to write this client package myself - becoming my first python3 client SDK.

It shows - also due to learning Python OOP principles.

Documentation of Rest API

Setting up the Sphinx auto-generate documentation:

What works and what does not?

Works:

  • get and put (i.e. update) fragment

Use Cases:

  • updating CI version numbers

Semi/or not working:

  • creating fragment was not tested, but is implemented as a Rest API call
  • get and put object -> here not tested extensively and one must expect bugs

Testing

Without having a Matrix42 ESM portal which allows API access and is publicly available for unlimited use, the only option how to test this library is to use your own ESM portal installation (be it in public cloud or on prem). Hence the need to use your own API keys, etc.

From this follows that this library cannot - as of now - include more python tests, at least not publicly available. It is my recommendation to write your own, private tests and report issues here.

Sorry for inconvenience!

Usage

Python 3 - Simple Testing

Using requests you can call

import requests

url = "https://xxxx/m42Services/api/ApiToken/GenerateAccessTokenFromApiToken/"

payload = {}
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer the 'short' version of bearer token generated from Administration Panel in the GUI'
}

response = requests.request("POST", url, headers=headers, data = payload, verify = False)

print(response.text.encode('utf8'))

# only then start using proper API requests
import requests

url = "https://xxxx/m42Services/api/data/fragments/Ud_SoftwareproduktVersionClassBase/775c82cf-d243-4bfb-a1b2-f3edad93c826"

payload = {}
headers = {
  'Authorization': 'Bearer "output of the previous requests "RawToken" '
}

response = requests.request("GET", url, headers=headers, data = payload)

print(response.text.encode('utf8'))

Matrix42 SDK for Python

To use Matrix42 SDK, first decide which authN approach you are going to use.

For a basic, create a Matrix42RestClient object by using your (or any other matrix42 CMBD) account:

import matrix42sdk
from matrix42sdk import Matrix42RestClient
from matrix42sdk.api_endpoints import *

For using Access/API Tokens, you can set your MATRIX42SDK_API_TOKEN via a shell (higher priority):

export MATRIX42_URL="xxx"
export MATRIX42SDK_API_TOKEN="xxx"

and then:

mat = api_endpoints.fragments.FragmentsDataService()

Then to get a fragment for a specific CI, insert correct parameters according to the documentation:

JUPYTERLAB_ID_FRAG = "8c51cfff-bf16-452e-8d2c-527cc25518c3"
SYS_ENTITY = "SPSSoftwareType"
full_ci_frg = mat.get_fragement(SYS_FRAGEMENT, JUPYTERLAB_ID_FRAG)

Documentation

We use https://sphinx-rtd-theme.readthedocs.io/ and https://www.sphinx-doc.org/en/master/

cd docs
sphinx-apidoc -o source ../matrix42sdk
make html

Building this package yourself

This package is being build on Azure DevOps services:

https://dev.azure.com/johnmalc/Matrix42SDK/_build

and further uses SonarCloud:

https://sonarcloud.io/dashboard?id=dmpe_matrix42sdk

Use to install package from non-PyPI feed (the azure one):

pip3 install --index https://pkgs.dev.azure.com/johnmalc/Matrix42SDK/_packaging/my-feed/pypi/simple/ matrix42sdk

PyPI

poetry build

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

matrix42sdk-3.0.3.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

matrix42sdk-3.0.3-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file matrix42sdk-3.0.3.tar.gz.

File metadata

  • Download URL: matrix42sdk-3.0.3.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for matrix42sdk-3.0.3.tar.gz
Algorithm Hash digest
SHA256 a02b2ec52ea74f00f35903f6949187c21c1844b6255533f557a071bc28795c18
MD5 b5543a089a441894519f77e810de36dd
BLAKE2b-256 baa6218efb1e72ff3e8df69897c3d7e6ef906355a1b9dd298dea644dfc8c53bf

See more details on using hashes here.

File details

Details for the file matrix42sdk-3.0.3-py3-none-any.whl.

File metadata

  • Download URL: matrix42sdk-3.0.3-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for matrix42sdk-3.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7d8b5e56fa382535365808d63f06cf1df7aa21e8502cec946ad7f235483e8127
MD5 1dab0145de74d8caa51a52e4eaf0af99
BLAKE2b-256 05bceb778c5a96debf82d98a29775b909c57199c585ecf3d8b2218e689a99a37

See more details on using hashes here.

Supported by

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