Invoking FunctionGraph Functions

Following pages demonstrate how to call a FunctionGraph implemented in Python:

For details on function invocation, see

in FunctionGraph API reference.

Prerequisites

Environment Variables

Following environment variables need to be set:

Environment Variables

Name

Description

OTC_SDK_PROJECTID

Project ID

OTC_SDK_REGION

Region, e.g. “eu-de”

OTC_SDK_AK

Access Key (*)

OTC_SDK_SK

Secret Key

OTC_USER_NAME

User name (*)

OTC_USER_PASSWORD

User password

OTC_DOMAIN_NAME

Domain name

OTC_IAM_ENDPOINT

IAM Endpoint, e.g. https://iam.eu-de.otc.t-systems.com/v3

(* User needs to have permission to invoke FunctionGraph)

Deployed FunctionGraph Event Function

Use following settings to create the FunctionGraph event function using the FunctionGraph console:

  • Project : as specified in the environment variable OTC_SDK_PROJECTID

  • Region: as specified in the environment variable OTC_SDK_REGION

  • Name: python-sample-invoke-function

  • Runtime: Python 3.10

  • Version: latest

  • Application: default

  • Function code: Use the following sample code for the function code.

    # -*- coding:utf-8 -*-
    import json
    def handler (event, context):
        return {
            "statusCode": 200,
            "isBase64Encoded": False,
            "body": json.dumps(event),
            "headers": {
                "Content-Type": "application/json"
            }
        }
    
  • Handler name: index.handler

Permissions

Make sure that your user has the necessary permissions to invoke the function.