Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
befbf03
feat: add http python impl
Niraj-Kamdar Mar 2, 2023
0c94f16
fix: issues
Niraj-Kamdar Mar 5, 2023
48f8b21
fix: pyproject file
Niraj-Kamdar Mar 5, 2023
2dd7aa9
chore: update poetry lock
Niraj-Kamdar Mar 5, 2023
cd025bd
v0.10.0-pre.10
Niraj-Kamdar Mar 15, 2023
4d1994a
fix: python http plugin
Niraj-Kamdar Apr 14, 2023
5729a3a
fix: tests
Niraj-Kamdar Apr 18, 2023
40fcf59
fix: package.json
Niraj-Kamdar Apr 18, 2023
68d1bfc
Merge branch 'main' into nk/http-py
Niraj-Kamdar Apr 18, 2023
b8c54a0
fix: package.json
Niraj-Kamdar Apr 18, 2023
337bb1c
feat: add readme
Niraj-Kamdar Apr 18, 2023
eb6d54b
Update README.md
Niraj-Kamdar Apr 18, 2023
c21d1bf
fix: ignore tox dir
Niraj-Kamdar Apr 18, 2023
e9d747f
feat: add ci/cd
Niraj-Kamdar Apr 18, 2023
ec60cc7
Merge branch 'nk/http-py' of https://github.com/polywrap/http into nk…
Niraj-Kamdar Apr 18, 2023
0c1d8fc
fix: issues in ci/cd
Niraj-Kamdar Apr 18, 2023
668c635
fix: package.json
Niraj-Kamdar Apr 18, 2023
f0d2533
fix: linting issues
Niraj-Kamdar Apr 18, 2023
36872b4
Temp: fix
Niraj-Kamdar Apr 23, 2023
76ecaaa
Update .github/workflows/http-plugin-py-cd.yaml
Niraj-Kamdar Apr 24, 2023
83b6e72
Merge remote-tracking branch 'origin/nk/http-py' into nk/http-py
Niraj-Kamdar Apr 26, 2023
1c9ab06
Merge remote-tracking branch 'origin/main' into nk/http-py
Niraj-Kamdar Apr 26, 2023
0c16deb
chore: bump polywrap version
Niraj-Kamdar Apr 26, 2023
1cbcada
feat: create workspace file
Niraj-Kamdar Apr 26, 2023
99670d2
chore: import sort
Niraj-Kamdar Apr 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/http-plugin-py-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: http-plugin-py-cd

on:
pull_request:
types: [closed]
branches:
- main
paths:
- "implementations/py/**"

jobs:
cd:
name: http-plugin-py-cd
if: |
github.event.pull_request.merged &&
startsWith(github.event.pull_request.title, '[CD]') == true &&
github.event.pull_request.user.login != 'github-actions'
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm
working-directory: ./implementations/py

- name: Setup Node.js
uses: actions/setup-node@master
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'

- name: Install dependencies
run: yarn install --nonInteractive --frozen-lockfile --prefer-offline
working-directory: ./implementations/py

- name: Codegen
run: yarn codegen
working-directory: ./implementations/py

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 -

- name: Install dependencies
run: poetry install
working-directory: ./implementations/py

- name: Publish
run: poetry publish --build -u __token__ -p {{ env.PYPI_TOKEN }}
working-directory: ./implementations/py
env:
PYPI_TOKEN: ${{ secrets.POLYWRAP_BUILD_BOT_PYPI_PAT }}

61 changes: 61 additions & 0 deletions .github/workflows/http-plugin-py-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: http-plugin-py-ci

on:
pull_request:
paths:
- "implementations/py/**"

jobs:
ci:
name: http-plugin-py-ci
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm
working-directory: ./implementations/py

- name: Setup Node.js
uses: actions/setup-node@master
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'

- name: Install dependencies
run: yarn install --nonInteractive --frozen-lockfile --prefer-offline
working-directory: ./implementations/py

- name: Codegen
run: yarn codegen
working-directory: ./implementations/py

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 -

- name: Install dependencies
run: poetry install
working-directory: ./implementations/py

- name: Typecheck
run: poetry run tox -e typecheck
working-directory: ./implementations/py

- name: Lint
run: poetry run tox -e lint
working-directory: ./implementations/py

- name: Security
run: poetry run tox -e secure
working-directory: ./implementations/py

- name: Test
run: poetry run tox
working-directory: ./implementations/py
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ bin
!packages/cli/bin
pkg
wasm-pack.log
.env
.env
**/__pycache__/
.pytest_cache/
dist/
27 changes: 27 additions & 0 deletions http-monorepo.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"folders": [
{
"name": "root",
"path": "."
},
{
"name": "interface",
"path": "interface"
},
{
"name": "python-plugin",
"path": "implementations/py"
},
{
"name": "javascript-plugin",
"path": "implementations/js"
},
],
"settings": {
"files.exclude": {
"**/interface/*": true,
"**/implementations/*": true
},
"liveServer.settings.multiRootWorkspaceName": "root",
}
}
5 changes: 5 additions & 0 deletions implementations/py/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/.vscode/
**/.pytest_cache/
**/dist/
**/node_modules/
**/.tox/
1 change: 1 addition & 0 deletions implementations/py/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v17.9.1
52 changes: 52 additions & 0 deletions implementations/py/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# @polywrap/http-plugin-js

Http plugin currently supports two different methods `GET` and `POST`. Similar to calling axios, when defining request you need to specify a response type. Headers and query parameters may also be defined.

## Response Types

`TEXT` - The server will respond with text, the HTTP plugin will return the text as-is.

`BINARY` - The server will respond with binary data (_bytes_), the HTTP plugin will encode as a **base64** string and return it.

## GET request

Below is sample invocation of the `GET` request with custom request headers and query parameters (`urlParams`).

```python
result = await client.invoke(
InvokerOptions(
uri="wrap://ens/http.polywrap.eth",
method="get",
args={
"url": "http://www.example.com/api",
"request": {
"responseType": "TEXT",
"urlParams": [{"key": "query", "value": "foo"}],
"headers": [{"key": "X-Request-Header", "value": "req-foo"}],
},
},
)
)
```

## POST request

Below is sample invocation of the `POST` request with custom request headers and query parameters (`urlParams`). It is also possible to set request body as shown below.

```python
response = await client.invoke(
InvokerOptions(
uri="wrap://ens/http.polywrap.eth",
method="post",
args={
"url": "http://www.example.com/api",
"request": {
"responseType": "TEXT",
"urlParams": [{"key": "query", "value": "foo"}],
"headers": [{"key": "X-Request-Header", "value": "req-foo"}],
"body": "{data: 'test-request'}",
}
}
)
)
```
12 changes: 12 additions & 0 deletions implementations/py/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@polywrap/python-http-plugin",
"description": "Polywrap Python Http Plugin",
"version": "0.10.2",
"private": true,
"devDependencies": {
"polywrap": "0.10.2"
},
"scripts": {
"codegen": "npx polywrap codegen"
}
}
Loading