diff --git a/notification/.gitattributes b/notification/.gitattributes new file mode 100755 index 000000000..4d75d5900 --- /dev/null +++ b/notification/.gitattributes @@ -0,0 +1,2 @@ +# This allows generated code to be indexed correctly +*.py linguist-generated=false \ No newline at end of file diff --git a/notification/.gitignore b/notification/.gitignore new file mode 100755 index 000000000..8ac3f51d4 --- /dev/null +++ b/notification/.gitignore @@ -0,0 +1,7 @@ +.python-version +.DS_Store +venv/ +src/*.egg-info/ +__pycache__/ +.pytest_cache/ +.python-version` diff --git a/notification/README.md b/notification/README.md index d7915fc85..edd12b409 100755 --- a/notification/README.md +++ b/notification/README.md @@ -12,40 +12,318 @@ pip install git+https://github.com/epilot-dev/sdk-python.git#subdirectory=notifi ```python import epilot -from epilot.models import operations, shared +from epilot.models import shared s = epilot.Epilot( security=shared.Security( - epilot_auth="Bearer YOUR_BEARER_TOKEN_HERE", + epilot_auth="", ), ) +req = shared.Notification( + additional_properties={ + "key": 'string', + }, + caller=shared.NotificationCallerContext( + additional_properties={ + "key": 'string', + }, + epilot_auth=shared.NotificationCallerContextEpilotAuth( + token=shared.NotificationCallerContextEpilotAuthToken( + cognito_username='example@epilot.cloud', + custom_ivy_user_id='10006129', + email='example@epilot.cloud', + sub='476e9b48-42f4-4234-a2b0-4668b34626ce', + ), + ), + ), + force_notify_users={ + "12345": 'string', + }, + message=shared.NotificationMessage( + de='{{caller}} habe etwas damit gemacht {{contact.entity.id}} {{branch.name}}.', + en='{{caller}} did something with {{contact.entity.id}} {{branch.name}}.', + ), + operations=[ + shared.EntityOperation( + entity='d9fa50df-3a77-4db4-9782-9e5cd1039cd9', + operation='updateEntity', + params=shared.EntityOperationParams( + slug='contact', + ), + payload={ + "status": 'string', + "_schema": 'string', + "_org": 'string', + }, + ), + ], + organization_id='206801', + payload={ + "entity": 'string', + }, + redirect_url='https://epilot.cloud', + title=shared.NotificationTitle( + de='Meine benutzerdefinierte Aktivität', + en='My custom notification', + ), + type='workflow', + visibility_user_ids=[ + '1', + '2', + '3', + '4', + '5', + ], +) -req = { - "deserunt": "porro", - "nulla": "id", - "vero": "perspiciatis", -} - res = s.notification.create_notification(req) if res.status_code == 200: # handle response + pass ``` -## SDK Available Operations +## Available Resources and Operations -### notification +### [notification](docs/sdks/notification/README.md) -* `create_notification` - createNotification -* `get_notification` - getNotification -* `get_notifications` - getNotifications -* `get_total_unread` - getTotalUnread -* `mark_all_as_read` - markAllAsRead -* `mark_as_read` - markAsRead +* [create_notification](docs/sdks/notification/README.md#create_notification) - createNotification +* [get_notification](docs/sdks/notification/README.md#get_notification) - getNotification +* [get_notifications](docs/sdks/notification/README.md#get_notifications) - getNotifications +* [get_total_unread](docs/sdks/notification/README.md#get_total_unread) - getTotalUnread +* [mark_all_as_read](docs/sdks/notification/README.md#mark_all_as_read) - markAllAsRead +* [mark_as_read](docs/sdks/notification/README.md#mark_as_read) - markAsRead + + + + + + + + + +# Pagination + +Some of the endpoints in this SDK support pagination. To use pagination, you make your SDK calls as usual, but the +returned response object will have a `Next` method that can be called to pull down the next group of results. If the +return value of `Next` is `None`, then there are no more pages to be fetched. + +Here's an example of one such pagination call: + + + + + +# Error Handling + +Handling errors in your SDK should largely match your expectations. All operations return a response object or raise an error. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type. + + + + + + + +# Server Selection + +## Select Server by Index + +You can override the default server globally by passing a server index to the `server_idx: int` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers: + +| # | Server | Variables | +| - | ------ | --------- | +| 0 | `https://notification.sls.epilot.io` | None | + +For example: + + +```python +import epilot +from epilot.models import shared + +s = epilot.Epilot( + security=shared.Security( + epilot_auth="", + ), + server_idx=0 +) + +req = shared.Notification( + additional_properties={ + "key": 'string', + }, + caller=shared.NotificationCallerContext( + additional_properties={ + "key": 'string', + }, + epilot_auth=shared.NotificationCallerContextEpilotAuth( + token=shared.NotificationCallerContextEpilotAuthToken( + cognito_username='example@epilot.cloud', + custom_ivy_user_id='10006129', + email='example@epilot.cloud', + sub='476e9b48-42f4-4234-a2b0-4668b34626ce', + ), + ), + ), + force_notify_users={ + "12345": 'string', + }, + message=shared.NotificationMessage( + de='{{caller}} habe etwas damit gemacht {{contact.entity.id}} {{branch.name}}.', + en='{{caller}} did something with {{contact.entity.id}} {{branch.name}}.', + ), + operations=[ + shared.EntityOperation( + entity='d9fa50df-3a77-4db4-9782-9e5cd1039cd9', + operation='updateEntity', + params=shared.EntityOperationParams( + slug='contact', + ), + payload={ + "_schema": 'string', + "_org": 'string', + "status": 'string', + }, + ), + ], + organization_id='206801', + payload={ + "entity": 'string', + }, + redirect_url='https://epilot.cloud', + title=shared.NotificationTitle( + de='Meine benutzerdefinierte Aktivität', + en='My custom notification', + ), + type='workflow', + visibility_user_ids=[ + '1', + '2', + '3', + '4', + '5', + ], +) + +res = s.notification.create_notification(req) + +if res.status_code == 200: + # handle response + pass +``` + + +## Override Server URL Per-Client + +The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example: + + +```python +import epilot +from epilot.models import shared + +s = epilot.Epilot( + security=shared.Security( + epilot_auth="", + ), + server_url="https://notification.sls.epilot.io" +) + +req = shared.Notification( + additional_properties={ + "key": 'string', + }, + caller=shared.NotificationCallerContext( + additional_properties={ + "key": 'string', + }, + epilot_auth=shared.NotificationCallerContextEpilotAuth( + token=shared.NotificationCallerContextEpilotAuthToken( + cognito_username='example@epilot.cloud', + custom_ivy_user_id='10006129', + email='example@epilot.cloud', + sub='476e9b48-42f4-4234-a2b0-4668b34626ce', + ), + ), + ), + force_notify_users={ + "12345": 'string', + }, + message=shared.NotificationMessage( + de='{{caller}} habe etwas damit gemacht {{contact.entity.id}} {{branch.name}}.', + en='{{caller}} did something with {{contact.entity.id}} {{branch.name}}.', + ), + operations=[ + shared.EntityOperation( + entity='d9fa50df-3a77-4db4-9782-9e5cd1039cd9', + operation='updateEntity', + params=shared.EntityOperationParams( + slug='contact', + ), + payload={ + "_org": 'string', + "status": 'string', + "_schema": 'string', + }, + ), + ], + organization_id='206801', + payload={ + "entity": 'string', + }, + redirect_url='https://epilot.cloud', + title=shared.NotificationTitle( + de='Meine benutzerdefinierte Aktivität', + en='My custom notification', + ), + type='workflow', + visibility_user_ids=[ + '1', + '2', + '3', + '4', + '5', + ], +) + +res = s.notification.create_notification(req) + +if res.status_code == 200: + # handle response + pass +``` + + + + + +# Custom HTTP Client + +The Python SDK makes API calls using the (requests)[https://pypi.org/project/requests/] HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom `requests.Session` object. + + +For example, you could specify a header for every request that your sdk makes as follows: + +```python +import epilot +import requests + +http_client = requests.Session() +http_client.headers.update({'x-custom-header': 'someValue'}) +s = epilot.Epilot(client: http_client) +``` + + + + + + + + ### SDK Generated by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks) diff --git a/notification/RELEASES.md b/notification/RELEASES.md index 275bd7fd5..7c05390ff 100644 --- a/notification/RELEASES.md +++ b/notification/RELEASES.md @@ -34,4 +34,548 @@ Based on: ### Changes Based on: - OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml -- Speakeasy CLI 1.19.2 (2.16.5) https://github.com/speakeasy-api/speakeasy \ No newline at end of file +- Speakeasy CLI 1.19.2 (2.16.5) https://github.com/speakeasy-api/speakeasy + +## 2023-04-01 01:16:49 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.19.3 (2.16.7) https://github.com/speakeasy-api/speakeasy + +## 2023-04-06 01:11:57 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.19.6 (2.17.8) https://github.com/speakeasy-api/speakeasy + +## 2023-04-12 01:14:03 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.19.7 (2.17.9) https://github.com/speakeasy-api/speakeasy + +## 2023-04-14 01:14:35 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.20.0 (2.18.0) https://github.com/speakeasy-api/speakeasy + +## 2023-04-18 01:13:47 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.20.1 (2.18.1) https://github.com/speakeasy-api/speakeasy + +## 2023-04-19 01:15:53 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.20.2 (2.18.2) https://github.com/speakeasy-api/speakeasy + +## 2023-04-21 01:13:44 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.21.4 (2.19.1) https://github.com/speakeasy-api/speakeasy + +## 2023-04-22 01:15:25 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.22.1 (2.20.1) https://github.com/speakeasy-api/speakeasy + +## 2023-04-26 01:14:54 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.23.1 (2.21.1) https://github.com/speakeasy-api/speakeasy + +## 2023-04-27 01:16:36 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.25.1 (2.22.0) https://github.com/speakeasy-api/speakeasy + +## 2023-04-28 01:16:05 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.26.2 (2.23.2) https://github.com/speakeasy-api/speakeasy + +## 2023-04-29 01:14:38 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.26.4 (2.23.4) https://github.com/speakeasy-api/speakeasy + +## 2023-05-02 01:15:37 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.26.5 (2.23.6) https://github.com/speakeasy-api/speakeasy + +## 2023-05-03 01:16:00 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.27.0 (2.24.0) https://github.com/speakeasy-api/speakeasy + +## 2023-05-05 01:08:54 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.29.0 (2.26.0) https://github.com/speakeasy-api/speakeasy + +## 2023-05-06 01:10:20 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.29.1 (2.26.1) https://github.com/speakeasy-api/speakeasy + +## 2023-05-10 01:14:09 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.29.2 (2.26.2) https://github.com/speakeasy-api/speakeasy + +## 2023-05-11 01:15:38 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.30.0 (2.26.3) https://github.com/speakeasy-api/speakeasy + +## 2023-05-12 01:15:17 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.30.1 (2.26.4) https://github.com/speakeasy-api/speakeasy + +## 2023-05-13 01:12:55 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.31.1 (2.27.0) https://github.com/speakeasy-api/speakeasy + +## 2023-05-16 01:16:45 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.32.0 (2.28.0) https://github.com/speakeasy-api/speakeasy + +## 2023-05-17 01:17:24 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.33.2 (2.29.0) https://github.com/speakeasy-api/speakeasy + +## 2023-05-18 01:15:24 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.34.0 (2.30.0) https://github.com/speakeasy-api/speakeasy + +## 2023-05-19 01:16:41 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.35.0 (2.31.0) https://github.com/speakeasy-api/speakeasy + +## 2023-05-23 01:16:36 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.37.5 (2.32.2) https://github.com/speakeasy-api/speakeasy + +## 2023-05-27 01:16:52 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.39.0 (2.32.7) https://github.com/speakeasy-api/speakeasy + +## 2023-06-01 01:56:45 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.40.2 (2.34.2) https://github.com/speakeasy-api/speakeasy + +## 2023-06-02 01:39:09 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.40.3 (2.34.7) https://github.com/speakeasy-api/speakeasy + +## 2023-06-03 01:35:54 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.43.0 (2.35.3) https://github.com/speakeasy-api/speakeasy + +## 2023-06-07 01:40:31 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.44.2 (2.35.9) https://github.com/speakeasy-api/speakeasy + +## 2023-06-08 01:39:55 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.45.0 (2.37.0) https://github.com/speakeasy-api/speakeasy + +## 2023-06-09 01:38:47 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.45.2 (2.37.2) https://github.com/speakeasy-api/speakeasy + +## 2023-06-10 01:23:25 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.47.0 (2.39.0) https://github.com/speakeasy-api/speakeasy + +## 2023-06-11 01:44:57 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.47.1 (2.39.2) https://github.com/speakeasy-api/speakeasy + +## 2023-06-14 01:24:20 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.47.3 (2.40.1) https://github.com/speakeasy-api/speakeasy + +## 2023-06-16 01:24:37 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.48.0 (2.41.1) https://github.com/speakeasy-api/speakeasy + +## 2023-06-20 01:21:17 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.49.0 (2.41.4) https://github.com/speakeasy-api/speakeasy + +## 2023-06-21 01:23:34 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.49.1 (2.41.5) https://github.com/speakeasy-api/speakeasy + +## 2023-06-23 01:41:54 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.50.1 (2.43.2) https://github.com/speakeasy-api/speakeasy + +## 2023-06-27 01:43:59 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.51.1 (2.50.2) https://github.com/speakeasy-api/speakeasy + +## 2023-06-29 01:39:14 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.51.3 (2.52.2) https://github.com/speakeasy-api/speakeasy + +## 2023-07-01 01:48:55 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.52.0 (2.55.0) https://github.com/speakeasy-api/speakeasy + +## 2023-07-06 01:43:39 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.52.2 (2.57.2) https://github.com/speakeasy-api/speakeasy + +## 2023-07-07 01:42:52 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.53.0 (2.58.0) https://github.com/speakeasy-api/speakeasy + +## 2023-07-08 01:41:30 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.53.1 (2.58.2) https://github.com/speakeasy-api/speakeasy + +## 2023-07-11 01:26:42 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.56.0 (2.61.0) https://github.com/speakeasy-api/speakeasy + +## 2023-07-12 01:43:33 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.56.4 (2.61.5) https://github.com/speakeasy-api/speakeasy + +## 2023-07-13 01:45:11 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.57.0 (2.62.1) https://github.com/speakeasy-api/speakeasy + +## 2023-07-14 01:44:48 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.59.0 (2.65.0) https://github.com/speakeasy-api/speakeasy + +## 2023-07-17 01:47:53 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.60.0 (2.66.0) https://github.com/speakeasy-api/speakeasy + +## 2023-07-18 01:54:10 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.61.0 (2.70.0) https://github.com/speakeasy-api/speakeasy + +## 2023-07-19 02:43:04 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.62.1 (2.70.2) https://github.com/speakeasy-api/speakeasy + +## 2023-07-22 01:19:41 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.64.0 (2.71.0) https://github.com/speakeasy-api/speakeasy + +## 2023-07-26 01:21:34 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.65.0 (2.73.0) https://github.com/speakeasy-api/speakeasy + +## 2023-07-27 01:11:29 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.65.1 (2.73.1) https://github.com/speakeasy-api/speakeasy + +## 2023-07-28 01:12:49 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.65.2 (2.75.1) https://github.com/speakeasy-api/speakeasy + +## 2023-08-01 01:22:51 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.66.1 (2.75.2) https://github.com/speakeasy-api/speakeasy + +## 2023-08-03 01:13:43 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.68.1 (2.77.1) https://github.com/speakeasy-api/speakeasy + +## 2023-08-04 01:15:58 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.68.3 (2.81.1) https://github.com/speakeasy-api/speakeasy + +## 2023-08-08 01:12:13 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.69.1 (2.82.0) https://github.com/speakeasy-api/speakeasy + +## 2023-08-15 01:01:58 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.72.0 (2.84.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.41.0] notification + +## 2023-08-19 01:00:09 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.74.3 (2.86.6) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.41.1] notification + +## 2023-08-25 01:03:23 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.74.11 (2.87.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.41.2] notification + +## 2023-08-26 01:00:46 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.74.16 (2.88.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.42.0] notification + +## 2023-08-29 01:03:36 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.74.17 (2.88.5) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.42.1] notification + +## 2023-08-31 01:03:39 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.76.1 (2.89.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.43.0] notification + +## 2023-09-01 01:07:37 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.77.0 (2.91.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.44.0] notification + +## 2023-09-02 01:01:21 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.77.2 (2.93.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.44.1] notification + +## 2023-09-05 01:02:31 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.78.3 (2.96.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.44.2] notification + +## 2023-09-12 01:02:00 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.82.5 (2.108.3) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.44.3] notification + +## 2023-09-16 01:02:32 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.86.0 (2.115.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.44.4] notification + +## 2023-09-20 01:04:15 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.88.0 (2.118.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.44.5] notification + +## 2023-09-26 01:04:57 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.91.0 (2.129.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.45.0] notification + +## 2023-09-27 01:04:58 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.91.2 (2.131.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.45.1] notification + +## 2023-09-29 01:04:37 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.91.3 (2.139.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.46.0] notification + +## 2023-10-01 01:12:57 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.92.2 (2.142.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.47.0] notification + +## 2023-10-02 01:05:17 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.92.3 (2.143.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.47.1] notification + +## 2023-10-05 01:05:02 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.94.0 (2.147.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.47.2] notification + +## 2023-10-07 01:04:10 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.96.1 (2.150.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.48.0] notification + +## 2023-10-13 01:06:48 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.99.1 (2.154.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v1.48.1] notification + +## 2023-10-18 01:05:08 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.101.0 (2.161.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v2.0.0] notification + +## 2023-10-21 01:03:21 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.104.0 (2.169.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v2.1.0] notification + +## 2023-10-28 01:02:46 +### Changes +Based on: +- OpenAPI Doc 1.0.0 https://docs.api.epilot.io/svc-notification-api.yaml +- Speakeasy CLI 1.109.0 (2.173.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v2.1.1] notification \ No newline at end of file diff --git a/notification/USAGE.md b/notification/USAGE.md index 48c8eb8a1..8177a3b2f 100755 --- a/notification/USAGE.md +++ b/notification/USAGE.md @@ -1,24 +1,77 @@ + + ```python import epilot -from epilot.models import operations, shared +from epilot.models import shared s = epilot.Epilot( security=shared.Security( - epilot_auth="Bearer YOUR_BEARER_TOKEN_HERE", + epilot_auth="", ), ) +req = shared.Notification( + additional_properties={ + "key": 'string', + }, + caller=shared.NotificationCallerContext( + additional_properties={ + "key": 'string', + }, + epilot_auth=shared.NotificationCallerContextEpilotAuth( + token=shared.NotificationCallerContextEpilotAuthToken( + cognito_username='example@epilot.cloud', + custom_ivy_user_id='10006129', + email='example@epilot.cloud', + sub='476e9b48-42f4-4234-a2b0-4668b34626ce', + ), + ), + ), + force_notify_users={ + "12345": 'string', + }, + message=shared.NotificationMessage( + de='{{caller}} habe etwas damit gemacht {{contact.entity.id}} {{branch.name}}.', + en='{{caller}} did something with {{contact.entity.id}} {{branch.name}}.', + ), + operations=[ + shared.EntityOperation( + entity='d9fa50df-3a77-4db4-9782-9e5cd1039cd9', + operation='updateEntity', + params=shared.EntityOperationParams( + slug='contact', + ), + payload={ + "status": 'string', + "_schema": 'string', + "_org": 'string', + }, + ), + ], + organization_id='206801', + payload={ + "entity": 'string', + }, + redirect_url='https://epilot.cloud', + title=shared.NotificationTitle( + de='Meine benutzerdefinierte Aktivität', + en='My custom notification', + ), + type='workflow', + visibility_user_ids=[ + '1', + '2', + '3', + '4', + '5', + ], +) -req = { - "deserunt": "porro", - "nulla": "id", - "vero": "perspiciatis", -} - res = s.notification.create_notification(req) if res.status_code == 200: # handle response + pass ``` \ No newline at end of file diff --git a/notification/docs/models/operations/createnotificationresponse.md b/notification/docs/models/operations/createnotificationresponse.md new file mode 100755 index 000000000..d61b506b4 --- /dev/null +++ b/notification/docs/models/operations/createnotificationresponse.md @@ -0,0 +1,10 @@ +# CreateNotificationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | +| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `raw_response` | [requests.Response](https://requests.readthedocs.io/en/latest/api/#requests.Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/notification/docs/models/operations/getnotificationrequest.md b/notification/docs/models/operations/getnotificationrequest.md new file mode 100755 index 000000000..835819387 --- /dev/null +++ b/notification/docs/models/operations/getnotificationrequest.md @@ -0,0 +1,8 @@ +# GetNotificationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `id` | *float* | :heavy_check_mark: | Notification Id | \ No newline at end of file diff --git a/notification/docs/models/operations/getnotificationresponse.md b/notification/docs/models/operations/getnotificationresponse.md new file mode 100755 index 000000000..acbffa832 --- /dev/null +++ b/notification/docs/models/operations/getnotificationresponse.md @@ -0,0 +1,11 @@ +# GetNotificationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | +| `notification_item` | [Optional[shared.NotificationItem]](../../models/shared/notificationitem.md) | :heavy_minus_sign: | Success | +| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `raw_response` | [requests.Response](https://requests.readthedocs.io/en/latest/api/#requests.Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/notification/docs/models/operations/getnotifications200applicationjson.md b/notification/docs/models/operations/getnotifications200applicationjson.md new file mode 100755 index 000000000..ca43e455d --- /dev/null +++ b/notification/docs/models/operations/getnotifications200applicationjson.md @@ -0,0 +1,12 @@ +# GetNotifications200ApplicationJSON + +Success + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | +| `results` | List[[shared.NotificationItem](../../models/shared/notificationitem.md)] | :heavy_minus_sign: | N/A | | +| `total` | *Optional[int]* | :heavy_minus_sign: | N/A | 1 | +| `total_unread` | *Optional[int]* | :heavy_minus_sign: | N/A | 1 | \ No newline at end of file diff --git a/notification/docs/models/operations/getnotificationsrequest.md b/notification/docs/models/operations/getnotificationsrequest.md new file mode 100755 index 000000000..4701e73a5 --- /dev/null +++ b/notification/docs/models/operations/getnotificationsrequest.md @@ -0,0 +1,9 @@ +# GetNotificationsRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------ | ------------------------------ | ------------------------------ | ------------------------------ | +| `after_id` | *Optional[int]* | :heavy_minus_sign: | N/A | +| `limit` | *Optional[int]* | :heavy_minus_sign: | The numbers of items to return | \ No newline at end of file diff --git a/notification/docs/models/operations/getnotificationsresponse.md b/notification/docs/models/operations/getnotificationsresponse.md new file mode 100755 index 000000000..7d3b67ee0 --- /dev/null +++ b/notification/docs/models/operations/getnotificationsresponse.md @@ -0,0 +1,11 @@ +# GetNotificationsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | +| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | +| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `raw_response` | [requests.Response](https://requests.readthedocs.io/en/latest/api/#requests.Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing | +| `get_notifications_200_application_json_object` | [Optional[GetNotifications200ApplicationJSON]](../../models/operations/getnotifications200applicationjson.md) | :heavy_minus_sign: | Success | \ No newline at end of file diff --git a/notification/docs/models/operations/gettotalunreadresponse.md b/notification/docs/models/operations/gettotalunreadresponse.md new file mode 100755 index 000000000..47cf5943a --- /dev/null +++ b/notification/docs/models/operations/gettotalunreadresponse.md @@ -0,0 +1,11 @@ +# GetTotalUnreadResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | +| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `raw_response` | [requests.Response](https://requests.readthedocs.io/en/latest/api/#requests.Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing | +| `get_total_unread_200_text_plain_number` | *Optional[str]* | :heavy_minus_sign: | Success | \ No newline at end of file diff --git a/notification/docs/models/operations/markallasreadresponse.md b/notification/docs/models/operations/markallasreadresponse.md new file mode 100755 index 000000000..b268b50ef --- /dev/null +++ b/notification/docs/models/operations/markallasreadresponse.md @@ -0,0 +1,10 @@ +# MarkAllAsReadResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | +| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `raw_response` | [requests.Response](https://requests.readthedocs.io/en/latest/api/#requests.Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/notification/docs/models/operations/markasreadrequest.md b/notification/docs/models/operations/markasreadrequest.md new file mode 100755 index 000000000..bde6aaffe --- /dev/null +++ b/notification/docs/models/operations/markasreadrequest.md @@ -0,0 +1,8 @@ +# MarkAsReadRequest + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | +| `id` | *int* | :heavy_check_mark: | Numeric ID of the notification to mark as read | \ No newline at end of file diff --git a/notification/docs/models/operations/markasreadresponse.md b/notification/docs/models/operations/markasreadresponse.md new file mode 100755 index 000000000..e43c8f227 --- /dev/null +++ b/notification/docs/models/operations/markasreadresponse.md @@ -0,0 +1,10 @@ +# MarkAsReadResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | +| `content_type` | *str* | :heavy_check_mark: | HTTP response content type for this operation | +| `status_code` | *int* | :heavy_check_mark: | HTTP response status code for this operation | +| `raw_response` | [requests.Response](https://requests.readthedocs.io/en/latest/api/#requests.Response) | :heavy_minus_sign: | Raw HTTP response; suitable for custom response parsing | \ No newline at end of file diff --git a/notification/docs/models/shared/entityoperation.md b/notification/docs/models/shared/entityoperation.md new file mode 100755 index 000000000..1f8b404f0 --- /dev/null +++ b/notification/docs/models/shared/entityoperation.md @@ -0,0 +1,11 @@ +# EntityOperation + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `entity` | *str* | :heavy_check_mark: | N/A | | +| `operation` | *Optional[str]* | :heavy_minus_sign: | N/A | updateEntity | +| `params` | [Optional[EntityOperationParams]](../../models/shared/entityoperationparams.md) | :heavy_minus_sign: | N/A | | +| `payload` | Dict[str, *Any*] | :heavy_minus_sign: | N/A | [object Object] | \ No newline at end of file diff --git a/notification/docs/models/shared/entityoperationparams.md b/notification/docs/models/shared/entityoperationparams.md new file mode 100755 index 000000000..f5ca2dacf --- /dev/null +++ b/notification/docs/models/shared/entityoperationparams.md @@ -0,0 +1,9 @@ +# EntityOperationParams + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------- | --------------------------------------------- | --------------------------------------------- | --------------------------------------------- | --------------------------------------------- | +| `id` | *Optional[str]* | :heavy_minus_sign: | N/A | | +| `slug` | *Optional[str]* | :heavy_minus_sign: | URL-friendly identifier for the entity schema | contact | \ No newline at end of file diff --git a/notification/docs/models/shared/notification.md b/notification/docs/models/shared/notification.md new file mode 100755 index 000000000..c44c3ce74 --- /dev/null +++ b/notification/docs/models/shared/notification.md @@ -0,0 +1,18 @@ +# Notification + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| `additional_properties` | Dict[str, *Any*] | :heavy_minus_sign: | N/A | | +| `caller` | [Optional[NotificationCallerContext]](../../models/shared/notificationcallercontext.md) | :heavy_minus_sign: | N/A | | +| `force_notify_users` | Dict[str, *Any*] | :heavy_minus_sign: | N/A | [object Object] | +| `message` | [NotificationMessage](../../models/shared/notificationmessage.md) | :heavy_check_mark: | N/A | | +| `operations` | List[[EntityOperation](../../models/shared/entityoperation.md)] | :heavy_minus_sign: | N/A | | +| `organization_id` | *Optional[str]* | :heavy_minus_sign: | Organization Id | 206801 | +| `payload` | Dict[str, *Any*] | :heavy_minus_sign: | N/A | [object Object] | +| `redirect_url` | *Optional[str]* | :heavy_minus_sign: | Redirect url | https://epilot.cloud | +| `title` | [NotificationTitle](../../models/shared/notificationtitle.md) | :heavy_check_mark: | N/A | | +| `type` | *str* | :heavy_check_mark: | Type of notification | workflow | +| `visibility_user_ids` | List[*str*] | :heavy_minus_sign: | The person who is the corresponding event recipient. | 1,2,3,4,5 | \ No newline at end of file diff --git a/notification/docs/models/shared/notificationcallercontext.md b/notification/docs/models/shared/notificationcallercontext.md new file mode 100755 index 000000000..acb197264 --- /dev/null +++ b/notification/docs/models/shared/notificationcallercontext.md @@ -0,0 +1,9 @@ +# NotificationCallerContext + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | +| `additional_properties` | Dict[str, *Any*] | :heavy_minus_sign: | N/A | +| `epilot_auth` | [Optional[NotificationCallerContextEpilotAuth]](../../models/shared/notificationcallercontextepilotauth.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/notification/docs/models/shared/notificationcallercontextepilotauth.md b/notification/docs/models/shared/notificationcallercontextepilotauth.md new file mode 100755 index 000000000..a20ed16d5 --- /dev/null +++ b/notification/docs/models/shared/notificationcallercontextepilotauth.md @@ -0,0 +1,8 @@ +# NotificationCallerContextEpilotAuth + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | +| `token` | [Optional[NotificationCallerContextEpilotAuthToken]](../../models/shared/notificationcallercontextepilotauthtoken.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/notification/docs/models/shared/notificationcallercontextepilotauthtoken.md b/notification/docs/models/shared/notificationcallercontextepilotauthtoken.md new file mode 100755 index 000000000..25c41523c --- /dev/null +++ b/notification/docs/models/shared/notificationcallercontextepilotauthtoken.md @@ -0,0 +1,11 @@ +# NotificationCallerContextEpilotAuthToken + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | +| `cognito_username` | *Optional[str]* | :heavy_minus_sign: | N/A | example@epilot.cloud | +| `custom_ivy_user_id` | *Optional[str]* | :heavy_minus_sign: | N/A | 10006129 | +| `email` | *Optional[str]* | :heavy_minus_sign: | N/A | example@epilot.cloud | +| `sub` | *Optional[str]* | :heavy_minus_sign: | N/A | 476e9b48-42f4-4234-a2b0-4668b34626ce | \ No newline at end of file diff --git a/notification/docs/models/shared/notificationitem.md b/notification/docs/models/shared/notificationitem.md new file mode 100755 index 000000000..f1075927c --- /dev/null +++ b/notification/docs/models/shared/notificationitem.md @@ -0,0 +1,21 @@ +# NotificationItem + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| `additional_properties` | Dict[str, *Any*] | :heavy_minus_sign: | N/A | | +| `caller` | [Optional[NotificationCallerContext]](../../models/shared/notificationcallercontext.md) | :heavy_minus_sign: | N/A | | +| `force_notify_users` | Dict[str, *Any*] | :heavy_minus_sign: | N/A | [object Object] | +| `id` | *Optional[float]* | :heavy_minus_sign: | N/A | 123456789 | +| `message` | [NotificationItemMessage](../../models/shared/notificationitemmessage.md) | :heavy_check_mark: | N/A | | +| `notification_id` | *Optional[float]* | :heavy_minus_sign: | N/A | 123456789 | +| `operations` | List[[EntityOperation](../../models/shared/entityoperation.md)] | :heavy_minus_sign: | N/A | | +| `organization_id` | *Optional[str]* | :heavy_minus_sign: | Organization Id | 206801 | +| `payload` | Dict[str, *Any*] | :heavy_minus_sign: | N/A | [object Object] | +| `read_state` | *Optional[bool]* | :heavy_minus_sign: | N/A | false | +| `redirect_url` | *Optional[str]* | :heavy_minus_sign: | Redirect url | https://epilot.cloud | +| `timestamp` | [date](https://docs.python.org/3/library/datetime.html#date-objects) | :heavy_minus_sign: | N/A | | +| `title` | [NotificationItemTitle](../../models/shared/notificationitemtitle.md) | :heavy_check_mark: | N/A | | +| `type` | *str* | :heavy_check_mark: | Type of notification | workflow | \ No newline at end of file diff --git a/notification/docs/models/shared/notificationitemmessage.md b/notification/docs/models/shared/notificationitemmessage.md new file mode 100755 index 000000000..b1a5f81fc --- /dev/null +++ b/notification/docs/models/shared/notificationitemmessage.md @@ -0,0 +1,9 @@ +# NotificationItemMessage + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `de` | *Optional[str]* | :heavy_minus_sign: | Message for notification. Supports handlebars syntax. | {{caller}} habe etwas damit gemacht {{contact.entity.id}} {{branch.name}}. | +| `en` | *Optional[str]* | :heavy_minus_sign: | Message for notification. Supports handlebars syntax. | {{caller}} did something with {{contact.entity.id}} {{branch.name}}. | \ No newline at end of file diff --git a/notification/docs/models/shared/notificationitemtitle.md b/notification/docs/models/shared/notificationitemtitle.md new file mode 100755 index 000000000..012167971 --- /dev/null +++ b/notification/docs/models/shared/notificationitemtitle.md @@ -0,0 +1,9 @@ +# NotificationItemTitle + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | +| `de` | *Optional[str]* | :heavy_minus_sign: | Title for notification. Supports handlebars syntax. | Meine benutzerdefinierte Aktivität | +| `en` | *Optional[str]* | :heavy_minus_sign: | Title for notification. Supports handlebars syntax. | My custom notification | \ No newline at end of file diff --git a/notification/docs/models/shared/notificationmessage.md b/notification/docs/models/shared/notificationmessage.md new file mode 100755 index 000000000..9d6bdc73c --- /dev/null +++ b/notification/docs/models/shared/notificationmessage.md @@ -0,0 +1,9 @@ +# NotificationMessage + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `de` | *Optional[str]* | :heavy_minus_sign: | Message for notification. Supports handlebars syntax. | {{caller}} habe etwas damit gemacht {{contact.entity.id}} {{branch.name}}. | +| `en` | *Optional[str]* | :heavy_minus_sign: | Message for notification. Supports handlebars syntax. | {{caller}} did something with {{contact.entity.id}} {{branch.name}}. | \ No newline at end of file diff --git a/notification/docs/models/shared/notificationtitle.md b/notification/docs/models/shared/notificationtitle.md new file mode 100755 index 000000000..183e5ec4f --- /dev/null +++ b/notification/docs/models/shared/notificationtitle.md @@ -0,0 +1,9 @@ +# NotificationTitle + + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | +| `de` | *Optional[str]* | :heavy_minus_sign: | Title for notification. Supports handlebars syntax. | Meine benutzerdefinierte Aktivität | +| `en` | *Optional[str]* | :heavy_minus_sign: | Title for notification. Supports handlebars syntax. | My custom notification | \ No newline at end of file diff --git a/notification/docs/models/shared/security.md b/notification/docs/models/shared/security.md new file mode 100755 index 000000000..f06333390 --- /dev/null +++ b/notification/docs/models/shared/security.md @@ -0,0 +1,8 @@ +# Security + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------ | ------------------ | ------------------ | ------------------ | ------------------ | +| `epilot_auth` | *str* | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/notification/docs/sdks/epilot/README.md b/notification/docs/sdks/epilot/README.md new file mode 100755 index 000000000..c6b199fd8 --- /dev/null +++ b/notification/docs/sdks/epilot/README.md @@ -0,0 +1,9 @@ +# Epilot SDK + + +## Overview + +Notification API: Notification API for epilot 360 + +### Available Operations + diff --git a/notification/docs/sdks/notification/README.md b/notification/docs/sdks/notification/README.md new file mode 100755 index 000000000..704985363 --- /dev/null +++ b/notification/docs/sdks/notification/README.md @@ -0,0 +1,282 @@ +# Notification +(*notification*) + +## Overview + +Notification + +### Available Operations + +* [create_notification](#create_notification) - createNotification +* [get_notification](#get_notification) - getNotification +* [get_notifications](#get_notifications) - getNotifications +* [get_total_unread](#get_total_unread) - getTotalUnread +* [mark_all_as_read](#mark_all_as_read) - markAllAsRead +* [mark_as_read](#mark_as_read) - markAsRead + +## create_notification + +Create a message that can be displayed in the notification panel. + +### Example Usage + +```python +import epilot +from epilot.models import shared + +s = epilot.Epilot( + security=shared.Security( + epilot_auth="", + ), +) + +req = shared.Notification( + additional_properties={ + "key": 'string', + }, + caller=shared.NotificationCallerContext( + additional_properties={ + "key": 'string', + }, + epilot_auth=shared.NotificationCallerContextEpilotAuth( + token=shared.NotificationCallerContextEpilotAuthToken( + cognito_username='example@epilot.cloud', + custom_ivy_user_id='10006129', + email='example@epilot.cloud', + sub='476e9b48-42f4-4234-a2b0-4668b34626ce', + ), + ), + ), + force_notify_users={ + "12345": 'string', + }, + message=shared.NotificationMessage( + de='{{caller}} habe etwas damit gemacht {{contact.entity.id}} {{branch.name}}.', + en='{{caller}} did something with {{contact.entity.id}} {{branch.name}}.', + ), + operations=[ + shared.EntityOperation( + entity='d9fa50df-3a77-4db4-9782-9e5cd1039cd9', + operation='updateEntity', + params=shared.EntityOperationParams( + slug='contact', + ), + payload={ + "_schema": 'string', + "_org": 'string', + "status": 'string', + }, + ), + ], + organization_id='206801', + payload={ + "entity": 'string', + }, + redirect_url='https://epilot.cloud', + title=shared.NotificationTitle( + de='Meine benutzerdefinierte Aktivität', + en='My custom notification', + ), + type='workflow', + visibility_user_ids=[ + '1', + '2', + '3', + '4', + '5', + ], +) + +res = s.notification.create_notification(req) + +if res.status_code == 200: + # handle response + pass +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `request` | [shared.Notification](../../models/shared/notification.md) | :heavy_check_mark: | The request object to use for the request. | + + +### Response + +**[operations.CreateNotificationResponse](../../models/operations/createnotificationresponse.md)** + + +## get_notification + +Get the details of a single notification. + +### Example Usage + +```python +import epilot +from epilot.models import operations, shared + +s = epilot.Epilot( + security=shared.Security( + epilot_auth="", + ), +) + +req = operations.GetNotificationRequest( + id=3493.28, +) + +res = s.notification.get_notification(req) + +if res.notification_item is not None: + # handle response + pass +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `request` | [operations.GetNotificationRequest](../../models/operations/getnotificationrequest.md) | :heavy_check_mark: | The request object to use for the request. | + + +### Response + +**[operations.GetNotificationResponse](../../models/operations/getnotificationresponse.md)** + + +## get_notifications + +Get notifications + +### Example Usage + +```python +import epilot +from epilot.models import operations, shared + +s = epilot.Epilot( + security=shared.Security( + epilot_auth="", + ), +) + +req = operations.GetNotificationsRequest() + +res = s.notification.get_notifications(req) + +if res.get_notifications_200_application_json_object is not None: + # handle response + pass +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `request` | [operations.GetNotificationsRequest](../../models/operations/getnotificationsrequest.md) | :heavy_check_mark: | The request object to use for the request. | + + +### Response + +**[operations.GetNotificationsResponse](../../models/operations/getnotificationsresponse.md)** + + +## get_total_unread + +Get total unread + +### Example Usage + +```python +import epilot +from epilot.models import shared + +s = epilot.Epilot( + security=shared.Security( + epilot_auth="", + ), +) + + +res = s.notification.get_total_unread() + +if res.get_total_unread_200_text_plain_number is not None: + # handle response + pass +``` + + +### Response + +**[operations.GetTotalUnreadResponse](../../models/operations/gettotalunreadresponse.md)** + + +## mark_all_as_read + +Mark all as read + +### Example Usage + +```python +import epilot +from epilot.models import shared + +s = epilot.Epilot( + security=shared.Security( + epilot_auth="", + ), +) + + +res = s.notification.mark_all_as_read() + +if res.status_code == 200: + # handle response + pass +``` + + +### Response + +**[operations.MarkAllAsReadResponse](../../models/operations/markallasreadresponse.md)** + + +## mark_as_read + +Mark as read + +### Example Usage + +```python +import epilot +from epilot.models import operations, shared + +s = epilot.Epilot( + security=shared.Security( + epilot_auth="", + ), +) + +req = operations.MarkAsReadRequest( + id=883397, +) + +res = s.notification.mark_as_read(req) + +if res.status_code == 200: + # handle response + pass +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `request` | [operations.MarkAsReadRequest](../../models/operations/markasreadrequest.md) | :heavy_check_mark: | The request object to use for the request. | + + +### Response + +**[operations.MarkAsReadResponse](../../models/operations/markasreadresponse.md)** + diff --git a/notification/files.gen b/notification/files.gen index be6ef325f..2f083ff6a 100755 --- a/notification/files.gen +++ b/notification/files.gen @@ -1,9 +1,11 @@ +src/epilot/sdkconfiguration.py src/epilot/notification.py src/epilot/sdk.py pylintrc setup.py src/epilot/__init__.py src/epilot/models/__init__.py +src/epilot/models/errors/sdkerror.py src/epilot/utils/__init__.py src/epilot/utils/retries.py src/epilot/utils/utils.py @@ -14,6 +16,36 @@ src/epilot/models/operations/gettotalunread.py src/epilot/models/operations/markallasread.py src/epilot/models/operations/markasread.py src/epilot/models/operations/__init__.py +src/epilot/models/shared/notification.py +src/epilot/models/shared/entityoperation.py +src/epilot/models/shared/notificationcallercontext.py +src/epilot/models/shared/notificationitem.py src/epilot/models/shared/security.py src/epilot/models/shared/__init__.py -USAGE.md \ No newline at end of file +src/epilot/models/errors/__init__.py +USAGE.md +docs/models/operations/createnotificationresponse.md +docs/models/operations/getnotificationrequest.md +docs/models/operations/getnotificationresponse.md +docs/models/operations/getnotificationsrequest.md +docs/models/operations/getnotifications200applicationjson.md +docs/models/operations/getnotificationsresponse.md +docs/models/operations/gettotalunreadresponse.md +docs/models/operations/markallasreadresponse.md +docs/models/operations/markasreadrequest.md +docs/models/operations/markasreadresponse.md +docs/models/shared/notificationmessage.md +docs/models/shared/notificationtitle.md +docs/models/shared/notification.md +docs/models/shared/entityoperationparams.md +docs/models/shared/entityoperation.md +docs/models/shared/notificationcallercontextepilotauthtoken.md +docs/models/shared/notificationcallercontextepilotauth.md +docs/models/shared/notificationcallercontext.md +docs/models/shared/notificationitemmessage.md +docs/models/shared/notificationitemtitle.md +docs/models/shared/notificationitem.md +docs/models/shared/security.md +docs/sdks/epilot/README.md +docs/sdks/notification/README.md +.gitattributes \ No newline at end of file diff --git a/notification/gen.yaml b/notification/gen.yaml index 41d2b3584..f89b1c26b 100644 --- a/notification/gen.yaml +++ b/notification/gen.yaml @@ -2,15 +2,25 @@ configVersion: 1.0.0 management: docChecksum: 0e661bd8cf4bb8f9a78a0eec763ee814 docVersion: 1.0.0 - speakeasyVersion: 1.19.2 - generationVersion: 2.16.5 + speakeasyVersion: 1.109.0 + generationVersion: 2.173.0 generation: - telemetryEnabled: false + repoURL: https://github.com/epilot-dev/sdk-python.git sdkClassName: epilot - sdkFlattening: true singleTagPerOp: false + telemetryEnabled: false +features: + python: + additionalProperties: 0.1.0 + core: 3.3.1 + globalSecurity: 2.82.0 + globalServerURLs: 2.82.0 python: - version: 1.2.2 + version: 2.1.1 author: epilot description: Python Client SDK for Epilot + flattenGlobalSecurity: false + installationURL: https://github.com/epilot-dev/sdk-python.git#subdirectory=notification + maxMethodParams: 0 packageName: epilot-notification + repoSubDirectory: notification diff --git a/notification/pylintrc b/notification/pylintrc index 79b8008d0..a2f54e249 100755 --- a/notification/pylintrc +++ b/notification/pylintrc @@ -88,7 +88,7 @@ persistent=yes # Minimum Python version to use for version dependent checks. Will default to # the version used to run pylint. -py-version=3.9 +py-version=3.8 # Discover python modules and packages in the file system subtree. recursive=no @@ -116,20 +116,15 @@ argument-naming-style=snake_case #argument-rgx= # Naming style matching correct attribute names. -attr-naming-style=snake_case +#attr-naming-style=snake_case # Regular expression matching correct attribute names. Overrides attr-naming- # style. If left empty, attribute names will be checked with the set naming # style. -#attr-rgx= +attr-rgx=[^\W\d][^\W]*|__.*__$ # Bad variable names which should always be refused, separated by a comma. -bad-names=foo, - bar, - baz, - toto, - tutu, - tata +bad-names= # Bad variable names regexes, separated by a comma. If names match any regex, # they will always be refused @@ -185,7 +180,9 @@ good-names=i, ex, Run, _, - id + id, + de, + en # Good variable names regexes, separated by a comma. If names match any regex, # they will always be accepted @@ -439,7 +436,13 @@ disable=raw-checker-failed, trailing-newlines, too-many-public-methods, too-many-locals, - too-many-lines + too-many-lines, + using-constant-test, + too-many-statements, + cyclic-import, + too-many-nested-blocks, + too-many-boolean-expressions, + no-else-raise # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -620,7 +623,7 @@ additional-builtins= allow-global-unused-variables=yes # List of names allowed to shadow builtins -allowed-redefined-builtins= +allowed-redefined-builtins=id,object # List of strings which can identify a callback function by name. A callback # name must start or end with one of those strings. diff --git a/notification/setup.py b/notification/setup.py index 7a1b99090..871122f8e 100755 --- a/notification/setup.py +++ b/notification/setup.py @@ -10,30 +10,31 @@ setuptools.setup( name="epilot-notification", - version="1.2.2", + version="2.1.1", author="epilot", description="Python Client SDK for Epilot", long_description=long_description, long_description_content_type="text/markdown", packages=setuptools.find_packages(where="src"), install_requires=[ - "certifi==2022.12.07", - "charset-normalizer==2.1.1", - "dataclasses-json-speakeasy==0.5.8", - "idna==3.3", - "marshmallow==3.17.1", - "marshmallow-enum==1.5.1", - "mypy-extensions==0.4.3", - "packaging==21.3", - "pyparsing==3.0.9", - "python-dateutil==2.8.2", - "requests==2.28.1", - "six==1.16.0", - "typing-inspect==0.8.0", - "typing_extensions==4.3.0", - "urllib3==1.26.12", - "pylint==2.16.2", + "certifi>=2023.7.22", + "charset-normalizer>=3.2.0", + "dataclasses-json>=0.6.1", + "idna>=3.4", + "jsonpath-python>=1.0.6 ", + "marshmallow>=3.19.0", + "mypy-extensions>=1.0.0", + "packaging>=23.1", + "python-dateutil>=2.8.2", + "requests>=2.31.0", + "six>=1.16.0", + "typing-inspect>=0.9.0", + "typing_extensions>=4.7.1", + "urllib3>=2.0.4", ], + extras_require={ + "dev":["pylint==2.16.2"] + }, package_dir={'': 'src'}, - python_requires='>=3.9' + python_requires='>=3.8' ) diff --git a/notification/src/epilot/__init__.py b/notification/src/epilot/__init__.py index b9e232018..e6c0deeb6 100755 --- a/notification/src/epilot/__init__.py +++ b/notification/src/epilot/__init__.py @@ -1,3 +1,4 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" from .sdk import * +from .sdkconfiguration import * diff --git a/notification/src/epilot/models/__init__.py b/notification/src/epilot/models/__init__.py index 889f8adcf..36628d6cc 100755 --- a/notification/src/epilot/models/__init__.py +++ b/notification/src/epilot/models/__init__.py @@ -1,2 +1,3 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" +# __init__.py diff --git a/notification/src/epilot/models/errors/__init__.py b/notification/src/epilot/models/errors/__init__.py new file mode 100755 index 000000000..cfd848441 --- /dev/null +++ b/notification/src/epilot/models/errors/__init__.py @@ -0,0 +1,4 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from .sdkerror import SDKError +__all__ = ["SDKError"] diff --git a/notification/src/epilot/models/errors/sdkerror.py b/notification/src/epilot/models/errors/sdkerror.py new file mode 100755 index 000000000..6bb02bbd6 --- /dev/null +++ b/notification/src/epilot/models/errors/sdkerror.py @@ -0,0 +1,24 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +import requests as requests_http + + +class SDKError(Exception): + """Represents an error returned by the API.""" + message: str + status_code: int + body: str + raw_response: requests_http.Response + + def __init__(self, message: str, status_code: int, body: str, raw_response: requests_http.Response): + self.message = message + self.status_code = status_code + self.body = body + self.raw_response = raw_response + + def __str__(self): + body = '' + if len(self.body) > 0: + body = f'\n{self.body}' + + return f'{self.message}: Status {self.status_code}{body}' diff --git a/notification/src/epilot/models/operations/createnotification.py b/notification/src/epilot/models/operations/createnotification.py index 9294c9e88..36ca0ee0e 100755 --- a/notification/src/epilot/models/operations/createnotification.py +++ b/notification/src/epilot/models/operations/createnotification.py @@ -8,8 +8,11 @@ @dataclasses.dataclass class CreateNotificationResponse: + content_type: str = dataclasses.field() + r"""HTTP response content type for this operation""" + status_code: int = dataclasses.field() + r"""HTTP response status code for this operation""" + raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) + r"""Raw HTTP response; suitable for custom response parsing""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + diff --git a/notification/src/epilot/models/operations/getnotification.py b/notification/src/epilot/models/operations/getnotification.py index 36733516a..ee2805765 100755 --- a/notification/src/epilot/models/operations/getnotification.py +++ b/notification/src/epilot/models/operations/getnotification.py @@ -3,22 +3,27 @@ from __future__ import annotations import dataclasses import requests as requests_http -from typing import Any, Optional +from ..shared import notificationitem as shared_notificationitem +from typing import Optional @dataclasses.dataclass class GetNotificationRequest: - id: float = dataclasses.field(metadata={'path_param': { 'field_name': 'id', 'style': 'simple', 'explode': False }}) - r"""Notification Id""" + r"""Notification Id""" + + @dataclasses.dataclass class GetNotificationResponse: + content_type: str = dataclasses.field() + r"""HTTP response content type for this operation""" + status_code: int = dataclasses.field() + r"""HTTP response status code for this operation""" + notification_item: Optional[shared_notificationitem.NotificationItem] = dataclasses.field(default=None) + r"""Success""" + raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) + r"""Raw HTTP response; suitable for custom response parsing""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - notification_item: Optional[dict[str, Any]] = dataclasses.field(default=None) - r"""Success""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + diff --git a/notification/src/epilot/models/operations/getnotifications.py b/notification/src/epilot/models/operations/getnotifications.py index 780e981db..36ba44815 100755 --- a/notification/src/epilot/models/operations/getnotifications.py +++ b/notification/src/epilot/models/operations/getnotifications.py @@ -3,35 +3,41 @@ from __future__ import annotations import dataclasses import requests as requests_http +from ..shared import notificationitem as shared_notificationitem from dataclasses_json import Undefined, dataclass_json from epilot import utils -from typing import Any, Optional +from typing import List, Optional @dataclasses.dataclass class GetNotificationsRequest: - - after_id: Optional[int] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'after_id', 'style': 'form', 'explode': True }}) + after_id: Optional[int] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'after_id', 'style': 'form', 'explode': True }}) limit: Optional[int] = dataclasses.field(default=None, metadata={'query_param': { 'field_name': 'limit', 'style': 'form', 'explode': True }}) - r"""The numbers of items to return""" + r"""The numbers of items to return""" + + @dataclass_json(undefined=Undefined.EXCLUDE) @dataclasses.dataclass class GetNotifications200ApplicationJSON: r"""Success""" + results: Optional[List[shared_notificationitem.NotificationItem]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('results'), 'exclude': lambda f: f is None }}) + total: Optional[int] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('total'), 'exclude': lambda f: f is None }}) + total_unread: Optional[int] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('total_unread'), 'exclude': lambda f: f is None }}) - results: Optional[list[dict[str, Any]]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('results'), 'exclude': lambda f: f is None }}) - total: Optional[int] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('total'), 'exclude': lambda f: f is None }}) - total_unread: Optional[int] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('total_unread'), 'exclude': lambda f: f is None }}) - + + @dataclasses.dataclass class GetNotificationsResponse: - - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() + content_type: str = dataclasses.field() + r"""HTTP response content type for this operation""" + status_code: int = dataclasses.field() + r"""HTTP response status code for this operation""" get_notifications_200_application_json_object: Optional[GetNotifications200ApplicationJSON] = dataclasses.field(default=None) - r"""Success""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + r"""Success""" + raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) + r"""Raw HTTP response; suitable for custom response parsing""" + + diff --git a/notification/src/epilot/models/operations/gettotalunread.py b/notification/src/epilot/models/operations/gettotalunread.py index 9520f8235..5caf22096 100755 --- a/notification/src/epilot/models/operations/gettotalunread.py +++ b/notification/src/epilot/models/operations/gettotalunread.py @@ -8,10 +8,13 @@ @dataclasses.dataclass class GetTotalUnreadResponse: - - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() + content_type: str = dataclasses.field() + r"""HTTP response content type for this operation""" + status_code: int = dataclasses.field() + r"""HTTP response status code for this operation""" get_total_unread_200_text_plain_number: Optional[str] = dataclasses.field(default=None) - r"""Success""" - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + r"""Success""" + raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) + r"""Raw HTTP response; suitable for custom response parsing""" + + diff --git a/notification/src/epilot/models/operations/markallasread.py b/notification/src/epilot/models/operations/markallasread.py index f30c618fb..62bf9a0d5 100755 --- a/notification/src/epilot/models/operations/markallasread.py +++ b/notification/src/epilot/models/operations/markallasread.py @@ -8,8 +8,11 @@ @dataclasses.dataclass class MarkAllAsReadResponse: + content_type: str = dataclasses.field() + r"""HTTP response content type for this operation""" + status_code: int = dataclasses.field() + r"""HTTP response status code for this operation""" + raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) + r"""Raw HTTP response; suitable for custom response parsing""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + diff --git a/notification/src/epilot/models/operations/markasread.py b/notification/src/epilot/models/operations/markasread.py index 3383493f8..e0d971eeb 100755 --- a/notification/src/epilot/models/operations/markasread.py +++ b/notification/src/epilot/models/operations/markasread.py @@ -8,15 +8,19 @@ @dataclasses.dataclass class MarkAsReadRequest: - id: int = dataclasses.field(metadata={'path_param': { 'field_name': 'id', 'style': 'simple', 'explode': False }}) - r"""Numeric ID of the notification to mark as read""" + r"""Numeric ID of the notification to mark as read""" + + @dataclasses.dataclass class MarkAsReadResponse: + content_type: str = dataclasses.field() + r"""HTTP response content type for this operation""" + status_code: int = dataclasses.field() + r"""HTTP response status code for this operation""" + raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) + r"""Raw HTTP response; suitable for custom response parsing""" - content_type: str = dataclasses.field() - status_code: int = dataclasses.field() - raw_response: Optional[requests_http.Response] = dataclasses.field(default=None) - \ No newline at end of file + diff --git a/notification/src/epilot/models/shared/__init__.py b/notification/src/epilot/models/shared/__init__.py index 4e48d0727..caaca6aa3 100755 --- a/notification/src/epilot/models/shared/__init__.py +++ b/notification/src/epilot/models/shared/__init__.py @@ -1,5 +1,9 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" +from .entityoperation import * +from .notification import * +from .notificationcallercontext import * +from .notificationitem import * from .security import * -__all__ = ["Security"] +__all__ = ["EntityOperation","EntityOperationParams","Notification","NotificationCallerContext","NotificationCallerContextEpilotAuth","NotificationCallerContextEpilotAuthToken","NotificationItem","NotificationItemMessage","NotificationItemTitle","NotificationMessage","NotificationTitle","Security"] diff --git a/notification/src/epilot/models/shared/entityoperation.py b/notification/src/epilot/models/shared/entityoperation.py new file mode 100755 index 000000000..b9b4b9f14 --- /dev/null +++ b/notification/src/epilot/models/shared/entityoperation.py @@ -0,0 +1,28 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from __future__ import annotations +import dataclasses +from dataclasses_json import Undefined, dataclass_json +from epilot import utils +from typing import Any, Dict, Optional + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class EntityOperationParams: + id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id'), 'exclude': lambda f: f is None }}) + slug: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('slug'), 'exclude': lambda f: f is None }}) + r"""URL-friendly identifier for the entity schema""" + + + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class EntityOperation: + entity: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('entity') }}) + operation: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('operation'), 'exclude': lambda f: f is None }}) + params: Optional[EntityOperationParams] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('params'), 'exclude': lambda f: f is None }}) + payload: Optional[Dict[str, Any]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('payload'), 'exclude': lambda f: f is None }}) + + diff --git a/notification/src/epilot/models/shared/notification.py b/notification/src/epilot/models/shared/notification.py new file mode 100755 index 000000000..688f42950 --- /dev/null +++ b/notification/src/epilot/models/shared/notification.py @@ -0,0 +1,53 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from __future__ import annotations +import dataclasses +from ..shared import entityoperation as shared_entityoperation +from ..shared import notificationcallercontext as shared_notificationcallercontext +from dataclasses_json import Undefined, dataclass_json +from epilot import utils +from typing import Any, Dict, List, Optional + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class NotificationMessage: + de: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('de'), 'exclude': lambda f: f is None }}) + r"""Message for notification. Supports handlebars syntax.""" + en: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('en'), 'exclude': lambda f: f is None }}) + r"""Message for notification. Supports handlebars syntax.""" + + + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class NotificationTitle: + de: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('de'), 'exclude': lambda f: f is None }}) + r"""Title for notification. Supports handlebars syntax.""" + en: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('en'), 'exclude': lambda f: f is None }}) + r"""Title for notification. Supports handlebars syntax.""" + + + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class Notification: + message: NotificationMessage = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('message') }}) + title: NotificationTitle = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('title') }}) + type: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('type') }}) + r"""Type of notification""" + additional_properties: Optional[Dict[str, Any]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'exclude': lambda f: f is None }}) + caller: Optional[shared_notificationcallercontext.NotificationCallerContext] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('caller'), 'exclude': lambda f: f is None }}) + force_notify_users: Optional[Dict[str, Any]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('force_notify_users'), 'exclude': lambda f: f is None }}) + operations: Optional[List[shared_entityoperation.EntityOperation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('operations'), 'exclude': lambda f: f is None }}) + organization_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('organization_id'), 'exclude': lambda f: f is None }}) + r"""Organization Id""" + payload: Optional[Dict[str, Any]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('payload'), 'exclude': lambda f: f is None }}) + redirect_url: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('redirect_url'), 'exclude': lambda f: f is None }}) + r"""Redirect url""" + visibility_user_ids: Optional[List[str]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('visibility_user_ids'), 'exclude': lambda f: f is None }}) + r"""The person who is the corresponding event recipient.""" + + diff --git a/notification/src/epilot/models/shared/notificationcallercontext.py b/notification/src/epilot/models/shared/notificationcallercontext.py new file mode 100755 index 000000000..527068a36 --- /dev/null +++ b/notification/src/epilot/models/shared/notificationcallercontext.py @@ -0,0 +1,35 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from __future__ import annotations +import dataclasses +from dataclasses_json import Undefined, dataclass_json +from epilot import utils +from typing import Any, Dict, Optional + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class NotificationCallerContextEpilotAuthToken: + cognito_username: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('cognito:username'), 'exclude': lambda f: f is None }}) + custom_ivy_user_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('custom:ivy_user_id'), 'exclude': lambda f: f is None }}) + email: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('email'), 'exclude': lambda f: f is None }}) + sub: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('sub'), 'exclude': lambda f: f is None }}) + + + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class NotificationCallerContextEpilotAuth: + token: Optional[NotificationCallerContextEpilotAuthToken] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('token'), 'exclude': lambda f: f is None }}) + + + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class NotificationCallerContext: + additional_properties: Optional[Dict[str, Any]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'exclude': lambda f: f is None }}) + epilot_auth: Optional[NotificationCallerContextEpilotAuth] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('EpilotAuth'), 'exclude': lambda f: f is None }}) + + diff --git a/notification/src/epilot/models/shared/notificationitem.py b/notification/src/epilot/models/shared/notificationitem.py new file mode 100755 index 000000000..095e88509 --- /dev/null +++ b/notification/src/epilot/models/shared/notificationitem.py @@ -0,0 +1,57 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +from __future__ import annotations +import dataclasses +import dateutil.parser +from ..shared import entityoperation as shared_entityoperation +from ..shared import notificationcallercontext as shared_notificationcallercontext +from dataclasses_json import Undefined, dataclass_json +from datetime import datetime +from epilot import utils +from typing import Any, Dict, List, Optional + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class NotificationItemMessage: + de: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('de'), 'exclude': lambda f: f is None }}) + r"""Message for notification. Supports handlebars syntax.""" + en: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('en'), 'exclude': lambda f: f is None }}) + r"""Message for notification. Supports handlebars syntax.""" + + + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class NotificationItemTitle: + de: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('de'), 'exclude': lambda f: f is None }}) + r"""Title for notification. Supports handlebars syntax.""" + en: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('en'), 'exclude': lambda f: f is None }}) + r"""Title for notification. Supports handlebars syntax.""" + + + + +@dataclass_json(undefined=Undefined.EXCLUDE) +@dataclasses.dataclass +class NotificationItem: + message: NotificationItemMessage = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('message') }}) + title: NotificationItemTitle = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('title') }}) + type: str = dataclasses.field(metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('type') }}) + r"""Type of notification""" + additional_properties: Optional[Dict[str, Any]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'exclude': lambda f: f is None }}) + caller: Optional[shared_notificationcallercontext.NotificationCallerContext] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('caller'), 'exclude': lambda f: f is None }}) + force_notify_users: Optional[Dict[str, Any]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('force_notify_users'), 'exclude': lambda f: f is None }}) + id: Optional[float] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('id'), 'exclude': lambda f: f is None }}) + notification_id: Optional[float] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('notification_id'), 'exclude': lambda f: f is None }}) + operations: Optional[List[shared_entityoperation.EntityOperation]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('operations'), 'exclude': lambda f: f is None }}) + organization_id: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('organization_id'), 'exclude': lambda f: f is None }}) + r"""Organization Id""" + payload: Optional[Dict[str, Any]] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('payload'), 'exclude': lambda f: f is None }}) + read_state: Optional[bool] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('read_state'), 'exclude': lambda f: f is None }}) + redirect_url: Optional[str] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('redirect_url'), 'exclude': lambda f: f is None }}) + r"""Redirect url""" + timestamp: Optional[datetime] = dataclasses.field(default=None, metadata={'dataclasses_json': { 'letter_case': utils.get_field_name('timestamp'), 'encoder': utils.datetimeisoformat(True), 'decoder': dateutil.parser.isoparse, 'exclude': lambda f: f is None }}) + + diff --git a/notification/src/epilot/models/shared/security.py b/notification/src/epilot/models/shared/security.py index cca0d01c8..bb832caeb 100755 --- a/notification/src/epilot/models/shared/security.py +++ b/notification/src/epilot/models/shared/security.py @@ -6,6 +6,6 @@ @dataclasses.dataclass class Security: + epilot_auth: str = dataclasses.field(metadata={'security': { 'scheme': True, 'type': 'http', 'sub_type': 'bearer', 'field_name': 'Authorization' }}) - epilot_auth: str = dataclasses.field(metadata={'security': { 'scheme': True, 'type': 'http', 'sub_type': 'bearer', 'field_name': 'Authorization' }}) - \ No newline at end of file + diff --git a/notification/src/epilot/notification.py b/notification/src/epilot/notification.py index 23539ff49..67b3acf2b 100755 --- a/notification/src/epilot/notification.py +++ b/notification/src/epilot/notification.py @@ -1,88 +1,86 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" -import requests as requests_http -from . import utils -from epilot.models import operations -from typing import Any, Optional +from .sdkconfiguration import SDKConfiguration +from epilot import utils +from epilot.models import errors, operations, shared +from typing import Optional class Notification: r"""Notification""" - _client: requests_http.Session - _security_client: requests_http.Session - _server_url: str - _language: str - _sdk_version: str - _gen_version: str - - def __init__(self, client: requests_http.Session, security_client: requests_http.Session, server_url: str, language: str, sdk_version: str, gen_version: str) -> None: - self._client = client - self._security_client = security_client - self._server_url = server_url - self._language = language - self._sdk_version = sdk_version - self._gen_version = gen_version - - def create_notification(self, request: dict[str, Any]) -> operations.CreateNotificationResponse: + sdk_configuration: SDKConfiguration + + def __init__(self, sdk_config: SDKConfiguration) -> None: + self.sdk_configuration = sdk_config + + + def create_notification(self, request: shared.Notification) -> operations.CreateNotificationResponse: r"""createNotification Create a message that can be displayed in the notification panel. """ - base_url = self._server_url - - url = base_url.removesuffix('/') + '/v1/notification/notifications' + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + url = base_url + '/v1/notification/notifications' headers = {} - req_content_type, data, form = utils.serialize_request_body(request, "request", 'json') + req_content_type, data, form = utils.serialize_request_body(request, "request", False, True, 'json') if req_content_type not in ('multipart/form-data', 'multipart/mixed'): headers['content-type'] = req_content_type + headers['Accept'] = '*/*' + headers['user-agent'] = self.sdk_configuration.user_agent - client = self._security_client + client = self.sdk_configuration.security_client http_res = client.request('POST', url, data=data, files=form, headers=headers) content_type = http_res.headers.get('Content-Type') res = operations.CreateNotificationResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) - if http_res.status_code == 202: - pass return res + def get_notification(self, request: operations.GetNotificationRequest) -> operations.GetNotificationResponse: r"""getNotification Get the details of a single notification. """ - base_url = self._server_url + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) url = utils.generate_url(operations.GetNotificationRequest, base_url, '/v1/notification/notifications/{id}', request) + headers = {} + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.security_client - client = self._security_client - - http_res = client.request('GET', url) + http_res = client.request('GET', url, headers=headers) content_type = http_res.headers.get('Content-Type') res = operations.GetNotificationResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) if http_res.status_code == 200: if utils.match_content_type(content_type, 'application/json'): - out = utils.unmarshal_json(http_res.text, Optional[dict[str, Any]]) + out = utils.unmarshal_json(http_res.text, Optional[shared.NotificationItem]) res.notification_item = out + else: + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) return res + def get_notifications(self, request: operations.GetNotificationsRequest) -> operations.GetNotificationsResponse: r"""getNotifications Get notifications """ - base_url = self._server_url - - url = base_url.removesuffix('/') + '/v1/notification/notifications' + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + url = base_url + '/v1/notification/notifications' + headers = {} query_params = utils.get_query_params(operations.GetNotificationsRequest, request) + headers['Accept'] = 'application/json' + headers['user-agent'] = self.sdk_configuration.user_agent - client = self._security_client + client = self.sdk_configuration.security_client - http_res = client.request('GET', url, params=query_params) + http_res = client.request('GET', url, params=query_params, headers=headers) content_type = http_res.headers.get('Content-Type') res = operations.GetNotificationsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) @@ -91,21 +89,26 @@ def get_notifications(self, request: operations.GetNotificationsRequest) -> oper if utils.match_content_type(content_type, 'application/json'): out = utils.unmarshal_json(http_res.text, Optional[operations.GetNotifications200ApplicationJSON]) res.get_notifications_200_application_json_object = out + else: + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) return res + def get_total_unread(self) -> operations.GetTotalUnreadResponse: r"""getTotalUnread Get total unread """ - base_url = self._server_url - - url = base_url.removesuffix('/') + '/v1/notification/unreads' + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + url = base_url + '/v1/notification/unreads' + headers = {} + headers['Accept'] = 'text/plain' + headers['user-agent'] = self.sdk_configuration.user_agent - client = self._security_client + client = self.sdk_configuration.security_client - http_res = client.request('GET', url) + http_res = client.request('GET', url, headers=headers) content_type = http_res.headers.get('Content-Type') res = operations.GetTotalUnreadResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) @@ -113,48 +116,52 @@ def get_total_unread(self) -> operations.GetTotalUnreadResponse: if http_res.status_code == 200: if utils.match_content_type(content_type, 'text/plain'): res.get_total_unread_200_text_plain_number = http_res.content + else: + raise errors.SDKError(f'unknown content-type received: {content_type}', http_res.status_code, http_res.text, http_res) return res + def mark_all_as_read(self) -> operations.MarkAllAsReadResponse: r"""markAllAsRead Mark all as read """ - base_url = self._server_url - - url = base_url.removesuffix('/') + '/v1/notification/notifications/mark' + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) + url = base_url + '/v1/notification/notifications/mark' + headers = {} + headers['Accept'] = '*/*' + headers['user-agent'] = self.sdk_configuration.user_agent - client = self._security_client + client = self.sdk_configuration.security_client - http_res = client.request('PUT', url) + http_res = client.request('PUT', url, headers=headers) content_type = http_res.headers.get('Content-Type') res = operations.MarkAllAsReadResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) - if http_res.status_code == 204: - pass return res + def mark_as_read(self, request: operations.MarkAsReadRequest) -> operations.MarkAsReadResponse: r"""markAsRead Mark as read """ - base_url = self._server_url + base_url = utils.template_url(*self.sdk_configuration.get_server_details()) url = utils.generate_url(operations.MarkAsReadRequest, base_url, '/v1/notification/notifications/{id}/mark', request) + headers = {} + headers['Accept'] = '*/*' + headers['user-agent'] = self.sdk_configuration.user_agent + client = self.sdk_configuration.security_client - client = self._security_client - - http_res = client.request('PUT', url) + http_res = client.request('PUT', url, headers=headers) content_type = http_res.headers.get('Content-Type') res = operations.MarkAsReadResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res) - if http_res.status_code == 204: - pass return res diff --git a/notification/src/epilot/sdk.py b/notification/src/epilot/sdk.py index eb08d693e..a897933c4 100755 --- a/notification/src/epilot/sdk.py +++ b/notification/src/epilot/sdk.py @@ -1,69 +1,57 @@ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" import requests as requests_http -from . import utils from .notification import Notification +from .sdkconfiguration import SDKConfiguration +from epilot import utils from epilot.models import shared - -SERVERS = [ - "https://notification.sls.epilot.io", -] -"""Contains the list of servers available to the SDK""" +from typing import Dict class Epilot: - r"""Notification API for epilot 360""" + r"""Notification API: Notification API for epilot 360""" notification: Notification r"""Notification""" - _client: requests_http.Session - _security_client: requests_http.Session - _server_url: str = SERVERS[0] - _language: str = "python" - _sdk_version: str = "1.2.2" - _gen_version: str = "2.16.5" + sdk_configuration: SDKConfiguration def __init__(self, security: shared.Security = None, + server_idx: int = None, server_url: str = None, - url_params: dict[str, str] = None, - client: requests_http.Session = None + url_params: Dict[str, str] = None, + client: requests_http.Session = None, + retry_config: utils.RetryConfig = None ) -> None: """Instantiates the SDK configuring it with the provided parameters. :param security: The security details required for authentication :type security: shared.Security + :param server_idx: The index of the server to use for all operations + :type server_idx: int :param server_url: The server URL to use for all operations :type server_url: str :param url_params: Parameters to optionally template the server URL with - :type url_params: dict[str, str] + :type url_params: Dict[str, str] :param client: The requests.Session HTTP client to use for all operations - :type client: requests_http.Session + :type client: requests_http.Session + :param retry_config: The utils.RetryConfig to use globally + :type retry_config: utils.RetryConfig """ - self._client = requests_http.Session() + if client is None: + client = requests_http.Session() - if server_url is not None: - if url_params is not None: - self._server_url = utils.template_url(server_url, url_params) - else: - self._server_url = server_url - - if client is not None: - self._client = client + security_client = utils.configure_security_client(client, security) - self._security_client = utils.configure_security_client(self._client, security) + if server_url is not None: + if url_params is not None: + server_url = utils.template_url(server_url, url_params) + self.sdk_configuration = SDKConfiguration(client, security_client, server_url, server_idx, retry_config=retry_config) + self._init_sdks() def _init_sdks(self): - self.notification = Notification( - self._client, - self._security_client, - self._server_url, - self._language, - self._sdk_version, - self._gen_version - ) - + self.notification = Notification(self.sdk_configuration) \ No newline at end of file diff --git a/notification/src/epilot/sdkconfiguration.py b/notification/src/epilot/sdkconfiguration.py new file mode 100755 index 000000000..0bc660ad0 --- /dev/null +++ b/notification/src/epilot/sdkconfiguration.py @@ -0,0 +1,34 @@ +"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.""" + +import requests +from dataclasses import dataclass +from typing import Dict, Tuple +from .utils.retries import RetryConfig +from .utils import utils + + +SERVERS = [ + 'https://notification.sls.epilot.io', +] +"""Contains the list of servers available to the SDK""" + +@dataclass +class SDKConfiguration: + client: requests.Session + security_client: requests.Session + server_url: str = '' + server_idx: int = 0 + language: str = 'python' + openapi_doc_version: str = '1.0.0' + sdk_version: str = '2.1.1' + gen_version: str = '2.173.0' + user_agent: str = 'speakeasy-sdk/python 2.1.1 2.173.0 1.0.0 epilot-notification' + retry_config: RetryConfig = None + + def get_server_details(self) -> Tuple[str, Dict[str, str]]: + if self.server_url: + return utils.remove_suffix(self.server_url, '/'), {} + if self.server_idx is None: + self.server_idx = 0 + + return SERVERS[self.server_idx], {} diff --git a/notification/src/epilot/utils/retries.py b/notification/src/epilot/utils/retries.py index c6251d948..25f49a1f2 100755 --- a/notification/src/epilot/utils/retries.py +++ b/notification/src/epilot/utils/retries.py @@ -2,6 +2,7 @@ import random import time +from typing import List import requests @@ -24,16 +25,17 @@ class RetryConfig: backoff: BackoffStrategy retry_connection_errors: bool - def __init__(self, strategy: str, retry_connection_errors: bool): + def __init__(self, strategy: str, backoff: BackoffStrategy, retry_connection_errors: bool): self.strategy = strategy + self.backoff = backoff self.retry_connection_errors = retry_connection_errors class Retries: config: RetryConfig - status_codes: list[str] + status_codes: List[str] - def __init__(self, config: RetryConfig, status_codes: list[str]): + def __init__(self, config: RetryConfig, status_codes: List[str]): self.config = config self.status_codes = status_codes diff --git a/notification/src/epilot/utils/utils.py b/notification/src/epilot/utils/utils.py index 9d4fba324..3ab126104 100755 --- a/notification/src/epilot/utils/utils.py +++ b/notification/src/epilot/utils/utils.py @@ -3,11 +3,14 @@ import base64 import json import re +import sys from dataclasses import Field, dataclass, fields, is_dataclass, make_dataclass from datetime import date, datetime +from decimal import Decimal from email.message import Message from enum import Enum -from typing import Any, Callable, Optional, Tuple, Union, get_args, get_origin +from typing import (Any, Callable, Dict, List, Optional, Tuple, Union, + get_args, get_origin) from xmlrpc.client import boolean import dateutil.parser @@ -17,14 +20,14 @@ class SecurityClient: client: requests.Session - query_params: dict[str, str] = {} + query_params: Dict[str, str] = {} def __init__(self, client: requests.Session): self.client = client def request(self, method, url, **kwargs): params = kwargs.get('params', {}) - kwargs["params"] = self.query_params | params + kwargs["params"] = {**self.query_params, **params} return self.client.request(method, url, **kwargs) @@ -67,7 +70,7 @@ def _parse_security_option(client: SecurityClient, option: dataclass): client, metadata, getattr(option, opt_field.name)) -def _parse_security_scheme(client: SecurityClient, scheme_metadata: dict, scheme: any): +def _parse_security_scheme(client: SecurityClient, scheme_metadata: Dict, scheme: any): scheme_type = scheme_metadata.get('type') sub_type = scheme_metadata.get('sub_type') @@ -91,7 +94,7 @@ def _parse_security_scheme(client: SecurityClient, scheme_metadata: dict, scheme client, scheme_metadata, scheme_metadata, scheme) -def _parse_security_scheme_value(client: SecurityClient, scheme_metadata: dict, security_metadata: dict, value: any): +def _parse_security_scheme_value(client: SecurityClient, scheme_metadata: Dict, security_metadata: Dict, value: any): scheme_type = scheme_metadata.get('type') sub_type = scheme_metadata.get('sub_type') @@ -112,7 +115,8 @@ def _parse_security_scheme_value(client: SecurityClient, scheme_metadata: dict, client.client.headers[header_name] = value elif scheme_type == 'http': if sub_type == 'bearer': - client.client.headers[header_name] = value + client.client.headers[header_name] = value.lower().startswith( + 'bearer ') and value or f'Bearer {value}' else: raise Exception('not supported') else: @@ -141,7 +145,8 @@ def _parse_basic_auth_scheme(client: SecurityClient, scheme: dataclass): client.client.headers['Authorization'] = f'Basic {base64.b64encode(data).decode()}' -def generate_url(clazz: type, server_url: str, path: str, path_params: dataclass, gbls: dict[str, dict[str, dict[str, Any]]] = None) -> str: +def generate_url(clazz: type, server_url: str, path: str, path_params: dataclass, + gbls: Dict[str, Dict[str, Dict[str, Any]]] = None) -> str: path_param_fields: Tuple[Field, ...] = fields(clazz) for field in path_param_fields: request_metadata = field.metadata.get('request') @@ -152,71 +157,80 @@ def generate_url(clazz: type, server_url: str, path: str, path_params: dataclass if param_metadata is None: continue - if param_metadata.get('style', 'simple') == 'simple': - param = getattr( - path_params, field.name) if path_params is not None else None - param = _populate_from_globals( - field.name, param, 'pathParam', gbls) - - if param is None: - continue - - if isinstance(param, list): - pp_vals: list[str] = [] - for pp_val in param: - if pp_val is None: - continue - pp_vals.append(_val_to_string(pp_val)) - path = path.replace( - '{' + param_metadata.get('field_name', field.name) + '}', ",".join(pp_vals), 1) - elif isinstance(param, dict): - pp_vals: list[str] = [] - for pp_key in param: - if param[pp_key] is None: - continue - if param_metadata.get('explode'): - pp_vals.append( - f"{pp_key}={_val_to_string(param[pp_key])}") - else: - pp_vals.append( - f"{pp_key},{_val_to_string(param[pp_key])}") - path = path.replace( - '{' + param_metadata.get('field_name', field.name) + '}', ",".join(pp_vals), 1) - elif not isinstance(param, (str, int, float, complex, bool)): - pp_vals: list[str] = [] - param_fields: Tuple[Field, ...] = fields(param) - for param_field in param_fields: - param_value_metadata = param_field.metadata.get( - 'path_param') - if not param_value_metadata: - continue + param = getattr( + path_params, field.name) if path_params is not None else None + param = _populate_from_globals( + field.name, param, 'pathParam', gbls) - parm_name = param_value_metadata.get( - 'field_name', field.name) + if param is None: + continue - param_field_val = getattr(param, param_field.name) - if param_field_val is None: - continue - if param_metadata.get('explode'): - pp_vals.append( - f"{parm_name}={_val_to_string(param_field_val)}") - else: - pp_vals.append( - f"{parm_name},{_val_to_string(param_field_val)}") - path = path.replace( - '{' + param_metadata.get('field_name', field.name) + '}', ",".join(pp_vals), 1) - else: + f_name = param_metadata.get("field_name", field.name) + serialization = param_metadata.get('serialization', '') + if serialization != '': + serialized_params = _get_serialized_params( + param_metadata, f_name, param) + for key, value in serialized_params.items(): path = path.replace( - '{' + param_metadata.get('field_name', field.name) + '}', _val_to_string(param), 1) + '{' + key + '}', value, 1) + else: + if param_metadata.get('style', 'simple') == 'simple': + if isinstance(param, List): + pp_vals: List[str] = [] + for pp_val in param: + if pp_val is None: + continue + pp_vals.append(_val_to_string(pp_val)) + path = path.replace( + '{' + param_metadata.get('field_name', field.name) + '}', ",".join(pp_vals), 1) + elif isinstance(param, Dict): + pp_vals: List[str] = [] + for pp_key in param: + if param[pp_key] is None: + continue + if param_metadata.get('explode'): + pp_vals.append( + f"{pp_key}={_val_to_string(param[pp_key])}") + else: + pp_vals.append( + f"{pp_key},{_val_to_string(param[pp_key])}") + path = path.replace( + '{' + param_metadata.get('field_name', field.name) + '}', ",".join(pp_vals), 1) + elif not isinstance(param, (str, int, float, complex, bool, Decimal)): + pp_vals: List[str] = [] + param_fields: Tuple[Field, ...] = fields(param) + for param_field in param_fields: + param_value_metadata = param_field.metadata.get( + 'path_param') + if not param_value_metadata: + continue + + parm_name = param_value_metadata.get( + 'field_name', field.name) + + param_field_val = getattr(param, param_field.name) + if param_field_val is None: + continue + if param_metadata.get('explode'): + pp_vals.append( + f"{parm_name}={_val_to_string(param_field_val)}") + else: + pp_vals.append( + f"{parm_name},{_val_to_string(param_field_val)}") + path = path.replace( + '{' + param_metadata.get('field_name', field.name) + '}', ",".join(pp_vals), 1) + else: + path = path.replace( + '{' + param_metadata.get('field_name', field.name) + '}', _val_to_string(param), 1) - return server_url.removesuffix("/") + path + return remove_suffix(server_url, '/') + path def is_optional(field): return get_origin(field) is Union and type(None) in get_args(field) -def template_url(url_with_params: str, params: dict[str, str]) -> str: +def template_url(url_with_params: str, params: Dict[str, str]) -> str: for key, value in params.items(): url_with_params = url_with_params.replace( '{' + key + '}', value) @@ -224,8 +238,9 @@ def template_url(url_with_params: str, params: dict[str, str]) -> str: return url_with_params -def get_query_params(clazz: type, query_params: dataclass, gbls: dict[str, dict[str, dict[str, Any]]] = None) -> dict[str, list[str]]: - params: dict[str, list[str]] = {} +def get_query_params(clazz: type, query_params: dataclass, gbls: Dict[str, Dict[str, Dict[str, Any]]] = None) -> Dict[ + str, List[str]]: + params: Dict[str, List[str]] = {} param_fields: Tuple[Field, ...] = fields(clazz) for field in param_fields: @@ -246,26 +261,33 @@ def get_query_params(clazz: type, query_params: dataclass, gbls: dict[str, dict[ f_name = metadata.get("field_name") serialization = metadata.get('serialization', '') if serialization != '': - params = params | _get_serialized_query_params( - metadata, f_name, value) + serialized_parms = _get_serialized_params(metadata, f_name, value) + for key, value in serialized_parms.items(): + if key in params: + params[key].extend(value) + else: + params[key] = [value] else: style = metadata.get('style', 'form') if style == 'deepObject': - params = params | _get_deep_object_query_params( - metadata, f_name, value) + params = {**params, **_get_deep_object_query_params( + metadata, f_name, value)} elif style == 'form': - params = params | _get_form_query_params( - metadata, f_name, value) + params = {**params, **_get_delimited_query_params( + metadata, f_name, value, ",")} + elif style == 'pipeDelimited': + params = {**params, **_get_delimited_query_params( + metadata, f_name, value, "|")} else: raise Exception('not yet implemented') return params -def get_headers(headers_params: dataclass) -> dict[str, str]: +def get_headers(headers_params: dataclass) -> Dict[str, str]: if headers_params is None: return {} - headers: dict[str, str] = {} + headers: Dict[str, str] = {} param_fields: Tuple[Field, ...] = fields(headers_params) for field in param_fields: @@ -282,8 +304,8 @@ def get_headers(headers_params: dataclass) -> dict[str, str]: return headers -def _get_serialized_query_params(metadata: dict, field_name: str, obj: any) -> dict[str, list[str]]: - params: dict[str, list[str]] = {} +def _get_serialized_params(metadata: Dict, field_name: str, obj: any) -> Dict[str, str]: + params: Dict[str, str] = {} serialization = metadata.get('serialization', '') if serialization == 'json': @@ -292,8 +314,8 @@ def _get_serialized_query_params(metadata: dict, field_name: str, obj: any) -> d return params -def _get_deep_object_query_params(metadata: dict, field_name: str, obj: any) -> dict[str, list[str]]: - params: dict[str, list[str]] = {} +def _get_deep_object_query_params(metadata: Dict, field_name: str, obj: any) -> Dict[str, List[str]]: + params: Dict[str, List[str]] = {} if obj is None: return params @@ -309,27 +331,30 @@ def _get_deep_object_query_params(metadata: dict, field_name: str, obj: any) -> if obj_val is None: continue - if isinstance(obj_val, list): + if isinstance(obj_val, List): for val in obj_val: if val is None: continue - if params.get(f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]') is None: - params[f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]'] = [ + if params.get( + f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]') is None: + params[ + f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]'] = [ ] params[ - f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]'].append(_val_to_string(val)) + f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]'].append( + _val_to_string(val)) else: params[ f'{metadata.get("field_name", field_name)}[{obj_param_metadata.get("field_name", obj_field.name)}]'] = [ _val_to_string(obj_val)] - elif isinstance(obj, dict): + elif isinstance(obj, Dict): for key, value in obj.items(): if value is None: continue - if isinstance(value, list): + if isinstance(value, List): for val in value: if val is None: continue @@ -355,28 +380,36 @@ def _get_query_param_field_name(obj_field: Field) -> str: return obj_param_metadata.get("field_name", obj_field.name) -def _get_form_query_params(metadata: dict, field_name: str, obj: any) -> dict[str, list[str]]: - return _populate_form(field_name, metadata.get("explode", True), obj, _get_query_param_field_name) +def _get_delimited_query_params(metadata: Dict, field_name: str, obj: any, delimiter: str) -> Dict[ + str, List[str]]: + return _populate_form(field_name, metadata.get("explode", True), obj, _get_query_param_field_name, delimiter) SERIALIZATION_METHOD_TO_CONTENT_TYPE = { - 'json': 'application/json', - 'form': 'application/x-www-form-urlencoded', + 'json': 'application/json', + 'form': 'application/x-www-form-urlencoded', 'multipart': 'multipart/form-data', - 'raw': 'application/octet-stream', - 'string': 'text/plain', + 'raw': 'application/octet-stream', + 'string': 'text/plain', } -def serialize_request_body(request: dataclass, request_field_name: str, serialization_method: str) -> Tuple[str, any, any]: +def serialize_request_body(request: dataclass, request_field_name: str, nullable: bool, optional: bool, serialization_method: str, encoder=None) -> Tuple[ + str, any, any]: if request is None: - return None, None, None, None + if not nullable and optional: + return None, None, None if not is_dataclass(request) or not hasattr(request, request_field_name): - return serialize_content_type(request_field_name, SERIALIZATION_METHOD_TO_CONTENT_TYPE[serialization_method], request) + return serialize_content_type(request_field_name, SERIALIZATION_METHOD_TO_CONTENT_TYPE[serialization_method], + request, encoder) request_val = getattr(request, request_field_name) + if request_val is None: + if not nullable and optional: + return None, None, None + request_fields: Tuple[Field, ...] = fields(request) request_metadata = None @@ -388,12 +421,13 @@ def serialize_request_body(request: dataclass, request_field_name: str, serializ if request_metadata is None: raise Exception('invalid request type') - return serialize_content_type(request_field_name, request_metadata.get('media_type', 'application/octet-stream'), request_val) + return serialize_content_type(request_field_name, request_metadata.get('media_type', 'application/octet-stream'), + request_val) -def serialize_content_type(field_name: str, media_type: str, request: dataclass) -> Tuple[str, any, list[list[any]]]: +def serialize_content_type(field_name: str, media_type: str, request: dataclass, encoder=None) -> Tuple[str, any, List[List[any]]]: if re.match(r'(application|text)\/.*?\+*json.*', media_type) is not None: - return media_type, marshal_json(request), None + return media_type, marshal_json(request, encoder), None if re.match(r'multipart\/.*', media_type) is not None: return serialize_multipart_form(media_type, request) if re.match(r'application\/x-www-form-urlencoded.*', media_type) is not None: @@ -407,8 +441,8 @@ def serialize_content_type(field_name: str, media_type: str, request: dataclass) f"invalid request body type {type(request)} for mediaType {media_type}") -def serialize_multipart_form(media_type: str, request: dataclass) -> Tuple[str, any, list[list[any]]]: - form: list[list[any]] = [] +def serialize_multipart_form(media_type: str, request: dataclass) -> Tuple[str, any, List[List[any]]]: + form: List[List[any]] = [] request_fields = fields(request) for field in request_fields: @@ -449,7 +483,7 @@ def serialize_multipart_form(media_type: str, request: dataclass) -> Tuple[str, else: field_name = field_metadata.get( "field_name", field.name) - if isinstance(val, list): + if isinstance(val, List): for value in val: if value is None: continue @@ -460,8 +494,8 @@ def serialize_multipart_form(media_type: str, request: dataclass) -> Tuple[str, return media_type, None, form -def serialize_dict(original: dict, explode: bool, field_name, existing: Optional[dict[str, list[str]]]) -> dict[ - str, list[str]]: +def serialize_dict(original: Dict, explode: bool, field_name, existing: Optional[Dict[str, List[str]]]) -> Dict[ + str, List[str]]: if existing is None: existing = [] @@ -481,8 +515,8 @@ def serialize_dict(original: dict, explode: bool, field_name, existing: Optional return existing -def serialize_form_data(field_name: str, data: dataclass) -> dict[str, any]: - form: dict[str, list[str]] = {} +def serialize_form_data(field_name: str, data: dataclass) -> Dict[str, any]: + form: Dict[str, List[str]] = {} if is_dataclass(data): for field in fields(data): @@ -500,12 +534,12 @@ def serialize_form_data(field_name: str, data: dataclass) -> dict[str, any]: form[field_name] = [marshal_json(val)] else: if metadata.get('style', 'form') == 'form': - form = form | _populate_form( - field_name, metadata.get('explode', True), val, _get_form_field_name) + form = {**form, **_populate_form( + field_name, metadata.get('explode', True), val, _get_form_field_name, ",")} else: raise Exception( f'Invalid form style for field {field.name}') - elif isinstance(data, dict): + elif isinstance(data, Dict): for key, value in data.items(): form[key] = [_val_to_string(value)] else: @@ -523,8 +557,9 @@ def _get_form_field_name(obj_field: Field) -> str: return obj_param_metadata.get("field_name", obj_field.name) -def _populate_form(field_name: str, explode: boolean, obj: any, get_field_name_func: Callable) -> dict[str, list[str]]: - params: dict[str, list[str]] = {} +def _populate_form(field_name: str, explode: boolean, obj: any, get_field_name_func: Callable, delimiter: str) -> \ + Dict[str, List[str]]: + params: Dict[str, List[str]] = {} if obj is None: return params @@ -546,11 +581,11 @@ def _populate_form(field_name: str, explode: boolean, obj: any, get_field_name_f params[obj_field_name] = [_val_to_string(val)] else: items.append( - f'{obj_field_name},{_val_to_string(val)}') + f'{obj_field_name}{delimiter}{_val_to_string(val)}') if len(items) > 0: - params[field_name] = [','.join(items)] - elif isinstance(obj, dict): + params[field_name] = [delimiter.join(items)] + elif isinstance(obj, Dict): items = [] for key, value in obj.items(): if value is None: @@ -559,11 +594,11 @@ def _populate_form(field_name: str, explode: boolean, obj: any, get_field_name_f if explode: params[key] = _val_to_string(value) else: - items.append(f'{key},{_val_to_string(value)}') + items.append(f'{key}{delimiter}{_val_to_string(value)}') if len(items) > 0: - params[field_name] = [','.join(items)] - elif isinstance(obj, list): + params[field_name] = [delimiter.join(items)] + elif isinstance(obj, List): items = [] for value in obj: @@ -578,7 +613,8 @@ def _populate_form(field_name: str, explode: boolean, obj: any, get_field_name_f items.append(_val_to_string(value)) if len(items) > 0: - params[field_name] = [','.join([str(item) for item in items])] + params[field_name] = [delimiter.join( + [str(item) for item in items])] else: params[field_name] = [_val_to_string(obj)] @@ -616,7 +652,7 @@ def _serialize_header(explode: bool, obj: any) -> str: if len(items) > 0: return ','.join(items) - elif isinstance(obj, dict): + elif isinstance(obj, Dict): items = [] for key, value in obj.items(): @@ -631,7 +667,7 @@ def _serialize_header(explode: bool, obj: any) -> str: if len(items) > 0: return ','.join([str(item) for item in items]) - elif isinstance(obj, list): + elif isinstance(obj, List): items = [] for value in obj: @@ -648,20 +684,28 @@ def _serialize_header(explode: bool, obj: any) -> str: return '' -def unmarshal_json(data, typ): - unmarhsal = make_dataclass('Unmarhsal', [('res', typ)], +def unmarshal_json(data, typ, decoder=None): + unmarshal = make_dataclass('Unmarshal', [('res', typ)], bases=(DataClassJsonMixin,)) json_dict = json.loads(data) - out = unmarhsal.from_dict({"res": json_dict}) - return out.res + try: + out = unmarshal.from_dict({"res": json_dict}) + except AttributeError as attr_err: + raise AttributeError( + f'unable to unmarshal {data} as {typ}') from attr_err + + return out.res if decoder is None else decoder(out.res) -def marshal_json(val): +def marshal_json(val, encoder=None): marshal = make_dataclass('Marshal', [('res', type(val))], bases=(DataClassJsonMixin,)) marshaller = marshal(res=val) json_dict = marshaller.to_dict() - return json.dumps(json_dict["res"]) + + val = json_dict["res"] if encoder is None else encoder(json_dict["res"]) + + return json.dumps(val) def match_content_type(content_type: str, pattern: str) -> boolean: @@ -705,6 +749,106 @@ def datefromisoformat(date_str: str): return dateutil.parser.parse(date_str).date() +def bigintencoder(optional: bool): + def bigintencode(val: int): + if optional and val is None: + return None + return str(val) + + return bigintencode + + +def bigintdecoder(val): + if isinstance(val, float): + raise ValueError(f"{val} is a float") + return int(val) + + +def decimalencoder(optional: bool, as_str: bool): + def decimalencode(val: Decimal): + if optional and val is None: + return None + + if as_str: + return str(val) + + return float(val) + + return decimalencode + + +def decimaldecoder(val): + return Decimal(str(val)) + + +def map_encoder(optional: bool, value_encoder: Callable): + def map_encode(val: Dict): + if optional and val is None: + return None + + encoded = {} + for key, value in val.items(): + encoded[key] = value_encoder(value) + + return encoded + + return map_encode + + +def map_decoder(value_decoder: Callable): + def map_decode(val: Dict): + decoded = {} + for key, value in val.items(): + decoded[key] = value_decoder(value) + + return decoded + + return map_decode + + +def list_encoder(optional: bool, value_encoder: Callable): + def list_encode(val: List): + if optional and val is None: + return None + + encoded = [] + for value in val: + encoded.append(value_encoder(value)) + + return encoded + + return list_encode + + +def list_decoder(value_decoder: Callable): + def list_decode(val: List): + decoded = [] + for value in val: + decoded.append(value_decoder(value)) + + return decoded + + return list_decode + +def union_encoder(all_encoders: Dict[str, Callable]): + def selective_encoder(val: any): + if type(val) in all_encoders: + return all_encoders[type(val)](val) + return val + return selective_encoder + +def union_decoder(all_decoders: List[Callable]): + def selective_decoder(val: any): + decoded = val + for decoder in all_decoders: + try: + decoded = decoder(val) + break + except (TypeError, ValueError): + continue + return decoded + return selective_decoder + def get_field_name(name): def override(_, _field_name=name): return _field_name @@ -718,12 +862,12 @@ def _val_to_string(val): if isinstance(val, datetime): return val.isoformat().replace('+00:00', 'Z') if isinstance(val, Enum): - return val.value + return str(val.value) return str(val) -def _populate_from_globals(param_name: str, value: any, param_type: str, gbls: dict[str, dict[str, dict[str, Any]]]): +def _populate_from_globals(param_name: str, value: any, param_type: str, gbls: Dict[str, Dict[str, Dict[str, Any]]]): if value is None and gbls is not None: if 'parameters' in gbls: if param_type in gbls['parameters']: @@ -733,3 +877,16 @@ def _populate_from_globals(param_name: str, value: any, param_type: str, gbls: d value = global_value return value + + +def decoder_with_discriminator(field_name): + def decode_fx(obj): + kls = getattr(sys.modules['sdk.models.shared'], obj[field_name]) + return unmarshal_json(json.dumps(obj), kls) + return decode_fx + + +def remove_suffix(input_string, suffix): + if suffix and input_string.endswith(suffix): + return input_string[:-len(suffix)] + return input_string