Merge pull request #414 from openziti/python-sdk-tweaks

Python sdk doc tweaks
This commit is contained in:
Kenneth Bingham 2023-10-19 08:29:41 -04:00 committed by GitHub
commit 1912b7b0ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 11 deletions

3
.gitignore vendored
View File

@ -33,3 +33,6 @@ yarn-debug.log*
yarn-error.log* yarn-error.log*
.obsidian .obsidian
sdk/examples/pastebin/cmd/copyto/copyto
sdk/examples/pastebin/cmd/copyto/payload
sdk/examples/pastebin/cmd/pastefrom/pastefrom

View File

@ -1,36 +1,55 @@
# zrok Pastebin # zrok Pastebin
This example shows the use of the zrok SDK spinning up a simple pastebin command. This example shows the use of the zrok SDK spinning up a simple pastebin command.
## Setup :wrench: ## Self-hosting Setup :wrench:
Refer to the [setup guide](../../../docs/guides/self-hosting/self_hosting_guide.md) for details on setting up your zrok environment needed for this example.
You don't need this section if you're using hosted zrok from NetFoundry (https://api.zrok.io/).
Refer to the [setup guide](../../../docs/guides/self-hosting/self_hosting_guide.md) for details on setting up your zrok
environment if you're self-hosting zrok.
### Install Python Requirements ### Install Python Requirements
The zrok SDK requires Python 3.10 or later.
If you haven't already installed them, you'll need the dependent libraries used in the examples. If you haven't already installed them, you'll need the dependent libraries used in the examples.
```bash ```bash
pip install -r ../requirements pip install -r ./sdk/python/examples/requirements.txt
``` ```
## Running the Example :arrow_forward: ## Running the Example :arrow_forward:
This example contains a `copyto` server portion and `pastefrom` client portion. This example contains a `copyto` server portion and `pastefrom` client portion.
### copyto ### copyto
The server portion expects to get data you want to send via stdin. It can be evoked by: The server portion expects to get data you want to send via stdin. It can be evoked by:
```shell
```bash
echo "this is a cool test" | python pastebin.py copyto echo "this is a cool test" | python pastebin.py copyto
``` ```
You should see some helpful info printed out to your terminal: You should see some helpful info printed out to your terminal:
```shell
```bash
access your pastebin using 'pastebin.py pastefrom vp0xgmknvisu' access your pastebin using 'pastebin.py pastefrom vp0xgmknvisu'
``` ```
The last token in that line is your share token. We'll use that in the pastefrom command to access our data. The last token in that line is your share token. We'll use that in the pastefrom command to access our data.
### pastefrom ### pastefrom
The `pastefrom` client expects the share token as an argument. The `pastefrom` client expects the share token as an argument.
If we envoke it using the same token as above: If we envoke it using the same token as above:
```shell
```bash
python pastebin.py pastefrom vp0xgmknvisu python pastebin.py pastefrom vp0xgmknvisu
``` ```
we see the data we had piped into the `copyto` server: we see the data we had piped into the `copyto` server:
```
```text
this is a cool test this is a cool test
``` ```