Skip to content

Commit a52c1f9

Browse files
committed
added product base type to products api methods
1 parent 818e762 commit a52c1f9

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

ayon_api/_api_helpers/products.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import typing
66
from typing import Optional, Iterable, Generator, Any
77

8+
from ayon_api.exceptions import UnsupportedServerVersion
89
from ayon_api.utils import (
910
prepare_list_filters,
1011
create_entity_id,
@@ -378,6 +379,7 @@ def create_product(
378379
tags: Optional[Iterable[str]] =None,
379380
status: Optional[str] = None,
380381
active: Optional[bool] = None,
382+
product_base_type: Optional[str] = None,
381383
product_id: Optional[str] = None,
382384
) -> str:
383385
"""Create new product.
@@ -392,13 +394,22 @@ def create_product(
392394
tags (Optional[Iterable[str]]): Product tags.
393395
status (Optional[str]): Product status.
394396
active (Optional[bool]): Product active state.
397+
product_base_type (Optional[str]): Product base type.
395398
product_id (Optional[str]): Product id. If not passed new id is
396399
generated.
397400
398401
Returns:
399402
str: Product id.
400403
401404
"""
405+
if (
406+
product_base_type is not None
407+
and not self.product_base_type_supported()
408+
):
409+
raise UnsupportedServerVersion(
410+
"Product base type is not supported for your server version."
411+
)
412+
402413
if not product_id:
403414
product_id = create_entity_id()
404415
create_data = {
@@ -408,6 +419,7 @@ def create_product(
408419
"folderId": folder_id,
409420
}
410421
for key, value in (
422+
("productBaseType", product_base_type),
411423
("attrib", attrib),
412424
("data", data),
413425
("tags", tags),
@@ -431,6 +443,7 @@ def update_product(
431443
name: Optional[str] = None,
432444
folder_id: Optional[str] = None,
433445
product_type: Optional[str] = None,
446+
product_base_type: Optional[str] = None,
434447
attrib: Optional[dict[str, Any]] = None,
435448
data: Optional[dict[str, Any]] = None,
436449
tags: Optional[Iterable[str]] = None,
@@ -450,17 +463,27 @@ def update_product(
450463
name (Optional[str]): New product name.
451464
folder_id (Optional[str]): New product id.
452465
product_type (Optional[str]): New product type.
466+
product_base_type (Optional[str]): New product base type.
453467
attrib (Optional[dict[str, Any]]): New product attributes.
454468
data (Optional[dict[str, Any]]): New product data.
455469
tags (Optional[Iterable[str]]): New product tags.
456470
status (Optional[str]): New product status.
457471
active (Optional[bool]): New product active state.
458472
459473
"""
474+
if (
475+
product_base_type is not None
476+
and not self.product_base_type_supported()
477+
):
478+
raise UnsupportedServerVersion(
479+
"Product base type is not supported for your server version."
480+
)
481+
460482
update_data = {}
461483
for key, value in (
462484
("name", name),
463485
("productType", product_type),
486+
("productBaseType", product_base_type),
464487
("folderId", folder_id),
465488
("attrib", attrib),
466489
("data", data),

0 commit comments

Comments
 (0)