Skip to content
This repository was archived by the owner on Aug 19, 2022. It is now read-only.

Commit 4d68049

Browse files
authored
Convert from Webhook Trigger to HTTP Trigger (#6)
* Starting conversion to http trigger * update usages * tests * Create CHANGELOG.md * Update README.md * Add body params * Edit for consistency * Update changelog and add links
1 parent f3ff7a4 commit 4d68049

File tree

7 files changed

+262
-132
lines changed

7 files changed

+262
-132
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
## [0.1.0] - 2019-11-13
5+
### Changed
6+
- **BREAKING**: Convert SDK to adhere to the [WayScript HTTP Trigger](https://docs.wayscript.com/library/triggers/http-trigger) specification.
7+
8+
### Added
9+
- Changelog
10+
11+
## [0.0.3] - 2019-07-02
12+
### Fixed
13+
- setup.py on Windows
14+
15+
## [0.0.2] - 2019-07-01
16+
### Added
17+
- Can now specify which function to run
18+
19+
## [0.0.1] - 2019-04-17
20+
### Released SDK
21+
22+
[Unreleased]: https://github.com/wayscript/wayscript-python/compare/0.1.0...HEAD
23+
[0.1.0]: https://github.com/wayscript/wayscript-python/compare/0.0.3...0.1.0
24+
[0.0.3]: https://github.com/wayscript/wayscript-python/compare/v0.0.2...0.0.3
25+
[0.0.2]: https://github.com/wayscript/wayscript-python/compare/0.0.1...v0.0.2
26+
[0.0.1]: https://github.com/wayscript/wayscript-python/releases/tag/0.0.1

README.md

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
[![PyPI version](https://img.shields.io/pypi/v/wayscript.svg?color=blue)](https://pypi.python.org/pypi/wayscript/) [![CircleCI Status](https://circleci.com/gh/wayscript/wayscript-python/tree/master.svg?style=shield)](https://circleci.com/gh/wayscript/wayscript-python/tree/master)
44

5-
### A new way to build software.
5+
### A rapid scripting platform for developers.
66

7-
* WayScript gives you flexible building blocks to seamlessly integrate, automate and host tools in the cloud. Unlock new potential with drag and drop programming.
7+
WayScript allows you to run Python in the cloud, and seamlessly integrate with your favorite APIs.
88

9-
* Instantly connect to hundreds of datasets including GitHub, Twitter, databases, ecommerce data, or build your own integration. WayScript can read data from Excel, Google Sheets, and an evergrowing list of third-party APIs.
10-
11-
* Seamlessly migrate to the cloud: Generate interfaces, instantly share, and run via event-based triggering.
9+
![Trigger scripts on any event or schedule.](https://user-images.githubusercontent.com/31461850/68791449-30fde880-05fe-11ea-86d1-8dc739cda767.png)
1210

1311
## Installation
1412

@@ -18,52 +16,57 @@ pip install wayscript
1816

1917
## Basic Usage
2018

21-
1. Get the API Key from your WayScript user profile page
19+
1. Add one or more [HTTP Triggers](https://docs.wayscript.com/library/triggers/http-trigger) to your script.
20+
21+
2. If you have a [password-protected endpoint](https://docs.wayscript.com/library/triggers/http-trigger#password-protect-your-endpoints), obtain your API key or the credentials you would like to use.
22+
23+
3. If you have specified a [custom endpoint](https://docs.wayscript.com/library/triggers/http-trigger#endpoints), you will need the name of that endpoint as well.
2224

23-
2. Run your WayScript programs from your Python code:
25+
4. If your HTTP Trigger takes [query parameters](https://docs.wayscript.com/library/triggers/http-trigger#request-query-parameters) and/or [JSON body parameters](https://docs.wayscript.com/library/triggers/http-trigger#request-json-body-parameters), you can pass those as a dictionary using the `params` and/or `data` arguments, respectively. (See [HTTP Trigger Outputs](https://docs.wayscript.com/library/triggers/http-trigger#outputs) for more information.)
26+
27+
5. Run your WayScript programs from your Python code:
2428

2529
```python
2630
from wayscript import WayScript
2731

28-
api_key = 'YOUR_API_KEY'
29-
wayscript = WayScript( api_key )
32+
# Create the WayScript client
33+
wayscript = WayScript()
34+
35+
# If your program requires a password to run, supply those credentials when creating the client
36+
username = 'YOUR_USERNAME'
37+
password = 'YOUR_PASSWORD'
38+
kwargs = { 'username': username, 'password': password }
39+
wayscript = WayScript( **kwargs )
40+
41+
# If your program requires a password to run, you can instead supply your API Key when creating the client
42+
kwargs = { 'api_key': 'MY_API_KEY' }
43+
wayscript = WayScript( **kwargs )
3044

3145
# Run a program by id
3246
program_id = 1234
33-
wayscript.run_program( program_id )
47+
wayscript.run( program_id )
3448

35-
# Pass variables to a program (optional)
36-
variables = [ 'one', 'two', 'three' ]
37-
wayscript.run_program( program_id, variables = variables )
49+
# Pass query parameters for the HTTP Trigger to output (optional)
50+
query_params = { 'var1': 'one', 'var2': 'two', 'var3': 'three' }
51+
wayscript.run( program_id, params = query_params )
3852

39-
# Run a specific function within your program (optional)
40-
function = 'My Function'
41-
wayscript.run_program( program_id, variables = variables, function = function )
53+
# Pass JSON body parameters for the HTTP Trigger to output (optional)
54+
body_params = { 'var4': 'four', 'var5': 'five', 'var6': 'six' }
55+
wayscript.run( program_id, data = body_params )
4256

43-
# Run a program asynchronously (optional)
44-
wayscript.run_program( program_id, run_async = True )
45-
wayscript.run_program( program_id, variables = variables, function = function, run_async = True )
57+
# Run a custom endpoint (optional)
58+
endpoint = 'my_endpoint'
59+
wayscript.run( program_id, endpoint = endpoint, params = query_params, data = body_params )
4660

4761
# Get the response from the server
48-
response = wayscript.run_program( program_id )
62+
response = wayscript.run( program_id )
4963
```
5064

51-
⭐ In order to run a program using the WayScript Python API, you must first add an active [Webhook Trigger](https://wayscript.com/documentation/trigger/webhook_trigger) to that program.
52-
53-
### Running a specific function
54-
55-
- The function you specify MUST have an active [Webhook Trigger](https://wayscript.com/documentation/trigger/webhook_trigger).
56-
- If you do not specify a function name in your request and your program has ***one*** function with a Webhook Trigger, the function with the Webhook Trigger will run.
57-
- If you do not specify a function name in your request and your program has ***multiple*** functions with Webhook Triggers, you will be asked to specify which function you would like to run.
58-
5965
## Run a WayScript program from command line
6066
```sh
61-
WS_API_KEY="YOUR_API_KEY"
6267
PROGRAM_ID=1234
63-
ARGUMENT="whatever"
64-
FUNCTION="My Function"
6568

66-
python -c "from wayscript import WayScript; WayScript('$WS_API_KEY').run_program($PROGRAM_ID, '$ARGUMENT', '$FUNCTION')"
69+
python -c "from wayscript import WayScript; WayScript().run($PROGRAM_ID)"
6770
```
6871

69-
If you don't want to use Python on the command line, you can use `curl`. (See the WayScript [REST API documentation](https://wayscript.com/documentation/apis/rest_api).)
72+
If you don't want to use Python on the command line, you can use `cURL`. (See the [HTTP Trigger Sample Code](https://docs.wayscript.com/library/triggers/http-trigger#sample-code) for an example.)

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
setuptools.setup(
1212
name="wayscript",
13-
version="0.0.3",
13+
version="0.1.0",
1414
author="Team WayScript",
1515
author_email="founders@wayscript.com",
1616
description="WayScript gives you flexible building blocks to seamlessly integrate, automate and host tools in the cloud.",
1717
long_description=long_description,
1818
long_description_content_type="text/markdown",
19-
install_requires=['requests>=2.21.0'],
19+
install_requires=['requests>=2.22.0'],
2020
url="https://github.com/wayscript/wayscript-python",
2121
packages=['wayscript'],
2222
license='MIT',
@@ -37,7 +37,7 @@
3737
"Operating System :: OS Independent",
3838
"Natural Language :: English",
3939
],
40-
keywords=['wayscript', 'productivity', 'software', 'superpowers', 'scripts', 'cloud', 'tools', 'backend',
41-
'visual', 'low-code', 'modules', 'trigger'],
40+
keywords=[ 'wayscript', 'productivity', 'software', 'superpowers', 'scripts', 'cloud', 'tools', 'backend',
41+
'visual', 'low-code', 'modules', 'trigger', 'integration', 'dev', 'http', 'webhook' ],
4242
zip_safe=False,
4343
)

0 commit comments

Comments
 (0)