Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ckuhtz committed Jul 25, 2024
1 parent 9df0f1f commit d289b42
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
28 changes: 26 additions & 2 deletions api/routers/configuration/get.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
# Configuration GET

def get():
return
# from enum import Enum
from ast import Dict
from fastapi import Request, Response

# Data models

# class SectionName(str, Enum):
# n0nbh = 'n0nbh'
# couchbase = 'couchbase'

def get(
response: Response,
request: Request,
instance_param: str = None,
section_param: str = None
) -> Dict:

return_dict = {'section': section_param, 'instance': instance_param}

# match section_param:
# case SectionName.couchbase:
# return_dict.update({'message': 'i am a futon.'})
# case SectionName.n0nbh:
# return_dict.update({'message': 'it is dark.'})

return return_dict
39 changes: 17 additions & 22 deletions api/routers/configuration/operations.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Configuration operations

from enum import Enum
from fastapi import APIRouter, Body, Request, Response
from typing import Optional
from fastapi import APIRouter, Body, Path, Request, Response, Query

from .get import get as configuration_get
from .put import put as configuration_put
Expand All @@ -20,34 +21,28 @@ class SectionName(str, Enum):
n0nbh = 'n0nbh'
couchbase = 'couchbase'



# GET

@router.get('/configuration')
async def get_config_all(
@router.get('/configuration/{instance}')
@router.get('/configuration/{instance}/{section}')
def get_config(
request: Request,
response: Response
response: Response,
instance: str = None,
section: SectionName = None
):
# get(
# request=request,
# response=response,
# )
return {'message': 'that\'s everything.'}
return_dict = configuration_get(
request=request,
response=response,
instance_param=instance,
section_param=section
)

print(f'return_dict: {return_dict}')

return return_dict

@router.get('/configuration/{instance}')
async def get_config_instance(instance: str):
return {'instance': instance}


@router.get('/configuration/{instance}/{section}')
async def get_config_instance_section(instance: str, section: SectionName):
match section:
case SectionName.couchbase:
return {'message': 'i am a futon.'}
case SectionName.n0nbh:
return {'message': 'it is dark.'}



Expand Down

0 comments on commit d289b42

Please sign in to comment.