Skip to main content

Library for creating Functions for CIM Database Cloud.

Project description

CONTACT Logo 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

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

contactsoftware_functions-0.23.0.tar.gz (284.8 kB view details)

Uploaded Source

Built Distribution

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

contactsoftware_functions-0.23.0-py3-none-any.whl (42.1 kB view details)

Uploaded Python 3

File details

Details for the file contactsoftware_functions-0.23.0.tar.gz.

File metadata

  • Download URL: contactsoftware_functions-0.23.0.tar.gz
  • Upload date:
  • Size: 284.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}

File hashes

Hashes for contactsoftware_functions-0.23.0.tar.gz
Algorithm Hash digest
SHA256 98a3dc316980a3d0d4b47f48fc6d7a9af369d011ab88f0820710ee149ad3ae89
MD5 2fdad23077a5626d4426292df2cd3af7
BLAKE2b-256 3397182884a77d0c25058879c74c2e30b09a64b138d3c94e9a4f7547bc847e17

See more details on using hashes here.

File details

Details for the file contactsoftware_functions-0.23.0-py3-none-any.whl.

File metadata

  • Download URL: contactsoftware_functions-0.23.0-py3-none-any.whl
  • Upload date:
  • Size: 42.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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}

File hashes

Hashes for contactsoftware_functions-0.23.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9cabe8766f134d11c74bcf8c8f0f40e2806a75d50e6da6426b264e9eb61a3f20
MD5 43417b48403a4d6afa22a24abecd63ad
BLAKE2b-256 ce71925654a0d1dc29c28a15b707c483424192415493b59d42a1d46c40d38b45

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