From 822f014c7d6426301287d6104d9e58e4a7f2cff0 Mon Sep 17 00:00:00 2001 From: Daniel Thom Date: Wed, 20 Nov 2024 09:30:40 -0700 Subject: [PATCH] feat: Add generated models --- src/r2x/models/generated/__init__.py | 39 +++ .../models/generated/average_rate_curve.py | 110 ++++++++ .../average_rate_curve_function_data.py | 169 ++++++++++++ src/r2x/models/generated/cost_curve.py | 123 +++++++++ .../generated/cost_curve_value_curve.py | 165 ++++++++++++ src/r2x/models/generated/fuel_curve.py | 137 ++++++++++ .../models/generated/fuel_curve_fuel_cost.py | 162 ++++++++++++ src/r2x/models/generated/incremental_curve.py | 110 ++++++++ .../incremental_curve_function_data.py | 147 +++++++++++ .../models/generated/input_output_curve.py | 108 ++++++++ .../input_output_curve_function_data.py | 169 ++++++++++++ .../models/generated/linear_function_data.py | 102 ++++++++ src/r2x/models/generated/min_max.py | 85 ++++++ .../models/generated/piecewise_linear_data.py | 110 ++++++++ .../piecewise_linear_data_points_inner.py | 85 ++++++ .../models/generated/piecewise_step_data.py | 102 ++++++++ .../generated/quadratic_function_data.py | 109 ++++++++ src/r2x/models/generated/start_up_stages.py | 86 ++++++ src/r2x/models/generated/thermal_standard.py | 244 ++++++++++++++++++ .../thermal_standard_operation_cost.py | 110 ++++++++ ...hermal_standard_operation_cost_start_up.py | 159 ++++++++++++ ...hermal_standard_operation_cost_variable.py | 149 +++++++++++ src/r2x/models/generated/up_down.py | 85 ++++++ 23 files changed, 2865 insertions(+) create mode 100644 src/r2x/models/generated/__init__.py create mode 100644 src/r2x/models/generated/average_rate_curve.py create mode 100644 src/r2x/models/generated/average_rate_curve_function_data.py create mode 100644 src/r2x/models/generated/cost_curve.py create mode 100644 src/r2x/models/generated/cost_curve_value_curve.py create mode 100644 src/r2x/models/generated/fuel_curve.py create mode 100644 src/r2x/models/generated/fuel_curve_fuel_cost.py create mode 100644 src/r2x/models/generated/incremental_curve.py create mode 100644 src/r2x/models/generated/incremental_curve_function_data.py create mode 100644 src/r2x/models/generated/input_output_curve.py create mode 100644 src/r2x/models/generated/input_output_curve_function_data.py create mode 100644 src/r2x/models/generated/linear_function_data.py create mode 100644 src/r2x/models/generated/min_max.py create mode 100644 src/r2x/models/generated/piecewise_linear_data.py create mode 100644 src/r2x/models/generated/piecewise_linear_data_points_inner.py create mode 100644 src/r2x/models/generated/piecewise_step_data.py create mode 100644 src/r2x/models/generated/quadratic_function_data.py create mode 100644 src/r2x/models/generated/start_up_stages.py create mode 100644 src/r2x/models/generated/thermal_standard.py create mode 100644 src/r2x/models/generated/thermal_standard_operation_cost.py create mode 100644 src/r2x/models/generated/thermal_standard_operation_cost_start_up.py create mode 100644 src/r2x/models/generated/thermal_standard_operation_cost_variable.py create mode 100644 src/r2x/models/generated/up_down.py diff --git a/src/r2x/models/generated/__init__.py b/src/r2x/models/generated/__init__.py new file mode 100644 index 00000000..0f272590 --- /dev/null +++ b/src/r2x/models/generated/__init__.py @@ -0,0 +1,39 @@ +# coding: utf-8 + +# flake8: noqa +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +# import models into model package +from openapi_client.models.average_rate_curve import AverageRateCurve +from openapi_client.models.average_rate_curve_function_data import AverageRateCurveFunctionData +from openapi_client.models.cost_curve import CostCurve +from openapi_client.models.cost_curve_value_curve import CostCurveValueCurve +from openapi_client.models.fuel_curve import FuelCurve +from openapi_client.models.fuel_curve_fuel_cost import FuelCurveFuelCost +from openapi_client.models.incremental_curve import IncrementalCurve +from openapi_client.models.incremental_curve_function_data import IncrementalCurveFunctionData +from openapi_client.models.input_output_curve import InputOutputCurve +from openapi_client.models.input_output_curve_function_data import InputOutputCurveFunctionData +from openapi_client.models.linear_function_data import LinearFunctionData +from openapi_client.models.min_max import MinMax +from openapi_client.models.piecewise_linear_data import PiecewiseLinearData +from openapi_client.models.piecewise_linear_data_points_inner import PiecewiseLinearDataPointsInner +from openapi_client.models.piecewise_step_data import PiecewiseStepData +from openapi_client.models.quadratic_function_data import QuadraticFunctionData +from openapi_client.models.start_up_stages import StartUpStages +from openapi_client.models.thermal_standard import ThermalStandard +from openapi_client.models.thermal_standard_operation_cost import ThermalStandardOperationCost +from openapi_client.models.thermal_standard_operation_cost_start_up import ThermalStandardOperationCostStartUp +from openapi_client.models.thermal_standard_operation_cost_variable import ( + ThermalStandardOperationCostVariable, +) +from openapi_client.models.up_down import UpDown diff --git a/src/r2x/models/generated/average_rate_curve.py b/src/r2x/models/generated/average_rate_curve.py new file mode 100644 index 00000000..a36f424c --- /dev/null +++ b/src/r2x/models/generated/average_rate_curve.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.average_rate_curve_function_data import AverageRateCurveFunctionData +from typing import Optional, Set +from typing_extensions import Self + + +class AverageRateCurve(Component): + """ + AverageRateCurve + """ # noqa: E501 + + curve_type: Optional[StrictStr] = None + function_data: AverageRateCurveFunctionData + initial_input: Optional[Union[StrictFloat, StrictInt]] = None + input_at_zero: Optional[Union[StrictFloat, StrictInt]] = None + __properties: ClassVar[List[str]] = ["curve_type", "function_data", "initial_input", "input_at_zero"] + + @field_validator("curve_type") + def curve_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["AVERAGE_RATE"]): + raise ValueError("must be one of enum values ('AVERAGE_RATE')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of AverageRateCurve from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of function_data + if self.function_data: + _dict["function_data"] = self.function_data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of AverageRateCurve from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "curve_type": obj.get("curve_type"), + "function_data": AverageRateCurveFunctionData.from_dict(obj["function_data"]) + if obj.get("function_data") is not None + else None, + "initial_input": obj.get("initial_input"), + "input_at_zero": obj.get("input_at_zero"), + } + ) + return _obj diff --git a/src/r2x/models/generated/average_rate_curve_function_data.py b/src/r2x/models/generated/average_rate_curve_function_data.py new file mode 100644 index 00000000..9ca460a2 --- /dev/null +++ b/src/r2x/models/generated/average_rate_curve_function_data.py @@ -0,0 +1,169 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import json +import pprint +from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator +from typing import Any, List, Optional +from openapi_client.models.linear_function_data import LinearFunctionData +from openapi_client.models.piecewise_linear_data import PiecewiseLinearData +from openapi_client.models.quadratic_function_data import QuadraticFunctionData +from pydantic import StrictStr, Field +from typing import Union, List, Set, Optional, Dict +from typing_extensions import Literal, Self + +AVERAGERATECURVEFUNCTIONDATA_ONE_OF_SCHEMAS = [ + "LinearFunctionData", + "PiecewiseLinearData", + "QuadraticFunctionData", +] + + +class AverageRateCurveFunctionData(BaseModel): + """ + AverageRateCurveFunctionData + """ + + # data type: LinearFunctionData + oneof_schema_1_validator: Optional[LinearFunctionData] = None + # data type: QuadraticFunctionData + oneof_schema_2_validator: Optional[QuadraticFunctionData] = None + # data type: PiecewiseLinearData + oneof_schema_3_validator: Optional[PiecewiseLinearData] = None + actual_instance: Optional[Union[LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData]] = None + one_of_schemas: Set[str] = {"LinearFunctionData", "PiecewiseLinearData", "QuadraticFunctionData"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + discriminator_value_class_map: Dict[str, str] = {} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + instance = AverageRateCurveFunctionData.model_construct() + error_messages = [] + match = 0 + # validate data type: LinearFunctionData + if not isinstance(v, LinearFunctionData): + error_messages.append(f"Error! Input type `{type(v)}` is not `LinearFunctionData`") + else: + match += 1 + # validate data type: QuadraticFunctionData + if not isinstance(v, QuadraticFunctionData): + error_messages.append(f"Error! Input type `{type(v)}` is not `QuadraticFunctionData`") + else: + match += 1 + # validate data type: PiecewiseLinearData + if not isinstance(v, PiecewiseLinearData): + error_messages.append(f"Error! Input type `{type(v)}` is not `PiecewiseLinearData`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when setting `actual_instance` in AverageRateCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in AverageRateCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into LinearFunctionData + try: + instance.actual_instance = LinearFunctionData.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into QuadraticFunctionData + try: + instance.actual_instance = QuadraticFunctionData.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into PiecewiseLinearData + try: + instance.actual_instance = PiecewiseLinearData.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into AverageRateCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into AverageRateCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict( + self, + ) -> Optional[Union[Dict[str, Any], LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/src/r2x/models/generated/cost_curve.py b/src/r2x/models/generated/cost_curve.py new file mode 100644 index 00000000..0a6cff2f --- /dev/null +++ b/src/r2x/models/generated/cost_curve.py @@ -0,0 +1,123 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from openapi_client.models.cost_curve_value_curve import CostCurveValueCurve +from openapi_client.models.input_output_curve import InputOutputCurve +from typing import Optional, Set +from typing_extensions import Self + + +class CostCurve(Component): + """ + CostCurve + """ # noqa: E501 + + power_units: StrictStr + value_curve: CostCurveValueCurve + variable_cost_type: Optional[StrictStr] = None + vom_cost: InputOutputCurve + __properties: ClassVar[List[str]] = ["power_units", "value_curve", "variable_cost_type", "vom_cost"] + + @field_validator("power_units") + def power_units_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["SYSTEM_BASE", "DEVICE_BASE", "NATURAL_UNITS"]): + raise ValueError("must be one of enum values ('SYSTEM_BASE', 'DEVICE_BASE', 'NATURAL_UNITS')") + return value + + @field_validator("variable_cost_type") + def variable_cost_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["COST"]): + raise ValueError("must be one of enum values ('COST')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of CostCurve from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of value_curve + if self.value_curve: + _dict["value_curve"] = self.value_curve.to_dict() + # override the default output from pydantic by calling `to_dict()` of vom_cost + if self.vom_cost: + _dict["vom_cost"] = self.vom_cost.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of CostCurve from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "power_units": obj.get("power_units"), + "value_curve": CostCurveValueCurve.from_dict(obj["value_curve"]) + if obj.get("value_curve") is not None + else None, + "variable_cost_type": obj.get("variable_cost_type"), + "vom_cost": InputOutputCurve.from_dict(obj["vom_cost"]) + if obj.get("vom_cost") is not None + else None, + } + ) + return _obj diff --git a/src/r2x/models/generated/cost_curve_value_curve.py b/src/r2x/models/generated/cost_curve_value_curve.py new file mode 100644 index 00000000..f764d55b --- /dev/null +++ b/src/r2x/models/generated/cost_curve_value_curve.py @@ -0,0 +1,165 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import json +import pprint +from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator +from typing import Any, List, Optional +from openapi_client.models.average_rate_curve import AverageRateCurve +from openapi_client.models.incremental_curve import IncrementalCurve +from openapi_client.models.input_output_curve import InputOutputCurve +from pydantic import StrictStr, Field +from typing import Union, List, Set, Optional, Dict +from typing_extensions import Literal, Self + +COSTCURVEVALUECURVE_ONE_OF_SCHEMAS = ["AverageRateCurve", "IncrementalCurve", "InputOutputCurve"] + + +class CostCurveValueCurve(BaseModel): + """ + CostCurveValueCurve + """ + + # data type: InputOutputCurve + oneof_schema_1_validator: Optional[InputOutputCurve] = None + # data type: IncrementalCurve + oneof_schema_2_validator: Optional[IncrementalCurve] = None + # data type: AverageRateCurve + oneof_schema_3_validator: Optional[AverageRateCurve] = None + actual_instance: Optional[Union[AverageRateCurve, IncrementalCurve, InputOutputCurve]] = None + one_of_schemas: Set[str] = {"AverageRateCurve", "IncrementalCurve", "InputOutputCurve"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + discriminator_value_class_map: Dict[str, str] = {} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + instance = CostCurveValueCurve.model_construct() + error_messages = [] + match = 0 + # validate data type: InputOutputCurve + if not isinstance(v, InputOutputCurve): + error_messages.append(f"Error! Input type `{type(v)}` is not `InputOutputCurve`") + else: + match += 1 + # validate data type: IncrementalCurve + if not isinstance(v, IncrementalCurve): + error_messages.append(f"Error! Input type `{type(v)}` is not `IncrementalCurve`") + else: + match += 1 + # validate data type: AverageRateCurve + if not isinstance(v, AverageRateCurve): + error_messages.append(f"Error! Input type `{type(v)}` is not `AverageRateCurve`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when setting `actual_instance` in CostCurveValueCurve with oneOf schemas: AverageRateCurve, IncrementalCurve, InputOutputCurve. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in CostCurveValueCurve with oneOf schemas: AverageRateCurve, IncrementalCurve, InputOutputCurve. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into InputOutputCurve + try: + instance.actual_instance = InputOutputCurve.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into IncrementalCurve + try: + instance.actual_instance = IncrementalCurve.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into AverageRateCurve + try: + instance.actual_instance = AverageRateCurve.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into CostCurveValueCurve with oneOf schemas: AverageRateCurve, IncrementalCurve, InputOutputCurve. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into CostCurveValueCurve with oneOf schemas: AverageRateCurve, IncrementalCurve, InputOutputCurve. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict( + self, + ) -> Optional[Union[Dict[str, Any], AverageRateCurve, IncrementalCurve, InputOutputCurve]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/src/r2x/models/generated/fuel_curve.py b/src/r2x/models/generated/fuel_curve.py new file mode 100644 index 00000000..719fd3ea --- /dev/null +++ b/src/r2x/models/generated/fuel_curve.py @@ -0,0 +1,137 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from openapi_client.models.cost_curve_value_curve import CostCurveValueCurve +from openapi_client.models.fuel_curve_fuel_cost import FuelCurveFuelCost +from openapi_client.models.input_output_curve import InputOutputCurve +from typing import Optional, Set +from typing_extensions import Self + + +class FuelCurve(Component): + """ + FuelCurve + """ # noqa: E501 + + fuel_cost: FuelCurveFuelCost + power_units: StrictStr + value_curve: CostCurveValueCurve + variable_cost_type: Optional[StrictStr] = None + vom_cost: InputOutputCurve + __properties: ClassVar[List[str]] = [ + "fuel_cost", + "power_units", + "value_curve", + "variable_cost_type", + "vom_cost", + ] + + @field_validator("power_units") + def power_units_validate_enum(cls, value): + """Validates the enum""" + if value not in set(["SYSTEM_BASE", "DEVICE_BASE", "NATURAL_UNITS"]): + raise ValueError("must be one of enum values ('SYSTEM_BASE', 'DEVICE_BASE', 'NATURAL_UNITS')") + return value + + @field_validator("variable_cost_type") + def variable_cost_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["FUEL"]): + raise ValueError("must be one of enum values ('FUEL')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of FuelCurve from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of fuel_cost + if self.fuel_cost: + _dict["fuel_cost"] = self.fuel_cost.to_dict() + # override the default output from pydantic by calling `to_dict()` of value_curve + if self.value_curve: + _dict["value_curve"] = self.value_curve.to_dict() + # override the default output from pydantic by calling `to_dict()` of vom_cost + if self.vom_cost: + _dict["vom_cost"] = self.vom_cost.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of FuelCurve from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "fuel_cost": FuelCurveFuelCost.from_dict(obj["fuel_cost"]) + if obj.get("fuel_cost") is not None + else None, + "power_units": obj.get("power_units"), + "value_curve": CostCurveValueCurve.from_dict(obj["value_curve"]) + if obj.get("value_curve") is not None + else None, + "variable_cost_type": obj.get("variable_cost_type"), + "vom_cost": InputOutputCurve.from_dict(obj["vom_cost"]) + if obj.get("vom_cost") is not None + else None, + } + ) + return _obj diff --git a/src/r2x/models/generated/fuel_curve_fuel_cost.py b/src/r2x/models/generated/fuel_curve_fuel_cost.py new file mode 100644 index 00000000..8bda6450 --- /dev/null +++ b/src/r2x/models/generated/fuel_curve_fuel_cost.py @@ -0,0 +1,162 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import json +import pprint +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictFloat, + StrictInt, + StrictStr, + ValidationError, + field_validator, +) +from typing import Any, List, Optional, Union +from pydantic import StrictStr, Field +from typing import Union, List, Set, Optional, Dict +from typing_extensions import Literal, Self + +FUELCURVEFUELCOST_ONE_OF_SCHEMAS = ["float", "str"] + + +class FuelCurveFuelCost(BaseModel): + """ + FuelCurveFuelCost + """ + + # data type: str + oneof_schema_1_validator: Optional[StrictStr] = None + # data type: float + oneof_schema_2_validator: Optional[Union[StrictFloat, StrictInt]] = None + actual_instance: Optional[Union[float, str]] = None + one_of_schemas: Set[str] = {"float", "str"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + instance = FuelCurveFuelCost.model_construct() + error_messages = [] + match = 0 + # validate data type: str + try: + instance.oneof_schema_1_validator = v + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: float + try: + instance.oneof_schema_2_validator = v + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when setting `actual_instance` in FuelCurveFuelCost with oneOf schemas: float, str. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in FuelCurveFuelCost with oneOf schemas: float, str. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into str + try: + # validation + instance.oneof_schema_1_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.oneof_schema_1_validator + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into float + try: + # validation + instance.oneof_schema_2_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.oneof_schema_2_validator + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into FuelCurveFuelCost with oneOf schemas: float, str. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into FuelCurveFuelCost with oneOf schemas: float, str. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], float, str]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/src/r2x/models/generated/incremental_curve.py b/src/r2x/models/generated/incremental_curve.py new file mode 100644 index 00000000..453074cf --- /dev/null +++ b/src/r2x/models/generated/incremental_curve.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.incremental_curve_function_data import IncrementalCurveFunctionData +from typing import Optional, Set +from typing_extensions import Self + + +class IncrementalCurve(Component): + """ + IncrementalCurve + """ # noqa: E501 + + curve_type: Optional[StrictStr] = None + function_data: IncrementalCurveFunctionData + initial_input: Optional[Union[StrictFloat, StrictInt]] = None + input_at_zero: Optional[Union[StrictFloat, StrictInt]] = None + __properties: ClassVar[List[str]] = ["curve_type", "function_data", "initial_input", "input_at_zero"] + + @field_validator("curve_type") + def curve_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["INCREMENTAL"]): + raise ValueError("must be one of enum values ('INCREMENTAL')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of IncrementalCurve from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of function_data + if self.function_data: + _dict["function_data"] = self.function_data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of IncrementalCurve from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "curve_type": obj.get("curve_type"), + "function_data": IncrementalCurveFunctionData.from_dict(obj["function_data"]) + if obj.get("function_data") is not None + else None, + "initial_input": obj.get("initial_input"), + "input_at_zero": obj.get("input_at_zero"), + } + ) + return _obj diff --git a/src/r2x/models/generated/incremental_curve_function_data.py b/src/r2x/models/generated/incremental_curve_function_data.py new file mode 100644 index 00000000..36e67eda --- /dev/null +++ b/src/r2x/models/generated/incremental_curve_function_data.py @@ -0,0 +1,147 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import json +import pprint +from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator +from typing import Any, List, Optional +from openapi_client.models.linear_function_data import LinearFunctionData +from openapi_client.models.piecewise_step_data import PiecewiseStepData +from pydantic import StrictStr, Field +from typing import Union, List, Set, Optional, Dict +from typing_extensions import Literal, Self + +INCREMENTALCURVEFUNCTIONDATA_ONE_OF_SCHEMAS = ["LinearFunctionData", "PiecewiseStepData"] + + +class IncrementalCurveFunctionData(BaseModel): + """ + IncrementalCurveFunctionData + """ + + # data type: LinearFunctionData + oneof_schema_1_validator: Optional[LinearFunctionData] = None + # data type: PiecewiseStepData + oneof_schema_2_validator: Optional[PiecewiseStepData] = None + actual_instance: Optional[Union[LinearFunctionData, PiecewiseStepData]] = None + one_of_schemas: Set[str] = {"LinearFunctionData", "PiecewiseStepData"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + instance = IncrementalCurveFunctionData.model_construct() + error_messages = [] + match = 0 + # validate data type: LinearFunctionData + if not isinstance(v, LinearFunctionData): + error_messages.append(f"Error! Input type `{type(v)}` is not `LinearFunctionData`") + else: + match += 1 + # validate data type: PiecewiseStepData + if not isinstance(v, PiecewiseStepData): + error_messages.append(f"Error! Input type `{type(v)}` is not `PiecewiseStepData`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when setting `actual_instance` in IncrementalCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseStepData. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in IncrementalCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseStepData. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into LinearFunctionData + try: + instance.actual_instance = LinearFunctionData.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into PiecewiseStepData + try: + instance.actual_instance = PiecewiseStepData.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into IncrementalCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseStepData. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into IncrementalCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseStepData. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], LinearFunctionData, PiecewiseStepData]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/src/r2x/models/generated/input_output_curve.py b/src/r2x/models/generated/input_output_curve.py new file mode 100644 index 00000000..62e6e7f5 --- /dev/null +++ b/src/r2x/models/generated/input_output_curve.py @@ -0,0 +1,108 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.input_output_curve_function_data import InputOutputCurveFunctionData +from typing import Optional, Set +from typing_extensions import Self + + +class InputOutputCurve(Component): + """ + InputOutputCurve + """ # noqa: E501 + + curve_type: Optional[StrictStr] = None + function_data: InputOutputCurveFunctionData + input_at_zero: Optional[Union[StrictFloat, StrictInt]] = None + __properties: ClassVar[List[str]] = ["curve_type", "function_data", "input_at_zero"] + + @field_validator("curve_type") + def curve_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["INPUT_OUTPUT"]): + raise ValueError("must be one of enum values ('INPUT_OUTPUT')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of InputOutputCurve from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of function_data + if self.function_data: + _dict["function_data"] = self.function_data.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of InputOutputCurve from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "curve_type": obj.get("curve_type"), + "function_data": InputOutputCurveFunctionData.from_dict(obj["function_data"]) + if obj.get("function_data") is not None + else None, + "input_at_zero": obj.get("input_at_zero"), + } + ) + return _obj diff --git a/src/r2x/models/generated/input_output_curve_function_data.py b/src/r2x/models/generated/input_output_curve_function_data.py new file mode 100644 index 00000000..55e1ab4a --- /dev/null +++ b/src/r2x/models/generated/input_output_curve_function_data.py @@ -0,0 +1,169 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import json +import pprint +from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator +from typing import Any, List, Optional +from openapi_client.models.linear_function_data import LinearFunctionData +from openapi_client.models.piecewise_linear_data import PiecewiseLinearData +from openapi_client.models.quadratic_function_data import QuadraticFunctionData +from pydantic import StrictStr, Field +from typing import Union, List, Set, Optional, Dict +from typing_extensions import Literal, Self + +INPUTOUTPUTCURVEFUNCTIONDATA_ONE_OF_SCHEMAS = [ + "LinearFunctionData", + "PiecewiseLinearData", + "QuadraticFunctionData", +] + + +class InputOutputCurveFunctionData(BaseModel): + """ + InputOutputCurveFunctionData + """ + + # data type: QuadraticFunctionData + oneof_schema_1_validator: Optional[QuadraticFunctionData] = None + # data type: LinearFunctionData + oneof_schema_2_validator: Optional[LinearFunctionData] = None + # data type: PiecewiseLinearData + oneof_schema_3_validator: Optional[PiecewiseLinearData] = None + actual_instance: Optional[Union[LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData]] = None + one_of_schemas: Set[str] = {"LinearFunctionData", "PiecewiseLinearData", "QuadraticFunctionData"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + discriminator_value_class_map: Dict[str, str] = {} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + instance = InputOutputCurveFunctionData.model_construct() + error_messages = [] + match = 0 + # validate data type: QuadraticFunctionData + if not isinstance(v, QuadraticFunctionData): + error_messages.append(f"Error! Input type `{type(v)}` is not `QuadraticFunctionData`") + else: + match += 1 + # validate data type: LinearFunctionData + if not isinstance(v, LinearFunctionData): + error_messages.append(f"Error! Input type `{type(v)}` is not `LinearFunctionData`") + else: + match += 1 + # validate data type: PiecewiseLinearData + if not isinstance(v, PiecewiseLinearData): + error_messages.append(f"Error! Input type `{type(v)}` is not `PiecewiseLinearData`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when setting `actual_instance` in InputOutputCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in InputOutputCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into QuadraticFunctionData + try: + instance.actual_instance = QuadraticFunctionData.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into LinearFunctionData + try: + instance.actual_instance = LinearFunctionData.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into PiecewiseLinearData + try: + instance.actual_instance = PiecewiseLinearData.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into InputOutputCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into InputOutputCurveFunctionData with oneOf schemas: LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict( + self, + ) -> Optional[Union[Dict[str, Any], LinearFunctionData, PiecewiseLinearData, QuadraticFunctionData]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/src/r2x/models/generated/linear_function_data.py b/src/r2x/models/generated/linear_function_data.py new file mode 100644 index 00000000..07da447b --- /dev/null +++ b/src/r2x/models/generated/linear_function_data.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + + +class LinearFunctionData(Component): + """ + LinearFunctionData + """ # noqa: E501 + + constant_term: Union[StrictFloat, StrictInt] + function_type: Optional[StrictStr] = None + proportional_term: Union[StrictFloat, StrictInt] + __properties: ClassVar[List[str]] = ["constant_term", "function_type", "proportional_term"] + + @field_validator("function_type") + def function_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["LINEAR"]): + raise ValueError("must be one of enum values ('LINEAR')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of LinearFunctionData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of LinearFunctionData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "constant_term": obj.get("constant_term"), + "function_type": obj.get("function_type"), + "proportional_term": obj.get("proportional_term"), + } + ) + return _obj diff --git a/src/r2x/models/generated/min_max.py b/src/r2x/models/generated/min_max.py new file mode 100644 index 00000000..e1fd4703 --- /dev/null +++ b/src/r2x/models/generated/min_max.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + + +class MinMax(Component): + """ + MinMax + """ # noqa: E501 + + max: Optional[Union[StrictFloat, StrictInt]] = None + min: Optional[Union[StrictFloat, StrictInt]] = None + __properties: ClassVar[List[str]] = ["max", "min"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of MinMax from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of MinMax from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"max": obj.get("max"), "min": obj.get("min")}) + return _obj diff --git a/src/r2x/models/generated/piecewise_linear_data.py b/src/r2x/models/generated/piecewise_linear_data.py new file mode 100644 index 00000000..ae8524a4 --- /dev/null +++ b/src/r2x/models/generated/piecewise_linear_data.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional +from openapi_client.models.piecewise_linear_data_points_inner import PiecewiseLinearDataPointsInner +from typing import Optional, Set +from typing_extensions import Self + + +class PiecewiseLinearData(Component): + """ + PiecewiseLinearData + """ # noqa: E501 + + function_type: Optional[StrictStr] = None + points: List[PiecewiseLinearDataPointsInner] + __properties: ClassVar[List[str]] = ["function_type", "points"] + + @field_validator("function_type") + def function_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["PIECEWISE_LINEAR"]): + raise ValueError("must be one of enum values ('PIECEWISE_LINEAR')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PiecewiseLinearData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in points (list) + _items = [] + if self.points: + for _item_points in self.points: + if _item_points: + _items.append(_item_points.to_dict()) + _dict["points"] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PiecewiseLinearData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "function_type": obj.get("function_type"), + "points": [PiecewiseLinearDataPointsInner.from_dict(_item) for _item in obj["points"]] + if obj.get("points") is not None + else None, + } + ) + return _obj diff --git a/src/r2x/models/generated/piecewise_linear_data_points_inner.py b/src/r2x/models/generated/piecewise_linear_data_points_inner.py new file mode 100644 index 00000000..29647154 --- /dev/null +++ b/src/r2x/models/generated/piecewise_linear_data_points_inner.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + + +class PiecewiseLinearDataPointsInner(Component): + """ + PiecewiseLinearDataPointsInner + """ # noqa: E501 + + x: Union[StrictFloat, StrictInt] + y: Union[StrictFloat, StrictInt] + __properties: ClassVar[List[str]] = ["x", "y"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PiecewiseLinearDataPointsInner from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PiecewiseLinearDataPointsInner from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"x": obj.get("x"), "y": obj.get("y")}) + return _obj diff --git a/src/r2x/models/generated/piecewise_step_data.py b/src/r2x/models/generated/piecewise_step_data.py new file mode 100644 index 00000000..5d13f048 --- /dev/null +++ b/src/r2x/models/generated/piecewise_step_data.py @@ -0,0 +1,102 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + + +class PiecewiseStepData(Component): + """ + PiecewiseStepData + """ # noqa: E501 + + function_type: Optional[StrictStr] = None + x_coords: List[Union[StrictFloat, StrictInt]] + y_coords: List[Union[StrictFloat, StrictInt]] + __properties: ClassVar[List[str]] = ["function_type", "x_coords", "y_coords"] + + @field_validator("function_type") + def function_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["PIECEWISE_STEP"]): + raise ValueError("must be one of enum values ('PIECEWISE_STEP')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PiecewiseStepData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PiecewiseStepData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "function_type": obj.get("function_type"), + "x_coords": obj.get("x_coords"), + "y_coords": obj.get("y_coords"), + } + ) + return _obj diff --git a/src/r2x/models/generated/quadratic_function_data.py b/src/r2x/models/generated/quadratic_function_data.py new file mode 100644 index 00000000..1ff6d75b --- /dev/null +++ b/src/r2x/models/generated/quadratic_function_data.py @@ -0,0 +1,109 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Optional, Set +from typing_extensions import Self + + +class QuadraticFunctionData(Component): + """ + QuadraticFunctionData + """ # noqa: E501 + + constant_term: Union[StrictFloat, StrictInt] + function_type: Optional[StrictStr] = None + proportional_term: Union[StrictFloat, StrictInt] + quadratic_term: Union[StrictFloat, StrictInt] + __properties: ClassVar[List[str]] = [ + "constant_term", + "function_type", + "proportional_term", + "quadratic_term", + ] + + @field_validator("function_type") + def function_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(["QUADRATIC"]): + raise ValueError("must be one of enum values ('QUADRATIC')") + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of QuadraticFunctionData from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of QuadraticFunctionData from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "constant_term": obj.get("constant_term"), + "function_type": obj.get("function_type"), + "proportional_term": obj.get("proportional_term"), + "quadratic_term": obj.get("quadratic_term"), + } + ) + return _obj diff --git a/src/r2x/models/generated/start_up_stages.py b/src/r2x/models/generated/start_up_stages.py new file mode 100644 index 00000000..a0e2b5bd --- /dev/null +++ b/src/r2x/models/generated/start_up_stages.py @@ -0,0 +1,86 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + + +class StartUpStages(Component): + """ + StartUpStages + """ # noqa: E501 + + cold: Union[StrictFloat, StrictInt] + hot: Union[StrictFloat, StrictInt] + warm: Union[StrictFloat, StrictInt] + __properties: ClassVar[List[str]] = ["cold", "hot", "warm"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of StartUpStages from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of StartUpStages from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"cold": obj.get("cold"), "hot": obj.get("hot"), "warm": obj.get("warm")}) + return _obj diff --git a/src/r2x/models/generated/thermal_standard.py b/src/r2x/models/generated/thermal_standard.py new file mode 100644 index 00000000..fab293e1 --- /dev/null +++ b/src/r2x/models/generated/thermal_standard.py @@ -0,0 +1,244 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictBool, + StrictFloat, + StrictInt, + StrictStr, + field_validator, +) +from typing import Any, ClassVar, Dict, List, Optional, Union +from openapi_client.models.min_max import MinMax +from openapi_client.models.thermal_standard_operation_cost import ThermalStandardOperationCost +from openapi_client.models.up_down import UpDown +from typing import Optional, Set +from typing_extensions import Self + + +class ThermalStandard(Component): + """ + ThermalStandard + """ # noqa: E501 + + active_power: Optional[Union[StrictFloat, StrictInt]] = 0.0 + active_power_limits: Optional[MinMax] = None + available: Optional[StrictBool] = True + base_power: Optional[Union[StrictFloat, StrictInt]] = 0.0 + bus_id: StrictInt + fuel_type: Optional[StrictStr] = Field( + default="OTHER", description="Thermal fuels that reflect options in the EIA annual energy review." + ) + id: StrictInt + must_run: Optional[StrictBool] = False + name: StrictStr + operation_cost: ThermalStandardOperationCost + prime_mover: Optional[StrictStr] = "OT" + ramp_limits: Optional[UpDown] = None + rating: Optional[Union[StrictFloat, StrictInt]] = 0.0 + reactive_power: Optional[Union[StrictFloat, StrictInt]] = 0.0 + reactive_power_limits: Optional[MinMax] = None + status: Optional[StrictBool] = True + time_limits: Optional[UpDown] = None + __properties: ClassVar[List[str]] = [ + "active_power", + "active_power_limits", + "available", + "base_power", + "bus_id", + "fuel_type", + "id", + "must_run", + "name", + "operation_cost", + "prime_mover", + "ramp_limits", + "rating", + "reactive_power", + "reactive_power_limits", + "status", + "time_limits", + ] + + @field_validator("fuel_type") + def fuel_type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set( + [ + "COAL", + "WASTE_COAL", + "DISTILLATE_FUEL_OIL", + "WASTE_OIL", + "PETROLEUM_COKE", + "RESIDUAL_FUEL_OIL", + "NATURAL_GAS", + "OTHER_GAS", + "NUCLEAR", + "AG_BIPRODUCT", + "MUNICIPAL_WASTE", + "WOOD_WASTE", + "GEOTHERMAL", + "OTHER", + ] + ): + raise ValueError( + "must be one of enum values ('COAL', 'WASTE_COAL', 'DISTILLATE_FUEL_OIL', 'WASTE_OIL', 'PETROLEUM_COKE', 'RESIDUAL_FUEL_OIL', 'NATURAL_GAS', 'OTHER_GAS', 'NUCLEAR', 'AG_BIPRODUCT', 'MUNICIPAL_WASTE', 'WOOD_WASTE', 'GEOTHERMAL', 'OTHER')" + ) + return value + + @field_validator("prime_mover") + def prime_mover_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set( + [ + "BA", + "BT", + "CA", + "CC", + "CE", + "CP", + "CS", + "CT", + "ES", + "FC", + "FW", + "GT", + "HA", + "HB", + "HK", + "HY", + "IC", + "PS", + "OT", + "ST", + "PVe", + "WT", + "WS", + ] + ): + raise ValueError( + "must be one of enum values ('BA', 'BT', 'CA', 'CC', 'CE', 'CP', 'CS', 'CT', 'ES', 'FC', 'FW', 'GT', 'HA', 'HB', 'HK', 'HY', 'IC', 'PS', 'OT', 'ST', 'PVe', 'WT', 'WS')" + ) + return value + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ThermalStandard from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of active_power_limits + if self.active_power_limits: + _dict["active_power_limits"] = self.active_power_limits.to_dict() + # override the default output from pydantic by calling `to_dict()` of operation_cost + if self.operation_cost: + _dict["operation_cost"] = self.operation_cost.to_dict() + # override the default output from pydantic by calling `to_dict()` of ramp_limits + if self.ramp_limits: + _dict["ramp_limits"] = self.ramp_limits.to_dict() + # override the default output from pydantic by calling `to_dict()` of reactive_power_limits + if self.reactive_power_limits: + _dict["reactive_power_limits"] = self.reactive_power_limits.to_dict() + # override the default output from pydantic by calling `to_dict()` of time_limits + if self.time_limits: + _dict["time_limits"] = self.time_limits.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ThermalStandard from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "active_power": obj.get("active_power") if obj.get("active_power") is not None else 0.0, + "active_power_limits": MinMax.from_dict(obj["active_power_limits"]) + if obj.get("active_power_limits") is not None + else None, + "available": obj.get("available") if obj.get("available") is not None else True, + "base_power": obj.get("base_power") if obj.get("base_power") is not None else 0.0, + "bus_id": obj.get("bus_id"), + "fuel_type": obj.get("fuel_type") if obj.get("fuel_type") is not None else "OTHER", + "id": obj.get("id"), + "must_run": obj.get("must_run") if obj.get("must_run") is not None else False, + "name": obj.get("name"), + "operation_cost": ThermalStandardOperationCost.from_dict(obj["operation_cost"]) + if obj.get("operation_cost") is not None + else None, + "prime_mover": obj.get("prime_mover") if obj.get("prime_mover") is not None else "OT", + "ramp_limits": UpDown.from_dict(obj["ramp_limits"]) + if obj.get("ramp_limits") is not None + else None, + "rating": obj.get("rating") if obj.get("rating") is not None else 0.0, + "reactive_power": obj.get("reactive_power") if obj.get("reactive_power") is not None else 0.0, + "reactive_power_limits": MinMax.from_dict(obj["reactive_power_limits"]) + if obj.get("reactive_power_limits") is not None + else None, + "status": obj.get("status") if obj.get("status") is not None else True, + "time_limits": UpDown.from_dict(obj["time_limits"]) + if obj.get("time_limits") is not None + else None, + } + ) + return _obj diff --git a/src/r2x/models/generated/thermal_standard_operation_cost.py b/src/r2x/models/generated/thermal_standard_operation_cost.py new file mode 100644 index 00000000..d55407c0 --- /dev/null +++ b/src/r2x/models/generated/thermal_standard_operation_cost.py @@ -0,0 +1,110 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from openapi_client.models.thermal_standard_operation_cost_start_up import ThermalStandardOperationCostStartUp +from openapi_client.models.thermal_standard_operation_cost_variable import ( + ThermalStandardOperationCostVariable, +) +from typing import Optional, Set +from typing_extensions import Self + + +class ThermalStandardOperationCost(Component): + """ + Cost representation for thermal generation units + """ # noqa: E501 + + fixed: Union[StrictFloat, StrictInt] = Field( + description="Fixed cost of keeping the unit online. For some cost represenations this field can be duplicative" + ) + shut_down: Union[StrictFloat, StrictInt] = Field(description="Cost to turn the unit off") + start_up: ThermalStandardOperationCostStartUp + variable: ThermalStandardOperationCostVariable + __properties: ClassVar[List[str]] = ["fixed", "shut_down", "start_up", "variable"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of ThermalStandardOperationCost from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of start_up + if self.start_up: + _dict["start_up"] = self.start_up.to_dict() + # override the default output from pydantic by calling `to_dict()` of variable + if self.variable: + _dict["variable"] = self.variable.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of ThermalStandardOperationCost from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate( + { + "fixed": obj.get("fixed"), + "shut_down": obj.get("shut_down"), + "start_up": ThermalStandardOperationCostStartUp.from_dict(obj["start_up"]) + if obj.get("start_up") is not None + else None, + "variable": ThermalStandardOperationCostVariable.from_dict(obj["variable"]) + if obj.get("variable") is not None + else None, + } + ) + return _obj diff --git a/src/r2x/models/generated/thermal_standard_operation_cost_start_up.py b/src/r2x/models/generated/thermal_standard_operation_cost_start_up.py new file mode 100644 index 00000000..82225e6d --- /dev/null +++ b/src/r2x/models/generated/thermal_standard_operation_cost_start_up.py @@ -0,0 +1,159 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import json +import pprint +from pydantic import ( + BaseModel, + ConfigDict, + Field, + StrictFloat, + StrictInt, + StrictStr, + ValidationError, + field_validator, +) +from typing import Any, List, Optional, Union +from openapi_client.models.start_up_stages import StartUpStages +from pydantic import StrictStr, Field +from typing import Union, List, Set, Optional, Dict +from typing_extensions import Literal, Self + +THERMALSTANDARDOPERATIONCOSTSTARTUP_ONE_OF_SCHEMAS = ["StartUpStages", "float"] + + +class ThermalStandardOperationCostStartUp(BaseModel): + """ + Start-up cost can take linear or multi-stage cost + """ + + # data type: float + oneof_schema_1_validator: Optional[Union[StrictFloat, StrictInt]] = None + # data type: StartUpStages + oneof_schema_2_validator: Optional[StartUpStages] = None + actual_instance: Optional[Union[StartUpStages, float]] = None + one_of_schemas: Set[str] = {"StartUpStages", "float"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + instance = ThermalStandardOperationCostStartUp.model_construct() + error_messages = [] + match = 0 + # validate data type: float + try: + instance.oneof_schema_1_validator = v + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # validate data type: StartUpStages + if not isinstance(v, StartUpStages): + error_messages.append(f"Error! Input type `{type(v)}` is not `StartUpStages`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when setting `actual_instance` in ThermalStandardOperationCostStartUp with oneOf schemas: StartUpStages, float. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in ThermalStandardOperationCostStartUp with oneOf schemas: StartUpStages, float. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into float + try: + # validation + instance.oneof_schema_1_validator = json.loads(json_str) + # assign value to actual_instance + instance.actual_instance = instance.oneof_schema_1_validator + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into StartUpStages + try: + instance.actual_instance = StartUpStages.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into ThermalStandardOperationCostStartUp with oneOf schemas: StartUpStages, float. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into ThermalStandardOperationCostStartUp with oneOf schemas: StartUpStages, float. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], StartUpStages, float]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/src/r2x/models/generated/thermal_standard_operation_cost_variable.py b/src/r2x/models/generated/thermal_standard_operation_cost_variable.py new file mode 100644 index 00000000..cf44d821 --- /dev/null +++ b/src/r2x/models/generated/thermal_standard_operation_cost_variable.py @@ -0,0 +1,149 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import json +import pprint +from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator +from typing import Any, List, Optional +from openapi_client.models.cost_curve import CostCurve +from openapi_client.models.fuel_curve import FuelCurve +from pydantic import StrictStr, Field +from typing import Union, List, Set, Optional, Dict +from typing_extensions import Literal, Self + +THERMALSTANDARDOPERATIONCOSTVARIABLE_ONE_OF_SCHEMAS = ["CostCurve", "FuelCurve"] + + +class ThermalStandardOperationCostVariable(BaseModel): + """ + ThermalStandardOperationCostVariable + """ + + # data type: CostCurve + oneof_schema_1_validator: Optional[CostCurve] = None + # data type: FuelCurve + oneof_schema_2_validator: Optional[FuelCurve] = None + actual_instance: Optional[Union[CostCurve, FuelCurve]] = None + one_of_schemas: Set[str] = {"CostCurve", "FuelCurve"} + + model_config = ConfigDict( + validate_assignment=True, + protected_namespaces=(), + ) + + discriminator_value_class_map: Dict[str, str] = {} + + def __init__(self, *args, **kwargs) -> None: + if args: + if len(args) > 1: + raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") + if kwargs: + raise ValueError("If a position argument is used, keyword arguments cannot be used.") + super().__init__(actual_instance=args[0]) + else: + super().__init__(**kwargs) + + @field_validator("actual_instance") + def actual_instance_must_validate_oneof(cls, v): + instance = ThermalStandardOperationCostVariable.model_construct() + error_messages = [] + match = 0 + # validate data type: CostCurve + if not isinstance(v, CostCurve): + error_messages.append(f"Error! Input type `{type(v)}` is not `CostCurve`") + else: + match += 1 + # validate data type: FuelCurve + if not isinstance(v, FuelCurve): + error_messages.append(f"Error! Input type `{type(v)}` is not `FuelCurve`") + else: + match += 1 + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when setting `actual_instance` in ThermalStandardOperationCostVariable with oneOf schemas: CostCurve, FuelCurve. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when setting `actual_instance` in ThermalStandardOperationCostVariable with oneOf schemas: CostCurve, FuelCurve. Details: " + + ", ".join(error_messages) + ) + else: + return v + + @classmethod + def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + return cls.from_json(json.dumps(obj)) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Returns the object represented by the json string""" + instance = cls.model_construct() + error_messages = [] + match = 0 + + # deserialize data into CostCurve + try: + instance.actual_instance = CostCurve.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + # deserialize data into FuelCurve + try: + instance.actual_instance = FuelCurve.from_json(json_str) + match += 1 + except (ValidationError, ValueError) as e: + error_messages.append(str(e)) + + if match > 1: + # more than 1 match + raise ValueError( + "Multiple matches found when deserializing the JSON string into ThermalStandardOperationCostVariable with oneOf schemas: CostCurve, FuelCurve. Details: " + + ", ".join(error_messages) + ) + elif match == 0: + # no match + raise ValueError( + "No match found when deserializing the JSON string into ThermalStandardOperationCostVariable with oneOf schemas: CostCurve, FuelCurve. Details: " + + ", ".join(error_messages) + ) + else: + return instance + + def to_json(self) -> str: + """Returns the JSON representation of the actual instance""" + if self.actual_instance is None: + return "null" + + if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json): + return self.actual_instance.to_json() + else: + return json.dumps(self.actual_instance) + + def to_dict(self) -> Optional[Union[Dict[str, Any], CostCurve, FuelCurve]]: + """Returns the dict representation of the actual instance""" + if self.actual_instance is None: + return None + + if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): + return self.actual_instance.to_dict() + else: + # primitive type + return self.actual_instance + + def to_str(self) -> str: + """Returns the string representation of the actual instance""" + return pprint.pformat(self.model_dump()) diff --git a/src/r2x/models/generated/up_down.py b/src/r2x/models/generated/up_down.py new file mode 100644 index 00000000..2c39dccd --- /dev/null +++ b/src/r2x/models/generated/up_down.py @@ -0,0 +1,85 @@ +# coding: utf-8 + +""" +PowerSystemModels + +No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + +The version of the OpenAPI document: 1.0.0 +Generated by OpenAPI Generator (https://openapi-generator.tech) + +Do not edit the class manually. +""" # noqa: E501 + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from infrasys import Component + +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union +from typing import Optional, Set +from typing_extensions import Self + + +class UpDown(Component): + """ + UpDown + """ # noqa: E501 + + down: Union[StrictFloat, StrictInt] + up: Union[StrictFloat, StrictInt] + __properties: ClassVar[List[str]] = ["down", "up"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of UpDown from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of UpDown from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({"down": obj.get("down"), "up": obj.get("up")}) + return _obj