GithubHelp home page GithubHelp logo

wayscript-python's Introduction

wayscript-python

Context

from wayscript import context

event = context.get_event()

Checking user by application key

from wayscript import context, utils

application_key = utils.get_application_key()
user = context.get_user_by_application_key(application_key)

Triggers

HTTP Triggers

from wayscript.triggers import http_trigger

payload = {"hello": "world"}
headers = {"content-type": "application/json"}
status_code = 200

http_trigger.send_response(data=payload, headers=headers, status_code=status_code)

Integrations

SQL

To connect to a postgres resource, use the following snippet:

import psycopg2
from wayscript.integrations import sql

kwargs = sql.get_psycopg2_connection_kwargs(_id)
connection = psycopg2.connect(**kwargs)

Secrets

Create/Update Secret

To create a new secret, or update an existing one:

from wayscript import secret_manager

my_secret_value = "an application key or other private information"
secret_manager.set_secret('my_secret_key', my_secret_value)
    

To test an existing secret, and update if the secret is no longer valid (expired authorization token):

import os
from wayscript import secret_manager

# Retrieve existing key from secret
auth_key = os.getenv('AUTH_KEY_MAY_EXPIRE')

# Test connection to service using auth_key
if not authorized:
    # Get new auth_key from service
    auth_key = 'New Key From Service Request'
    secret_manager.set_secret('AUTH_KEY_MAY_EXPIRE', auth_key)

# Continue flow as normal

wayscript-python's People

Contributors

dependabot[bot] avatar hrgreene avatar jdhayford avatar jeffbuswell avatar meierj-wayscript avatar rachellhea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wayscript-python's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.