Skip to main content

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

Metadata

Release files for wayscript 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wayscript 0.4.0
File Size Uploaded
wayscript-0.4.0.tar.gz 7.9 kB Details

Release files / wayscript-0.4.0.tar.gz

Download URL wayscript-0.4.0.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
70dcd34c95d8dd7c4519524c24a552215d05f0bb711a8c47fd92cc281086551a
BLAKE2b-256 checksum
How to use checksums
89e6a5f45a9433aaf346e0eb13098ed0a84d528ddaecb24c5f9e98abb188b367
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.9

Release history Release notifications | RSS feed

This release

0.4.0 This release

1 release file

0.3.0

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page