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/13 13:46:17 UTC

[incubator-streampipes] branch STREAMPIPES-607 updated: [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 STREAMPIPES-607
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/STREAMPIPES-607 by this push:
     new 99429bad2 [STREAMPIPES-607] add quickstart section to README
99429bad2 is described below

commit 99429bad2b9c4839728fac016da8fea0e79c2509
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                |  52 ++++++++++++++++++++-
 .../docs/img/how-to-get-api-key.gif                | Bin 0 -> 196505 bytes
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/streampipes-client-python/README.md b/streampipes-client-python/README.md
index 18e74e247..7b31ca048 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,53 @@ 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")
+```
+
+`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:
+
+![Howto API Key](https://raw.githubusercontent.com/apache/incubator-streampipes/STREAMPIPES-607/streampipes-client-python/docs/img/how-to-get-api-key.gif)
\ 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