platform API에 대한 HTTP 요청을 사용하여 작업을 호출 할 수 있습니다. OpenWhisk의 Python 런타임에는 HTTP 호출을위한 requests 라이브러리가 포함되어 있습니다.
다음은 동일한 네임 스페이스에서 다른 (child
)을 호출하는 동작의 예입니다.
import os
import requests
APIHOST = os.environ.get('__OW_API_HOST')
NAMESPACE = os.environ.get('__OW_NAMESPACE')
USER_PASS = os.environ.get('__OW_API_KEY').split(':')
def main(params):
action = 'child'
url = APIHOST + '/api/v1/namespaces/' + NAMESPACE + '/actions/' + action
response = requests.post(url, data=params, params={'blocking': 'true'}, auth=(USER_PASS[0], USER_PASS[1]))
print(response.json())
return {"text": "invoked!"}
전체 API에 대한 스 거거 문서는 here입니다.
이 작업을보다 쉽게하기 위해 Python 클라이언트 라이브러리를 만들려면 open issue이 있습니다.