-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add python implementation #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 0c94f16
fix: issues
Niraj-Kamdar 48f8b21
fix: pyproject file
Niraj-Kamdar 2dd7aa9
chore: update poetry lock
Niraj-Kamdar cd025bd
v0.10.0-pre.10
Niraj-Kamdar 4d1994a
fix: python http plugin
Niraj-Kamdar 5729a3a
fix: tests
Niraj-Kamdar 40fcf59
fix: package.json
Niraj-Kamdar 68d1bfc
Merge branch 'main' into nk/http-py
Niraj-Kamdar b8c54a0
fix: package.json
Niraj-Kamdar 337bb1c
feat: add readme
Niraj-Kamdar eb6d54b
Update README.md
Niraj-Kamdar c21d1bf
fix: ignore tox dir
Niraj-Kamdar e9d747f
feat: add ci/cd
Niraj-Kamdar ec60cc7
Merge branch 'nk/http-py' of https://github.com/polywrap/http into nk…
Niraj-Kamdar 0c1d8fc
fix: issues in ci/cd
Niraj-Kamdar 668c635
fix: package.json
Niraj-Kamdar f0d2533
fix: linting issues
Niraj-Kamdar 36872b4
Temp: fix
Niraj-Kamdar 76ecaaa
Update .github/workflows/http-plugin-py-cd.yaml
Niraj-Kamdar 83b6e72
Merge remote-tracking branch 'origin/nk/http-py' into nk/http-py
Niraj-Kamdar 1c9ab06
Merge remote-tracking branch 'origin/main' into nk/http-py
Niraj-Kamdar 0c16deb
chore: bump polywrap version
Niraj-Kamdar 1cbcada
feat: create workspace file
Niraj-Kamdar 99670d2
chore: import sort
Niraj-Kamdar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,4 +16,7 @@ bin | |
| !packages/cli/bin | ||
| pkg | ||
| wasm-pack.log | ||
| .env | ||
| .env | ||
| **/__pycache__/ | ||
| .pytest_cache/ | ||
| dist/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| **/.vscode/ | ||
| **/.pytest_cache/ | ||
| **/dist/ | ||
| **/node_modules/ | ||
| **/.tox/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| v17.9.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'}", | ||
| } | ||
| } | ||
| ) | ||
| ) | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.