skip to navigation
skip to content

aliyun-fc 0.6

Aliyun FunctionCompute SDK

Aliyun FunctionCompute Python SDK

.. image::
.. image::
.. image::


The SDK of this version is dependent on the third-party HTTP library `requests <https:"" kennethreitz="" requests="">`_.

Running environment

Python 2.7, Python 3.6


Install the official release version through PIP (taking Linux as an example):

.. code-block:: bash

$ pip install aliyun-fc

You can also install the unzipped installer package directly:

.. code-block:: bash

$ sudo python install

Getting started

.. code-block:: python

# -*- coding: utf-8 -*-

import fc

# To know the endpoint and access key id/secret info, please refer to:
client = fc.Client(
endpoint='<your endpoint="">',
accessKeyID='<your accesskeyid="">',
accessKeySecret='<your accesskeysecret="">')

# Create service.

# Create function.
# the current directory has a file ( which has a function of myhandler)
client.create_function('service_name', 'function_name', 'main.my_handler', codeZipFile = '')

# Invoke function synchronously.
client.invoke_function('service_name', 'function_name')

# Invoke a function with a input parameter.
client.invoke_function('service_name', 'function_name', payload=bytes('hello_world'))

# Read a image and invoke a function with the file data as input parameter.
src = open('src_image_file_path', 'rb') # Note: please open it as binary.
r = client.invoke_function('service_name', 'function_name', payload=src)
# save the result as the output image.
dst = open('dst_image_file_path', 'wb')

# Invoke function asynchronously.
client.async_invoke_function('service_name', 'function_name')

# List services.

# List functions with prefix and limit.
client.list_functions('service_name', prefix='the_prefix', limit=10)

# Delete service.

# Delete function.
client.delete_function('service_name', 'function_name')


To run the tests, please set the access key id/secret, endpoint as environment variables.
Take the Linux system for example:

.. code-block:: bash

$ export ENDPOINT=<endpoint>
$ export ACCESS_KEY_ID=<accesskeyid>
$ export ACCESS_KEY_SECRET=<accesskeysecret>
$ export STS_TOKEN=<rolearn>

Run the test in the following method:

.. code-block:: bash

$ nosetests # First install nose

More resources
- `Aliyun FunctionCompute docs <https:"" product="" 50980.html="">`_

Contacting us
- `Links <https:"" document_detail="" 53087.html="">`_

- `MIT <https:"" aliyun="" fc-python-sdk="" blob="" master="" license="">`_
File Type Py Version Uploaded on Size
aliyun-fc-0.6.tar.gz (md5) Source 2017-11-14 9KB