Python dataclasses for the Envoy Data-Plane-API
Project description
envoy_data_plane
A conversion of envoyproxy/data-plane-api protocol buffers into Python dataclasses using betterproto
Intended usage
This is a helper library that allows importing every type available in the envoy API.
One use-case might be generating Envoy configuration using a Python script.
In my case, I will use this library in my custom built control-plane, so that I have autocompletion in my IDE, and a basic form of validation.
In future, this may also help with building an idiomatic GRPC control-plane in Python.
Installation
This package is published to PyPI:
python -m pip install envoy_data_plane
Example
import stringcase
import json
import envoy_data_plane.envoy.api.v2 as envoy
route_config = envoy.RouteConfiguration(
name='MyRouteConfig',
virtual_hosts=[
envoy.route.VirtualHost(
name='SomeWebsite',
domains=['foobar.com'],
routes=[
envoy.route.Route(
name='catchall',
match=envoy.route.RouteMatch(
prefix='/'
),
direct_response=envoy.route.DirectResponseAction(
status=200,
body=envoy.core.DataSource(
inline_string='Hello there'
)
)
)
]
)
]
)
response = envoy.DiscoveryResponse(
version_info='0',
resources=[
route_config
],
)
print(
json.dumps(response.to_dict(casing=stringcase.snakecase), indent=2)
)
Result:
{
"version_info": "0",
"resources": [
{
"name": "MyRouteConfig",
"virtual_hosts": [
{
"name": "SomeWebsite",
"domains": [
"foobar.com"
],
"routes": [
{
"name": "catchall",
"match": {
"prefix": "/",
"headers": [],
"query_parameters": []
},
"direct_response": {
"status": 200,
"body": {
"inline_string": "Hello there"
}
},
"request_headers_to_add": [],
"response_headers_to_add": []
}
],
"virtual_clusters": [],
"rate_limits": [],
"request_headers_to_add": [],
"response_headers_to_add": []
}
],
"response_headers_to_add": [],
"request_headers_to_add": []
}
]
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
envoy_data_plane-0.2.0.tar.gz
(62.7 kB
view hashes)
Built Distributions
envoy_data_plane-0.2.0-py3.8.egg
(152.7 kB
view hashes)
envoy_data_plane-0.2.0-py3.7.egg
(152.6 kB
view hashes)
Close
Hashes for envoy_data_plane-0.2.0-py3.8.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90959a9256853a17fb768703ab20064be6d4612e5c99626b23efe9323f0054a4 |
|
MD5 | 610ddcebbe1b1a33d8f5c454389535e6 |
|
BLAKE2b-256 | f2cc50da8ba1448a474c380c4277adc185a64f807e60de9fda37262dd0e0e9e9 |
Close
Hashes for envoy_data_plane-0.2.0-py3.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b13723f671f5c78b93d8373ec5fad3c0af331b36929582fab64d98bd5aa9114 |
|
MD5 | 2b5e0064e204f49d47eb647f4724fa8f |
|
BLAKE2b-256 | 403675022c96961334f389b0bf19c50897ca9b4b96c183364b115e8e2b2ad581 |