from typing import Any
from q2_sdk.core.dynamic_imports import (
api_ExecuteStoredProcedure as ExecuteStoredProcedure,
)
from .db_object import DbObject
from .representation_row_base import RepresentationRowBase
SqlParameters = ExecuteStoredProcedure.SqlParameters
SqlParam = ExecuteStoredProcedure.SqlParam
DataType = ExecuteStoredProcedure.DataType
[docs]
class ZoneSystemPropertyDataWithReferencesRow(RepresentationRowBase):
# Direct fields from Q2_ZoneSystemPropertyData
ZoneSystemPropertyDataID: int | None
ZoneID: int | None
ZoneSystemPropertyID: int | None
PropertyValue: str | None
Weight: int | None
UISourceID: int | None
ProductTypeID: int | None
ProductID: int | None
GroupID: int | None
HADE_ID: int | None
PropertyID: int | None
# JSON References
Property: Any | None
UISource: Any | None
ProductType: Any | None
Product: Any | None
Group: Any | None
HADE: Any | None
ZoneSystemProperty: Any | None
Zone: Any | None
[docs]
class ZoneSystemPropertyDataWithReferences(DbObject):
NAME = "ZoneSystemPropertyDataWithReferences"
REPRESENTATION_ROW_CLASS = ZoneSystemPropertyDataWithReferencesRow
def _get_params_from_query(
self,
zone_system_property_data_id: int | None = None,
zone_id: int | None = None,
zone_system_property_id: int | None = None,
property_id: int | None = None,
property_name: str | None = None,
product_id: int | None = None,
product_type_id: int | None = None,
hade_id: int | None = None,
) -> SqlParameters:
params = []
if zone_system_property_data_id not in [None, ""]:
params.append(
SqlParam(
DataType.Int,
"ZoneSystemPropertyDataID",
zone_system_property_data_id,
)
)
if zone_id not in [None, ""]:
params.append(SqlParam(DataType.Int, "ZoneID", zone_id))
if zone_system_property_id not in [None, ""]:
params.append(
SqlParam(DataType.Int, "ZoneSystemPropertyID", zone_system_property_id)
)
if property_id not in [None, ""]:
params.append(SqlParam(DataType.Int, "PropertyID", property_id))
if property_name not in [None, ""]:
params.append(SqlParam(DataType.VarChar, "PropertyName", property_name))
if product_id not in [None, ""]:
params.append(SqlParam(DataType.Int, "ProductID", product_id))
if product_type_id not in [None, ""]:
params.append(SqlParam(DataType.Int, "ProductTypeID", product_type_id))
if hade_id not in [None, ""]:
params.append(SqlParam(DataType.Int, "HADE_ID", hade_id))
return SqlParameters(params)
[docs]
async def get(
self,
zone_system_property_data_id: int | None = None,
zone_id: int | None = None,
zone_system_property_id: int | None = None,
property_id: int | None = None,
property_name: str | None = None,
product_id: int | None = None,
product_type_id: int | None = None,
hade_id: int | None = None,
serialize_for_cli=False,
) -> list[ZoneSystemPropertyDataWithReferencesRow]:
sql_params = self._get_params_from_query(
zone_system_property_data_id,
zone_id,
zone_system_property_id,
property_id,
property_name,
product_id,
product_type_id,
hade_id,
)
response = await self.call_hq(
"sdk_GetZoneSystemPropertyDataWithReferences",
sql_parameters=sql_params,
)
if serialize_for_cli:
fields_to_truncate = []
columns = [
"ZoneSystemPropertyDataID",
"ZoneID",
"ZoneSystemPropertyID",
"UISourceID",
"PropertyID",
"PropertyValue",
"ProductID",
"ProductTypeID",
"GroupID",
"HADE_ID",
]
response = self.serialize_for_cli(
response,
fields_to_display=columns,
fields_to_truncate=fields_to_truncate,
)
return response
[docs]
async def add(
self,
property_name: str,
property_value: str,
zone_id: int,
zone_system_property_id: int,
ui_source_id: int | None = None,
product_type_id: int | None = None,
product_id: int | None = None,
group_id: int | None = None,
hade_id: int | None = None,
) -> Any:
params = [
SqlParam(DataType.VarChar, "PropertyName", property_name),
SqlParam(DataType.NVarChar, "PropertyValue", property_value),
SqlParam(DataType.Int, "ZoneID", zone_id),
SqlParam(DataType.Int, "ZoneSystemPropertyID", zone_system_property_id),
]
if ui_source_id is not None:
params.append(SqlParam(DataType.Int, "UISourceID", ui_source_id))
if product_type_id is not None:
params.append(SqlParam(DataType.Int, "ProductTypeID", product_type_id))
if product_id is not None:
params.append(SqlParam(DataType.Int, "ProductID", product_id))
if group_id is not None:
params.append(SqlParam(DataType.Int, "GroupID", group_id))
if hade_id is not None:
params.append(SqlParam(DataType.Int, "HADE_ID", hade_id))
sql_parameters = SqlParameters(params)
return await self.call_hq(
"sdk_AddZoneSystemPropertyDataWithReferences",
sql_parameters=sql_parameters,
)
[docs]
async def update(
self,
zone_system_property_data_id: int,
property_name: str,
property_value: str,
zone_id: int,
zone_system_property_id: int,
ui_source_id: int | None = None,
product_type_id: int | None = None,
product_id: int | None = None,
group_id: int | None = None,
hade_id: int | None = None,
) -> Any:
params = [
SqlParam(
DataType.Int, "ZoneSystemPropertyDataID", zone_system_property_data_id
),
SqlParam(DataType.VarChar, "PropertyName", property_name),
SqlParam(DataType.NVarChar, "PropertyValue", property_value),
SqlParam(DataType.Int, "ZoneID", zone_id),
SqlParam(DataType.Int, "ZoneSystemPropertyID", zone_system_property_id),
]
if ui_source_id is not None:
params.append(SqlParam(DataType.Int, "UISourceID", ui_source_id))
if product_type_id is not None:
params.append(SqlParam(DataType.Int, "ProductTypeID", product_type_id))
if product_id is not None:
params.append(SqlParam(DataType.Int, "ProductID", product_id))
if group_id is not None:
params.append(SqlParam(DataType.Int, "GroupID", group_id))
if hade_id is not None:
params.append(SqlParam(DataType.Int, "HADE_ID", hade_id))
sql_parameters = SqlParameters(params)
return await self.call_hq(
"sdk_UpdateZoneSystemPropertyDataWithReferences",
sql_parameters=sql_parameters,
)