Functions-SDK for Python
This SDK provides the csfunctions library for developing Functions with Python.
Functions are deeply integrated in the CIM Database Cloud Webhooks technology. They are designed to work seamlessly together. The goal is to allow implementing custom business logic in a CIM Database Cloud SaaS application without leaving the CONTACT Cloud and without the need to create and maintain a separate infrastructure.
Documentation: https://cslab.github.io/functions-sdk-python/
Source code: https://github.com/cslab/functions-sdk-python
Requirements
Python 3.10+
csfunctions is built with Pydantic 2
Installation
Install using pip:
pip install contactsoftware-functions
Usage
Build the Function
Folder content of a minimal example for a Function implementation:
my_example_functions/
├── environment.yaml
├── mymodule.py
└── requirements.txt
Code for a Function:
import requests
import json
from csfunctions import MetaData, Service
from csfunctions.events import DocumentReleaseEvent
def send_doc_to_erp(metadata: MetaData, event: DocumentReleaseEvent, service: Service):
# iterate over the documents contained in the event
for document in event.data.documents:
# create the payload for our (fictional ERP system)
payload = json.dumps({
"document_number": document.z_nummer,
"document_index": document.z_index,
"document_title": document.titel
})
res = requests.post("https://example.com", data=payload)
if res.status_code != 200:
return ValueError(f"Failed to upload document to ERP. Got response code {res.status_code}")
Environment file to define runtime and Function entrypoints:
runtime: python3.10
version: v1
functions:
- name: send_doc_to_erp
entrypoint: mymodule.send_doc_to_erp
Define requirements:
contactsoftware-functions
Deploy the Code
To deploy the Code you first need to install the contactsoftware-functions-client and retrieve developer credentials in the CONTACT Portal.
Install client:
pip install contactsoftware-functions-client
Login:
cfc login
Create a new environment:
cfc env create myenv
Upload code into new environment:
cfc env deploy myenv
Metadata
Release files for contactsoftware-functions 0.28.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| contactsoftware_functions-0.28.0.tar.gz | 293.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| contactsoftware_functions-0.28.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 345.0 kB
Release files / contactsoftware_functions-0.28.0.tar.gz
| Download URL | contactsoftware_functions-0.28.0.tar.gz |
|---|---|
| Size | 293.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f713de3d05e579c0346a470f533e5102c2fb791f013614bb79e27228a01af48
|
|
BLAKE2b-256 checksum How to use checksums |
4171ed2b19174e404fdde6dd549116fe821a1afdc15a985d7133573ec2da0404
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.4 {"installer":{"name":"uv","version":"0.12.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / contactsoftware_functions-0.28.0-py3-none-any.whl
| Download URL | contactsoftware_functions-0.28.0-py3-none-any.whl |
|---|---|
| Size | 51.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7997a4f14ae05f779a0063fd7209c37ac2b009a71a9833df3bbb8fd9bd94e7cf
|
|
BLAKE2b-256 checksum How to use checksums |
2a70cfa310218182369f480970af454b37ad07bb5dea1d772694060ce6f258db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.4 {"installer":{"name":"uv","version":"0.12.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|