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


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.13.1.tar.gz (17.7 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.13.1-py3-none-any.whl (33.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: contactsoftware_functions-0.13.1.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.11.12 Linux/6.8.0-1021-azure

File hashes

Hashes for contactsoftware_functions-0.13.1.tar.gz
Algorithm Hash digest
SHA256 a1a45912a6f75c163d6efa1e5858c417c2377b1cb9b9aca8c4a77c8e44425dbb
MD5 665a368cf2ba7ae1f17eb16bd5822feb
BLAKE2b-256 2cf580fe6fd400110439648b0ad34a9e15326668b258f682bd9967d5c6f7b524

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for contactsoftware_functions-0.13.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e51647e55ef81791044be2094ef76387905d88120bae66a6ee1df2de6d92fdd5
MD5 6047a4d6633589d716bb9c1d1a56b51b
BLAKE2b-256 aced24c9b38447367691d80d67da794078a5ed698d3a6abcdff68074bee5e60d

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