Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,63 @@ activitysmith.live_activities.end(
)
```

### Live Activity Action

Just like Actionable Push Notifications, Live Activities can have a button that opens provided URL in a browser or triggers a webhook. Webhooks are executed by the ActivitySmith backend.

<p align="center">
<img src="https://cdn.activitysmith.com/features/live-activity-with-action.png?v=20260319-1" alt="Live Activity with action" width="680" />
</p>

#### Open URL action

```python
start = activitysmith.live_activities.start(
{
"content_state": {
"title": "Deploying payments-api",
"subtitle": "Running database migrations",
"number_of_steps": 5,
"current_step": 3,
"type": "segmented_progress",
},
"action": {
"title": "Open Workflow",
"type": "open_url",
"url": "https://github.com/acme/payments-api/actions/runs/1234567890",
},
}
)

activity_id = start.activity_id
```

#### Webhook action

```python
activitysmith.live_activities.update(
{
"activity_id": activity_id,
"content_state": {
"title": "Reindexing product search",
"subtitle": "Shard 7 of 12",
"number_of_steps": 12,
"current_step": 7,
},
"action": {
"title": "Pause Reindex",
"type": "webhook",
"url": "https://ops.example.com/hooks/search/reindex/pause",
"method": "POST",
"body": {
"job_id": "reindex-2026-03-19",
"requested_by": "activitysmith-python",
},
},
}
)
```

## Channels

Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
Expand Down
5 changes: 4 additions & 1 deletion activitysmith_openapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
""" # noqa: E501


__version__ = "0.1.7"
__version__ = "1.0.0"

# import apis into sdk package
from activitysmith_openapi.api.live_activities_api import LiveActivitiesApi
Expand All @@ -39,13 +39,16 @@
from activitysmith_openapi.models.content_state_start import ContentStateStart
from activitysmith_openapi.models.content_state_update import ContentStateUpdate
from activitysmith_openapi.models.forbidden_error import ForbiddenError
from activitysmith_openapi.models.live_activity_action import LiveActivityAction
from activitysmith_openapi.models.live_activity_action_type import LiveActivityActionType
from activitysmith_openapi.models.live_activity_end_request import LiveActivityEndRequest
from activitysmith_openapi.models.live_activity_end_response import LiveActivityEndResponse
from activitysmith_openapi.models.live_activity_limit_error import LiveActivityLimitError
from activitysmith_openapi.models.live_activity_start_request import LiveActivityStartRequest
from activitysmith_openapi.models.live_activity_start_response import LiveActivityStartResponse
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.no_recipients_error import NoRecipientsError
from activitysmith_openapi.models.push_notification_action import PushNotificationAction
from activitysmith_openapi.models.push_notification_action_type import PushNotificationActionType
Expand Down
2 changes: 1 addition & 1 deletion activitysmith_openapi/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/0.1.7/python'
self.user_agent = 'OpenAPI-Generator/1.0.0/python'
self.client_side_validation = configuration.client_side_validation

def __enter__(self):
Expand Down
2 changes: 1 addition & 1 deletion activitysmith_openapi/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: 0.1.7".\
"SDK Package Version: 1.0.0".\
format(env=sys.platform, pyversion=sys.version)

def get_host_settings(self):
Expand Down
34 changes: 34 additions & 0 deletions activitysmith_openapi/docs/LiveActivityAction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# LiveActivityAction

Optional single action button shown in the Live Activity UI.

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**title** | **str** | Button title displayed in the Live Activity UI. |
**type** | [**LiveActivityActionType**](LiveActivityActionType.md) | |
**url** | **str** | HTTPS URL. For open_url it is opened in browser. For webhook it is called by ActivitySmith backend. |
**method** | [**LiveActivityWebhookMethod**](LiveActivityWebhookMethod.md) | Webhook HTTP method. Used only when type&#x3D;webhook. | [optional] [default to LiveActivityWebhookMethod.POST]
**body** | **Dict[str, object]** | Optional webhook payload body. Used only when type&#x3D;webhook. | [optional]

## Example

```python
from activitysmith_openapi.models.live_activity_action import LiveActivityAction

# TODO update the JSON string below
json = "{}"
# create an instance of LiveActivityAction from a JSON string
live_activity_action_instance = LiveActivityAction.from_json(json)
# print the JSON string representation of the object
print(LiveActivityAction.to_json())

# convert the object into a dict
live_activity_action_dict = live_activity_action_instance.to_dict()
# create an instance of LiveActivityAction from a dict
live_activity_action_from_dict = LiveActivityAction.from_dict(live_activity_action_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)


12 changes: 12 additions & 0 deletions activitysmith_openapi/docs/LiveActivityActionType.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# LiveActivityActionType


## Enum

