From 009ae30f3d94b1ecccb0b92ecdcd52489af39176 Mon Sep 17 00:00:00 2001 From: Matthias Veit Date: Mon, 30 Sep 2024 16:25:02 +0200 Subject: [PATCH] [feat] Allow definition of keys in metadata section (#629) --- fixbackend/inventory/inventory_client.py | 6 +++--- fixbackend/inventory/inventory_router.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fixbackend/inventory/inventory_client.py b/fixbackend/inventory/inventory_client.py index 34adb495..ac52c25e 100644 --- a/fixbackend/inventory/inventory_client.py +++ b/fixbackend/inventory/inventory_client.py @@ -245,7 +245,7 @@ def search_history( if after: params["after"] = utc_str(after) if change: - params["change"] = ",".join(c.value for c in change) + params["change"] = ",".join(change) return self._stream( "POST", f"/graph/{graph}/search/history/list", @@ -468,7 +468,7 @@ async def model( # format options with_properties: bool = True, with_relatives: bool = True, - with_metadata: bool = True, + with_metadata: Union[bool, List[str]] = True, graph: str = DefaultGraph, ) -> List[Json]: log.info(f"Get model with flat={flat}, with_bases={with_bases}, with_property_kinds={with_property_kinds}") @@ -482,7 +482,7 @@ async def model( "aggregate_roots_only": json.dumps(aggregate_roots_only), "with_properties": json.dumps(with_properties), "with_relatives": json.dumps(with_relatives), - "with_metadata": json.dumps(with_metadata), + "with_metadata": ",".join(with_metadata) if isinstance(with_metadata, list) else json.dumps(with_metadata), } response = await self._request( "GET", diff --git a/fixbackend/inventory/inventory_router.py b/fixbackend/inventory/inventory_router.py index 24c5cf06..2e961309 100644 --- a/fixbackend/inventory/inventory_router.py +++ b/fixbackend/inventory/inventory_router.py @@ -13,7 +13,7 @@ # along with this program. If not, see . import logging from datetime import datetime, timedelta -from typing import Annotated, List, Literal, Optional, AsyncIterator, Dict +from typing import Annotated, List, Literal, Optional, AsyncIterator, Dict, Union from fastapi import APIRouter, Body, Depends, Form, Path, Query, Request from fastapi.responses import JSONResponse, Response @@ -174,7 +174,7 @@ async def model( aggregate_roots_only: bool = Query(default=True, description="Include only aggregate roots."), with_properties: bool = Query(default=True, description="Include properties."), with_relatives: bool = Query(default=True, description="Include property kinds."), - with_metadata: bool = Query(default=True, description="Include property kinds."), + with_metadata: Union[bool, List[str]] = Query(default=True, description="Include property kinds."), flat: bool = Query(default=True, description="Return a flat list of kinds."), ) -> List[Json]: return await inventory().client.model(