Skip to main content

Dapr Api Wrapper

This is a simple Interface built over Microsoft Dapr APIs for easy transition from libraries like requests and aiohttp to dapr's grpc interface without additional changes in code.

Requirements

  1. Kubernetes cluster (eg. Azure Kubernetes)
  2. Dapr Setup in Kubernetes

Setup

Step:1

Copy the contents of configuration yml from dapr_api_wrapper > setup > setup.yml

Step:2

Paste them in a new dapr_setup.yml file and add references to passwords (recommended) or passwords directly. Change namespace if required.

Step:3

Apply changes to your kubernetes cluster by running: kubectl apply -f path/to/your/dapr_setup.yml

Step:4

In your kubernetes pod deployment.yml configuration add dapr annotations as referenced here.

apiVersion: apps/v1
kind: Deployment
metadata:
labels:
    app: myawesome-svc
name: myawesome-svc-deployment
spec:
replicas: 1
selector:
    matchLabels:
    app: myawesome-svc

# Add the below lines
# Remove '#' to uncomment any annotation

template:
    metadata:
        annotations:
            dapr.io/app-id: myawesome-svc
            dapr.io/app-port: "<myawesome-svc-port>"
            dapr.io/app-protocol: http # http | grpc
            dapr.io/config: appconfig
            # dapr.io/enable-metrics: "true"
            # dapr.io/enable-profiling: "true" # Setting this paramater to true starts the Dapr profiling server on port 7777
            dapr.io/enabled: "true"
            # dapr.io/http-max-request-size: 64 # Increasing max size of request body http and grpc servers parameter in MB to handle uploading of big files. Default is 4 MB
            # dapr.io/log-as-json: "false"
            dapr.io/log-level: debug # info | warn | error
            # dapr.io/metrics-port: "9090"
            # dapr.io/sidecar-cpu-limit: 1
            # dapr.io/sidecar-memory-limit: 500Mi

        labels:
            app: myawesome-svc
            redis-client: "true"
# Add the above lines
    # Further configuration
    spec:
    containers:
    

Understanding the request

Get the request arguments from the docstring of below mentioned class.

from dapr_api_wrapper.requests import DaprRequest

API Usage

from dapr_api_wrapper import requests as dapr_requests
from datetime import datetime

request_body = {
    "id": "12345",
    "api_key": "1234567",
    "updated_at": str(datetime.now()),
    "num": 1234567,
    "is_auth": True,
}

resp = dapr_requests.post(
    app_id="myawesome-svc",
    url_path="http://myawesome-svc-svc/test",
    data=request_body,
    content_type="application/json",
    headers={"key1": "value1"},
    http_query_params={"querykey1": "queryvalue1"},
)
resp_json = resp.json()

resp_text = resp.text

resp_bytes = resp.bytes()

print (f"\n{resp_json = }\n{resp_text = }\n{resp_bytes = }", flush=True)

Metadata

Release files for dapr-api-wrapper 1.2.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dapr-api-wrapper 1.2.8
File Size Uploaded Provenance
dapr_api_wrapper-1.2.8.tar.gz 8.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dapr-api-wrapper 1.2.8
File Interpreter ABI Platform
dapr_api_wrapper-1.2.8-py3-none-any.whl Python 3 none any Details

Total release size: 18.5 kB

Release files / dapr_api_wrapper-1.2.8.tar.gz

Download URL dapr_api_wrapper-1.2.8.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0903808de1a0ef15843e0d5e84847d30f1eb425f7124461e85c2aedd5d632169
BLAKE2b-256 checksum
How to use checksums
e5b6ef872d2f2d9f025edc15dd1e1634fef8923ea5975e17dd39f29c19295445
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.0

Release files / dapr_api_wrapper-1.2.8-py3-none-any.whl

Download URL dapr_api_wrapper-1.2.8-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6cfa259e8c892e816ca6a2df122c29da66a007de6aff42a7d6b01f169926ca7
BLAKE2b-256 checksum
How to use checksums
33cb8a3e526bc00b92c356c6f383fc5c6d54e5b89b9353bdaea77106f4c06be6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.0

Security for dapr-api-wrapper 1.2.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page