How to use the fdk.application.decorators function in fdk

To help you get started, we’ve selected a few fdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fnproject / fdk-python / samples / application / app.py View on Github external
    @decorators.fn(gpi_image=GPI_IMAGE, dependencies={
        "requests_get": requests.get
    })
    def request(self, *args, **kwargs) -> dict:
        requests_get = kwargs["dependencies"].get("requests_get")
        r = requests_get('https://api.github.com/events')
        r.raise_for_status()
        return r.content
github fnproject / fdk-python / samples / application / app.py View on Github external
    @decorators.fn(gpi_image=GPI_IMAGE)
    def dummy(*args, **kwargs) -> str:
        return ""
github fnproject / fdk-python / samples / application / app.py View on Github external
    @decorators.with_type_cast(
        return_type=lambda x: ujson.loads(x))
    @decorators.fn(gpi_image=GPI_IMAGE, dependencies={
        "requests_get": requests.get
    })
    def request(self, *args, **kwargs) -> dict:
        requests_get = kwargs["dependencies"].get("requests_get")
        r = requests_get('https://api.github.com/events')
        r.raise_for_status()
        return r.content
github fnproject / fdk-python / samples / application / app.py View on Github external
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import requests
import ujson

from fdk.application import decorators


GPI_IMAGE = "denismakogon/python3-fn-gpi:0.0.6"


@decorators.fn_app
class Application(object):

    def __init__(self, *args, **kwargs):
        pass

    @decorators.fn(gpi_image=GPI_IMAGE)
    def dummy(*args, **kwargs) -> str:
        return ""

    @decorators.fn(gpi_image=GPI_IMAGE)
    def square(self, x: int, y: int, *args, **kwargs) -> bytes:
        return x * y

    @decorators.with_type_cast(
        return_type=lambda x: {"power": x})
    @decorators.fn(gpi_image=GPI_IMAGE)