Skip to content

Commit c812c28

Browse files
author
activitysmith-bot
committed
chore: regenerate SDK
1 parent d2e8b92 commit c812c28

8 files changed

Lines changed: 252 additions & 10 deletions

File tree

activitysmith_openapi/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
# import models into sdk package
3636
from activitysmith_openapi.models.activity_metric import ActivityMetric
37+
from activitysmith_openapi.models.activity_metric_value import ActivityMetricValue
3738
from activitysmith_openapi.models.alert_payload import AlertPayload
3839
from activitysmith_openapi.models.bad_request_error import BadRequestError
3940
from activitysmith_openapi.models.channel_target import ChannelTarget

activitysmith_openapi/docs/ActivityMetric.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
Name | Type | Description | Notes
77
------------ | ------------- | ------------- | -------------
88
**label** | **str** | |
9-
**value** | **float** | |
9+
**value** | [**ActivityMetricValue**](ActivityMetricValue.md) | |
1010
**unit** | **str** | | [optional]
11+
**color** | **str** | Optional per-metric accent color for metrics and stats activities. | [optional]
1112

1213
## Example
1314

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# ActivityMetricValue
2+
3+
4+
## Properties
5+
6+
Name | Type | Description | Notes
7+
------------ | ------------- | ------------- | -------------
8+
9+
## Example
10+
11+
```python
12+
from activitysmith_openapi.models.activity_metric_value import ActivityMetricValue
13+
14+
# TODO update the JSON string below
15+
json = "{}"
16+
# create an instance of ActivityMetricValue from a JSON string
17+
activity_metric_value_instance = ActivityMetricValue.from_json(json)
18+
# print the JSON string representation of the object
19+
print(ActivityMetricValue.to_json())
20+
21+
# convert the object into a dict
22+
activity_metric_value_dict = activity_metric_value_instance.to_dict()
23+
# create an instance of ActivityMetricValue from a dict
24+
activity_metric_value_from_dict = ActivityMetricValue.from_dict(activity_metric_value_dict)
25+
```
26+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
27+
28+

activitysmith_openapi/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
# import models into model package
1717
from activitysmith_openapi.models.activity_metric import ActivityMetric
18+
from activitysmith_openapi.models.activity_metric_value import ActivityMetricValue
1819
from activitysmith_openapi.models.alert_payload import AlertPayload
1920
from activitysmith_openapi.models.bad_request_error import BadRequestError
2021
from activitysmith_openapi.models.channel_target import ChannelTarget

activitysmith_openapi/models/activity_metric.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
import re # noqa: F401
1818
import json
1919

20-
from pydantic import BaseModel, ConfigDict, Field, StrictStr
21-
from typing import Any, ClassVar, Dict, List, Optional, Union
20+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
21+
from typing import Any, ClassVar, Dict, List, Optional
2222
from typing_extensions import Annotated
23+
from activitysmith_openapi.models.activity_metric_value import ActivityMetricValue
2324
from typing import Optional, Set
2425
from typing_extensions import Self
2526

