Skip to content

Commit

Permalink
fix: Move arguments out of body object (#2351)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleixhub authored Jan 14, 2025
1 parent abe303d commit 9e54859
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 22 deletions.
7 changes: 3 additions & 4 deletions catalog/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,12 @@ async def bookmark_post(request):
@routes.delete("/api/user-manager/bookmarks")
async def bookmark_delete(request):
user = await get_proxy_user(request)
data = await request.json()
data["email"] = user['metadata']['name']
asset_uuid = request.query.get("asset_uuid")
email = user['metadata']['name']
return await api_proxy(
data=json.dumps(data),
headers=request.headers,
method="DELETE",
url=f"{ratings_api}/api/user-manager/v1/bookmarks",
url=f"{ratings_api}/api/user-manager/v1/bookmarks?asset_uuid={asset_uuid}&email={email}",
)

@routes.get("/api/ratings/catalogitem/{asset_uuid}/history")
Expand Down
2 changes: 1 addition & 1 deletion catalog/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ api:
threads: 1
image:
#override:
tag: v1.0.8
tag: v1.0.9
repository: quay.io/redhat-gpte/babylon-catalog-api
pullPolicy: IfNotPresent
imagePullSecrets: []
Expand Down
25 changes: 16 additions & 9 deletions catalog/ui/src/app/Catalog/CatalogItemDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,22 @@ const CatalogItemDetails: React.FC<{ catalogItem: CatalogItem; onClose: () => vo
return null;
}
setIsLoadingFavorites(true);
const fav = await fetcher(apiPaths.FAVORITES({}), {
method: isFavorite ? 'DELETE' : 'POST',
body: JSON.stringify({
asset_uuid,
}),
headers: {
'Content-Type': 'application/json',
},
});
let fav = null;
if (isFavorite) {
fav = await fetcher(apiPaths.FAVORITES_DELETE({ asset_uuid }), {
method: 'DELETE',
});
} else {
fav = await fetcher(apiPaths.FAVORITES({}), {
method: 'POST',
body: JSON.stringify({
asset_uuid,
}),
headers: {
'Content-Type': 'application/json',
},
});
}
mutateFavorites(fav);
setIsLoadingFavorites(false);
return null;
Expand Down
1 change: 1 addition & 0 deletions catalog/ui/src/app/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1795,5 +1795,6 @@ export const apiPaths: { [key in ResourceType]: (args: any) => string } = {
SFDC_BY_ACCOUNT: ({ sales_type, account_id }: { sales_type: string; account_id: string }) =>
`/api/salesforce/accounts/${account_id}?sales_type=${sales_type}`,
FAVORITES: () => `/api/user-manager/bookmarks`,
FAVORITES_DELETE: ({ asset_uuid }: { asset_uuid: string }) => `/api/user-manager/bookmarks?asset_uuid=${asset_uuid}`,
EXTERNAL_ITEM_REQUEST: ({ asset_uuid }: { asset_uuid: string }) => `/api/external_item/${asset_uuid}/request`,
};
1 change: 1 addition & 0 deletions catalog/ui/src/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ export type ResourceType =
| 'SFDC_ACCOUNTS'
| 'SFDC_BY_ACCOUNT'
| 'FAVORITES'
| 'FAVORITES_DELETE'
| 'EXTERNAL_ITEM_REQUEST';

export type ServiceActionActions = 'start' | 'stop' | 'delete' | 'rate' | 'retirement';
Expand Down
2 changes: 1 addition & 1 deletion helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ catalog:
image:
pullPolicy: IfNotPresent
repository: quay.io/redhat-gpte/babylon-catalog-api
tag: v1.0.8
tag: v1.0.9
loggingLevel: INFO
replicaCount: 1
resources:
Expand Down
18 changes: 13 additions & 5 deletions ratings/api/routers/bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,23 @@ async def bookmarks_post(bookmark_obj: BookmarkRequestSchema) -> BookmarkListRes
response_model=BookmarkListResponseSchema,
summary="Delete bookmark",
)
async def bookmarks_delete(bookmark_obj: BookmarkRequestSchema) -> BookmarkListResponseSchema:
async def bookmarks_delete() -> BookmarkListResponseSchema:
asset_uuid = request.query.get("asset_uuid")
email = request.query.get("email")

logger.info(f"Delete favorite item for user {bookmark_obj.email}")
# Validate query parameters
if not asset_uuid or not email:
return aiohttp.web.json_response(
{"error": "Missing required query parameters: asset_uuid and/or email"},
status=400,
)
logger.info(f"Delete favorite item for user {email}")
try:
user = await User.get_by_email(bookmark_obj.email)
user = await User.get_by_email(email)
if user:
bookmark = Bookmark.from_dict({"user_id": user.id, "asset_uuid": bookmark_obj.asset_uuid})
bookmark = Bookmark.from_dict({"user_id": user.id, "asset_uuid": asset_uuid})
await bookmark.delete()
user = await User.get_by_email(bookmark_obj.email)
user = await User.get_by_email(email)
bookmarks_response = [
BookmarkSchema.from_orm(bookmark).dict(exclude={"user_id"}) for bookmark in user.bookmarks
]
Expand Down
4 changes: 2 additions & 2 deletions ratings/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: babylon-ratings
description: A Helm chart for the babylon ratings component.
type: application
version: 1.0.9
appVersion: 1.0.9
version: 1.0.10
appVersion: 1.0.10

0 comments on commit 9e54859

Please sign in to comment.