Metadata-Version: 2.1
Name: wayscript
Version: 0.3.0
Summary: Quickly build services, data pipelines, internal tools, and more.
Home-page: https://github.com/wayscript/wayscript-python
Author: Team WayScript
Author-email: founders@wayscript.com
License: MIT
Keywords: wayscript,productivity,software,scripts,cloud,tools,backend,trigger,integration,dev,http,webhook
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Communications
Classifier: Topic :: Database
Classifier: Topic :: Office/Business
Classifier: Topic :: Utilities
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Natural Language :: English
Description-Content-Type: text/markdown
License-File: LICENSE

# 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
```
