An open API service indexing awesome lists of open source software.

https://github.com/alexdemure/gadfastetcd

A FastAPI integration with Etcd for managing configuration settings via a RESTful API.
https://github.com/alexdemure/gadfastetcd

fastapi-etdc pydantic-etdc python-etdc

Last synced: about 1 year ago
JSON representation

A FastAPI integration with Etcd for managing configuration settings via a RESTful API.

Awesome Lists containing this project

README

          



logo


A FastAPI integration with Etcd for managing configuration settings via a RESTful API

---

### Installation

```
pip install gadfastetcd
```

### Usage

#### API
Set
```curl
curl -X 'PUT' \
'http://127.0.0.1:8000/-/etcd' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"test": 1
}
```
Get
```
curl -X 'GET' \
'http://127.0.0.1:8000/-/etcd' \
-H 'accept: application/json'

{
"test": 1
}
```

#### Code
```python
import pydantic

import fastapi

from gadfastetcd import Etcd

class Settings(pydantic.BaseModel):
class Config:
extra = "allow"

settings = Settings()

etcd = Etcd(url="localhost:2379", storage="/{service_name}/{environment}", settings=settings)

app = fastapi.FastAPI()

app.include_router(etcd.router)

>>> settings.test
```