You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by bo...@apache.org on 2022/11/17 16:33:00 UTC
[incubator-streampipes] 05/10: [STREAMPIPES-607] add quickstart section to README
This is an automated email from the ASF dual-hosted git repository.
bossenti pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit 24e5c9c4ebdb9ffc9e7c4a9c5d1741a355cab2ab
Author: bossenti <bo...@posteo.de>
AuthorDate: Sun Nov 13 14:46:06 2022 +0100
[STREAMPIPES-607] add quickstart section to README
---
streampipes-client-python/README.md | 53 ++++++++++++++++++++-
.../docs/img/how-to-get-api-key.gif | Bin 0 -> 196505 bytes
2 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/streampipes-client-python/README.md b/streampipes-client-python/README.md
index 18e74e247..1cf17bb23 100644
--- a/streampipes-client-python/README.md
+++ b/streampipes-client-python/README.md
@@ -24,7 +24,7 @@ and the amazing universe of data analytics libraries in Python.
<h1 align="center">
<br>
- <img src="https://github.com/bossenti/incubator-streampipes/blob/feature/STREAMPIPES-607/streampipes-client-python/docs/img/streampipes-python.png"
+ <img src="https://raw.githubusercontent.com/apache/incubator-streampipes/STREAMPIPES-607/streampipes-client-python/docs/img/streampipes-python.png"
alt="StreamPipes Logo with Python" title="Apache StreamPipes Logo with Python" width="75%"/>
<br>
</h1>
@@ -44,3 +44,54 @@ and the amazing universe of data analytics libraries in Python.
**:exclamation::exclamation::exclamation:IMPORTANT:exclamation::exclamation::exclamation:**
<br>
+
+## ⚡️ Quickstart
+
+As a quick example, we demonstrate how to set up and configure a StreamPipes client.
+In addition, we will get the available data lake measures out of StreamPipes.
+
+```python
+>>> from streampipes_client.client import StreamPipesClient
+>>> from streampipes_client.client.client_config import StreamPipesClientConfig
+>>> from streampipes_client.client.credential_provider import StreamPipesApiKeyCredentials
+
+>>> config = StreamPipesClientConfig(
+... credential_provider=StreamPipesApiKeyCredentials(
+... username="test@streampipes.apache.org",
+... api_key="DEMO-KEY",
+... ),
+... host_address="localhost",
+... http_disabled=True,
+... port=80
+...)
+
+>>> client = StreamPipesClient(client_config=config)
+
+# get all available datat lake measures
+>>> measures = client.dataLakeMeasureApi.all()
+
+# get amount of retrieved measures
+>>> len(measures)
+1
+
+# inspect the data lake measures as pandas dataframe
+>>> measures.to_pandas()
+ measure_name timestamp_field ... pipeline_is_running num_event_properties
+0 test s0::timestamp ... False 2
+[1 rows x 6 columns]
+```
+<br>
+Alternatively, you can provide your credentials via environment variables.
+Simply define your credential provider as follows:
+
+```python
+>>> from streampipes_client.client.credential_provider import StreamPipesApiKeyCredentials
+
+StreamPipesApiKeyCredentials.from_env(username_env="USER", api_key_env="API-KEY")
+```
+<br>
+
+`username` is always the username that is used to log in into StreamPipes. <br>
+The `api_key` can be generated within the UI as demonstrated below:
+
+
\ No newline at end of file
diff --git a/streampipes-client-python/docs/img/how-to-get-api-key.gif b/streampipes-client-python/docs/img/how-to-get-api-key.gif
new file mode 100644
index 000000000..879ec8adb
Binary files /dev/null and b/streampipes-client-python/docs/img/how-to-get-api-key.gif differ