Skip to content

Commit 1671072

Browse files
committed
api
1 parent 2268177 commit 1671072

File tree

6 files changed

+181
-102
lines changed

6 files changed

+181
-102
lines changed

api/specs/web-server/_products.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
GetCreditPrice,
1414
InvitationGenerated,
1515
ProductGet,
16+
ProductUIGet,
1617
UpdateProductTemplate,
1718
)
1819
from models_library.generics import Envelope
@@ -50,6 +51,14 @@ async def get_product(_params: Annotated[_ProductsRequestParams, Depends()]):
5051
...
5152

5253

54+
@router.get(
55+
"/products/current/ui",
56+
response_model=Envelope[ProductUIGet],
57+
)
58+
async def get_current_product_ui():
59+
...
60+
61+
5362
@router.put(
5463
"/products/{product_name}/templates/{template_id}",
5564
status_code=status.HTTP_204_NO_CONTENT,

packages/models-library/src/models_library/api_schemas_webserver/product.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from datetime import datetime
2-
from typing import Annotated, TypeAlias
2+
from typing import Annotated, Any, TypeAlias
33

44
from pydantic import (
55
ConfigDict,
@@ -90,6 +90,13 @@ class ProductGet(OutputSchema):
9090
]
9191

9292

93+
class ProductUIGet(OutputSchema):
94+
product_name: ProductName
95+
ui: Annotated[
96+
dict[str, Any], Field(description="Front-end owned ui product configuration")
97+
]
98+
99+
93100
ExtraCreditsUsdRangeInt: TypeAlias = Annotated[int, Field(ge=0, lt=500)]
94101

95102

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 134 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,8 @@ paths:
11141114
- products
11151115
- po
11161116
summary: Get Product
1117+
description: 'NOTE: `/products/current` is used to define current project w/o
1118+
naming it'
11171119
operationId: get_product
11181120
parameters:
11191121
- name: product_name
@@ -1133,7 +1135,20 @@ paths:
11331135
content:
11341136
application/json:
11351137
schema:
1136-
$ref: '#/components/schemas/Envelope_GetProduct_'
1138+
$ref: '#/components/schemas/Envelope_ProductGet_'
1139+
/v0/products/current/ui:
1140+
get:
1141+
tags:
1142+
- products
1143+
summary: Get Current Product Ui
1144+
operationId: get_current_product_ui
1145+
responses:
1146+
'200':
1147+
description: Successful Response
1148+
content:
1149+
application/json:
1150+
schema:
1151+
$ref: '#/components/schemas/Envelope_ProductUIGet_'
11371152
/v0/products/{product_name}/templates/{template_id}:
11381153
put:
11391154
tags:
@@ -7909,19 +7924,6 @@ components:
79097924
title: Error
79107925
type: object
79117926
title: Envelope[GetCreditPrice]
7912-
Envelope_GetProduct_:
7913-
properties:
7914-
data:
7915-
anyOf:
7916-
- $ref: '#/components/schemas/GetProduct'
7917-
- type: 'null'
7918-
error:
7919-
anyOf:
7920-
- {}
7921-
- type: 'null'
7922-
title: Error
7923-
type: object
7924-
title: Envelope[GetProduct]
79257927
Envelope_GetProjectInactivityResponse_:
79267928
properties:
79277929
data:
@@ -8234,6 +8236,32 @@ components:
82348236
title: Error
82358237
type: object
82368238
title: Envelope[PricingUnitGet]
8239+
Envelope_ProductGet_:
8240+
properties:
8241+
data:
8242+
anyOf:
8243+
- $ref: '#/components/schemas/ProductGet'
8244+
- type: 'null'
8245+
error:
8246+
anyOf:
8247+
- {}
8248+
- type: 'null'
8249+
title: Error
8250+
type: object
8251+
title: Envelope[ProductGet]
8252+
Envelope_ProductUIGet_:
8253+
properties:
8254+
data:
8255+
anyOf:
8256+
- $ref: '#/components/schemas/ProductUIGet'
8257+
- type: 'null'
8258+
error:
8259+
anyOf:
8260+
- {}
8261+
- type: 'null'
8262+
title: Error
8263+
type: object
8264+
title: Envelope[ProductUIGet]
82378265
Envelope_ProjectGet_:
82388266
properties:
82398267
data:
@@ -9711,84 +9739,6 @@ components:
97119739
- usdPerCredit
97129740
- minPaymentAmountUsd
97139741
title: GetCreditPrice
9714-
GetProduct:
9715-
properties:
9716-
name:
9717-
type: string
9718-
title: Name
9719-
displayName:
9720-
type: string
9721-
title: Displayname
9722-
shortName:
9723-
anyOf:
9724-
- type: string
9725-
- type: 'null'
9726-
title: Shortname
9727-
description: Short display name for SMS
9728-
vendor:
9729-
anyOf:
9730-
- type: object
9731-
- type: 'null'
9732-
title: Vendor
9733-
description: vendor attributes
9734-
issues:
9735-
anyOf:
9736-
- items:
9737-
type: object
9738-
type: array
9739-
- type: 'null'
9740-
title: Issues
9741-
description: Reference to issues tracker
9742-
manuals:
9743-
anyOf:
9744-
- items:
9745-
type: object
9746-
type: array
9747-
- type: 'null'
9748-
title: Manuals
9749-
description: List of manuals
9750-
support:
9751-
anyOf:
9752-
- items:
9753-
type: object
9754-
type: array
9755-
- type: 'null'
9756-
title: Support
9757-
description: List of support resources
9758-
loginSettings:
9759-
type: object
9760-
title: Loginsettings
9761-
maxOpenStudiesPerUser:
9762-
anyOf:
9763-
- type: integer
9764-
exclusiveMinimum: true
9765-
minimum: 0
9766-
- type: 'null'
9767-
title: Maxopenstudiesperuser
9768-
isPaymentEnabled:
9769-
type: boolean
9770-
title: Ispaymentenabled
9771-
creditsPerUsd:
9772-
anyOf:
9773-
- type: string
9774-
- type: 'null'
9775-
title: Creditsperusd
9776-
templates:
9777-
items:
9778-
$ref: '#/components/schemas/GetProductTemplate'
9779-
type: array
9780-
title: Templates
9781-
description: List of templates available to this product for communications
9782-
(e.g. emails, sms, etc)
9783-
type: object
9784-
required:
9785-
- name
9786-
- displayName
9787-
- loginSettings
9788-
- maxOpenStudiesPerUser
9789-
- isPaymentEnabled
9790-
- creditsPerUsd
9791-
title: GetProduct
97929742
GetProductTemplate:
97939743
properties:
97949744
id:
@@ -12060,6 +12010,98 @@ components:
1206012010
- currentCostPerUnit
1206112011
- default
1206212012
title: PricingUnitGet
12013+
ProductGet:
12014+
properties:
12015+
name:
12016+
type: string
12017+
title: Name
12018+
displayName:
12019+
type: string
12020+
title: Displayname
12021+
shortName:
12022+
anyOf:
12023+
- type: string
12024+
- type: 'null'
12025+
title: Shortname
12026+
description: Short display name for SMS
12027+
vendor:
12028+
anyOf:
12029+
- type: object
12030+
- type: 'null'
12031+
title: Vendor
12032+
description: vendor attributes
12033+
issues:
12034+
anyOf:
12035+
- items:
12036+
type: object
12037+
type: array
12038+
- type: 'null'
12039+
title: Issues
12040+
description: Reference to issues tracker
12041+
manuals:
12042+
anyOf:
12043+
- items:
12044+
type: object
12045+
type: array
12046+
- type: 'null'
12047+
title: Manuals
12048+
description: List of manuals
12049+
support:
12050+
anyOf:
12051+
- items:
12052+
type: object
12053+
type: array
12054+
- type: 'null'
12055+
title: Support
12056+
description: List of support resources
12057+
loginSettings:
12058+
type: object
12059+
title: Loginsettings
12060+
maxOpenStudiesPerUser:
12061+
anyOf:
12062+
- type: integer
12063+
exclusiveMinimum: true
12064+
minimum: 0
12065+
- type: 'null'
12066+
title: Maxopenstudiesperuser
12067+
isPaymentEnabled:
12068+
type: boolean
12069+
title: Ispaymentenabled
12070+
creditsPerUsd:
12071+
anyOf:
12072+
- type: string
12073+
- type: 'null'
12074+
title: Creditsperusd
12075+
templates:
12076+
items:
12077+
$ref: '#/components/schemas/GetProductTemplate'
12078+
type: array
12079+
title: Templates
12080+
description: List of templates available to this product for communications
12081+
(e.g. emails, sms, etc)
12082+
type: object
12083+
required:
12084+
- name
12085+
- displayName
12086+
- loginSettings
12087+
- maxOpenStudiesPerUser
12088+
- isPaymentEnabled
12089+
- creditsPerUsd
12090+
title: ProductGet
12091+
ProductUIGet:
12092+
properties:
12093+
productName:
12094+
type: string
12095+
title: Productname
12096+
ui:
12097+
type: object
12098+
title: Ui
12099+
description: Front-end owned ui product configuration
12100+
type: object
12101+
required:
12102+
- productName
12103+
- ui
12104+
title: ProductUIGet
1206312105
ProjectCopyOverride:
1206412106
properties:
1206512107
name:

services/web/server/src/simcore_service_webserver/products/_handlers.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
from typing import Literal
33

44
from aiohttp import web
5-
from models_library.api_schemas_webserver.product import GetCreditPrice, ProductGet
5+
from models_library.api_schemas_webserver.product import (
6+
GetCreditPrice,
7+
ProductGet,
8+
ProductUIGet,
9+
)
610
from models_library.basic_types import IDStr
711
from models_library.rest_base import RequestParameters, StrictRequestParameters
812
from models_library.users import UserID
@@ -75,6 +79,17 @@ async def _get_product(request: web.Request):
7579
return envelope_json_response(data)
7680

7781

82+
@routes.get(f"/{VTAG}/products/current/ui", name="get_current_product_ui")
83+
@login_required
84+
@permission_required("product.ui.read")
85+
async def _get_current_product_ui(request: web.Request):
86+
req_ctx = _ProductsRequestContext.model_validate(request)
87+
product_name = req_ctx.product_name
88+
89+
data = ProductUIGet(product_name=product_name, ui={})
90+
return envelope_json_response(data)
91+
92+
7893
class _ProductTemplateParams(_ProductsRequestParams):
7994
template_id: IDStr
8095

services/web/server/src/simcore_service_webserver/security/_authz_access_roles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class PermissionDict(TypedDict, total=False):
6161
"groups.*",
6262
"catalog/licensed-items.*",
6363
"product.price.read",
64+
"product.ui.read",
6465
"project.folders.*",
6566
"project.access_rights.update",
6667
"project.classifier.*",

0 commit comments

Comments
 (0)