moderation_api 1.0.0__py3-none-any.whl

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.
Files changed (93) hide show
  1. moderation_api/__init__.py +102 -0
  2. moderation_api/_base_client.py +1995 -0
  3. moderation_api/_client.py +454 -0
  4. moderation_api/_compat.py +219 -0
  5. moderation_api/_constants.py +14 -0
  6. moderation_api/_exceptions.py +108 -0
  7. moderation_api/_files.py +123 -0
  8. moderation_api/_models.py +857 -0
  9. moderation_api/_qs.py +150 -0
  10. moderation_api/_resource.py +43 -0
  11. moderation_api/_response.py +832 -0
  12. moderation_api/_streaming.py +333 -0
  13. moderation_api/_types.py +260 -0
  14. moderation_api/_utils/__init__.py +64 -0
  15. moderation_api/_utils/_compat.py +45 -0
  16. moderation_api/_utils/_datetime_parse.py +136 -0
  17. moderation_api/_utils/_logs.py +25 -0
  18. moderation_api/_utils/_proxy.py +65 -0
  19. moderation_api/_utils/_reflection.py +42 -0
  20. moderation_api/_utils/_resources_proxy.py +24 -0
  21. moderation_api/_utils/_streams.py +12 -0
  22. moderation_api/_utils/_sync.py +58 -0
  23. moderation_api/_utils/_transform.py +457 -0
  24. moderation_api/_utils/_typing.py +156 -0
  25. moderation_api/_utils/_utils.py +421 -0
  26. moderation_api/_version.py +4 -0
  27. moderation_api/lib/.keep +4 -0
  28. moderation_api/py.typed +0 -0
  29. moderation_api/resources/__init__.py +103 -0
  30. moderation_api/resources/account.py +135 -0
  31. moderation_api/resources/actions/__init__.py +33 -0
  32. moderation_api/resources/actions/actions.py +810 -0
  33. moderation_api/resources/actions/execute.py +354 -0
  34. moderation_api/resources/auth.py +204 -0
  35. moderation_api/resources/authors.py +714 -0
  36. moderation_api/resources/content.py +244 -0
  37. moderation_api/resources/queue/__init__.py +33 -0
  38. moderation_api/resources/queue/items.py +445 -0
  39. moderation_api/resources/queue/queue.py +302 -0
  40. moderation_api/resources/wordlist/__init__.py +33 -0
  41. moderation_api/resources/wordlist/wordlist.py +470 -0
  42. moderation_api/resources/wordlist/words.py +274 -0
  43. moderation_api/types/__init__.py +35 -0
  44. moderation_api/types/account_list_response.py +31 -0
  45. moderation_api/types/action_create_params.py +94 -0
  46. moderation_api/types/action_create_response.py +82 -0
  47. moderation_api/types/action_delete_response.py +13 -0
  48. moderation_api/types/action_list_params.py +13 -0
  49. moderation_api/types/action_list_response.py +113 -0
  50. moderation_api/types/action_retrieve_response.py +105 -0
  51. moderation_api/types/action_update_params.py +94 -0
  52. moderation_api/types/action_update_response.py +82 -0
  53. moderation_api/types/actions/__init__.py +8 -0
  54. moderation_api/types/actions/execute_execute_by_id_params.py +24 -0
  55. moderation_api/types/actions/execute_execute_by_id_response.py +20 -0
  56. moderation_api/types/actions/execute_execute_params.py +30 -0
  57. moderation_api/types/actions/execute_execute_response.py +10 -0
  58. moderation_api/types/auth_create_response.py +16 -0
  59. moderation_api/types/auth_retrieve_response.py +13 -0
  60. moderation_api/types/author_create_params.py +57 -0
  61. moderation_api/types/author_create_response.py +120 -0
  62. moderation_api/types/author_delete_response.py +9 -0
  63. moderation_api/types/author_list_params.py +40 -0
  64. moderation_api/types/author_list_response.py +147 -0
  65. moderation_api/types/author_retrieve_response.py +120 -0
  66. moderation_api/types/author_update_params.py +54 -0
  67. moderation_api/types/author_update_response.py +120 -0
  68. moderation_api/types/content_submit_params.py +352 -0
  69. moderation_api/types/content_submit_response.py +269 -0
  70. moderation_api/types/queue/__init__.py +10 -0
  71. moderation_api/types/queue/item_list_params.py +36 -0
  72. moderation_api/types/queue/item_list_response.py +90 -0
  73. moderation_api/types/queue/item_resolve_params.py +15 -0
  74. moderation_api/types/queue/item_resolve_response.py +19 -0
  75. moderation_api/types/queue/item_unresolve_params.py +15 -0
  76. moderation_api/types/queue/item_unresolve_response.py +17 -0
  77. moderation_api/types/queue_get_stats_params.py +14 -0
  78. moderation_api/types/queue_get_stats_response.py +110 -0
  79. moderation_api/types/queue_retrieve_response.py +64 -0
  80. moderation_api/types/wordlist/__init__.py +8 -0
  81. moderation_api/types/wordlist/word_add_params.py +14 -0
  82. moderation_api/types/wordlist/word_add_response.py +20 -0
  83. moderation_api/types/wordlist/word_remove_params.py +14 -0
  84. moderation_api/types/wordlist/word_remove_response.py +20 -0
  85. moderation_api/types/wordlist_get_embedding_status_response.py +18 -0
  86. moderation_api/types/wordlist_list_response.py +30 -0
  87. moderation_api/types/wordlist_retrieve_response.py +32 -0
  88. moderation_api/types/wordlist_update_params.py +29 -0
  89. moderation_api/types/wordlist_update_response.py +32 -0
  90. moderation_api-1.0.0.dist-info/METADATA +458 -0
  91. moderation_api-1.0.0.dist-info/RECORD +93 -0
  92. moderation_api-1.0.0.dist-info/WHEEL +4 -0
  93. moderation_api-1.0.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,470 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ import httpx
