recoms 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- recoms-0.1.0/LICENSE +21 -0
- recoms-0.1.0/PKG-INFO +263 -0
- recoms-0.1.0/README.md +226 -0
- recoms-0.1.0/pyproject.toml +106 -0
- recoms-0.1.0/src/recoms/__init__.py +329 -0
- recoms-0.1.0/src/recoms/_default_clients.py +30 -0
- recoms-0.1.0/src/recoms/client.py +328 -0
- recoms-0.1.0/src/recoms/comments/__init__.py +34 -0
- recoms-0.1.0/src/recoms/comments/client.py +705 -0
- recoms-0.1.0/src/recoms/comments/raw_client.py +1805 -0
- recoms-0.1.0/src/recoms/comments/types/__init__.py +34 -0
- recoms-0.1.0/src/recoms/comments/types/list_comments_request_sort.py +5 -0
- recoms-0.1.0/src/recoms/core/__init__.py +135 -0
- recoms-0.1.0/src/recoms/core/api_error.py +23 -0
- recoms-0.1.0/src/recoms/core/client_wrapper.py +150 -0
- recoms-0.1.0/src/recoms/core/datetime_utils.py +70 -0
- recoms-0.1.0/src/recoms/core/file.py +67 -0
- recoms-0.1.0/src/recoms/core/force_multipart.py +18 -0
- recoms-0.1.0/src/recoms/core/http_client.py +975 -0
- recoms-0.1.0/src/recoms/core/http_response.py +63 -0
- recoms-0.1.0/src/recoms/core/http_sse/__init__.py +42 -0
- recoms-0.1.0/src/recoms/core/http_sse/_api.py +455 -0
- recoms-0.1.0/src/recoms/core/http_sse/_decoders.py +74 -0
- recoms-0.1.0/src/recoms/core/http_sse/_exceptions.py +7 -0
- recoms-0.1.0/src/recoms/core/http_sse/_models.py +17 -0
- recoms-0.1.0/src/recoms/core/idempotency.py +7 -0
- recoms-0.1.0/src/recoms/core/jsonable_encoder.py +133 -0
- recoms-0.1.0/src/recoms/core/logging.py +107 -0
- recoms-0.1.0/src/recoms/core/pagination.py +165 -0
- recoms-0.1.0/src/recoms/core/parse_error.py +36 -0
- recoms-0.1.0/src/recoms/core/pydantic_utilities.py +486 -0
- recoms-0.1.0/src/recoms/core/query_encoder.py +58 -0
- recoms-0.1.0/src/recoms/core/remove_none_from_dict.py +11 -0
- recoms-0.1.0/src/recoms/core/request_options.py +43 -0
- recoms-0.1.0/src/recoms/core/serialization.py +347 -0
- recoms-0.1.0/src/recoms/dashboard/__init__.py +4 -0
- recoms-0.1.0/src/recoms/dashboard/client.py +163 -0
- recoms-0.1.0/src/recoms/dashboard/raw_client.py +298 -0
- recoms-0.1.0/src/recoms/environment.py +7 -0
- recoms-0.1.0/src/recoms/errors/__init__.py +68 -0
- recoms-0.1.0/src/recoms/errors/bad_request_error.py +11 -0
- recoms-0.1.0/src/recoms/errors/conflict_error.py +11 -0
- recoms-0.1.0/src/recoms/errors/content_too_large_error.py +11 -0
- recoms-0.1.0/src/recoms/errors/forbidden_error.py +11 -0
- recoms-0.1.0/src/recoms/errors/internal_server_error.py +11 -0
- recoms-0.1.0/src/recoms/errors/method_not_allowed_error.py +11 -0
- recoms-0.1.0/src/recoms/errors/not_found_error.py +11 -0
- recoms-0.1.0/src/recoms/errors/payment_required_error.py +11 -0
- recoms-0.1.0/src/recoms/errors/too_many_requests_error.py +11 -0
- recoms-0.1.0/src/recoms/errors/unauthorized_error.py +11 -0
- recoms-0.1.0/src/recoms/errors/unprocessable_entity_error.py +11 -0
- recoms-0.1.0/src/recoms/me/__init__.py +40 -0
- recoms-0.1.0/src/recoms/me/client.py +82 -0
- recoms-0.1.0/src/recoms/me/comments/__init__.py +37 -0
- recoms-0.1.0/src/recoms/me/comments/client.py +288 -0
- recoms-0.1.0/src/recoms/me/comments/raw_client.py +544 -0
- recoms-0.1.0/src/recoms/me/comments/types/__init__.py +38 -0
- recoms-0.1.0/src/recoms/me/comments/types/list_comments_request_latest_revision_status_item.py +7 -0
- recoms-0.1.0/src/recoms/me/comments/types/list_comments_request_sort.py +5 -0
- recoms-0.1.0/src/recoms/me/raw_client.py +13 -0
- recoms-0.1.0/src/recoms/me/reactions/__init__.py +4 -0
- recoms-0.1.0/src/recoms/me/reactions/client.py +183 -0
- recoms-0.1.0/src/recoms/me/reactions/raw_client.py +261 -0
- recoms-0.1.0/src/recoms/project/__init__.py +42 -0
- recoms-0.1.0/src/recoms/project/client.py +730 -0
- recoms-0.1.0/src/recoms/project/comments/__init__.py +34 -0
- recoms-0.1.0/src/recoms/project/comments/client.py +364 -0
- recoms-0.1.0/src/recoms/project/comments/raw_client.py +766 -0
- recoms-0.1.0/src/recoms/project/comments/types/__init__.py +34 -0
- recoms-0.1.0/src/recoms/project/comments/types/review_comment_decision.py +5 -0
- recoms-0.1.0/src/recoms/project/moderation/__init__.py +4 -0
- recoms-0.1.0/src/recoms/project/moderation/client.py +151 -0
- recoms-0.1.0/src/recoms/project/moderation/raw_client.py +271 -0
- recoms-0.1.0/src/recoms/project/provider/__init__.py +34 -0
- recoms-0.1.0/src/recoms/project/provider/client.py +242 -0
- recoms-0.1.0/src/recoms/project/provider/raw_client.py +502 -0
- recoms-0.1.0/src/recoms/project/provider/types/__init__.py +34 -0
- recoms-0.1.0/src/recoms/project/provider/types/configure_provider_credential_intent.py +5 -0
- recoms-0.1.0/src/recoms/project/raw_client.py +1604 -0
- recoms-0.1.0/src/recoms/py.typed +0 -0
- recoms-0.1.0/src/recoms/reactions/__init__.py +34 -0
- recoms-0.1.0/src/recoms/reactions/client.py +270 -0
- recoms-0.1.0/src/recoms/reactions/raw_client.py +708 -0
- recoms-0.1.0/src/recoms/reactions/types/__init__.py +34 -0
- recoms-0.1.0/src/recoms/reactions/types/set_reaction_request_type.py +5 -0
- recoms-0.1.0/src/recoms/resources/__init__.py +4 -0
- recoms-0.1.0/src/recoms/resources/client.py +120 -0
- recoms-0.1.0/src/recoms/resources/raw_client.py +191 -0
- recoms-0.1.0/src/recoms/types/__init__.py +259 -0
- recoms-0.1.0/src/recoms/types/accessible_project.py +42 -0
- recoms-0.1.0/src/recoms/types/accessible_project_role.py +5 -0
- recoms-0.1.0/src/recoms/types/allowed_policy_test.py +17 -0
- recoms-0.1.0/src/recoms/types/analytics_bucket.py +5 -0
- recoms-0.1.0/src/recoms/types/analytics_range_preset.py +8 -0
- recoms-0.1.0/src/recoms/types/author_comment.py +162 -0
- recoms-0.1.0/src/recoms/types/author_comment_list_response.py +37 -0
- recoms-0.1.0/src/recoms/types/author_comment_response.py +24 -0
- recoms-0.1.0/src/recoms/types/author_comment_status.py +5 -0
- recoms-0.1.0/src/recoms/types/author_reaction.py +41 -0
- recoms-0.1.0/src/recoms/types/author_reaction_list_response.py +37 -0
- recoms-0.1.0/src/recoms/types/author_reaction_type.py +5 -0
- recoms-0.1.0/src/recoms/types/comment_list_response.py +37 -0
- recoms-0.1.0/src/recoms/types/comment_response.py +24 -0
- recoms-0.1.0/src/recoms/types/dashboard_comment_list_row.py +127 -0
- recoms-0.1.0/src/recoms/types/dashboard_comment_list_row_status.py +7 -0
- recoms-0.1.0/src/recoms/types/dashboard_comment_revision.py +157 -0
- recoms-0.1.0/src/recoms/types/dashboard_comment_revision_ai_outcome.py +5 -0
- recoms-0.1.0/src/recoms/types/dashboard_comment_revision_reviewed_by.py +36 -0
- recoms-0.1.0/src/recoms/types/dashboard_comment_revision_status.py +5 -0
- recoms-0.1.0/src/recoms/types/dashboard_comment_sort.py +5 -0
- recoms-0.1.0/src/recoms/types/dashboard_comment_status.py +7 -0
- recoms-0.1.0/src/recoms/types/dashboard_comments.py +55 -0
- recoms-0.1.0/src/recoms/types/dashboard_comments_queues.py +31 -0
- recoms-0.1.0/src/recoms/types/delete_comment_response.py +24 -0
- recoms-0.1.0/src/recoms/types/deleted_comment.py +32 -0
- recoms-0.1.0/src/recoms/types/deleted_comment_status.py +5 -0
- recoms-0.1.0/src/recoms/types/disallowed_policy_test.py +19 -0
- recoms-0.1.0/src/recoms/types/discussion_analytics.py +105 -0
- recoms-0.1.0/src/recoms/types/discussion_analytics_comparison.py +64 -0
- recoms-0.1.0/src/recoms/types/discussion_analytics_range.py +43 -0
- recoms-0.1.0/src/recoms/types/discussion_analytics_series_item.py +74 -0
- recoms-0.1.0/src/recoms/types/discussion_analytics_top_authors_item.py +42 -0
- recoms-0.1.0/src/recoms/types/discussion_analytics_top_resources_item.py +57 -0
- recoms-0.1.0/src/recoms/types/error_response.py +27 -0
- recoms-0.1.0/src/recoms/types/error_response_error.py +32 -0
- recoms-0.1.0/src/recoms/types/error_response_error_code.py +27 -0
- recoms-0.1.0/src/recoms/types/failed_policy_test.py +23 -0
- recoms-0.1.0/src/recoms/types/latest_revision.py +32 -0
- recoms-0.1.0/src/recoms/types/latest_revision_status.py +5 -0
- recoms-0.1.0/src/recoms/types/moderation_analytics.py +98 -0
- recoms-0.1.0/src/recoms/types/moderation_analytics_outcomes_item.py +44 -0
- recoms-0.1.0/src/recoms/types/moderation_mode.py +5 -0
- recoms-0.1.0/src/recoms/types/o_auth_availability.py +20 -0
- recoms-0.1.0/src/recoms/types/policy_test_result.py +71 -0
- recoms-0.1.0/src/recoms/types/project.py +81 -0
- recoms-0.1.0/src/recoms/types/project_action_result.py +46 -0
- recoms-0.1.0/src/recoms/types/project_action_result_status.py +5 -0
- recoms-0.1.0/src/recoms/types/project_ai_configuration.py +70 -0
- recoms-0.1.0/src/recoms/types/project_ai_configuration_availability.py +7 -0
- recoms-0.1.0/src/recoms/types/project_ai_configuration_source.py +5 -0
- recoms-0.1.0/src/recoms/types/project_analytics.py +30 -0
- recoms-0.1.0/src/recoms/types/project_billing_account.py +63 -0
- recoms-0.1.0/src/recoms/types/project_billing_account_access_state.py +5 -0
- recoms-0.1.0/src/recoms/types/project_billing_account_plan_code.py +5 -0
- recoms-0.1.0/src/recoms/types/project_comment_moderation_summary.py +57 -0
- recoms-0.1.0/src/recoms/types/project_comment_moderation_summary_comparison.py +31 -0
- recoms-0.1.0/src/recoms/types/project_comment_moderation_summary_series_item.py +39 -0
- recoms-0.1.0/src/recoms/types/project_context.py +35 -0
- recoms-0.1.0/src/recoms/types/project_membership.py +28 -0
- recoms-0.1.0/src/recoms/types/project_membership_role.py +5 -0
- recoms-0.1.0/src/recoms/types/project_review_queues.py +27 -0
- recoms-0.1.0/src/recoms/types/project_usage.py +37 -0
- recoms-0.1.0/src/recoms/types/project_usage_period.py +42 -0
- recoms-0.1.0/src/recoms/types/public_comment.py +157 -0
- recoms-0.1.0/src/recoms/types/public_comment_status.py +5 -0
- recoms-0.1.0/src/recoms/types/reaction_response.py +24 -0
- recoms-0.1.0/src/recoms/types/reaction_result.py +77 -0
- recoms-0.1.0/src/recoms/types/reaction_result_type.py +5 -0
- recoms-0.1.0/src/recoms/types/resource_comment_count.py +59 -0
- recoms-0.1.0/src/recoms/types/resource_comment_counts_response.py +23 -0
- recoms-0.1.0/src/recoms/version.py +3 -0
recoms-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Recoms.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
recoms-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: recoms
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Server-side SDK for the RECOMS comments API
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: recoms,comments,moderation,sdk
|
|
7
|
+
Requires-Python: >=3.10,<4.0
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: MacOS
|
|
11
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Operating System :: POSIX
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Provides-Extra: aiohttp
|
|
26
|
+
Requires-Dist: aiohttp (>=3.14.1,<4) ; (python_version >= "3.10") and (extra == "aiohttp")
|
|
27
|
+
Requires-Dist: httpx (>=0.21.2)
|
|
28
|
+
Requires-Dist: httpx-aiohttp (>=0.1.8,<0.2.0) ; (python_version >= "3.10") and (extra == "aiohttp")
|
|
29
|
+
Requires-Dist: pydantic (>=1.9.2)
|
|
30
|
+
Requires-Dist: pydantic-core (>=2.18.2,<3.0.0)
|
|
31
|
+
Requires-Dist: typing_extensions (>=4.0.0)
|
|
32
|
+
Project-URL: Documentation, https://recoms.tech/docs
|
|
33
|
+
Project-URL: Homepage, https://recoms.tech
|
|
34
|
+
Project-URL: Repository, https://github.com/theromanticsoul/recoms-sdk-python
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# Recoms Python Library
|
|
38
|
+
|
|
39
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Ftheromanticsoul%2Frecoms-sdk-python)
|
|
40
|
+
[](https://pypi.python.org/pypi/recoms)
|
|
41
|
+
|
|
42
|
+
Server-side client for RECOMS comments, threads, reactions and project management. Your backend owns end-user authentication; keep project API keys on your server.
|
|
43
|
+
|
|
44
|
+
## Table of Contents
|
|
45
|
+
|
|
46
|
+
- [Documentation](#documentation)
|
|
47
|
+
- [Installation](#installation)
|
|
48
|
+
- [Reference](#reference)
|
|
49
|
+
- [Usage](#usage)
|
|
50
|
+
- [Environments](#environments)
|
|
51
|
+
- [Async Client](#async-client)
|
|
52
|
+
- [Exception Handling](#exception-handling)
|
|
53
|
+
- [Pagination](#pagination)
|
|
54
|
+
- [Advanced](#advanced)
|
|
55
|
+
- [Access Raw Response Data](#access-raw-response-data)
|
|
56
|
+
- [Retries](#retries)
|
|
57
|
+
- [Timeouts](#timeouts)
|
|
58
|
+
- [Custom Client](#custom-client)
|
|
59
|
+
- [Contributing](#contributing)
|
|
60
|
+
|
|
61
|
+
## Documentation
|
|
62
|
+
|
|
63
|
+
API reference documentation is available [here](https://recoms.tech/docs).
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
pip install recoms
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Reference
|
|
72
|
+
|
|
73
|
+
A full reference for this library is available [here](https://github.com/theromanticsoul/recoms-sdk-python/blob/HEAD/./reference.md).
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
Instantiate and use the client with the following:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from recoms import RecomsClient
|
|
81
|
+
|
|
82
|
+
client = RecomsClient(
|
|
83
|
+
token="<token>",
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
client.comments.create(
|
|
87
|
+
idempotency_key="0198a6ec-9e00-7000-8000-000000000010",
|
|
88
|
+
resource_id="article:postgresql-cursors",
|
|
89
|
+
author_user_id="usr_42",
|
|
90
|
+
content="This explanation of **cursor pagination** was helpful.",
|
|
91
|
+
)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Environments
|
|
95
|
+
|
|
96
|
+
This SDK allows you to configure different environments for API requests.
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from recoms import RecomsClient
|
|
100
|
+
from recoms.environment import RecomsClientEnvironment
|
|
101
|
+
|
|
102
|
+
client = RecomsClient(
|
|
103
|
+
environment=RecomsClientEnvironment.DEFAULT,
|
|
104
|
+
)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Async Client
|
|
108
|
+
|
|
109
|
+
The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
import asyncio
|
|
113
|
+
|
|
114
|
+
from recoms import AsyncRecomsClient
|
|
115
|
+
|
|
116
|
+
client = AsyncRecomsClient(
|
|
117
|
+
token="<token>",
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
async def main() -> None:
|
|
122
|
+
await client.comments.create(
|
|
123
|
+
idempotency_key="0198a6ec-9e00-7000-8000-000000000010",
|
|
124
|
+
resource_id="article:postgresql-cursors",
|
|
125
|
+
author_user_id="usr_42",
|
|
126
|
+
content="This explanation of **cursor pagination** was helpful.",
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
asyncio.run(main())
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Exception Handling
|
|
134
|
+
|
|
135
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
136
|
+
will be thrown.
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from recoms.core.api_error import ApiError
|
|
140
|
+
|
|
141
|
+
try:
|
|
142
|
+
client.comments.create(...)
|
|
143
|
+
except ApiError as e:
|
|
144
|
+
print(e.status_code)
|
|
145
|
+
print(e.body)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Pagination
|
|
149
|
+
|
|
150
|
+
Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used as generators for the underlying object.
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from recoms import RecomsClient
|
|
154
|
+
|
|
155
|
+
client = RecomsClient(
|
|
156
|
+
token="<token>",
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
client.comments.list(
|
|
160
|
+
resource_id="article:postgresql-cursors",
|
|
161
|
+
limit=20,
|
|
162
|
+
)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
# You can also iterate through pages and access the typed response per page
|
|
167
|
+
pager = client.comments.list(...)
|
|
168
|
+
for page in pager.iter_pages():
|
|
169
|
+
print(page.response) # access the typed response for each page
|
|
170
|
+
for item in page:
|
|
171
|
+
print(item)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Advanced
|
|
175
|
+
|
|
176
|
+
### Access Raw Response Data
|
|
177
|
+
|
|
178
|
+
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
|
|
179
|
+
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from recoms import RecomsClient
|
|
183
|
+
|
|
184
|
+
client = RecomsClient(...)
|
|
185
|
+
response = client.comments.with_raw_response.create(...)
|
|
186
|
+
print(response.headers) # access the response headers
|
|
187
|
+
print(response.status_code) # access the response status code
|
|
188
|
+
print(response.data) # access the underlying object
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Retries
|
|
192
|
+
|
|
193
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
194
|
+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
195
|
+
retry limit (default: 2).
|
|
196
|
+
|
|
197
|
+
Which status codes are retried depends on the `retryStatusCodes` generator configuration:
|
|
198
|
+
|
|
199
|
+
**`legacy`** (current default): retries on
|
|
200
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
201
|
+
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
|
|
202
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
203
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)
|
|
204
|
+
|
|
205
|
+
**`recommended`**: retries on
|
|
206
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
207
|
+
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
|
|
208
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
209
|
+
- [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
|
|
210
|
+
- [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
|
|
211
|
+
- [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)
|
|
212
|
+
|
|
213
|
+
Use the `max_retries` request option to configure this behavior.
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
client.comments.create(..., request_options={
|
|
217
|
+
"max_retries": 1
|
|
218
|
+
})
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Timeouts
|
|
222
|
+
|
|
223
|
+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
from recoms import RecomsClient
|
|
227
|
+
|
|
228
|
+
client = RecomsClient(..., timeout=20.0)
|
|
229
|
+
|
|
230
|
+
# Override timeout for a specific method
|
|
231
|
+
client.comments.create(..., request_options={
|
|
232
|
+
"timeout": 1
|
|
233
|
+
})
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Custom Client
|
|
237
|
+
|
|
238
|
+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
|
|
239
|
+
and transports.
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
import httpx
|
|
243
|
+
from recoms import RecomsClient
|
|
244
|
+
|
|
245
|
+
client = RecomsClient(
|
|
246
|
+
...,
|
|
247
|
+
httpx_client=httpx.Client(
|
|
248
|
+
proxy="http://my.test.proxy.example.com",
|
|
249
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
250
|
+
),
|
|
251
|
+
)
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Contributing
|
|
255
|
+
|
|
256
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
257
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
258
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
259
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
260
|
+
an issue first to discuss with us!
|
|
261
|
+
|
|
262
|
+
On the other hand, contributions to the README are always very welcome!
|
|
263
|
+
|
recoms-0.1.0/README.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# Recoms Python Library
|
|
2
|
+
|
|
3
|
+
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Ftheromanticsoul%2Frecoms-sdk-python)
|
|
4
|
+
[](https://pypi.python.org/pypi/recoms)
|
|
5
|
+
|
|
6
|
+
Server-side client for RECOMS comments, threads, reactions and project management. Your backend owns end-user authentication; keep project API keys on your server.
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Documentation](#documentation)
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Reference](#reference)
|
|
13
|
+
- [Usage](#usage)
|
|
14
|
+
- [Environments](#environments)
|
|
15
|
+
- [Async Client](#async-client)
|
|
16
|
+
- [Exception Handling](#exception-handling)
|
|
17
|
+
- [Pagination](#pagination)
|
|
18
|
+
- [Advanced](#advanced)
|
|
19
|
+
- [Access Raw Response Data](#access-raw-response-data)
|
|
20
|
+
- [Retries](#retries)
|
|
21
|
+
- [Timeouts](#timeouts)
|
|
22
|
+
- [Custom Client](#custom-client)
|
|
23
|
+
- [Contributing](#contributing)
|
|
24
|
+
|
|
25
|
+
## Documentation
|
|
26
|
+
|
|
27
|
+
API reference documentation is available [here](https://recoms.tech/docs).
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
pip install recoms
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Reference
|
|
36
|
+
|
|
37
|
+
A full reference for this library is available [here](https://github.com/theromanticsoul/recoms-sdk-python/blob/HEAD/./reference.md).
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Instantiate and use the client with the following:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from recoms import RecomsClient
|
|
45
|
+
|
|
46
|
+
client = RecomsClient(
|
|
47
|
+
token="<token>",
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
client.comments.create(
|
|
51
|
+
idempotency_key="0198a6ec-9e00-7000-8000-000000000010",
|
|
52
|
+
resource_id="article:postgresql-cursors",
|
|
53
|
+
author_user_id="usr_42",
|
|
54
|
+
content="This explanation of **cursor pagination** was helpful.",
|
|
55
|
+
)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Environments
|
|
59
|
+
|
|
60
|
+
This SDK allows you to configure different environments for API requests.
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from recoms import RecomsClient
|
|
64
|
+
from recoms.environment import RecomsClientEnvironment
|
|
65
|
+
|
|
66
|
+
client = RecomsClient(
|
|
67
|
+
environment=RecomsClientEnvironment.DEFAULT,
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Async Client
|
|
72
|
+
|
|
73
|
+
The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
import asyncio
|
|
77
|
+
|
|
78
|
+
from recoms import AsyncRecomsClient
|
|
79
|
+
|
|
80
|
+
client = AsyncRecomsClient(
|
|
81
|
+
token="<token>",
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
async def main() -> None:
|
|
86
|
+
await client.comments.create(
|
|
87
|
+
idempotency_key="0198a6ec-9e00-7000-8000-000000000010",
|
|
88
|
+
resource_id="article:postgresql-cursors",
|
|
89
|
+
author_user_id="usr_42",
|
|
90
|
+
content="This explanation of **cursor pagination** was helpful.",
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
asyncio.run(main())
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Exception Handling
|
|
98
|
+
|
|
99
|
+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
100
|
+
will be thrown.
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from recoms.core.api_error import ApiError
|
|
104
|
+
|
|
105
|
+
try:
|
|
106
|
+
client.comments.create(...)
|
|
107
|
+
except ApiError as e:
|
|
108
|
+
print(e.status_code)
|
|
109
|
+
print(e.body)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Pagination
|
|
113
|
+
|
|
114
|
+
Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used as generators for the underlying object.
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from recoms import RecomsClient
|
|
118
|
+
|
|
119
|
+
client = RecomsClient(
|
|
120
|
+
token="<token>",
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
client.comments.list(
|
|
124
|
+
resource_id="article:postgresql-cursors",
|
|
125
|
+
limit=20,
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
# You can also iterate through pages and access the typed response per page
|
|
131
|
+
pager = client.comments.list(...)
|
|
132
|
+
for page in pager.iter_pages():
|
|
133
|
+
print(page.response) # access the typed response for each page
|
|
134
|
+
for item in page:
|
|
135
|
+
print(item)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Advanced
|
|
139
|
+
|
|
140
|
+
### Access Raw Response Data
|
|
141
|
+
|
|
142
|
+
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
|
|
143
|
+
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from recoms import RecomsClient
|
|
147
|
+
|
|
148
|
+
client = RecomsClient(...)
|
|
149
|
+
response = client.comments.with_raw_response.create(...)
|
|
150
|
+
print(response.headers) # access the response headers
|
|
151
|
+
print(response.status_code) # access the response status code
|
|
152
|
+
print(response.data) # access the underlying object
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Retries
|
|
156
|
+
|
|
157
|
+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
158
|
+
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
159
|
+
retry limit (default: 2).
|
|
160
|
+
|
|
161
|
+
Which status codes are retried depends on the `retryStatusCodes` generator configuration:
|
|
162
|
+
|
|
163
|
+
**`legacy`** (current default): retries on
|
|
164
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
165
|
+
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
|
|
166
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
167
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)
|
|
168
|
+
|
|
169
|
+
**`recommended`**: retries on
|
|
170
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
171
|
+
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
|
|
172
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
173
|
+
- [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
|
|
174
|
+
- [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
|
|
175
|
+
- [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)
|
|
176
|
+
|
|
177
|
+
Use the `max_retries` request option to configure this behavior.
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
client.comments.create(..., request_options={
|
|
181
|
+
"max_retries": 1
|
|
182
|
+
})
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Timeouts
|
|
186
|
+
|
|
187
|
+
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
from recoms import RecomsClient
|
|
191
|
+
|
|
192
|
+
client = RecomsClient(..., timeout=20.0)
|
|
193
|
+
|
|
194
|
+
# Override timeout for a specific method
|
|
195
|
+
client.comments.create(..., request_options={
|
|
196
|
+
"timeout": 1
|
|
197
|
+
})
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Custom Client
|
|
201
|
+
|
|
202
|
+
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
|
|
203
|
+
and transports.
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
import httpx
|
|
207
|
+
from recoms import RecomsClient
|
|
208
|
+
|
|
209
|
+
client = RecomsClient(
|
|
210
|
+
...,
|
|
211
|
+
httpx_client=httpx.Client(
|
|
212
|
+
proxy="http://my.test.proxy.example.com",
|
|
213
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
214
|
+
),
|
|
215
|
+
)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Contributing
|
|
219
|
+
|
|
220
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
221
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
|
222
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
223
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
224
|
+
an issue first to discuss with us!
|
|
225
|
+
|
|
226
|
+
On the other hand, contributions to the README are always very welcome!
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "recoms"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
license = "MIT"
|
|
5
|
+
license-files = ["LICENSE"]
|
|
6
|
+
|
|
7
|
+
[tool.poetry]
|
|
8
|
+
name = "recoms"
|
|
9
|
+
version = "v0.1.0"
|
|
10
|
+
description = "Server-side SDK for the RECOMS comments API"
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
authors = []
|
|
13
|
+
keywords = [
|
|
14
|
+
"recoms",
|
|
15
|
+
"comments",
|
|
16
|
+
"moderation",
|
|
17
|
+
"sdk"
|
|
18
|
+
]
|
|
19
|
+
license = "MIT"
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Intended Audience :: Developers",
|
|
22
|
+
"Programming Language :: Python",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Programming Language :: Python :: 3.13",
|
|
28
|
+
"Programming Language :: Python :: 3.14",
|
|
29
|
+
"Programming Language :: Python :: 3.15",
|
|
30
|
+
"Operating System :: OS Independent",
|
|
31
|
+
"Operating System :: POSIX",
|
|
32
|
+
"Operating System :: MacOS",
|
|
33
|
+
"Operating System :: POSIX :: Linux",
|
|
34
|
+
"Operating System :: Microsoft :: Windows",
|
|
35
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
36
|
+
"Typing :: Typed"
|
|
37
|
+
]
|
|
38
|
+
packages = [
|
|
39
|
+
{ include = "recoms", from = "src"}
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[tool.poetry.urls]
|
|
43
|
+
Documentation = 'https://recoms.tech/docs'
|
|
44
|
+
Homepage = 'https://recoms.tech'
|
|
45
|
+
Repository = 'https://github.com/theromanticsoul/recoms-sdk-python'
|
|
46
|
+
|
|
47
|
+
[tool.poetry.dependencies]
|
|
48
|
+
python = "^3.10"
|
|
49
|
+
aiohttp = { version = ">=3.14.1,<4", optional = true, python = ">=3.10"}
|
|
50
|
+
httpx = ">=0.21.2"
|
|
51
|
+
httpx-aiohttp = { version = "^0.1.8", optional = true, python = ">=3.10"}
|
|
52
|
+
pydantic = ">= 1.9.2"
|
|
53
|
+
pydantic-core = ">=2.18.2,<3.0.0"
|
|
54
|
+
typing_extensions = ">= 4.0.0"
|
|
55
|
+
|
|
56
|
+
[tool.poetry.group.dev.dependencies]
|
|
57
|
+
mypy = "==1.13.0"
|
|
58
|
+
pytest = "^9.0.3"
|
|
59
|
+
pytest-asyncio = "^1.0.0"
|
|
60
|
+
pytest-xdist = "^3.6.1"
|
|
61
|
+
python-dateutil = "^2.9.0"
|
|
62
|
+
types-python-dateutil = "^2.9.0.20240316"
|
|
63
|
+
urllib3 = ">=2.6.3,<3.0.0"
|
|
64
|
+
ruff = "==0.11.5"
|
|
65
|
+
|
|
66
|
+
[tool.pytest.ini_options]
|
|
67
|
+
testpaths = [ "tests" ]
|
|
68
|
+
asyncio_mode = "auto"
|
|
69
|
+
norecursedirs = [ "src" ]
|
|
70
|
+
markers = [
|
|
71
|
+
"aiohttp: tests that require httpx_aiohttp to be installed",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
[tool.mypy]
|
|
75
|
+
plugins = ["pydantic.mypy"]
|
|
76
|
+
|
|
77
|
+
[tool.ruff]
|
|
78
|
+
line-length = 120
|
|
79
|
+
|
|
80
|
+
[tool.ruff.lint]
|
|
81
|
+
select = [
|
|
82
|
+
"E", # pycodestyle errors
|
|
83
|
+
"F", # pyflakes
|
|
84
|
+
"I", # isort
|
|
85
|
+
]
|
|
86
|
+
ignore = [
|
|
87
|
+
"E402", # Module level import not at top of file
|
|
88
|
+
"E501", # Line too long
|
|
89
|
+
"E711", # Comparison to `None` should be `cond is not None`
|
|
90
|
+
"E712", # Avoid equality comparisons to `True`; use `if ...:` checks
|
|
91
|
+
"E721", # Use `is` and `is not` for type comparisons, or `isinstance()` for insinstance checks
|
|
92
|
+
"E722", # Do not use bare `except`
|
|
93
|
+
"E731", # Do not assign a `lambda` expression, use a `def`
|
|
94
|
+
"F821", # Undefined name
|
|
95
|
+
"F841" # Local variable ... is assigned to but never used
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
[tool.ruff.lint.isort]
|
|
99
|
+
section-order = ["future", "standard-library", "third-party", "first-party"]
|
|
100
|
+
|
|
101
|
+
[build-system]
|
|
102
|
+
requires = ["poetry-core"]
|
|
103
|
+
build-backend = "poetry.core.masonry.api"
|
|
104
|
+
|
|
105
|
+
[tool.poetry.extras]
|
|
106
|
+
aiohttp=["aiohttp", "httpx-aiohttp"]
|