@@ -28,10 +29,21 @@ class ActivityMetric(BaseModel):
2829
ActivityMetric
2930
""" # noqa: E501
3031
label: Annotated[str, Field(min_length=1, strict=True)]
31-
value: Union[Annotated[float, Field(le=100, strict=True, ge=0)], Annotated[int, Field(le=100, strict=True, ge=0)]]
32+
value: ActivityMetricValue
3233
unit: Optional[StrictStr] = None
34+
color: Optional[StrictStr] = Field(default=None, description="Optional per-metric accent color for metrics and stats activities.")
3335
additional_properties: Dict[str, Any] = {}
34-
__properties: ClassVar[List[str]] = ["label", "value", "unit"]
36+
__properties: ClassVar[List[str]] = ["label", "value", "unit", "color"]
37+
38+
@field_validator('color')
39+
def color_validate_enum(cls, value):
40+
"""Validates the enum"""
41+
if value is None:
42+
return value
43+
44+
if value not in set(['lime', 'green', 'cyan', 'blue', 'purple', 'magenta', 'red', 'orange', 'yellow']):
45+
raise ValueError("must be one of enum values ('lime', 'green', 'cyan', 'blue', 'purple', 'magenta', 'red', 'orange', 'yellow')")
46+
return value
3547

3648
model_config = ConfigDict(
3749
populate_by_name=True,
@@ -74,6 +86,9 @@ def to_dict(self) -> Dict[str, Any]:
7486
exclude=excluded_fields,
7587
exclude_none=True,
7688
)
89+
# override the default output from pydantic by calling `to_dict()` of value
90+
if self.value:
91+
_dict['value'] = self.value.to_dict()
7792
# puts key-value pairs in additional_properties in the top level
7893
if self.additional_properties is not None:
7994
for _key, _value in self.additional_properties.items():
@@ -92,8 +107,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
92107

93108
_obj = cls.model_validate({
94109
"label": obj.get("label"),
95-
"value": obj.get("value"),
96-
"unit": obj.get("unit")
110+
"value": ActivityMetricValue.from_dict(obj["value"]) if obj.get("value") is not None else None,
111+
"unit": obj.get("unit"),
112+
"color": obj.get("color")
97113
})
98114
# store additional fields in additional_properties
99115
for _key in obj.keys():
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# coding: utf-8
2+
3+
"""
4+
ActivitySmith API
5+
6+
Send push notifications and Live Activities to your own devices via a single API key.
7+
8+
The version of the OpenAPI document: 1.0.0
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
""" # noqa: E501
13+
14+
15+
from __future__ import annotations
16+
import json
17+
import pprint
18+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
19+
from typing import Any, List, Optional, Union
20+
from typing_extensions import Annotated
21+
from pydantic import StrictStr, Field
22+
from typing import Union, List, Set, Optional, Dict
23+
from typing_extensions import Literal, Self
24+
25+
ACTIVITYMETRICVALUE_ONE_OF_SCHEMAS = ["float", "str"]
26+
27+
class ActivityMetricValue(BaseModel):
28+
"""
29+
ActivityMetricValue
30+
"""
31+
# data type: float
32+
oneof_schema_1_validator: Optional[Union[Annotated[float, Field(strict=True, ge=0)], Annotated[int, Field(strict=True, ge=0)]]] = None
33+
# data type: str
34+
oneof_schema_2_validator: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=64)]] = None
35+
actual_instance: Optional[Union[float, str]] = None
36+
one_of_schemas: Set[str] = { "float", "str" }
37+
38+
model_config = ConfigDict(
39+
validate_assignment=True,
40+
protected_namespaces=(),
41+
)
42+
43+
44+
def __init__(self, *args, **kwargs) -> None:
45+
if args:
46+
if len(args) > 1:
47+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
48+
if kwargs:
49+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
50+
super().__init__(actual_instance=args[0])
51+
else:
52+
super().__init__(**kwargs)
53+
54+
@field_validator('actual_instance')
55+
def actual_instance_must_validate_oneof(cls, v):
56+
instance = ActivityMetricValue.model_construct()
57+
error_messages = []
58+
match = 0
59+
# validate data type: float
60+
try:
61+
instance.oneof_schema_1_validator = v
62+
match += 1
63+
except (ValidationError, ValueError) as e:
64+
error_messages.append(str(e))
65+
# validate data type: str
66+
try:
67+
instance.oneof_schema_2_validator = v
68+
match += 1
69+
except (ValidationError, ValueError) as e:
70+
error_messages.append(str(e))
71+
if match > 1:
72+
# more than 1 match
73+
raise ValueError("Multiple matches found when setting `actual_instance` in ActivityMetricValue with oneOf schemas: float, str. Details: " + ", ".join(error_messages))
74+
elif match == 0:
75+
# no match
76+
raise ValueError("No match found when setting `actual_instance` in ActivityMetricValue with oneOf schemas: float, str. Details: " + ", ".join(error_messages))
77+
else:
78+
return v
79+
80+
@classmethod
81+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
82+
return cls.from_json(json.dumps(obj))
83+
84+
@classmethod
85+
def from_json(cls, json_str: str) -> Self:
86+
"""Returns the object represented by the json string"""
87+
instance = cls.model_construct()
88+
error_messages = []
89+
match = 0
90+
91+
# deserialize data into float
92+
try:
93+
# validation
94+
instance.oneof_schema_1_validator = json.loads(json_str)
95+
# assign value to actual_instance
96+
instance.actual_instance = instance.oneof_schema_1_validator
97+
match += 1
98+
except (ValidationError, ValueError) as e:
99+
error_messages.append(str(e))
100+
# deserialize data into str
101+
try:
102+
# validation
103+
instance.oneof_schema_2_validator = json.loads(json_str)
104+
# assign value to actual_instance
105+
instance.actual_instance = instance.oneof_schema_2_validator
106+
match += 1
107+
except (ValidationError, ValueError) as e:
108+
error_messages.append(str(e))
109+
110+
if match > 1:
111+
# more than 1 match
112+
raise ValueError("Multiple matches found when deserializing the JSON string into ActivityMetricValue with oneOf schemas: float, str. Details: " + ", ".join(error_messages))
113+
elif match == 0:
114+
# no match
115+
raise ValueError("No match found when deserializing the JSON string into ActivityMetricValue with oneOf schemas: float, str. Details: " + ", ".join(error_messages))
116+
else:
117+
return instance
118+
119+
def to_json(self) -> str:
120+
"""Returns the JSON representation of the actual instance"""
121+
if self.actual_instance is None:
122+
return "null"
123+
124+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
125+
return self.actual_instance.to_json()
126+
else:
127+
return json.dumps(self.actual_instance)
128+
129+
def to_dict(self) -> Optional[Union[Dict[str, Any], float, str]]:
130+
"""Returns the dict representation of the actual instance"""
131+
if self.actual_instance is None:
132+
return None
133+
134+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
135+
return self.actual_instance.to_dict()
136+
else:
137+
# primitive type
138+
return self.actual_instance
139+
140+
def to_str(self) -> str:
141+
"""Returns the string representation of the actual instance"""
142+
return pprint.pformat(self.model_dump())
143+
144+

activitysmith_openapi/test/test_activity_metric.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ def make_instance(self, include_optional) -> ActivityMetric:
3636
if include_optional:
3737
return ActivityMetric(
3838
label = '0',
39-
value = 0,
40-
unit = ''
39+
value = None,
40+
unit = '',
41+
color = 'lime'
4142
)
4243
else:
4344
return ActivityMetric(
4445
label = '0',
45-
value = 0,
46+
value = None,
4647
)
4748
"""
4849

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# coding: utf-8
2+
3+
"""
4+
ActivitySmith API
5+
6+
Send push notifications and Live Activities to your own devices via a single API key.
7+
8+
The version of the OpenAPI document: 1.0.0
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
""" # noqa: E501
13+
14+
15+
import unittest
16+
17+
from activitysmith_openapi.models.activity_metric_value import ActivityMetricValue
18+
19+
class TestActivityMetricValue(unittest.TestCase):
20+
"""ActivityMetricValue unit test stubs"""
21+
22+
def setUp(self):
23+
pass
24+
25+
def tearDown(self):
26+
pass
27+
28+
def make_instance(self, include_optional) -> ActivityMetricValue:
29+
"""Test ActivityMetricValue
30+
include_optional is a boolean, when False only required
31+
params are included, when True both required and
32+
optional params are included """
33+
# uncomment below to create an instance of `ActivityMetricValue`
34+
"""
35+
model = ActivityMetricValue()
36+
if include_optional:
37+
return ActivityMetricValue(
38+
)
39+
else:
40+
return ActivityMetricValue(
41+
)
42+
"""
43+
44+
def testActivityMetricValue(self):
45+
"""Test ActivityMetricValue"""
46+
# inst_req_only = self.make_instance(include_optional=False)
47+
# inst_req_and_optional = self.make_instance(include_optional=True)
48+
49+
if __name__ == '__main__':
50+
unittest.main()

0 commit comments

Comments
 (0)