6
+
7
+ from .words import (
8
+ WordsResource,
9
+ AsyncWordsResource,
10
+ WordsResourceWithRawResponse,
11
+ AsyncWordsResourceWithRawResponse,
12
+ WordsResourceWithStreamingResponse,
13
+ AsyncWordsResourceWithStreamingResponse,
14
+ )
15
+ from ...types import wordlist_update_params
16
+ from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
17
+ from ..._utils import maybe_transform, async_maybe_transform
18
+ from ..._compat import cached_property
19
+ from ..._resource import SyncAPIResource, AsyncAPIResource
20
+ from ..._response import (
21
+ to_raw_response_wrapper,
22
+ to_streamed_response_wrapper,
23
+ async_to_raw_response_wrapper,
24
+ async_to_streamed_response_wrapper,
25
+ )
26
+ from ..._base_client import make_request_options
27
+ from ...types.wordlist_list_response import WordlistListResponse
28
+ from ...types.wordlist_update_response import WordlistUpdateResponse
29
+ from ...types.wordlist_retrieve_response import WordlistRetrieveResponse
30
+ from ...types.wordlist_get_embedding_status_response import WordlistGetEmbeddingStatusResponse
31
+
32
+ __all__ = ["WordlistResource", "AsyncWordlistResource"]
33
+
34
+
35
+ class WordlistResource(SyncAPIResource):
36
+ @cached_property
37
+ def words(self) -> WordsResource:
38
+ return WordsResource(self._client)
39
+
40
+ @cached_property
41
+ def with_raw_response(self) -> WordlistResourceWithRawResponse:
42
+ """
43
+ This property can be used as a prefix for any HTTP method call to return
44
+ the raw response object instead of the parsed content.
45
+
46
+ For more information, see https://www.github.com/moderation-api/sdk-python#accessing-raw-response-data-eg-headers
47
+ """
48
+ return WordlistResourceWithRawResponse(self)
49
+
50
+ @cached_property
51
+ def with_streaming_response(self) -> WordlistResourceWithStreamingResponse:
52
+ """
53
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
54
+
55
+ For more information, see https://www.github.com/moderation-api/sdk-python#with_streaming_response
56
+ """
57
+ return WordlistResourceWithStreamingResponse(self)
58
+
59
+ def retrieve(
60
+ self,
61
+ id: str,
62
+ *,
63
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
64
+ # The extra values given here take precedence over values defined on the client or passed to this method.
65
+ extra_headers: Headers | None = None,
66
+ extra_query: Query | None = None,
67
+ extra_body: Body | None = None,
68
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
69
+ ) -> WordlistRetrieveResponse:
70
+ """
71
+ Get a specific wordlist by ID
72
+
73
+ Args:
74
+ id: ID of the wordlist to get
75
+
76
+ extra_headers: Send extra headers
77
+
78
+ extra_query: Add additional query parameters to the request
79
+
80
+ extra_body: Add additional JSON properties to the request
81
+
82
+ timeout: Override the client-level default timeout for this request, in seconds
83
+ """
84
+ if not id:
85
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
86
+ return self._get(
87
+ f"/wordlist/{id}",
88
+ options=make_request_options(
89
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
90
+ ),
91
+ cast_to=WordlistRetrieveResponse,
92
+ )
93
+
94
+ def update(
95
+ self,
96
+ id: str,
97
+ *,
98
+ description: str | Omit = omit,
99
+ key: str | Omit = omit,
100
+ name: str | Omit = omit,
101
+ strict: bool | Omit = omit,
102
+ words: SequenceNotStr[str] | Omit = omit,
103
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
104
+ # The extra values given here take precedence over values defined on the client or passed to this method.
105
+ extra_headers: Headers | None = None,
106
+ extra_query: Query | None = None,
107
+ extra_body: Body | None = None,
108
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
109
+ ) -> WordlistUpdateResponse:
110
+ """
111
+ Update a wordlist
112
+
113
+ Args:
114
+ id: ID of the wordlist to update
115
+
116
+ description: New description for the wordlist
117
+
118
+ key: New key for the wordlist
119
+
120
+ name: New name for the wordlist
121
+
122
+ strict: Deprecated. Now using threshold in project settings.
123
+
124
+ words: New words for the wordlist. Replace the existing words with these new ones.
125
+ Duplicate words will be ignored.
126
+
127
+ extra_headers: Send extra headers
128
+
129
+ extra_query: Add additional query parameters to the request
130
+
131
+ extra_body: Add additional JSON properties to the request
132
+
133
+ timeout: Override the client-level default timeout for this request, in seconds
134
+ """
135
+ if not id:
136
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
137
+ return self._put(
138
+ f"/wordlist/{id}",
139
+ body=maybe_transform(
140
+ {
141
+ "description": description,
142
+ "key": key,
143
+ "name": name,
144
+ "strict": strict,
145
+ "words": words,
146
+ },
147
+ wordlist_update_params.WordlistUpdateParams,
148
+ ),
149
+ options=make_request_options(
150
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
151
+ ),
152
+ cast_to=WordlistUpdateResponse,
153
+ )
154
+
155
+ def list(
156
+ self,
157
+ *,
158
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
159
+ # The extra values given here take precedence over values defined on the client or passed to this method.
160
+ extra_headers: Headers | None = None,
161
+ extra_query: Query | None = None,
162
+ extra_body: Body | None = None,
163
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
164
+ ) -> WordlistListResponse:
165
+ """List all wordlists for the authenticated organization"""
166
+ return self._get(
167
+ "/wordlist",
168
+ options=make_request_options(
169
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
170
+ ),
171
+ cast_to=WordlistListResponse,
172
+ )
173
+
174
+ def get_embedding_status(
175
+ self,
176
+ id: str,
177
+ *,
178
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
179
+ # The extra values given here take precedence over values defined on the client or passed to this method.
180
+ extra_headers: Headers | None = None,
181
+ extra_query: Query | None = None,
182
+ extra_body: Body | None = None,
183
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
184
+ ) -> WordlistGetEmbeddingStatusResponse:
185
+ """
186
+ Get the current embedding progress status for a wordlist
187
+
188
+ Args:
189
+ id: ID of the wordlist to check embedding status for
190
+
191
+ extra_headers: Send extra headers
192
+
193
+ extra_query: Add additional query parameters to the request
194
+
195
+ extra_body: Add additional JSON properties to the request
196
+
197
+ timeout: Override the client-level default timeout for this request, in seconds
198
+ """
199
+ if not id:
200
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
201
+ return self._get(
202
+ f"/wordlist/{id}/embedding-status",
203
+ options=make_request_options(
204
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
205
+ ),
206
+ cast_to=WordlistGetEmbeddingStatusResponse,
207
+ )
208
+
209
+
210
+ class AsyncWordlistResource(AsyncAPIResource):
211
+ @cached_property
212
+ def words(self) -> AsyncWordsResource:
213
+ return AsyncWordsResource(self._client)
214
+
215
+ @cached_property
216
+ def with_raw_response(self) -> AsyncWordlistResourceWithRawResponse:
217
+ """
218
+ This property can be used as a prefix for any HTTP method call to return
219
+ the raw response object instead of the parsed content.
220
+
221
+ For more information, see https://www.github.com/moderation-api/sdk-python#accessing-raw-response-data-eg-headers
222
+ """
223
+ return AsyncWordlistResourceWithRawResponse(self)
224
+
225
+ @cached_property
226
+ def with_streaming_response(self) -> AsyncWordlistResourceWithStreamingResponse:
227
+ """
228
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
229
+
230
+ For more information, see https://www.github.com/moderation-api/sdk-python#with_streaming_response
231
+ """
232
+ return AsyncWordlistResourceWithStreamingResponse(self)
233
+
234
+ async def retrieve(
235
+ self,
236
+ id: str,
237
+ *,
238
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
239
+ # The extra values given here take precedence over values defined on the client or passed to this method.
240
+ extra_headers: Headers | None = None,
241
+ extra_query: Query | None = None,
242
+ extra_body: Body | None = None,
243
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
244
+ ) -> WordlistRetrieveResponse:
245
+ """
246
+ Get a specific wordlist by ID
247
+
248
+ Args:
249
+ id: ID of the wordlist to get
250
+
251
+ extra_headers: Send extra headers
252
+
253
+ extra_query: Add additional query parameters to the request
254
+
255
+ extra_body: Add additional JSON properties to the request
256
+
257
+ timeout: Override the client-level default timeout for this request, in seconds
258
+ """
259
+ if not id:
260
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
261
+ return await self._get(
262
+ f"/wordlist/{id}",
263
+ options=make_request_options(
264
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
265
+ ),
266
+ cast_to=WordlistRetrieveResponse,
267
+ )
268
+
269
+ async def update(
270
+ self,
271
+ id: str,
272
+ *,
273
+ description: str | Omit = omit,
274
+ key: str | Omit = omit,
275
+ name: str | Omit = omit,
276
+ strict: bool | Omit = omit,
277
+ words: SequenceNotStr[str] | Omit = omit,
278
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
279
+ # The extra values given here take precedence over values defined on the client or passed to this method.
280
+ extra_headers: Headers | None = None,
281
+ extra_query: Query | None = None,
282
+ extra_body: Body | None = None,
283
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
284
+ ) -> WordlistUpdateResponse:
285
+ """
286
+ Update a wordlist
287
+
288
+ Args:
289
+ id: ID of the wordlist to update
290
+
291
+ description: New description for the wordlist
292
+
293
+ key: New key for the wordlist
294
+
295
+ name: New name for the wordlist
296
+
297
+ strict: Deprecated. Now using threshold in project settings.
298
+
299
+ words: New words for the wordlist. Replace the existing words with these new ones.
300
+ Duplicate words will be ignored.
301
+
302
+ extra_headers: Send extra headers
303
+
304
+ extra_query: Add additional query parameters to the request
305
+
306
+ extra_body: Add additional JSON properties to the request
307
+
308
+ timeout: Override the client-level default timeout for this request, in seconds
309
+ """
310
+ if not id:
311
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
312
+ return await self._put(
313
+ f"/wordlist/{id}",
314
+ body=await async_maybe_transform(
315
+ {
316
+ "description": description,
317
+ "key": key,
318
+ "name": name,
319
+ "strict": strict,
320
+ "words": words,
321
+ },
322
+ wordlist_update_params.WordlistUpdateParams,
323
+ ),
324
+ options=make_request_options(
325
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
326
+ ),
327
+ cast_to=WordlistUpdateResponse,
328
+ )
329
+
330
+ async def list(
331
+ self,
332
+ *,
333
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
334
+ # The extra values given here take precedence over values defined on the client or passed to this method.
335
+ extra_headers: Headers | None = None,
336
+ extra_query: Query | None = None,
337
+ extra_body: Body | None = None,
338
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
339
+ ) -> WordlistListResponse:
340
+ """List all wordlists for the authenticated organization"""
341
+ return await self._get(
342
+ "/wordlist",
343
+ options=make_request_options(
344
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
345
+ ),
346
+ cast_to=WordlistListResponse,
347
+ )
348
+
349
+ async def get_embedding_status(
350
+ self,
351
+ id: str,
352
+ *,
353
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
354
+ # The extra values given here take precedence over values defined on the client or passed to this method.
355
+ extra_headers: Headers | None = None,
356
+ extra_query: Query | None = None,
357
+ extra_body: Body | None = None,
358
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
359
+ ) -> WordlistGetEmbeddingStatusResponse:
360
+ """
361
+ Get the current embedding progress status for a wordlist
362
+
363
+ Args:
364
+ id: ID of the wordlist to check embedding status for
365
+
366
+ extra_headers: Send extra headers
367
+
368
+ extra_query: Add additional query parameters to the request
369
+
370
+ extra_body: Add additional JSON properties to the request
371
+
372
+ timeout: Override the client-level default timeout for this request, in seconds
373
+ """
374
+ if not id:
375
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
376
+ return await self._get(
377
+ f"/wordlist/{id}/embedding-status",
378
+ options=make_request_options(
379
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
380
+ ),
381
+ cast_to=WordlistGetEmbeddingStatusResponse,
382
+ )
383
+
384
+
385
+ class WordlistResourceWithRawResponse:
386
+ def __init__(self, wordlist: WordlistResource) -> None:
387
+ self._wordlist = wordlist
388
+
389
+ self.retrieve = to_raw_response_wrapper(
390
+ wordlist.retrieve,
391
+ )
392
+ self.update = to_raw_response_wrapper(
393
+ wordlist.update,
394
+ )
395
+ self.list = to_raw_response_wrapper(
396
+ wordlist.list,
397
+ )
398
+ self.get_embedding_status = to_raw_response_wrapper(
399
+ wordlist.get_embedding_status,
400
+ )
401
+
402
+ @cached_property
403
+ def words(self) -> WordsResourceWithRawResponse:
404
+ return WordsResourceWithRawResponse(self._wordlist.words)
405
+
406
+
407
+ class AsyncWordlistResourceWithRawResponse:
408
+ def __init__(self, wordlist: AsyncWordlistResource) -> None:
409
+ self._wordlist = wordlist
410
+
411
+ self.retrieve = async_to_raw_response_wrapper(
412
+ wordlist.retrieve,
413
+ )
414
+ self.update = async_to_raw_response_wrapper(
415
+ wordlist.update,
416
+ )
417
+ self.list = async_to_raw_response_wrapper(
418
+ wordlist.list,
419
+ )
420
+ self.get_embedding_status = async_to_raw_response_wrapper(
421
+ wordlist.get_embedding_status,
422
+ )
423
+
424
+ @cached_property
425
+ def words(self) -> AsyncWordsResourceWithRawResponse:
426
+ return AsyncWordsResourceWithRawResponse(self._wordlist.words)
427
+
428
+
429
+ class WordlistResourceWithStreamingResponse:
430
+ def __init__(self, wordlist: WordlistResource) -> None:
431
+ self._wordlist = wordlist
432
+
433
+ self.retrieve = to_streamed_response_wrapper(
434
+ wordlist.retrieve,
435
+ )
436
+ self.update = to_streamed_response_wrapper(
437
+ wordlist.update,
438
+ )
439
+ self.list = to_streamed_response_wrapper(
440
+ wordlist.list,
441
+ )
442
+ self.get_embedding_status = to_streamed_response_wrapper(
443
+ wordlist.get_embedding_status,
444
+ )
445
+
446
+ @cached_property
447
+ def words(self) -> WordsResourceWithStreamingResponse:
448
+ return WordsResourceWithStreamingResponse(self._wordlist.words)
449
+
450
+
451
+ class AsyncWordlistResourceWithStreamingResponse:
452
+ def __init__(self, wordlist: AsyncWordlistResource) -> None:
453
+ self._wordlist = wordlist
454
+
455
+ self.retrieve = async_to_streamed_response_wrapper(
456
+ wordlist.retrieve,
457
+ )
458
+ self.update = async_to_streamed_response_wrapper(
459
+ wordlist.update,
460
+ )
461
+ self.list = async_to_streamed_response_wrapper(
462
+ wordlist.list,
463
+ )
464
+ self.get_embedding_status = async_to_streamed_response_wrapper(
465
+ wordlist.get_embedding_status,
466
+ )
467
+
468
+ @cached_property
469
+ def words(self) -> AsyncWordsResourceWithStreamingResponse:
470
+ return AsyncWordsResourceWithStreamingResponse(self._wordlist.words)