Library for creating Functions for CIM Database Cloud.
Project description
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 build 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
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
File details
Details for the file contactsoftware_functions-0.8.1.tar.gz
.
File metadata
- Download URL: contactsoftware_functions-0.8.1.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6bae0b7ba0b9cd48be8f62a471b505cb7fd6757a0827d3827b9f692f02a279d |
|
MD5 | 3e73494fb12158b3c89ffa239712ead5 |
|
BLAKE2b-256 | e7459a8067dec0e055cea76412b4359e4190bef45510e2d6bd899fbed80f6e33 |
File details
Details for the file contactsoftware_functions-0.8.1-py3-none-any.whl
.
File metadata
- Download URL: contactsoftware_functions-0.8.1-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.5.0-1025-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c118845cf48df5ac360b4b5cb5f6e66927a216f3bafc54b678d4d548a5143f7 |
|
MD5 | f72a3de366bae22915f852bd5a2d3cd3 |
|
BLAKE2b-256 | c8b76f229be3ed3d9e8e2b07deae8f0120a853ed151a68e2ff218a1482a154b8 |