The Dapr client package allows you to interact with other Dapr applications from a Python application.
The dapr package contains the DaprClient
which will be used to create and use a client.
from dapr.clients import DaprClient
The Python SDK allows you to interface with all of the Dapr building blocks.
from dapr.clients import DaprClient
with DaprClient() as d:
resp = d.invoke_service(id='service-to-invoke', method='method-to-invoke', data='{"message":"Hello World"}')
from dapr.clients import DaprClient
with DaprClient() as d:
# Save state
d.save_state(store_name="statestore", key="key1", value="value1")
# Get state
data = d.get_state(store_name="statestore", key="key1").data
# Delete state
d.delete_state(store_name="statestore", key="key1")
from dapr.clients import DaprClient
with DaprClient() as d:
resp = d.publish_event(pubsub_name='pubsub', topic='TOPIC_A', data='{"message":"Hello World"}')
from dapr.clients import DaprClient
with DaprClient() as d:
resp = d.invoke_binding(name='kafkaBinding', operation='create', data='{"message":"Hello World"}')
from dapr.clients import DaprClient
with DaprClient() as d:
resp = d.get_secret(store_name='localsecretstore', key='secretKey')