diff --git a/activitysmith_openapi/__init__.py b/activitysmith_openapi/__init__.py index 96ebe14..5cc7390 100644 --- a/activitysmith_openapi/__init__.py +++ b/activitysmith_openapi/__init__.py @@ -14,7 +14,7 @@ """ # noqa: E501 -__version__ = "1.1.0" +__version__ = "1.2.0" # import apis into sdk package from activitysmith_openapi.api.live_activities_api import LiveActivitiesApi @@ -72,4 +72,3 @@ from activitysmith_openapi.models.send_push_notification429_response import SendPushNotification429Response from activitysmith_openapi.models.stream_content_state import StreamContentState from activitysmith_openapi.models.widget_metric import WidgetMetric -from activitysmith_openapi.models.widget_metric_latest_value import WidgetMetricLatestValue diff --git a/activitysmith_openapi/api/metrics_api.py b/activitysmith_openapi/api/metrics_api.py index eb00eae..171733e 100644 --- a/activitysmith_openapi/api/metrics_api.py +++ b/activitysmith_openapi/api/metrics_api.py @@ -59,7 +59,7 @@ def update_metric_value( ) -> MetricValueUpdateResponse: """Update a widget metric value - Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters. + Updates the latest value for a metric displayed in ActivitySmith widgets. Create the metric in the web app first, then update its value using the key. :param key: Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed. (required) :type key: str @@ -133,7 +133,7 @@ def update_metric_value_with_http_info( ) -> ApiResponse[MetricValueUpdateResponse]: """Update a widget metric value - Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters. + Updates the latest value for a metric displayed in ActivitySmith widgets. Create the metric in the web app first, then update its value using the key. :param key: Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed. (required) :type key: str @@ -207,7 +207,7 @@ def update_metric_value_without_preload_content( ) -> RESTResponseType: """Update a widget metric value - Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters. + Updates the latest value for a metric displayed in ActivitySmith widgets. Create the metric in the web app first, then update its value using the key. :param key: Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed. (required) :type key: str diff --git a/activitysmith_openapi/api_client.py b/activitysmith_openapi/api_client.py index d1c61ba..054f3dc 100644 --- a/activitysmith_openapi/api_client.py +++ b/activitysmith_openapi/api_client.py @@ -88,7 +88,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/1.1.0/python' + self.user_agent = 'OpenAPI-Generator/1.2.0/python' self.client_side_validation = configuration.client_side_validation def __enter__(self): diff --git a/activitysmith_openapi/configuration.py b/activitysmith_openapi/configuration.py index 19f9246..ac53963 100644 --- a/activitysmith_openapi/configuration.py +++ b/activitysmith_openapi/configuration.py @@ -393,7 +393,7 @@ def to_debug_report(self): "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: 1.0.0\n"\ - "SDK Package Version: 1.1.0".\ + "SDK Package Version: 1.2.0".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self): diff --git a/activitysmith_openapi/docs/MetricValueUpdateResponse.md b/activitysmith_openapi/docs/MetricValueUpdateResponse.md index beeda07..9fe1ba8 100644 --- a/activitysmith_openapi/docs/MetricValueUpdateResponse.md +++ b/activitysmith_openapi/docs/MetricValueUpdateResponse.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**metric** | [**WidgetMetric**](WidgetMetric.md) | | +**success** | **bool** | | ## Example diff --git a/activitysmith_openapi/docs/MetricsApi.md b/activitysmith_openapi/docs/MetricsApi.md index 5cc945f..81cf084 100644 --- a/activitysmith_openapi/docs/MetricsApi.md +++ b/activitysmith_openapi/docs/MetricsApi.md @@ -12,7 +12,7 @@ Method | HTTP request | Description Update a widget metric value -Updates the latest value for a metric configured in ActivitySmith widgets. Create the metric in the web app first, then write values using its key. Numeric metric formats accept finite numbers. String metrics accept non-empty text up to 64 characters. +Updates the latest value for a metric displayed in ActivitySmith widgets. Create the metric in the web app first, then update its value using the key. ### Example diff --git a/activitysmith_openapi/docs/WidgetMetric.md b/activitysmith_openapi/docs/WidgetMetric.md index fe4a2ad..9e272a2 100644 --- a/activitysmith_openapi/docs/WidgetMetric.md +++ b/activitysmith_openapi/docs/WidgetMetric.md @@ -13,7 +13,7 @@ Name | Type | Description | Notes **unit** | **str** | Present when format is unit. | **unit_spacing** | [**MetricUnitSpacing**](MetricUnitSpacing.md) | | **format** | [**MetricFormat**](MetricFormat.md) | | -**latest_value** | [**WidgetMetricLatestValue**](WidgetMetricLatestValue.md) | | +**latest_value** | **float** | Latest metric value. Numeric formats return a number. String metrics return text. | **latest_value_at** | **datetime** | | **created_at** | **datetime** | | **updated_at** | **datetime** | | diff --git a/activitysmith_openapi/docs/WidgetMetricLatestValue.md b/activitysmith_openapi/docs/WidgetMetricLatestValue.md deleted file mode 100644 index dc06c32..0000000 --- a/activitysmith_openapi/docs/WidgetMetricLatestValue.md +++ /dev/null @@ -1,29 +0,0 @@ -# WidgetMetricLatestValue - -Latest metric value. Numeric formats return a number. String metrics return text. - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - -## Example - -```python -from activitysmith_openapi.models.widget_metric_latest_value import WidgetMetricLatestValue - -# TODO update the JSON string below -json = "{}" -# create an instance of WidgetMetricLatestValue from a JSON string -widget_metric_latest_value_instance = WidgetMetricLatestValue.from_json(json) -# print the JSON string representation of the object -print(WidgetMetricLatestValue.to_json()) - -# convert the object into a dict -widget_metric_latest_value_dict = widget_metric_latest_value_instance.to_dict() -# create an instance of WidgetMetricLatestValue from a dict -widget_metric_latest_value_from_dict = WidgetMetricLatestValue.from_dict(widget_metric_latest_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 749755a..08c4afb 100644 --- a/activitysmith_openapi/models/__init__.py +++ b/activitysmith_openapi/models/__init__.py @@ -53,4 +53,3 @@ from activitysmith_openapi.models.send_push_notification429_response import SendPushNotification429Response from activitysmith_openapi.models.stream_content_state import StreamContentState from activitysmith_openapi.models.widget_metric import WidgetMetric -from activitysmith_openapi.models.widget_metric_latest_value import WidgetMetricLatestValue diff --git a/activitysmith_openapi/models/metric_value_update_response.py b/activitysmith_openapi/models/metric_value_update_response.py index fe0b8ab..50fa5f8 100644 --- a/activitysmith_openapi/models/metric_value_update_response.py +++ b/activitysmith_openapi/models/metric_value_update_response.py @@ -17,9 +17,8 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict +from pydantic import BaseModel, ConfigDict, StrictBool from typing import Any, ClassVar, Dict, List -from activitysmith_openapi.models.widget_metric import WidgetMetric from typing import Optional, Set from typing_extensions import Self @@ -27,9 +26,9 @@ class MetricValueUpdateResponse(BaseModel): """ MetricValueUpdateResponse """ # noqa: E501 - metric: WidgetMetric + success: StrictBool additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["metric"] + __properties: ClassVar[List[str]] = ["success"] model_config = ConfigDict( populate_by_name=True, @@ -72,9 +71,6 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of metric - if self.metric: - _dict['metric'] = self.metric.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,7 +88,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ - "metric": WidgetMetric.from_dict(obj["metric"]) if obj.get("metric") is not None else None + "success": obj.get("success") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/activitysmith_openapi/models/widget_metric.py b/activitysmith_openapi/models/widget_metric.py index 2180043..3d929f1 100644 --- a/activitysmith_openapi/models/widget_metric.py +++ b/activitysmith_openapi/models/widget_metric.py @@ -18,12 +18,11 @@ import json from datetime import datetime -from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional +from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator +from typing import Any, ClassVar, Dict, List, Union from typing_extensions import Annotated from activitysmith_openapi.models.metric_format import MetricFormat from activitysmith_openapi.models.metric_unit_spacing import MetricUnitSpacing -from activitysmith_openapi.models.widget_metric_latest_value import WidgetMetricLatestValue from typing import Optional, Set from typing_extensions import Self @@ -34,12 +33,12 @@ class WidgetMetric(BaseModel): public_id: StrictStr key: Annotated[str, Field(min_length=1, strict=True, max_length=64)] label: Annotated[str, Field(min_length=1, strict=True, max_length=80)] - currency_code: Optional[Annotated[str, Field(min_length=3, strict=True, max_length=3)]] = Field(description="Present when format is currency.") - unit: Optional[Annotated[str, Field(strict=True, max_length=16)]] = Field(description="Present when format is unit.") + currency_code: Annotated[str, Field(min_length=3, strict=True, max_length=3)] = Field(description="Present when format is currency.") + unit: Annotated[str, Field(strict=True, max_length=16)] = Field(description="Present when format is unit.") unit_spacing: MetricUnitSpacing format: MetricFormat - latest_value: Optional[WidgetMetricLatestValue] - latest_value_at: Optional[datetime] + latest_value: Union[StrictFloat, StrictInt] = Field(description="Latest metric value. Numeric formats return a number. String metrics return text.") + latest_value_at: datetime created_at: datetime updated_at: datetime additional_properties: Dict[str, Any] = {} @@ -55,9 +54,6 @@ def key_validate_regular_expression(cls, value): @field_validator('currency_code') def currency_code_validate_regular_expression(cls, value): """Validates the regular expression""" - if value is None: - return value - if not re.match(r"^[A-Z]{3}$", value): raise ValueError(r"must validate the regular expression /^[A-Z]{3}$/") return value @@ -103,34 +99,11 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) - # override the default output from pydantic by calling `to_dict()` of latest_value - if self.latest_value: - _dict['latest_value'] = self.latest_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(): _dict[_key] = _value - # set to None if currency_code (nullable) is None - # and model_fields_set contains the field - if self.currency_code is None and "currency_code" in self.model_fields_set: - _dict['currency_code'] = None - - # set to None if unit (nullable) is None - # and model_fields_set contains the field - if self.unit is None and "unit" in self.model_fields_set: - _dict['unit'] = None - - # set to None if latest_value (nullable) is None - # and model_fields_set contains the field - if self.latest_value is None and "latest_value" in self.model_fields_set: - _dict['latest_value'] = None - - # set to None if latest_value_at (nullable) is None - # and model_fields_set contains the field - if self.latest_value_at is None and "latest_value_at" in self.model_fields_set: - _dict['latest_value_at'] = None - return _dict @classmethod @@ -150,7 +123,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "unit": obj.get("unit"), "unit_spacing": obj.get("unit_spacing"), "format": obj.get("format"), - "latest_value": WidgetMetricLatestValue.from_dict(obj["latest_value"]) if obj.get("latest_value") is not None else None, + "latest_value": obj.get("latest_value"), "latest_value_at": obj.get("latest_value_at"), "created_at": obj.get("created_at"), "updated_at": obj.get("updated_at") diff --git a/activitysmith_openapi/models/widget_metric_latest_value.py b/activitysmith_openapi/models/widget_metric_latest_value.py deleted file mode 100644 index f68ff6e..0000000 --- a/activitysmith_openapi/models/widget_metric_latest_value.py +++ /dev/null @@ -1,144 +0,0 @@ -# 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 -from inspect import getfullargspec -import json -import pprint -import re # noqa: F401 -from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, ValidationError, field_validator -from typing import Optional, Union -from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict -from typing_extensions import Literal, Self -from pydantic import Field - -WIDGETMETRICLATESTVALUE_ANY_OF_SCHEMAS = ["float", "str"] - -class WidgetMetricLatestValue(BaseModel): - """ - Latest metric value. Numeric formats return a number. String metrics return text. - """ - - # data type: float - anyof_schema_1_validator: Optional[Union[StrictFloat, StrictInt]] = None - # data type: str - anyof_schema_2_validator: Optional[StrictStr] = None - if TYPE_CHECKING: - actual_instance: Optional[Union[float, str]] = None - else: - actual_instance: Any = None - any_of_schemas: Set[str] = { "float", "str" } - - model_config = { - "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_anyof(cls, v): - if v is None: - return v - - instance = WidgetMetricLatestValue.model_construct() - error_messages = [] - # validate data type: float - try: - instance.anyof_schema_1_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: str - try: - instance.anyof_schema_2_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in WidgetMetricLatestValue with anyOf schemas: float, str. Details: " + ", ".join(error_messages)) - else: - return v - - @classmethod - def from_dict(cls, obj: 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() - if json_str is None: - return instance - - error_messages = [] - # deserialize data into float - try: - # validation - instance.anyof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_1_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into str - try: - # validation - instance.anyof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_2_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into WidgetMetricLatestValue with anyOf 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: - 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_metric_value_update_response.py b/activitysmith_openapi/test/test_metric_value_update_response.py index 2d4ad69..4661251 100644 --- a/activitysmith_openapi/test/test_metric_value_update_response.py +++ b/activitysmith_openapi/test/test_metric_value_update_response.py @@ -35,11 +35,11 @@ def make_instance(self, include_optional) -> MetricValueUpdateResponse: model = MetricValueUpdateResponse() if include_optional: return MetricValueUpdateResponse( - metric = { } + success = True ) else: return MetricValueUpdateResponse( - metric = { }, + success = True, ) """ diff --git a/activitysmith_openapi/test/test_widget_metric_latest_value.py b/activitysmith_openapi/test/test_widget_metric_latest_value.py deleted file mode 100644 index 2b58d6e..0000000 --- a/activitysmith_openapi/test/test_widget_metric_latest_value.py +++ /dev/null @@ -1,50 +0,0 @@ -# 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.widget_metric_latest_value import WidgetMetricLatestValue - -class TestWidgetMetricLatestValue(unittest.TestCase): - """WidgetMetricLatestValue unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> WidgetMetricLatestValue: - """Test WidgetMetricLatestValue - 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 `WidgetMetricLatestValue` - """ - model = WidgetMetricLatestValue() - if include_optional: - return WidgetMetricLatestValue( - ) - else: - return WidgetMetricLatestValue( - ) - """ - - def testWidgetMetricLatestValue(self): - """Test WidgetMetricLatestValue""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main()