-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,80 @@ | ||
# Configuration operations | ||
|
||
from enum import Enum | ||
from fastapi import APIRouter | ||
import redis | ||
from fastapi import APIRouter, Body | ||
|
||
router = APIRouter() | ||
|
||
# Data models | ||
|
||
class SectionName(str, Enum): | ||
n0nbh = 'n0nbh' | ||
couchbase = 'couchbase' | ||
|
||
|
||
|
||
# GET | ||
|
||
@router.get('/configuration') | ||
async def get_configuration(): | ||
return {'instance': 'instance'} | ||
async def get_config(): | ||
return {'message': 'that\'s everything.'} | ||
|
||
@router.get('/configuration/{instance}') | ||
async def get_configuration_instance(instance: str): | ||
async def get_config_instance(instance: str): | ||
return {'instance': instance} | ||
|
||
@router.get('/configuration/{instance}/{section}') | ||
async def get_configuration_instance_section(instance: str, section: SectionName): | ||
async def get_config_instance_section(instance: str, section: SectionName): | ||
match section: | ||
case SectionName.couchbase: | ||
return {'instance': instance}, {'message': 'I am a futon.'} | ||
return {'message': 'i am a futon.'} | ||
case SectionName.n0nbh: | ||
return {'instance': instance}, {'message': 'It is dark.'} | ||
return {'message': 'it is dark.'} | ||
|
||
|
||
|
||
# PUT | ||
|
||
@router.put('/configuration') | ||
async def put_config(body: dict = Body (...)): | ||
return body | ||
|
||
@router.get('/configuration/{instance}') | ||
async def put_config_instance(instance: str, body: dict = Body (...)): | ||
return body | ||
|
||
@router.get('/configuration/{instance}/{section}') | ||
async def put_config_instance_section(instance: str, section: SectionName, body: dict = Body (...)): | ||
return body | ||
|
||
|
||
|
||
# PATCH | ||
|
||
@router.patch('/configuration') | ||
async def patch_config(): | ||
return {'instance': 'instance'} | ||
|
||
@router.patch('/configuration/{instance}') | ||
async def patch_config_instance(instance: str): | ||
return {'instance': 'instance'} | ||
|
||
@router.patch('/configuration/{instance}/{section}') | ||
async def patch_config_instance_section(instance: str, section: SectionName): | ||
return {'instance': 'instance'} | ||
|
||
|
||
|
||
# DELETE | ||
|
||
@router.delete('/configuration') | ||
async def delete_config(): | ||
return {'message': 'he\'s dead, jim.'} | ||
|
||
@router.delete('/configuration/{instance}') | ||
async def delete_config_instance(instance: str): | ||
return {'message': 'he\'s dead, jim.'} | ||
|
||
@router.delete('/configuration/{instance}/{section}') | ||
async def delete_config_instance_section(instance: str, section: SectionName): | ||
return {'message': 'he\'s dead, jim.'} |