diff --git a/activitysmith_openapi/__init__.py b/activitysmith_openapi/__init__.py index 162b32a..96ebe14 100644 --- a/activitysmith_openapi/__init__.py +++ b/activitysmith_openapi/__init__.py @@ -14,10 +14,11 @@ """ # noqa: E501 -__version__ = "1.0.0" +__version__ = "1.1.0" # import apis into sdk package from activitysmith_openapi.api.live_activities_api import LiveActivitiesApi +from activitysmith_openapi.api.metrics_api import MetricsApi from activitysmith_openapi.api.push_notifications_api import PushNotificationsApi # import ApiClient @@ -54,6 +55,12 @@ from activitysmith_openapi.models.live_activity_update_request import LiveActivityUpdateRequest from activitysmith_openapi.models.live_activity_update_response import LiveActivityUpdateResponse from activitysmith_openapi.models.live_activity_webhook_method import LiveActivityWebhookMethod +from activitysmith_openapi.models.metric_error import MetricError +from activitysmith_openapi.models.metric_format import MetricFormat +from activitysmith_openapi.models.metric_unit_spacing import MetricUnitSpacing +from activitysmith_openapi.models.metric_value_update_request import MetricValueUpdateRequest +from activitysmith_openapi.models.metric_value_update_request_value import MetricValueUpdateRequestValue +from activitysmith_openapi.models.metric_value_update_response import MetricValueUpdateResponse from activitysmith_openapi.models.no_recipients_error import NoRecipientsError from activitysmith_openapi.models.not_found_error import NotFoundError from activitysmith_openapi.models.push_notification_action import PushNotificationAction @@ -64,3 +71,5 @@ from activitysmith_openapi.models.rate_limit_error import RateLimitError 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/__init__.py b/activitysmith_openapi/api/__init__.py index 832ae15..42c9218 100644 --- a/activitysmith_openapi/api/__init__.py +++ b/activitysmith_openapi/api/__init__.py @@ -2,5 +2,6 @@ # import apis into api package from activitysmith_openapi.api.live_activities_api import LiveActivitiesApi +from activitysmith_openapi.api.metrics_api import MetricsApi from activitysmith_openapi.api.push_notifications_api import PushNotificationsApi diff --git a/activitysmith_openapi/api/live_activities_api.py b/activitysmith_openapi/api/live_activities_api.py index ac2c8a5..d9d6b48 100644 --- a/activitysmith_openapi/api/live_activities_api.py +++ b/activitysmith_openapi/api/live_activities_api.py @@ -67,7 +67,7 @@ def end_live_activity( ) -> LiveActivityEndResponse: """End a Live Activity - Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. + Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. :param live_activity_end_request: (required) :type live_activity_end_request: LiveActivityEndRequest @@ -136,7 +136,7 @@ def end_live_activity_with_http_info( ) -> ApiResponse[LiveActivityEndResponse]: """End a Live Activity - Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. + Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. :param live_activity_end_request: (required) :type live_activity_end_request: LiveActivityEndRequest @@ -205,7 +205,7 @@ def end_live_activity_without_preload_content( ) -> RESTResponseType: """End a Live Activity - Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. + Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. :param live_activity_end_request: (required) :type live_activity_end_request: LiveActivityEndRequest @@ -940,7 +940,7 @@ def start_live_activity( ) -> LiveActivityStartResponse: """Start a Live Activity - Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. + Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. :param live_activity_start_request: (required) :type live_activity_start_request: LiveActivityStartRequest @@ -979,7 +979,7 @@ def start_live_activity( '400': "BadRequestError", '403': "ForbiddenError", '404': "NoRecipientsError", - '429': "RateLimitError", + '429': "SendPushNotification429Response", } response_data = self.api_client.call_api( *_param, @@ -1011,7 +1011,7 @@ def start_live_activity_with_http_info( ) -> ApiResponse[LiveActivityStartResponse]: """Start a Live Activity - Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. + Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. :param live_activity_start_request: (required) :type live_activity_start_request: LiveActivityStartRequest @@ -1050,7 +1050,7 @@ def start_live_activity_with_http_info( '400': "BadRequestError", '403': "ForbiddenError", '404': "NoRecipientsError", - '429': "RateLimitError", + '429': "SendPushNotification429Response", } response_data = self.api_client.call_api( *_param, @@ -1082,7 +1082,7 @@ def start_live_activity_without_preload_content( ) -> RESTResponseType: """Start a Live Activity - Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. + Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. :param live_activity_start_request: (required) :type live_activity_start_request: LiveActivityStartRequest @@ -1121,7 +1121,7 @@ def start_live_activity_without_preload_content( '400': "BadRequestError", '403': "ForbiddenError", '404': "NoRecipientsError", - '429': "RateLimitError", + '429': "SendPushNotification429Response", } response_data = self.api_client.call_api( *_param, @@ -1224,7 +1224,7 @@ def update_live_activity( ) -> LiveActivityUpdateResponse: """Update a Live Activity - Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. + Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. :param live_activity_update_request: (required) :type live_activity_update_request: LiveActivityUpdateRequest @@ -1293,7 +1293,7 @@ def update_live_activity_with_http_info( ) -> ApiResponse[LiveActivityUpdateResponse]: """Update a Live Activity - Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. + Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. :param live_activity_update_request: (required) :type live_activity_update_request: LiveActivityUpdateRequest @@ -1362,7 +1362,7 @@ def update_live_activity_without_preload_content( ) -> RESTResponseType: """Update a Live Activity - Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. + Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. :param live_activity_update_request: (required) :type live_activity_update_request: LiveActivityUpdateRequest diff --git a/activitysmith_openapi/api/metrics_api.py b/activitysmith_openapi/api/metrics_api.py new file mode 100644 index 0000000..eb00eae --- /dev/null +++ b/activitysmith_openapi/api/metrics_api.py @@ -0,0 +1,335 @@ +# 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 warnings +from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt +from typing import Any, Dict, List, Optional, Tuple, Union +from typing_extensions import Annotated + +from pydantic import Field, field_validator +from typing_extensions import Annotated +from activitysmith_openapi.models.metric_value_update_request import MetricValueUpdateRequest +from activitysmith_openapi.models.metric_value_update_response import MetricValueUpdateResponse + +from activitysmith_openapi.api_client import ApiClient, RequestSerialized +from activitysmith_openapi.api_response import ApiResponse +from activitysmith_openapi.rest import RESTResponseType + + +class MetricsApi: + """NOTE: This class is auto generated by OpenAPI Generator + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + def __init__(self, api_client=None) -> None: + if api_client is None: + api_client = ApiClient.get_default() + self.api_client = api_client + + + @validate_call + def update_metric_value( + self, + key: Annotated[str, Field(min_length=1, strict=True, max_length=64, description="Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed.")], + metric_value_update_request: MetricValueUpdateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> 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. + + :param key: Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed. (required) + :type key: str + :param metric_value_update_request: (required) + :type metric_value_update_request: MetricValueUpdateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._update_metric_value_serialize( + key=key, + metric_value_update_request=metric_value_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "MetricValueUpdateResponse", + '400': "MetricError", + '404': "MetricError", + '429': "RateLimitError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def update_metric_value_with_http_info( + self, + key: Annotated[str, Field(min_length=1, strict=True, max_length=64, description="Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed.")], + metric_value_update_request: MetricValueUpdateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> 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. + + :param key: Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed. (required) + :type key: str + :param metric_value_update_request: (required) + :type metric_value_update_request: MetricValueUpdateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._update_metric_value_serialize( + key=key, + metric_value_update_request=metric_value_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "MetricValueUpdateResponse", + '400': "MetricError", + '404': "MetricError", + '429': "RateLimitError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def update_metric_value_without_preload_content( + self, + key: Annotated[str, Field(min_length=1, strict=True, max_length=64, description="Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed.")], + metric_value_update_request: MetricValueUpdateRequest, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> 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. + + :param key: Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed. (required) + :type key: str + :param metric_value_update_request: (required) + :type metric_value_update_request: MetricValueUpdateRequest + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._update_metric_value_serialize( + key=key, + metric_value_update_request=metric_value_update_request, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "MetricValueUpdateResponse", + '400': "MetricError", + '404': "MetricError", + '429': "RateLimitError", + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _update_metric_value_serialize( + self, + key, + metric_value_update_request, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> RequestSerialized: + + _host = None + + _collection_formats: Dict[str, str] = { + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, Union[str, bytes]] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if key is not None: + _path_params['key'] = key + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if metric_value_update_request is not None: + _body_params = metric_value_update_request + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'application/json' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + 'apiKeyAuth' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/metrics/{key}/value', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + diff --git a/activitysmith_openapi/api_client.py b/activitysmith_openapi/api_client.py index b6da1f5..d1c61ba 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.0.0/python' + self.user_agent = 'OpenAPI-Generator/1.1.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 dadedf9..19f9246 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.0.0".\ + "SDK Package Version: 1.1.0".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self): diff --git a/activitysmith_openapi/docs/ContentStateEnd.md b/activitysmith_openapi/docs/ContentStateEnd.md index 43c1475..09917e5 100644 --- a/activitysmith_openapi/docs/ContentStateEnd.md +++ b/activitysmith_openapi/docs/ContentStateEnd.md @@ -1,6 +1,6 @@ # ContentStateEnd -End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Legacy counter/timer/countdown types also use current_step and number_of_steps. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start. +End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start. ## Properties diff --git a/activitysmith_openapi/docs/ContentStateStart.md b/activitysmith_openapi/docs/ContentStateStart.md index ea42d5a..bbc04a1 100644 --- a/activitysmith_openapi/docs/ContentStateStart.md +++ b/activitysmith_openapi/docs/ContentStateStart.md @@ -1,6 +1,6 @@ # ContentStateStart -Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Legacy counter/timer/countdown types also use current_step and number_of_steps. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls. +Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls. ## Properties diff --git a/activitysmith_openapi/docs/ContentStateUpdate.md b/activitysmith_openapi/docs/ContentStateUpdate.md index 47a0f16..fac4197 100644 --- a/activitysmith_openapi/docs/ContentStateUpdate.md +++ b/activitysmith_openapi/docs/ContentStateUpdate.md @@ -1,6 +1,6 @@ # ContentStateUpdate -Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Legacy counter/timer/countdown types also use current_step and number_of_steps. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates. +Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates. ## Properties diff --git a/activitysmith_openapi/docs/LiveActivitiesApi.md b/activitysmith_openapi/docs/LiveActivitiesApi.md index f319c95..baea488 100644 --- a/activitysmith_openapi/docs/LiveActivitiesApi.md +++ b/activitysmith_openapi/docs/LiveActivitiesApi.md @@ -16,7 +16,7 @@ Method | HTTP request | Description End a Live Activity -Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. +Ends a Live Activity and archives its lifecycle. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can send the latest number_of_steps here if the workflow changed after start. ### Example @@ -49,7 +49,7 @@ configuration = activitysmith_openapi.Configuration( with activitysmith_openapi.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = activitysmith_openapi.LiveActivitiesApi(api_client) - live_activity_end_request = {"activity_id":"pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW","content_state":{"title":"Nightly database backup","subtitle":"verify restore","number_of_steps":4,"current_step":4,"auto_dismiss_minutes":2}} # LiveActivityEndRequest | + live_activity_end_request = {"activity_id":"pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW","content_state":{"title":"Nightly database backup","subtitle":"verify restore","number_of_steps":3,"current_step":3,"auto_dismiss_minutes":2}} # LiveActivityEndRequest | try: # End a Live Activity @@ -266,7 +266,7 @@ Name | Type | Description | Notes Start a Live Activity -Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. +Starts a Live Activity on devices matched by API key scope and optional target channels. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, number_of_steps can be changed later during update or end calls if the workflow changes. ### Example @@ -349,7 +349,7 @@ Name | Type | Description | Notes Update a Live Activity -Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. +Updates an existing Live Activity. If the per-activity token is not registered yet, the update is queued. Supports segmented_progress, progress, and metrics activity types. For segmented_progress activities, you can increase or decrease number_of_steps here as the workflow changes. ### Example @@ -382,7 +382,7 @@ configuration = activitysmith_openapi.Configuration( with activitysmith_openapi.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = activitysmith_openapi.LiveActivitiesApi(api_client) - live_activity_update_request = {"activity_id":"pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW","content_state":{"title":"Nightly database backup","subtitle":"upload archive","number_of_steps":4,"current_step":2}} # LiveActivityUpdateRequest | + live_activity_update_request = {"activity_id":"pLAr-Hnq9ZFW4sxlk43Lhbuok4GLh7UW","content_state":{"title":"Nightly database backup","subtitle":"upload archive","number_of_steps":3,"current_step":2}} # LiveActivityUpdateRequest | try: # Update a Live Activity diff --git a/activitysmith_openapi/docs/MetricError.md b/activitysmith_openapi/docs/MetricError.md new file mode 100644 index 0000000..581f5ac --- /dev/null +++ b/activitysmith_openapi/docs/MetricError.md @@ -0,0 +1,30 @@ +# MetricError + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**error** | **str** | | +**message** | **str** | | [optional] + +## Example + +```python +from activitysmith_openapi.models.metric_error import MetricError + +# TODO update the JSON string below +json = "{}" +# create an instance of MetricError from a JSON string +metric_error_instance = MetricError.from_json(json) +# print the JSON string representation of the object +print(MetricError.to_json()) + +# convert the object into a dict +metric_error_dict = metric_error_instance.to_dict() +# create an instance of MetricError from a dict +metric_error_from_dict = MetricError.from_dict(metric_error_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/docs/MetricFormat.md b/activitysmith_openapi/docs/MetricFormat.md new file mode 100644 index 0000000..e44178e --- /dev/null +++ b/activitysmith_openapi/docs/MetricFormat.md @@ -0,0 +1,18 @@ +# MetricFormat + + +## Enum + +* `NUMBER` (value: `'number'`) + +* `CURRENCY` (value: `'currency'`) + +* `PERCENT` (value: `'percent'`) + +* `UNIT` (value: `'unit'`) + +* `STRING` (value: `'string'`) + +[[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/docs/MetricUnitSpacing.md b/activitysmith_openapi/docs/MetricUnitSpacing.md new file mode 100644 index 0000000..f208976 --- /dev/null +++ b/activitysmith_openapi/docs/MetricUnitSpacing.md @@ -0,0 +1,12 @@ +# MetricUnitSpacing + + +## Enum + +* `NONE` (value: `'none'`) + +* `SPACE` (value: `'space'`) + +[[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/docs/MetricValueUpdateRequest.md b/activitysmith_openapi/docs/MetricValueUpdateRequest.md new file mode 100644 index 0000000..70290f1 --- /dev/null +++ b/activitysmith_openapi/docs/MetricValueUpdateRequest.md @@ -0,0 +1,31 @@ +# MetricValueUpdateRequest + +Latest metric value to display in widgets. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**value** | [**MetricValueUpdateRequestValue**](MetricValueUpdateRequestValue.md) | | +**timestamp** | **datetime** | Optional ISO timestamp for when the metric value was measured. Defaults to the server receive time. | [optional] + +## Example + +```python +from activitysmith_openapi.models.metric_value_update_request import MetricValueUpdateRequest + +# TODO update the JSON string below +json = "{}" +# create an instance of MetricValueUpdateRequest from a JSON string +metric_value_update_request_instance = MetricValueUpdateRequest.from_json(json) +# print the JSON string representation of the object +print(MetricValueUpdateRequest.to_json()) + +# convert the object into a dict +metric_value_update_request_dict = metric_value_update_request_instance.to_dict() +# create an instance of MetricValueUpdateRequest from a dict +metric_value_update_request_from_dict = MetricValueUpdateRequest.from_dict(metric_value_update_request_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/docs/MetricValueUpdateRequestValue.md b/activitysmith_openapi/docs/MetricValueUpdateRequestValue.md new file mode 100644 index 0000000..74d9567 --- /dev/null +++ b/activitysmith_openapi/docs/MetricValueUpdateRequestValue.md @@ -0,0 +1,28 @@ +# MetricValueUpdateRequestValue + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Example + +```python +from activitysmith_openapi.models.metric_value_update_request_value import MetricValueUpdateRequestValue + +# TODO update the JSON string below +json = "{}" +# create an instance of MetricValueUpdateRequestValue from a JSON string +metric_value_update_request_value_instance = MetricValueUpdateRequestValue.from_json(json) +# print the JSON string representation of the object +print(MetricValueUpdateRequestValue.to_json()) + +# convert the object into a dict +metric_value_update_request_value_dict = metric_value_update_request_value_instance.to_dict() +# create an instance of MetricValueUpdateRequestValue from a dict +metric_value_update_request_value_from_dict = MetricValueUpdateRequestValue.from_dict(metric_value_update_request_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/docs/MetricValueUpdateResponse.md b/activitysmith_openapi/docs/MetricValueUpdateResponse.md new file mode 100644 index 0000000..beeda07 --- /dev/null +++ b/activitysmith_openapi/docs/MetricValueUpdateResponse.md @@ -0,0 +1,29 @@ +# MetricValueUpdateResponse + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**metric** | [**WidgetMetric**](WidgetMetric.md) | | + +## Example + +```python +from activitysmith_openapi.models.metric_value_update_response import MetricValueUpdateResponse + +# TODO update the JSON string below +json = "{}" +# create an instance of MetricValueUpdateResponse from a JSON string +metric_value_update_response_instance = MetricValueUpdateResponse.from_json(json) +# print the JSON string representation of the object +print(MetricValueUpdateResponse.to_json()) + +# convert the object into a dict +metric_value_update_response_dict = metric_value_update_response_instance.to_dict() +# create an instance of MetricValueUpdateResponse from a dict +metric_value_update_response_from_dict = MetricValueUpdateResponse.from_dict(metric_value_update_response_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/docs/MetricsApi.md b/activitysmith_openapi/docs/MetricsApi.md new file mode 100644 index 0000000..5cc945f --- /dev/null +++ b/activitysmith_openapi/docs/MetricsApi.md @@ -0,0 +1,93 @@ +# activitysmith_openapi.MetricsApi + +All URIs are relative to *https://activitysmith.com/api* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**update_metric_value**](MetricsApi.md#update_metric_value) | **POST** /metrics/{key}/value | Update a widget metric value + + +# **update_metric_value** +> MetricValueUpdateResponse update_metric_value(key, metric_value_update_request) + +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. + +### Example + +* Bearer (API Key) Authentication (apiKeyAuth): + +```python +import activitysmith_openapi +from activitysmith_openapi.models.metric_value_update_request import MetricValueUpdateRequest +from activitysmith_openapi.models.metric_value_update_response import MetricValueUpdateResponse +from activitysmith_openapi.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://activitysmith.com/api +# See configuration.py for a list of all supported configuration parameters. +configuration = activitysmith_openapi.Configuration( + host = "https://activitysmith.com/api" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure Bearer authorization (API Key): apiKeyAuth +configuration = activitysmith_openapi.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with activitysmith_openapi.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = activitysmith_openapi.MetricsApi(api_client) + key = 'key_example' # str | Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed. + metric_value_update_request = {"value":42} # MetricValueUpdateRequest | + + try: + # Update a widget metric value + api_response = api_instance.update_metric_value(key, metric_value_update_request) + print("The response of MetricsApi->update_metric_value:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling MetricsApi->update_metric_value: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **key** | **str**| Metric key configured in the web app. Lowercase letters, numbers, dots, underscores, and dashes are allowed. | + **metric_value_update_request** | [**MetricValueUpdateRequest**](MetricValueUpdateRequest.md)| | + +### Return type + +[**MetricValueUpdateResponse**](MetricValueUpdateResponse.md) + +### Authorization + +[apiKeyAuth](../README.md#apiKeyAuth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Metric value updated | - | +**400** | Bad request (invalid key, value, or timestamp) | - | +**404** | Metric not found | - | +**429** | Rate limit exceeded | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/activitysmith_openapi/docs/StreamContentState.md b/activitysmith_openapi/docs/StreamContentState.md index 6d855bb..ec02902 100644 --- a/activitysmith_openapi/docs/StreamContentState.md +++ b/activitysmith_openapi/docs/StreamContentState.md @@ -1,6 +1,6 @@ # StreamContentState -Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based types. +Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress, and metrics types. ## Properties @@ -8,8 +8,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **title** | **str** | | **subtitle** | **str** | | [optional] -**number_of_steps** | **int** | Use for segmented_progress, counter, timer, and countdown. | [optional] -**current_step** | **int** | Use for segmented_progress, counter, timer, and countdown. | [optional] +**number_of_steps** | **int** | Use for segmented_progress. | [optional] +**current_step** | **int** | Use for segmented_progress. | [optional] **percentage** | **float** | Use for progress. Takes precedence over value/upper_limit if both are provided. | [optional] **value** | **float** | Current progress value. Use with upper_limit for progress. | [optional] **upper_limit** | **float** | Maximum progress value. Use with value for progress. | [optional] diff --git a/activitysmith_openapi/docs/WidgetMetric.md b/activitysmith_openapi/docs/WidgetMetric.md new file mode 100644 index 0000000..fe4a2ad --- /dev/null +++ b/activitysmith_openapi/docs/WidgetMetric.md @@ -0,0 +1,40 @@ +# WidgetMetric + +A metric configured for ActivitySmith widgets. + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**public_id** | **str** | | +**key** | **str** | | +**label** | **str** | | +**currency_code** | **str** | Present when format is currency. | +**unit** | **str** | Present when format is unit. | +**unit_spacing** | [**MetricUnitSpacing**](MetricUnitSpacing.md) | | +**format** | [**MetricFormat**](MetricFormat.md) | | +**latest_value** | [**WidgetMetricLatestValue**](WidgetMetricLatestValue.md) | | +**latest_value_at** | **datetime** | | +**created_at** | **datetime** | | +**updated_at** | **datetime** | | + +## Example + +```python +from activitysmith_openapi.models.widget_metric import WidgetMetric + +# TODO update the JSON string below +json = "{}" +# create an instance of WidgetMetric from a JSON string +widget_metric_instance = WidgetMetric.from_json(json) +# print the JSON string representation of the object +print(WidgetMetric.to_json()) + +# convert the object into a dict +widget_metric_dict = widget_metric_instance.to_dict() +# create an instance of WidgetMetric from a dict +widget_metric_from_dict = WidgetMetric.from_dict(widget_metric_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/docs/WidgetMetricLatestValue.md b/activitysmith_openapi/docs/WidgetMetricLatestValue.md new file mode 100644 index 0000000..dc06c32 --- /dev/null +++ b/activitysmith_openapi/docs/WidgetMetricLatestValue.md @@ -0,0 +1,29 @@ +# 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 3817266..749755a 100644 --- a/activitysmith_openapi/models/__init__.py +++ b/activitysmith_openapi/models/__init__.py @@ -36,6 +36,12 @@ from activitysmith_openapi.models.live_activity_update_request import LiveActivityUpdateRequest from activitysmith_openapi.models.live_activity_update_response import LiveActivityUpdateResponse from activitysmith_openapi.models.live_activity_webhook_method import LiveActivityWebhookMethod +from activitysmith_openapi.models.metric_error import MetricError +from activitysmith_openapi.models.metric_format import MetricFormat +from activitysmith_openapi.models.metric_unit_spacing import MetricUnitSpacing +from activitysmith_openapi.models.metric_value_update_request import MetricValueUpdateRequest +from activitysmith_openapi.models.metric_value_update_request_value import MetricValueUpdateRequestValue +from activitysmith_openapi.models.metric_value_update_response import MetricValueUpdateResponse from activitysmith_openapi.models.no_recipients_error import NoRecipientsError from activitysmith_openapi.models.not_found_error import NotFoundError from activitysmith_openapi.models.push_notification_action import PushNotificationAction @@ -46,3 +52,5 @@ from activitysmith_openapi.models.rate_limit_error import RateLimitError 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/content_state_end.py b/activitysmith_openapi/models/content_state_end.py index a2e4267..7c17aa7 100644 --- a/activitysmith_openapi/models/content_state_end.py +++ b/activitysmith_openapi/models/content_state_end.py @@ -26,7 +26,7 @@ class ContentStateEnd(BaseModel): """ - End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Legacy counter/timer/countdown types also use current_step and number_of_steps. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start. + End payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Type is optional when ending an existing activity. You can send an updated number_of_steps here if the workflow changed after start. """ # noqa: E501 title: StrictStr subtitle: Optional[StrictStr] = None @@ -50,8 +50,8 @@ def type_validate_enum(cls, value): if value is None: return value - if value not in set(['segmented_progress', 'progress', 'metrics', 'counter', 'timer', 'countdown']): - raise ValueError("must be one of enum values ('segmented_progress', 'progress', 'metrics', 'counter', 'timer', 'countdown')") + if value not in set(['segmented_progress', 'progress', 'metrics']): + raise ValueError("must be one of enum values ('segmented_progress', 'progress', 'metrics')") return value @field_validator('color') diff --git a/activitysmith_openapi/models/content_state_start.py b/activitysmith_openapi/models/content_state_start.py index f53be1e..eabb4b6 100644 --- a/activitysmith_openapi/models/content_state_start.py +++ b/activitysmith_openapi/models/content_state_start.py @@ -26,7 +26,7 @@ class ContentStateStart(BaseModel): """ - Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Legacy counter/timer/countdown types also use current_step and number_of_steps. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls. + Start payload requires title and type. For segmented_progress include number_of_steps and current_step. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. For segmented_progress, number_of_steps is not locked and can be changed in later update or end calls. """ # noqa: E501 title: StrictStr subtitle: Optional[StrictStr] = None @@ -46,8 +46,8 @@ class ContentStateStart(BaseModel): @field_validator('type') def type_validate_enum(cls, value): """Validates the enum""" - if value not in set(['segmented_progress', 'progress', 'metrics', 'counter', 'timer', 'countdown']): - raise ValueError("must be one of enum values ('segmented_progress', 'progress', 'metrics', 'counter', 'timer', 'countdown')") + if value not in set(['segmented_progress', 'progress', 'metrics']): + raise ValueError("must be one of enum values ('segmented_progress', 'progress', 'metrics')") return value @field_validator('color') diff --git a/activitysmith_openapi/models/content_state_update.py b/activitysmith_openapi/models/content_state_update.py index c98156e..bb77a5c 100644 --- a/activitysmith_openapi/models/content_state_update.py +++ b/activitysmith_openapi/models/content_state_update.py @@ -26,7 +26,7 @@ class ContentStateUpdate(BaseModel): """ - Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Legacy counter/timer/countdown types also use current_step and number_of_steps. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates. + Update payload requires title. For segmented_progress include current_step and optionally number_of_steps. For progress include percentage or value with upper_limit. For metrics include a non-empty metrics array. Type is optional when updating an existing activity. You can increase or decrease number_of_steps during updates. """ # noqa: E501 title: StrictStr subtitle: Optional[StrictStr] = None @@ -49,8 +49,8 @@ def type_validate_enum(cls, value): if value is None: return value - if value not in set(['segmented_progress', 'progress', 'metrics', 'counter', 'timer', 'countdown']): - raise ValueError("must be one of enum values ('segmented_progress', 'progress', 'metrics', 'counter', 'timer', 'countdown')") + if value not in set(['segmented_progress', 'progress', 'metrics']): + raise ValueError("must be one of enum values ('segmented_progress', 'progress', 'metrics')") return value @field_validator('color') diff --git a/activitysmith_openapi/models/metric_error.py b/activitysmith_openapi/models/metric_error.py new file mode 100644 index 0000000..a9bc675 --- /dev/null +++ b/activitysmith_openapi/models/metric_error.py @@ -0,0 +1,102 @@ +# 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 pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class MetricError(BaseModel): + """ + MetricError + """ # noqa: E501 + error: StrictStr + message: Optional[StrictStr] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["error", "message"] + + 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 MetricError 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. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # 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 + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of MetricError from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "error": obj.get("error"), + "message": obj.get("message") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/activitysmith_openapi/models/metric_format.py b/activitysmith_openapi/models/metric_format.py new file mode 100644 index 0000000..aff0f78 --- /dev/null +++ b/activitysmith_openapi/models/metric_format.py @@ -0,0 +1,40 @@ +# 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 +from enum import Enum +from typing_extensions import Self + + +class MetricFormat(str, Enum): + """ + MetricFormat + """ + + """ + allowed enum values + """ + NUMBER = 'number' + CURRENCY = 'currency' + PERCENT = 'percent' + UNIT = 'unit' + STRING = 'string' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of MetricFormat from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/activitysmith_openapi/models/metric_unit_spacing.py b/activitysmith_openapi/models/metric_unit_spacing.py new file mode 100644 index 0000000..4144a12 --- /dev/null +++ b/activitysmith_openapi/models/metric_unit_spacing.py @@ -0,0 +1,37 @@ +# 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 +from enum import Enum +from typing_extensions import Self + + +class MetricUnitSpacing(str, Enum): + """ + MetricUnitSpacing + """ + + """ + allowed enum values + """ + NONE = 'none' + SPACE = 'space' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of MetricUnitSpacing from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/activitysmith_openapi/models/metric_value_update_request.py b/activitysmith_openapi/models/metric_value_update_request.py new file mode 100644 index 0000000..d90f96b --- /dev/null +++ b/activitysmith_openapi/models/metric_value_update_request.py @@ -0,0 +1,107 @@ +# 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 pprint +import re # noqa: F401 +import json + +from datetime import datetime +from pydantic import BaseModel, ConfigDict, Field +from typing import Any, ClassVar, Dict, List, Optional +from activitysmith_openapi.models.metric_value_update_request_value import MetricValueUpdateRequestValue +from typing import Optional, Set +from typing_extensions import Self + +class MetricValueUpdateRequest(BaseModel): + """ + Latest metric value to display in widgets. + """ # noqa: E501 + value: MetricValueUpdateRequestValue + timestamp: Optional[datetime] = Field(default=None, description="Optional ISO timestamp for when the metric value was measured. Defaults to the server receive time.") + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["value", "timestamp"] + + 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 MetricValueUpdateRequest 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. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _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 + 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(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of MetricValueUpdateRequest from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "value": MetricValueUpdateRequestValue.from_dict(obj["value"]) if obj.get("value") is not None else None, + "timestamp": obj.get("timestamp") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/activitysmith_openapi/models/metric_value_update_request_value.py b/activitysmith_openapi/models/metric_value_update_request_value.py new file mode 100644 index 0000000..c84be7a --- /dev/null +++ b/activitysmith_openapi/models/metric_value_update_request_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, StrictFloat, StrictInt, 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 + +METRICVALUEUPDATEREQUESTVALUE_ONE_OF_SCHEMAS = ["float", "str"] + +class MetricValueUpdateRequestValue(BaseModel): + """ + MetricValueUpdateRequestValue + """ + # data type: float + oneof_schema_1_validator: Optional[Union[StrictFloat, StrictInt]] = 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 = MetricValueUpdateRequestValue.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 MetricValueUpdateRequestValue with oneOf schemas: float, str. Details: " + ", ".join(error_messages)) + elif match == 0: + # no match + raise ValueError("No match found when setting `actual_instance` in MetricValueUpdateRequestValue 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 MetricValueUpdateRequestValue 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 MetricValueUpdateRequestValue 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/models/metric_value_update_response.py b/activitysmith_openapi/models/metric_value_update_response.py new file mode 100644 index 0000000..fe0b8ab --- /dev/null +++ b/activitysmith_openapi/models/metric_value_update_response.py @@ -0,0 +1,104 @@ +# 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 pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict +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 + +class MetricValueUpdateResponse(BaseModel): + """ + MetricValueUpdateResponse + """ # noqa: E501 + metric: WidgetMetric + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["metric"] + + 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 MetricValueUpdateResponse 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. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + 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(): + _dict[_key] = _value + + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of MetricValueUpdateResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "metric": WidgetMetric.from_dict(obj["metric"]) if obj.get("metric") is not None else None + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/activitysmith_openapi/models/stream_content_state.py b/activitysmith_openapi/models/stream_content_state.py index 05441d7..be89634 100644 --- a/activitysmith_openapi/models/stream_content_state.py +++ b/activitysmith_openapi/models/stream_content_state.py @@ -26,12 +26,12 @@ class StreamContentState(BaseModel): """ - Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress, metrics, and the legacy counter/timer/countdown step-based types. + Current state for a managed Live Activity stream. Include type on the first PUT, and whenever the stream may need to start a fresh activity. Supports segmented_progress, progress, and metrics types. """ # noqa: E501 title: StrictStr subtitle: Optional[StrictStr] = None - number_of_steps: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="Use for segmented_progress, counter, timer, and countdown.") - current_step: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="Use for segmented_progress, counter, timer, and countdown.") + number_of_steps: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="Use for segmented_progress.") + current_step: Optional[Annotated[int, Field(strict=True, ge=1)]] = Field(default=None, description="Use for segmented_progress.") percentage: Optional[Union[Annotated[float, Field(le=100, strict=True, ge=0)], Annotated[int, Field(le=100, strict=True, ge=0)]]] = Field(default=None, description="Use for progress. Takes precedence over value/upper_limit if both are provided.") value: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Current progress value. Use with upper_limit for progress.") upper_limit: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Maximum progress value. Use with value for progress.") @@ -51,8 +51,8 @@ def type_validate_enum(cls, value): if value is None: return value - if value not in set(['segmented_progress', 'progress', 'metrics', 'counter', 'timer', 'countdown']): - raise ValueError("must be one of enum values ('segmented_progress', 'progress', 'metrics', 'counter', 'timer', 'countdown')") + if value not in set(['segmented_progress', 'progress', 'metrics']): + raise ValueError("must be one of enum values ('segmented_progress', 'progress', 'metrics')") return value @field_validator('color') diff --git a/activitysmith_openapi/models/widget_metric.py b/activitysmith_openapi/models/widget_metric.py new file mode 100644 index 0000000..2180043 --- /dev/null +++ b/activitysmith_openapi/models/widget_metric.py @@ -0,0 +1,165 @@ +# 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 pprint +import re # noqa: F401 +import json + +from datetime import datetime +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.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 + +class WidgetMetric(BaseModel): + """ + A metric configured for ActivitySmith widgets. + """ # noqa: E501 + 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.") + unit_spacing: MetricUnitSpacing + format: MetricFormat + latest_value: Optional[WidgetMetricLatestValue] + latest_value_at: Optional[datetime] + created_at: datetime + updated_at: datetime + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["public_id", "key", "label", "currency_code", "unit", "unit_spacing", "format", "latest_value", "latest_value_at", "created_at", "updated_at"] + + @field_validator('key') + def key_validate_regular_expression(cls, value): + """Validates the regular expression""" + if not re.match(r"^[a-z0-9][a-z0-9_.-]{0,63}$", value): + raise ValueError(r"must validate the regular expression /^[a-z0-9][a-z0-9_.-]{0,63}$/") + return 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 + + 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 WidgetMetric 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. + * Fields in `self.additional_properties` are added to the output dict. + """ + excluded_fields: Set[str] = set([ + "additional_properties", + ]) + + _dict = self.model_dump( + by_alias=True, + 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 + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of WidgetMetric from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "public_id": obj.get("public_id"), + "key": obj.get("key"), + "label": obj.get("label"), + "currency_code": obj.get("currency_code"), + "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_at": obj.get("latest_value_at"), + "created_at": obj.get("created_at"), + "updated_at": obj.get("updated_at") + }) + # store additional fields in additional_properties + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj + + diff --git a/activitysmith_openapi/models/widget_metric_latest_value.py b/activitysmith_openapi/models/widget_metric_latest_value.py new file mode 100644 index 0000000..f68ff6e --- /dev/null +++ b/activitysmith_openapi/models/widget_metric_latest_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 +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_error.py b/activitysmith_openapi/test/test_metric_error.py new file mode 100644 index 0000000..c15d84f --- /dev/null +++ b/activitysmith_openapi/test/test_metric_error.py @@ -0,0 +1,53 @@ +# 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.metric_error import MetricError + +class TestMetricError(unittest.TestCase): + """MetricError unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> MetricError: + """Test MetricError + 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 `MetricError` + """ + model = MetricError() + if include_optional: + return MetricError( + error = '', + message = '' + ) + else: + return MetricError( + error = '', + ) + """ + + def testMetricError(self): + """Test MetricError""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/activitysmith_openapi/test/test_metric_format.py b/activitysmith_openapi/test/test_metric_format.py new file mode 100644 index 0000000..aaa3b1a --- /dev/null +++ b/activitysmith_openapi/test/test_metric_format.py @@ -0,0 +1,33 @@ +# 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.metric_format import MetricFormat + +class TestMetricFormat(unittest.TestCase): + """MetricFormat unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testMetricFormat(self): + """Test MetricFormat""" + # inst = MetricFormat() + +if __name__ == '__main__': + unittest.main() diff --git a/activitysmith_openapi/test/test_metric_unit_spacing.py b/activitysmith_openapi/test/test_metric_unit_spacing.py new file mode 100644 index 0000000..5ec8e6c --- /dev/null +++ b/activitysmith_openapi/test/test_metric_unit_spacing.py @@ -0,0 +1,33 @@ +# 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.metric_unit_spacing import MetricUnitSpacing + +class TestMetricUnitSpacing(unittest.TestCase): + """MetricUnitSpacing unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testMetricUnitSpacing(self): + """Test MetricUnitSpacing""" + # inst = MetricUnitSpacing() + +if __name__ == '__main__': + unittest.main() diff --git a/activitysmith_openapi/test/test_metric_value_update_request.py b/activitysmith_openapi/test/test_metric_value_update_request.py new file mode 100644 index 0000000..429e2fd --- /dev/null +++ b/activitysmith_openapi/test/test_metric_value_update_request.py @@ -0,0 +1,53 @@ +# 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.metric_value_update_request import MetricValueUpdateRequest + +class TestMetricValueUpdateRequest(unittest.TestCase): + """MetricValueUpdateRequest unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> MetricValueUpdateRequest: + """Test MetricValueUpdateRequest + 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 `MetricValueUpdateRequest` + """ + model = MetricValueUpdateRequest() + if include_optional: + return MetricValueUpdateRequest( + value = None, + timestamp = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f') + ) + else: + return MetricValueUpdateRequest( + value = None, + ) + """ + + def testMetricValueUpdateRequest(self): + """Test MetricValueUpdateRequest""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/activitysmith_openapi/test/test_metric_value_update_request_value.py b/activitysmith_openapi/test/test_metric_value_update_request_value.py new file mode 100644 index 0000000..d159130 --- /dev/null +++ b/activitysmith_openapi/test/test_metric_value_update_request_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.metric_value_update_request_value import MetricValueUpdateRequestValue + +class TestMetricValueUpdateRequestValue(unittest.TestCase): + """MetricValueUpdateRequestValue unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> MetricValueUpdateRequestValue: + """Test MetricValueUpdateRequestValue + 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 `MetricValueUpdateRequestValue` + """ + model = MetricValueUpdateRequestValue() + if include_optional: + return MetricValueUpdateRequestValue( + ) + else: + return MetricValueUpdateRequestValue( + ) + """ + + def testMetricValueUpdateRequestValue(self): + """Test MetricValueUpdateRequestValue""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/activitysmith_openapi/test/test_metric_value_update_response.py b/activitysmith_openapi/test/test_metric_value_update_response.py new file mode 100644 index 0000000..2d4ad69 --- /dev/null +++ b/activitysmith_openapi/test/test_metric_value_update_response.py @@ -0,0 +1,52 @@ +# 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.metric_value_update_response import MetricValueUpdateResponse + +class TestMetricValueUpdateResponse(unittest.TestCase): + """MetricValueUpdateResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> MetricValueUpdateResponse: + """Test MetricValueUpdateResponse + 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 `MetricValueUpdateResponse` + """ + model = MetricValueUpdateResponse() + if include_optional: + return MetricValueUpdateResponse( + metric = { } + ) + else: + return MetricValueUpdateResponse( + metric = { }, + ) + """ + + def testMetricValueUpdateResponse(self): + """Test MetricValueUpdateResponse""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/activitysmith_openapi/test/test_metrics_api.py b/activitysmith_openapi/test/test_metrics_api.py new file mode 100644 index 0000000..254e254 --- /dev/null +++ b/activitysmith_openapi/test/test_metrics_api.py @@ -0,0 +1,38 @@ +# 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.api.metrics_api import MetricsApi + + +class TestMetricsApi(unittest.TestCase): + """MetricsApi unit test stubs""" + + def setUp(self) -> None: + self.api = MetricsApi() + + def tearDown(self) -> None: + pass + + def test_update_metric_value(self) -> None: + """Test case for update_metric_value + + Update a widget metric value + """ + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/activitysmith_openapi/test/test_widget_metric.py b/activitysmith_openapi/test/test_widget_metric.py new file mode 100644 index 0000000..2817717 --- /dev/null +++ b/activitysmith_openapi/test/test_widget_metric.py @@ -0,0 +1,72 @@ +# 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 import WidgetMetric + +class TestWidgetMetric(unittest.TestCase): + """WidgetMetric unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> WidgetMetric: + """Test WidgetMetric + 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 `WidgetMetric` + """ + model = WidgetMetric() + if include_optional: + return WidgetMetric( + public_id = '', + key = 'w6otgfww_r74cm.fyln9uyrj1gzi.i4v8m.oy3c3lv1-42d1z89qs7dlt2ggwxdm0', + label = '0', + currency_code = 'AEI012', + unit = '', + unit_spacing = 'none', + format = 'number', + latest_value = 1.337, + latest_value_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + created_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f') + ) + else: + return WidgetMetric( + public_id = '', + key = 'w6otgfww_r74cm.fyln9uyrj1gzi.i4v8m.oy3c3lv1-42d1z89qs7dlt2ggwxdm0', + label = '0', + currency_code = 'AEI012', + unit = '', + unit_spacing = 'none', + format = 'number', + latest_value = 1.337, + latest_value_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + created_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + ) + """ + + def testWidgetMetric(self): + """Test WidgetMetric""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/activitysmith_openapi/test/test_widget_metric_latest_value.py b/activitysmith_openapi/test/test_widget_metric_latest_value.py new file mode 100644 index 0000000..2b58d6e --- /dev/null +++ b/activitysmith_openapi/test/test_widget_metric_latest_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.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()