* `OPEN_URL` (value: `'open_url'`)

* `WEBHOOK` (value: `'webhook'`)

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


1 change: 1 addition & 0 deletions activitysmith_openapi/docs/LiveActivityEndRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**activity_id** | **str** | |
**content_state** | [**ContentStateEnd**](ContentStateEnd.md) | |
**action** | [**LiveActivityAction**](LiveActivityAction.md) | | [optional]

## Example

Expand Down
1 change: 1 addition & 0 deletions activitysmith_openapi/docs/LiveActivityStartRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Start a new Live Activity. The response includes activity_id for later update an
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**content_state** | [**ContentStateStart**](ContentStateStart.md) | |
**action** | [**LiveActivityAction**](LiveActivityAction.md) | | [optional]
**alert** | [**AlertPayload**](AlertPayload.md) | | [optional]
**target** | [**ChannelTarget**](ChannelTarget.md) | | [optional]

Expand Down
1 change: 1 addition & 0 deletions activitysmith_openapi/docs/LiveActivityUpdateRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**activity_id** | **str** | |
**content_state** | [**ContentStateUpdate**](ContentStateUpdate.md) | |
**action** | [**LiveActivityAction**](LiveActivityAction.md) | | [optional]

## Example

Expand Down
12 changes: 12 additions & 0 deletions activitysmith_openapi/docs/LiveActivityWebhookMethod.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# LiveActivityWebhookMethod


## Enum

* `GET` (value: `'GET'`)

* `POST` (value: `'POST'`)

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


3 changes: 3 additions & 0 deletions activitysmith_openapi/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
from activitysmith_openapi.models.content_state_start import ContentStateStart
from activitysmith_openapi.models.content_state_update import ContentStateUpdate
from activitysmith_openapi.models.forbidden_error import ForbiddenError
from activitysmith_openapi.models.live_activity_action import LiveActivityAction
from activitysmith_openapi.models.live_activity_action_type import LiveActivityActionType
from activitysmith_openapi.models.live_activity_end_request import LiveActivityEndRequest
from activitysmith_openapi.models.live_activity_end_response import LiveActivityEndResponse
from activitysmith_openapi.models.live_activity_limit_error import LiveActivityLimitError
from activitysmith_openapi.models.live_activity_start_request import LiveActivityStartRequest
from activitysmith_openapi.models.live_activity_start_response import LiveActivityStartResponse
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.no_recipients_error import NoRecipientsError
from activitysmith_openapi.models.push_notification_action import PushNotificationAction
from activitysmith_openapi.models.push_notification_action_type import PushNotificationActionType
Expand Down
118 changes: 118 additions & 0 deletions activitysmith_openapi/models/live_activity_action.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# 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, Field, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from activitysmith_openapi.models.live_activity_action_type import LiveActivityActionType
from activitysmith_openapi.models.live_activity_webhook_method import LiveActivityWebhookMethod
from typing import Optional, Set
from typing_extensions import Self

class LiveActivityAction(BaseModel):
"""
Optional single action button shown in the Live Activity UI.
""" # noqa: E501
title: StrictStr = Field(description="Button title displayed in the Live Activity UI.")
type: LiveActivityActionType
url: Annotated[str, Field(strict=True)] = Field(description="HTTPS URL. For open_url it is opened in browser. For webhook it is called by ActivitySmith backend.")
method: Optional[LiveActivityWebhookMethod] = Field(default=LiveActivityWebhookMethod.POST, description="Webhook HTTP method. Used only when type=webhook.")
body: Optional[Dict[str, Any]] = Field(default=None, description="Optional webhook payload body. Used only when type=webhook.")
additional_properties: Dict[str, Any] = {}
__properties: ClassVar[List[str]] = ["title", "type", "url", "method", "body"]

@field_validator('url')
def url_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if not re.match(r"^https:\/\/", value):
raise ValueError(r"must validate the regular expression /^https:\/\//")
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 LiveActivityAction 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 LiveActivityAction from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate({
"title": obj.get("title"),
"type": obj.get("type"),
"url": obj.get("url"),
"method": obj.get("method") if obj.get("method") is not None else LiveActivityWebhookMethod.POST,
"body": obj.get("body")
})
# 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


37 changes: 37 additions & 0 deletions activitysmith_openapi/models/live_activity_action_type.py
Original file line number Diff line number Diff line change
@@ -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 LiveActivityActionType(str, Enum):
"""
LiveActivityActionType
"""

"""
allowed enum values
"""
OPEN_URL = 'open_url'
WEBHOOK = 'webhook'

@classmethod
def from_json(cls, json_str: str) -> Self:
"""Create an instance of LiveActivityActionType from a JSON string"""
return cls(json.loads(json_str))


Loading
Loading