Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Expose /licensed-items endpoint in api server #6958

Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
829eae9
db layer licensed items purchase
matusdrobuliak66 Dec 9, 2024
a975a63
rut part
matusdrobuliak66 Dec 10, 2024
fc62c0d
merge master
matusdrobuliak66 Dec 10, 2024
78ef2cc
renaming tests
matusdrobuliak66 Dec 10, 2024
a6f49cd
rpc interface
matusdrobuliak66 Dec 10, 2024
f5de79b
RUT unit tests
matusdrobuliak66 Dec 10, 2024
acd4c88
RUT unit tests
matusdrobuliak66 Dec 10, 2024
317cf1d
RUT unit tests
matusdrobuliak66 Dec 10, 2024
932fb00
webserver part
matusdrobuliak66 Dec 10, 2024
06f5743
webserver part
matusdrobuliak66 Dec 10, 2024
dbd1ffe
open api specs
matusdrobuliak66 Dec 10, 2024
6bec5ff
webserver part tests
matusdrobuliak66 Dec 10, 2024
754cd58
Merge branch 'master' into introduce-vip-models-pricing-4-part
matusdrobuliak66 Dec 10, 2024
3755dce
open api specs
matusdrobuliak66 Dec 10, 2024
8f264b1
Merge branch 'introduce-vip-models-pricing-4-part' of github.com:matu…
matusdrobuliak66 Dec 10, 2024
4185852
fix type
matusdrobuliak66 Dec 10, 2024
4c31cd0
fix type
matusdrobuliak66 Dec 10, 2024
530fda0
fix type
matusdrobuliak66 Dec 10, 2024
00d40bd
fix type
matusdrobuliak66 Dec 10, 2024
fa3c648
Merge branch 'master' into introduce-vip-models-pricing-4-part
matusdrobuliak66 Dec 10, 2024
12ebf32
Merge branch 'master' into introduce-vip-models-pricing-4-part
matusdrobuliak66 Dec 11, 2024
969f982
review @pcrespov
matusdrobuliak66 Dec 11, 2024
138412e
adding purchase item functionality
matusdrobuliak66 Dec 11, 2024
7e9de14
open api specs
matusdrobuliak66 Dec 11, 2024
4f1c5d6
improve error handling
matusdrobuliak66 Dec 11, 2024
26f9c57
open api specs
matusdrobuliak66 Dec 11, 2024
583b2b4
fix import
matusdrobuliak66 Dec 11, 2024
4a1008f
fix import
matusdrobuliak66 Dec 11, 2024
776806b
fix typecheck
matusdrobuliak66 Dec 11, 2024
fadfa1f
fix typecheck
matusdrobuliak66 Dec 11, 2024
e1337f0
Merge branch 'master' into introduce-vip-models-pricing-5-part
matusdrobuliak66 Dec 11, 2024
0766313
contract between webserver and api server
matusdrobuliak66 Dec 11, 2024
f09fb33
Merge branch 'master' into introduce-vip-models-pricing-5-part
matusdrobuliak66 Dec 11, 2024
a851dd1
add rabbitmq_rpc client to api-server
bisgaard-itis Dec 11, 2024
08484fb
Merge branch 'master' into 6948-expose-licensing-endpoints-api-server
bisgaard-itis Dec 11, 2024
6ba9ca5
Merge remote-tracking branch 'matusdrobuliak66/introduce-vip-models-p…
bisgaard-itis Dec 11, 2024
1cfbfc7
start adding first endpoint
bisgaard-itis Dec 11, 2024
c715cdf
minor change
bisgaard-itis Dec 11, 2024
c3fd714
Merge branch 'master' into 6948-expose-licensing-endpoints-api-server
bisgaard-itis Dec 12, 2024
a41e126
services -> services_http
bisgaard-itis Dec 12, 2024
deed91a
start developing an webapi rpc client
bisgaard-itis Dec 12, 2024
6d220d3
webserver.py -> webserver_http.py
bisgaard-itis Dec 12, 2024
a027ecf
connect pieces to expose licensed items
bisgaard-itis Dec 12, 2024
cefc23e
start adding test
bisgaard-itis Dec 12, 2024
542b80b
mock backend with pydantic model example
bisgaard-itis Dec 12, 2024
51ef078
require input input names in exception mapper
bisgaard-itis Dec 12, 2024
044199e
handle rpc client exceptions
bisgaard-itis Dec 12, 2024
3577938
update openapi spes
bisgaard-itis Dec 12, 2024
2cdaab8
Merge branch 'master' into 6948-expose-licensing-endpoints-api-server
bisgaard-itis Dec 12, 2024
0bd8e4f
fix import
bisgaard-itis Dec 12, 2024
582fb9b
ensure relative imports
bisgaard-itis Dec 12, 2024
9e173b9
fix exception detail
bisgaard-itis Dec 12, 2024
3512611
@pcrespov @matusdrobuliak66 remove /page in endpoint
bisgaard-itis Dec 12, 2024
115a60f
@pcrespov rename rpc client to _client
bisgaard-itis Dec 12, 2024
f87ccb4
@pcrespov move model_config below fields
bisgaard-itis Dec 12, 2024
87f5b57
@pcrespov name -> display_name
bisgaard-itis Dec 12, 2024
30eb799
hide endpoint from openapi.json @pcrespov @matusdrobuliak66
bisgaard-itis Dec 12, 2024
19728f5
Merge branch 'master' into 6948-expose-licensing-endpoints-api-server
bisgaard-itis Dec 12, 2024
f040401
make mypy happy
bisgaard-itis Dec 12, 2024
85fdb00
add __init__.py
bisgaard-itis Dec 12, 2024
7afde22
fix pylint
bisgaard-itis Dec 13, 2024
f80853a
small fix
bisgaard-itis Dec 13, 2024
8a52ec3
fix unit api-server tests
bisgaard-itis Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from models_library.licensed_items import LicensedItemID, LicensedResourceType
from models_library.resource_tracker import PricingPlanId
from pydantic import PositiveInt
from pydantic import ConfigDict, PositiveInt

