Calling FunctionGraph using gopertelekomcloud¶
Source for this sample can be found in: /samples-doc/invoke-fg-openstack/src/invokeSync_UsernamePassword.go.
For details on gopertelekomcloud, see gopertelekomcloud on Github.
Prerequisites¶
Environment Variables¶
See environment variables section in: Prerequisites
Deployed FunctionGraph Event Function¶
Method A: Deploy using console¶
Deploy the function manually as described in Prerequisites using the OpenTelekomCloud Console.
Method B: Deploy using gopertelekomcloud¶
Or deploy the function using the provided Go code using gopertelekomcloud.
cd samples-doc/invoke-fg-openstack/src
go test -run TestCreateFunction_UsernamePassword
this will create function with code and parameters from:
package invoke_fg_openstack
const appCode = `
# -*- coding:utf-8 -*-
import json
def handler (event, context):
return {
"statusCode": 200,
"isBase64Encoded": False,
"body": json.dumps(event),
"headers": {
"Content-Type": "application/json"
}
}
`
const functionApp = "default"
const functionName = "DefaultPython3_10_From_Go_SDK"
const functionVersion = "latest"
After testing, you can delete the function using:
cd samples-doc/invoke-fg-openstack/src
go test -run TestDeleteFunction_UsernamePassword
Source for this sample can be found in: /samples-doc/invoke-fg-openstack.
Call Functiongraph using Username and Password synchronously¶
To run the sample, execute:
cd samples-doc/invoke-fg-openstack/src
go test -run TestInvokeSync_UsernamePassword
Call Functiongraph using AK/SK synchronously¶
Source for this sample can be found in: /samples-doc/invoke-fg-openstack/src/invokeSync_AKSK.go.
To run the sample, execute:
cd samples-doc/invoke-fg-openstack/src
go test -run TestInvokeSync_AKSK
Note
Don’t forget to clean up the deployed resources after testing.