Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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 @@ -28,6 +28,7 @@ class LicensedItemRpcGet(BaseModel):
licensed_resource_type: LicensedResourceType
licensed_resources: list[dict[str, Any]]
pricing_plan_id: PricingPlanId
is_hidden_on_market: bool
created_at: datetime
modified_at: datetime

Expand All @@ -42,6 +43,7 @@ class LicensedItemRpcGet(BaseModel):
"licensed_resource_type": f"{LicensedResourceType.VIP_MODEL}",
"licensed_resources": [cast(JsonDict, VIP_DETAILS_EXAMPLE)],
"pricing_plan_id": "15",
"is_hidden_on_market": False,
"created_at": "2024-12-12 09:59:26.422140",
"modified_at": "2024-12-12 09:59:26.422140",
}
Expand Down
3 changes: 3 additions & 0 deletions packages/models-library/src/models_library/licenses.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class LicensedItemDB(BaseModel):

pricing_plan_id: PricingPlanId
product_name: ProductName
is_hidden_on_market: bool

# states
created: datetime
Expand Down Expand Up @@ -124,6 +125,7 @@ class LicensedItem(BaseModel):
licensed_resource_type: LicensedResourceType
licensed_resources: list[dict[str, Any]]
pricing_plan_id: PricingPlanId
is_hidden_on_market: bool
created_at: datetime
modified_at: datetime

Expand All @@ -149,6 +151,7 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
)
],
"pricing_plan_id": "15",
"is_hidden_on_market": False,
"created_at": "2024-12-12 09:59:26.422140",
"modified_at": "2024-12-12 09:59:26.422140",
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""add is_hidden_on_market field

Revision ID: e8ffc0c96336
Revises: a53c3c153bc8
Create Date: 2025-02-13 18:05:42.851252+00:00

"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "e8ffc0c96336"
down_revision = "a53c3c153bc8"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"licensed_items",
sa.Column(
"is_hidden_on_market",
sa.Boolean(),
server_default=sa.text("false"),
nullable=False,
),
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("licensed_items", "is_hidden_on_market")
# ### end Alembic commands ###
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ class LicensedResourceType(str, enum.Enum):
nullable=False,
doc="Product name identifier. If None, then the item is not exposed",
),
sa.Column(
"is_hidden_on_market",
sa.Boolean(),
nullable=False,
server_default=sa.text("false"),
doc="If true, the item is not listed on the market. (Public API might want to see all of them, even if they are not listed on the Market)",
),
column_created_datetime(timezone=True),
column_modified_datetime(timezone=True),
sa.Index("idx_licensed_items_key_version", "key", "version", unique=True),
Expand Down
5 changes: 5 additions & 0 deletions services/api-server/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6716,6 +6716,10 @@
"title": "Pricing Plan Id",
"minimum": 0
},
"is_hidden_on_market": {
"type": "boolean",
"title": "Is Hidden On Market"
},
"created_at": {
"type": "string",
"format": "date-time",
Expand All @@ -6736,6 +6740,7 @@
"licensed_resource_type",
"licensed_resources",
"pricing_plan_id",
"is_hidden_on_market",
"created_at",
"modified_at"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class LicensedItemGet(BaseModel):
licensed_resource_type: LicensedResourceType
licensed_resources: list[dict[str, Any]]
pricing_plan_id: PricingPlanId
is_hidden_on_market: bool
created_at: datetime
modified_at: datetime
model_config = ConfigDict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def _create_licensed_items_get_page(
licensed_resource_type=elm.licensed_resource_type,
licensed_resources=elm.licensed_resources,
pricing_plan_id=elm.pricing_plan_id,
is_hidden_on_market=elm.is_hidden_on_market,
created_at=elm.created_at,
modified_at=elm.modified_at,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ async def list_(
order_by: OrderBy,
# filters
filter_by_licensed_resource_type: LicensedResourceType | None = None,
include_hidden_items_on_market: bool = False,
) -> tuple[int, list[LicensedItemDB]]:

base_query = (
Expand All @@ -111,6 +112,8 @@ async def list_(
base_query.where(
licensed_items.c.licensed_resource_type == filter_by_licensed_resource_type
)
if not include_hidden_items_on_market:
base_query.where(licensed_items.c.is_hidden_on_market.is_(False))

# Select total count from base_query
subquery = base_query.subquery()
Expand Down Expand Up @@ -282,6 +285,7 @@ async def list_licensed_items(
order_by: OrderBy,
# filters
filter_by_licensed_resource_type: LicensedResourceType | None = None,
include_hidden_items_on_market: bool = False,
) -> tuple[int, list[LicensedItem]]:

base_query = (
Expand Down Expand Up @@ -310,6 +314,8 @@ async def list_licensed_items(
base_query.where(
licensed_items.c.licensed_resource_type == filter_by_licensed_resource_type
)
if not include_hidden_items_on_market:
base_query.where(licensed_items.c.is_hidden_on_market.is_(False))

# Select total count from base_query
subquery = base_query.subquery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async def list_licensed_items(request: web.Request):
await _licensed_items_service.list_licensed_items(
app=request.app,
product_name=req_ctx.product_name,
include_hidden_items_on_market=False,
offset=query_params.offset,
limit=query_params.limit,
order_by=OrderBy.model_construct(**query_params.order_by.model_dump()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ async def list_licensed_items(
app: web.Application,
*,
product_name: ProductName,
include_hidden_items_on_market: bool,
offset: NonNegativeInt,
limit: int,
order_by: OrderBy,
) -> LicensedItemPage:
total_count, items = await _licensed_items_repository.list_licensed_items(
app,
product_name=product_name,
include_hidden_items_on_market=include_hidden_items_on_market,
offset=offset,
limit=limit,
order_by=order_by,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async def get_licensed_items(
await _licensed_items_service.list_licensed_items(
app=app,
product_name=product_name,
include_hidden_items_on_market=True,
offset=offset,
limit=limit,
order_by=OrderBy(field=IDStr("display_name")),
Expand All @@ -60,6 +61,7 @@ async def get_licensed_items(
licensed_resource_type=licensed_item.licensed_resource_type,
licensed_resources=licensed_item.licensed_resources,
pricing_plan_id=licensed_item.pricing_plan_id,
is_hidden_on_market=licensed_item.is_hidden_on_market,
created_at=licensed_item.created_at,
modified_at=licensed_item.modified_at,
)
Expand Down
Loading