from ._base import OutputSchema

Expand All @@ -15,6 +15,20 @@ class LicensedItemGet(OutputSchema):
pricing_plan_id: PricingPlanId
created_at: datetime
modified_at: datetime
model_config = ConfigDict(
json_schema_extra={
"examples": [
{
"licensed_item_id": "0362b88b-91f8-4b41-867c-35544ad1f7a1",
"name": "best-model",
"licensed_resource_type": f"{LicensedResourceType.VIP_MODEL}",
"pricing_plan_id": "15",
"created_at": "2024-12-12 09:59:26.422140",
"modified_at": "2024-12-12 09:59:26.422140",
}
]
}
)


class LicensedItemGetPage(NamedTuple):
Expand Down
220 changes: 220 additions & 0 deletions services/api-server/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -5348,6 +5348,118 @@
}
]
}
},
"/v0/licensed-items/page": {
"get": {
"tags": [
"licensed-items"
],
"summary": "Get Licensed Items",
"description": "Get all licensed items",
"operationId": "get_licensed_items",
"security": [
{
"HTTPBasic": []
}
],
"parameters": [
{
"name": "limit",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"maximum": 100,
"minimum": 1,
"default": 50,
"title": "Limit"
}
},
{
"name": "offset",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"minimum": 0,
"default": 0,
"title": "Offset"
}
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Page_LicensedItemGet_"
}
}
}
},
"429": {
"description": "Too many requests",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorGet"
}
}
}
},
"500": {
"description": "Internal server error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorGet"
}
}
}
},
"502": {
"description": "Unexpected error when communicating with backend service",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorGet"
}
}
}
},
"503": {
"description": "Service unavailable",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorGet"
}
}
}
},
"504": {
"description": "Request to a backend service timed out.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorGet"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
}
},
"components": {
Expand Down Expand Up @@ -6086,6 +6198,55 @@
"submitted_at": "2021-04-01 07:15:54.631007"
}
},
"LicensedItemGet": {
"properties": {
"licensed_item_id": {
"type": "string",
"format": "uuid",
"title": "Licensed Item Id"
},
"name": {
"type": "string",
"title": "Name"
},
"licensed_resource_type": {
"$ref": "#/components/schemas/LicensedResourceType"
},
"pricing_plan_id": {
"type": "integer",
"exclusiveMinimum": true,
"title": "Pricing Plan Id",
"minimum": 0
},
"created_at": {
"type": "string",
"format": "date-time",
"title": "Created At"
},
"modified_at": {
"type": "string",
"format": "date-time",
"title": "Modified At"
}
},
"type": "object",
"required": [
"licensed_item_id",
"name",
"licensed_resource_type",
"pricing_plan_id",
"created_at",
"modified_at"
],
"title": "LicensedItemGet"
},
"LicensedResourceType": {
"type": "string",
"enum": [
"VIP_MODEL"
],
"title": "LicensedResourceType"
},
"Links": {
"properties": {
"first": {
Expand Down Expand Up @@ -6409,6 +6570,65 @@
],
"title": "Page[Job]"
},
"Page_LicensedItemGet_": {
"properties": {
"items": {
"items": {
"$ref": "#/components/schemas/LicensedItemGet"
},
"type": "array",
"title": "Items"
},
"total": {
"anyOf": [
{
"type": "integer",
"minimum": 0
},
{
"type": "null"
}
],
"title": "Total"
},
"limit": {
"anyOf": [
{
"type": "integer",
"minimum": 1
},
{
"type": "null"
}
],
"title": "Limit"
},
"offset": {
"anyOf": [
{
"type": "integer",
"minimum": 0
},
{
"type": "null"
}
],
"title": "Offset"
},
"links": {
"$ref": "#/components/schemas/Links"
}
},
"type": "object",
"required": [
"items",
"total",
"limit",
"offset",
"links"
],
"title": "Page[LicensedItemGet]"
},
"Page_Study_": {
"properties": {
"items": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@
from servicelib.aiohttp.application_setup import ApplicationSetupError
from servicelib.fastapi.dependencies import get_app
from servicelib.rabbitmq import RabbitMQClient
from servicelib.rabbitmq._client_rpc import RabbitMQRPCClient
from tenacity import before_sleep_log, retry, stop_after_delay, wait_fixed

from ...services.log_streaming import LogDistributor
from ...services_http.log_streaming import LogDistributor

_MAX_WAIT_FOR_LOG_DISTRIBUTOR_SECONDS: Final[int] = 10

_logger = logging.getLogger(__name__)


def get_rabbitmq_rpc_client(
app: Annotated[FastAPI, Depends(get_app)]
) -> RabbitMQRPCClient:
assert app.state.rabbitmq_rpc_client # nosec
return cast(RabbitMQRPCClient, app.state.rabbitmq_rpc_client)


def get_rabbitmq_client(app: Annotated[FastAPI, Depends(get_app)]) -> RabbitMQClient:
assert app.state.rabbitmq_client # nosec
return cast(RabbitMQClient, app.state.rabbitmq_client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from ..._constants import MSG_BACKEND_SERVICE_UNAVAILABLE
from ...core.settings import ApplicationSettings, WebServerSettings
from ...services.webserver import AuthSession
from ...services_http.webserver import AuthSession
from .application import get_app, get_settings
from .authentication import Identity, get_active_user_email, get_current_identity

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import Annotated, cast

from fastapi import Depends, FastAPI
from servicelib.fastapi.dependencies import get_app

from ...services_rpc.wb_api_server import WbApiRpcClient


async def get_wb_api_rpc_client(
app: Annotated[FastAPI, Depends(get_app)]
) -> WbApiRpcClient:
assert app.state.wb_api_rpc_client # nosec
return cast(WbApiRpcClient, app.state.wb_api_rpc_client)
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .routes import (
files,
health,
licensed_items,
meta,
solvers,
solvers_jobs,
Expand Down Expand Up @@ -40,6 +41,9 @@ def create_router(settings: ApplicationSettings):
router.include_router(studies_jobs.router, tags=["studies"], prefix="/studies")
router.include_router(wallets.router, tags=["wallets"], prefix="/wallets")
router.include_router(_credits.router, tags=["credits"], prefix="/credits")
router.include_router(
licensed_items.router, tags=["licensed-items"], prefix="/licensed-items"
)

# NOTE: multiple-files upload is currently disabled
# Web form to upload files at http://localhost:8000/v0/upload-form-view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fastapi import APIRouter, Depends, status

from ...models.schemas.model_adapter import GetCreditPriceLegacy
from ..dependencies.webserver import AuthSession, get_webserver_session
from ..dependencies.webserver_http import AuthSession, get_webserver_session
from ._constants import FMSG_CHANGELOG_NEW_IN_VERSION

router = APIRouter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
FileUploadData,
UploadLinks,
)
from ...services.storage import StorageApi, StorageFileMetaData, to_file_api_model
from ...services_http.storage import StorageApi, StorageFileMetaData, to_file_api_model
from ..dependencies.authentication import get_current_user_id
from ..dependencies.services import get_api_client
from ._common import API_SERVER_DEV_FEATURES_ENABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

from ..._meta import API_VERSION, PROJECT_NAME
from ...core.health_checker import ApiServerHealthChecker, get_health_checker
from ...services.catalog import CatalogApi
from ...services.director_v2 import DirectorV2Api
from ...services.storage import StorageApi
from ...services.webserver import WebserverApi
from ...services_http.catalog import CatalogApi
from ...services_http.director_v2 import DirectorV2Api
from ...services_http.storage import StorageApi
from ...services_http.webserver import WebserverApi
from ..dependencies.application import get_reverse_url_mapper
from ..dependencies.services import get_api_client

Expand Down
Loading
Loading