Create a Function

The first step in creating your own Function is coding it. Currently, you can do this using Python or Go by choosing the appropriate language template. Each template gives you a basic structure, and you can use auxiliary functions to refactor your code, making sure the main Function is there. Please don't rename the main Function or change its definition.

This main Function receives all the information from the HTTP request made to invoke the Function:
  • Path
  • Method (POST, GET, PUT, PATCH or DELETE)
  • Headers
  • Query parameters
  • Body

This information is the data you can provide to your Function.

When the task of your Function has finished, you may want to return some result or feedback in your response. For this you can:
  • Set a status code
  • Use the response body
  • Add headers to the response

The details on how to get the request data and how to set the response info is language and template specific, so check the documentation about the template you want to use to build your Function.

  1. Under User Functions, click Functions.
  2. Click New Function.


  3. Enter the Function's name and description (optional).
    Figure 1.


  4. From the Template drop down menu, choose the type of Function you want to code:
    • FMU: Upload an FMU file to run a simulation model
    • Go: Code your serverless Function using Go language
    • Python: Code your serverless Function using Python language
  5. If you choose to run a simulation model by using a FMU, upload the FMU file and click Save. Go to Upload an FMU File to Run a Simulation Model.
  6. If you choose to code your serverless function (either using Go or Python language), a template for the code appears in the panel. The Libraries drop-down menu displays the available libraries you can use while coding. To use any library, select it from the list provided.
    Note: This action will allow you to add it to your template, but you will still need to add the import line to your code. The libraries added by default follow the same behaviour; imports need to be added to your code.
    Figure 2.