From c812c28f8b337b04ec25a6cb5de2d67441571e2e Mon Sep 17 00:00:00 2001 From: activitysmith-bot Date: Sat, 9 May 2026 12:15:13 +0000 Subject: [PATCH] chore: regenerate SDK --- activitysmith_openapi/__init__.py | 1 + activitysmith_openapi/docs/ActivityMetric.md | 3 +- .../docs/ActivityMetricValue.md | 28 ++++ activitysmith_openapi/models/__init__.py | 1 + .../models/activity_metric.py | 28 +++- .../models/activity_metric_value.py | 144 ++++++++++++++++++ .../test/test_activity_metric.py | 7 +- .../test/test_activity_metric_value.py | 50 ++++++ 8 files changed, 252 insertions(+), 10 deletions(-) create mode 100644 activitysmith_openapi/docs/ActivityMetricValue.md create mode 100644 activitysmith_openapi/models/activity_metric_value.py create mode 100644 activitysmith_openapi/test/test_activity_metric_value.py diff --git a/activitysmith_openapi/__init__.py b/activitysmith_openapi/__init__.py index 955b471..2d5d830 100644 --- a/activitysmith_openapi/__init__.py +++ b/activitysmith_openapi/__init__.py @@ -34,6 +34,7 @@ # import models into sdk package from activitysmith_openapi.models.activity_metric import ActivityMetric +from activitysmith_openapi.models.activity_metric_value import ActivityMetricValue from activitysmith_openapi.models.alert_payload import AlertPayload from activitysmith_openapi.models.bad_request_error import BadRequestError from activitysmith_openapi.models.channel_target import ChannelTarget diff --git a/activitysmith_openapi/docs/ActivityMetric.md b/activitysmith_openapi/docs/ActivityMetric.md index ae0b4f0..b1643e7 100644 --- a/activitysmith_openapi/docs/ActivityMetric.md +++ b/activitysmith_openapi/docs/ActivityMetric.md @@ -6,8 +6,9 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **label** | **str** | | -**value** | **float** | | +**value** | [**ActivityMetricValue**](ActivityMetricValue.md) | | **unit** | **str** | | [optional] +**color** | **str** | Optional per-metric accent color for metrics and stats activities. | [optional] ## Example diff --git a/activitysmith_openapi/docs/ActivityMetricValue.md b/activitysmith_openapi/docs/ActivityMetricValue.md new file mode 100644 index 0000000..4017693 --- /dev/null +++ b/activitysmith_openapi/docs/ActivityMetricValue.md @@ -0,0 +1,28 @@ +# ActivityMetricValue + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Example + +```python +from activitysmith_openapi.models.activity_metric_value import ActivityMetricValue + +# TODO update the JSON string below +json = "{}" +# create an instance of ActivityMetricValue from a JSON string +activity_metric_value_instance = ActivityMetricValue.from_json(json) +# print the JSON string representation of the object +print(ActivityMetricValue.to_json()) + +# convert the object into a dict +activity_metric_value_dict = activity_metric_value_instance.to_dict() +# create an instance of ActivityMetricValue from a dict +activity_metric_value_from_dict = ActivityMetricValue.from_dict(activity_metric_value_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/activitysmith_openapi/models/__init__.py b/activitysmith_openapi/models/__init__.py index 0fa4210..20012de 100644 --- a/activitysmith_openapi/models/__init__.py +++ b/activitysmith_openapi/models/__init__.py @@ -15,6 +15,7 @@ # import models into model package from activitysmith_openapi.models.activity_metric import ActivityMetric +from activitysmith_openapi.models.activity_metric_value import ActivityMetricValue from activitysmith_openapi.models.alert_payload import AlertPayload from activitysmith_openapi.models.bad_request_error import BadRequestError from activitysmith_openapi.models.channel_target import ChannelTarget diff --git a/activitysmith_openapi/models/activity_metric.py b/activitysmith_openapi/models/activity_metric.py index 052c5b3..980f03f 100644 --- a/activitysmith_openapi/models/activity_metric.py +++ b/activitysmith_openapi/models/activity_metric.py @@ -17,9 +17,10 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional, Union +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated +from activitysmith_openapi.models.activity_metric_value import ActivityMetricValue from typing import Optional, Set from typing_extensions import Self @@ -28,10 +29,21 @@ class ActivityMetric(BaseModel): ActivityMetric """ # noqa: E501 label: Annotated[str, Field(min_length=1, strict=True)] - value: Union[Annotated[float, Field(le=100, strict=True, ge=0)], Annotated[int, Field(le=100, strict=True, ge=0)]] + value: ActivityMetricValue unit: Optional[StrictStr] = None + color: Optional[StrictStr] = Field(default=None, description="Optional per-metric accent color for metrics and stats activities.") additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["label", "value", "unit"] + __properties: ClassVar[List[str]] = ["label", "value", "unit", "color"] + + @field_validator('color') + def color_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['lime', 'green', 'cyan', 'blue', 'purple', 'magenta', 'red', 'orange', 'yellow']): + raise ValueError("must be one of enum values ('lime', 'green', 'cyan', 'blue', 'purple', 'magenta', 'red', 'orange', 'yellow')") + return value model_config = ConfigDict( populate_by_name=True, @@ -74,6 +86,9 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of value + if self.value: + _dict['value'] = self.value.to_dict() # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: for _key, _value in self.additional_properties.items(): @@ -92,8 +107,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "label": obj.get("label"), - "value": obj.get("value"), - "unit": obj.get("unit") + "value": ActivityMetricValue.from_dict(obj["value"]) if obj.get("value") is not None else None, + "unit": obj.get("unit"), + "color": obj.get("color") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/activitysmith_openapi/models/activity_metric_value.py b/activitysmith_openapi/models/activity_metric_value.py new file mode 100644 index 0000000..7375992 --- /dev/null +++ b/activitysmith_openapi/models/activity_metric_value.py @@ -0,0 +1,144 @@ +# coding: utf-8 + +""" + ActivitySmith API + + Send push notifications and Live Activities to your own devices via a single API key. + + 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, Union +from typing_extensions import Annotated +from pydantic import StrictStr, Field +from typing import Union, List, Set, Optional, Dict +from typing_extensions import Literal, Self + +ACTIVITYMETRICVALUE_ONE_OF_SCHEMAS = ["float", "str"] + +class ActivityMetricValue(BaseModel): + """ + ActivityMetricValue + """ + # data type: float + oneof_schema_1_validator: Optional[Union[Annotated[float, Field(strict=True, ge=0)], Annotated[int, Field(strict=True, ge=0)]]] = None + # data type: str + oneof_schema_2_validator: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=64)]] = 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 = ActivityMetricValue.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: str + 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 ActivityMetricValue with oneOf schemas: float, str. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in ActivityMetricValue 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 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 str + 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 ActivityMetricValue 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 ActivityMetricValue 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/activitysmith_openapi/test/test_activity_metric.py b/activitysmith_openapi/test/test_activity_metric.py index 9b9e89d..ed532d2 100644 --- a/activitysmith_openapi/test/test_activity_metric.py +++ b/activitysmith_openapi/test/test_activity_metric.py @@ -36,13 +36,14 @@ def make_instance(self, include_optional) -> ActivityMetric: if include_optional: return ActivityMetric( label = '0', - value = 0, - unit = '' + value = None, + unit = '', + color = 'lime' ) else: return ActivityMetric( label = '0', - value = 0, + value = None, ) """ diff --git a/activitysmith_openapi/test/test_activity_metric_value.py b/activitysmith_openapi/test/test_activity_metric_value.py new file mode 100644 index 0000000..522675c --- /dev/null +++ b/activitysmith_openapi/test/test_activity_metric_value.py @@ -0,0 +1,50 @@ +# coding: utf-8 + +""" + ActivitySmith API + + Send push notifications and Live Activities to your own devices via a single API key. + + 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 unittest + +from activitysmith_openapi.models.activity_metric_value import ActivityMetricValue + +class TestActivityMetricValue(unittest.TestCase): + """ActivityMetricValue unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> ActivityMetricValue: + """Test ActivityMetricValue + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `ActivityMetricValue` + """ + model = ActivityMetricValue() + if include_optional: + return ActivityMetricValue( + ) + else: + return ActivityMetricValue( + ) + """ + + def testActivityMetricValue(self): + """Test ActivityMetricValue""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main()