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,810 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Iterable, Optional
6
+ from typing_extensions import Literal
7
+
8
+ import httpx
9
+
10
+ from ...types import action_list_params, action_create_params, action_update_params
11
+ from .execute import (
12
+ ExecuteResource,
13
+ AsyncExecuteResource,
14
+ ExecuteResourceWithRawResponse,
15
+ AsyncExecuteResourceWithRawResponse,
16
+ ExecuteResourceWithStreamingResponse,
17
+ AsyncExecuteResourceWithStreamingResponse,
18
+ )
19
+ from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
20
+ from ..._utils import maybe_transform, async_maybe_transform
21
+ from ..._compat import cached_property
22
+ from ..._resource import SyncAPIResource, AsyncAPIResource
23
+ from ..._response import (
24
+ to_raw_response_wrapper,
25
+ to_streamed_response_wrapper,
26
+ async_to_raw_response_wrapper,
27
+ async_to_streamed_response_wrapper,
28
+ )
29
+ from ..._base_client import make_request_options
30
+ from ...types.action_list_response import ActionListResponse
31
+ from ...types.action_create_response import ActionCreateResponse
32
+ from ...types.action_delete_response import ActionDeleteResponse
33
+ from ...types.action_update_response import ActionUpdateResponse
34
+ from ...types.action_retrieve_response import ActionRetrieveResponse
35
+
36
+ __all__ = ["ActionsResource", "AsyncActionsResource"]
37
+
38
+
39
+ class ActionsResource(SyncAPIResource):
40
+ @cached_property
41
+ def execute(self) -> ExecuteResource:
42
+ return ExecuteResource(self._client)
43
+
44
+ @cached_property
45
+ def with_raw_response(self) -> ActionsResourceWithRawResponse:
46
+ """
47
+ This property can be used as a prefix for any HTTP method call to return
48
+ the raw response object instead of the parsed content.
49
+
50
+ For more information, see https://www.github.com/moderation-api/sdk-python#accessing-raw-response-data-eg-headers
51
+ """
52
+ return ActionsResourceWithRawResponse(self)
53
+
54
+ @cached_property
55
+ def with_streaming_response(self) -> ActionsResourceWithStreamingResponse:
56
+ """
57
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
58
+
59
+ For more information, see https://www.github.com/moderation-api/sdk-python#with_streaming_response
60
+ """
61
+ return ActionsResourceWithStreamingResponse(self)
62
+
63
+ def create(
64
+ self,
65
+ *,
66
+ name: str,
67
+ built_in: Optional[bool] | Omit = omit,
68
+ description: Optional[str] | Omit = omit,
69
+ filter_in_queue_ids: SequenceNotStr[str] | Omit = omit,
70
+ free_text: bool | Omit = omit,
71
+ key: Optional[str] | Omit = omit,
72
+ position: Literal["ALL_QUEUES", "SOME_QUEUES", "HIDDEN"] | Omit = omit,
73
+ possible_values: Iterable[action_create_params.PossibleValue] | Omit = omit,
74
+ queue_behaviour: Literal["REMOVE", "ADD", "NO_CHANGE"] | Omit = omit,
75
+ type: Optional[
76
+ Literal[
77
+ "AUTHOR_BLOCK",
78
+ "AUTHOR_BLOCK_TEMP",
79
+ "AUTHOR_UNBLOCK",
80
+ "AUTHOR_DELETE",
81
+ "AUTHOR_REPORT",
82
+ "AUTHOR_WARN",
83
+ "AUTHOR_CUSTOM",
84
+ "ITEM_REJECT",
85
+ "ITEM_ALLOW",
86
+ "ITEM_CUSTOM",
87
+ ]
88
+ ]
89
+ | Omit = omit,
90
+ value_required: bool | Omit = omit,
91
+ webhooks: Iterable[action_create_params.Webhook] | Omit = omit,
92
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
93
+ # The extra values given here take precedence over values defined on the client or passed to this method.
94
+ extra_headers: Headers | None = None,
95
+ extra_query: Query | None = None,
96
+ extra_body: Body | None = None,
97
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
98
+ ) -> ActionCreateResponse:
99
+ """
100
+ Create an action.
101
+
102
+ Args:
103
+ name: The name of the action.
104
+
105
+ built_in: Whether the action is a built-in action or a custom one.
106
+
107
+ description: The description of the action.
108
+
109
+ filter_in_queue_ids: The IDs of the queues the action is available in.
110
+
111
+ free_text: Whether the action allows any text to be entered as a value or if it must be one
112
+ of the possible values.
113
+
114
+ key: User defined key of the action.
115
+
116
+ position: Show the action in all queues, selected queues or no queues (to use via API
117
+ only).
118
+
119
+ possible_values: The possible values of the action. The user will be prompted to select one of
120
+ these values when executing the action.
121
+
122
+ queue_behaviour: Whether the action resolves and removes the item, unresolves and re-add it to
123
+ the queue, or does not change the resolve status.
124
+
125
+ type: The type of the action.
126
+
127
+ value_required: Whether the action requires a value to be executed.
128
+
129
+ webhooks: The action's webhooks.
130
+
131
+ extra_headers: Send extra headers
132
+
133
+ extra_query: Add additional query parameters to the request
134
+
135
+ extra_body: Add additional JSON properties to the request
136
+
137
+ timeout: Override the client-level default timeout for this request, in seconds
138
+ """
139
+ return self._post(
140
+ "/actions",
141
+ body=maybe_transform(
142
+ {
143
+ "name": name,
144
+ "built_in": built_in,
145
+ "description": description,
146
+ "filter_in_queue_ids": filter_in_queue_ids,
147
+ "free_text": free_text,
148
+ "key": key,
149
+ "position": position,
150
+ "possible_values": possible_values,
151
+ "queue_behaviour": queue_behaviour,
152
+ "type": type,
153
+ "value_required": value_required,
154
+ "webhooks": webhooks,
155
+ },
156
+ action_create_params.ActionCreateParams,
157
+ ),
158
+ options=make_request_options(
159
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
160
+ ),
161
+ cast_to=ActionCreateResponse,
162
+ )
163
+
164
+ def retrieve(
165
+ self,
166
+ id: str,
167
+ *,
168
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
169
+ # The extra values given here take precedence over values defined on the client or passed to this method.
170
+ extra_headers: Headers | None = None,
171
+ extra_query: Query | None = None,
172
+ extra_body: Body | None = None,
173
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
174
+ ) -> ActionRetrieveResponse:
175
+ """
176
+ Get an action by ID.
177
+
178
+ Args:
179
+ id: The ID of the action to get.
180
+
181
+ extra_headers: Send extra headers
182
+
183
+ extra_query: Add additional query parameters to the request
184
+
185
+ extra_body: Add additional JSON properties to the request
186
+
187
+ timeout: Override the client-level default timeout for this request, in seconds
188
+ """
189
+ if not id:
190
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
191
+ return self._get(
192
+ f"/actions/{id}",
193
+ options=make_request_options(
194
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
195
+ ),
196
+ cast_to=ActionRetrieveResponse,
197
+ )
198
+
199
+ def update(
200
+ self,
201
+ id: str,
202
+ *,
203
+ built_in: Optional[bool] | Omit = omit,
204
+ description: Optional[str] | Omit = omit,
205
+ filter_in_queue_ids: SequenceNotStr[str] | Omit = omit,
206
+ free_text: bool | Omit = omit,
207
+ key: Optional[str] | Omit = omit,
208
+ name: str | Omit = omit,
209
+ position: Literal["ALL_QUEUES", "SOME_QUEUES", "HIDDEN"] | Omit = omit,
210
+ possible_values: Iterable[action_update_params.PossibleValue] | Omit = omit,
211
+ queue_behaviour: Literal["REMOVE", "ADD", "NO_CHANGE"] | Omit = omit,
212
+ type: Optional[
213
+ Literal[
214
+ "AUTHOR_BLOCK",
215
+ "AUTHOR_BLOCK_TEMP",
216
+ "AUTHOR_UNBLOCK",
217
+ "AUTHOR_DELETE",
218
+ "AUTHOR_REPORT",
219
+ "AUTHOR_WARN",
220
+ "AUTHOR_CUSTOM",
221
+ "ITEM_REJECT",
222
+ "ITEM_ALLOW",
223
+ "ITEM_CUSTOM",
224
+ ]
225
+ ]
226
+ | Omit = omit,
227
+ value_required: bool | Omit = omit,
228
+ webhooks: Iterable[action_update_params.Webhook] | Omit = omit,
229
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
230
+ # The extra values given here take precedence over values defined on the client or passed to this method.
231
+ extra_headers: Headers | None = None,
232
+ extra_query: Query | None = None,
233
+ extra_body: Body | None = None,
234
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
235
+ ) -> ActionUpdateResponse:
236
+ """
237
+ Update an action.
238
+
239
+ Args:
240
+ id: The ID of the action to update.
241
+
242
+ built_in: Whether the action is a built-in action or a custom one.
243
+
244
+ description: The description of the action.
245
+
246
+ filter_in_queue_ids: The IDs of the queues the action is available in.
247
+
248
+ free_text: Whether the action allows any text to be entered as a value or if it must be one
249
+ of the possible values.
250
+
251
+ key: User defined key of the action.
252
+
253
+ name: The name of the action.
254
+
255
+ position: Show the action in all queues, selected queues or no queues (to use via API
256
+ only).
257
+
258
+ possible_values: The possible values of the action. The user will be prompted to select one of
259
+ these values when executing the action.
260
+
261
+ queue_behaviour: Whether the action resolves and removes the item, unresolves and re-add it to
262
+ the queue, or does not change the resolve status.
263
+
264
+ type: The type of the action.
265
+
266
+ value_required: Whether the action requires a value to be executed.
267
+
268
+ webhooks: The action's webhooks.
269
+
270
+ extra_headers: Send extra headers
271
+
272
+ extra_query: Add additional query parameters to the request
273
+
274
+ extra_body: Add additional JSON properties to the request
275
+
276
+ timeout: Override the client-level default timeout for this request, in seconds
277
+ """
278
+ if not id:
279
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
280
+ return self._put(
281
+ f"/actions/{id}",
282
+ body=maybe_transform(
283
+ {
284
+ "built_in": built_in,
285
+ "description": description,
286
+ "filter_in_queue_ids": filter_in_queue_ids,
287
+ "free_text": free_text,
288
+ "key": key,
289
+ "name": name,
290
+ "position": position,
291
+ "possible_values": possible_values,
292
+ "queue_behaviour": queue_behaviour,
293
+ "type": type,
294
+ "value_required": value_required,
295
+ "webhooks": webhooks,
296
+ },
297
+ action_update_params.ActionUpdateParams,
298
+ ),
299
+ options=make_request_options(
300
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
301
+ ),
302
+ cast_to=ActionUpdateResponse,
303
+ )
304
+
305
+ def list(
306
+ self,
307
+ *,
308
+ queue_id: str | Omit = omit,
309
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
310
+ # The extra values given here take precedence over values defined on the client or passed to this method.
311
+ extra_headers: Headers | None = None,
312
+ extra_query: Query | None = None,
313
+ extra_body: Body | None = None,
314
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
315
+ ) -> ActionListResponse:
316
+ """
317
+ List all available moderation actions for the authenticated organization.
318
+
319
+ Args:
320
+ extra_headers: Send extra headers
321
+
322
+ extra_query: Add additional query parameters to the request
323
+
324
+ extra_body: Add additional JSON properties to the request
325
+
326
+ timeout: Override the client-level default timeout for this request, in seconds
327
+ """
328
+ return self._get(
329
+ "/actions",
330
+ options=make_request_options(
331
+ extra_headers=extra_headers,
332
+ extra_query=extra_query,
333
+ extra_body=extra_body,
334
+ timeout=timeout,
335
+ query=maybe_transform({"queue_id": queue_id}, action_list_params.ActionListParams),
336
+ ),
337
+ cast_to=ActionListResponse,
338
+ )
339
+
340
+ def delete(
341
+ self,
342
+ id: str,
343
+ *,
344
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
345
+ # The extra values given here take precedence over values defined on the client or passed to this method.
346
+ extra_headers: Headers | None = None,
347
+ extra_query: Query | None = None,
348
+ extra_body: Body | None = None,
349
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
350
+ ) -> ActionDeleteResponse:
351
+ """
352
+ Delete an action and all of its webhooks.
353
+
354
+ Args:
355
+ id: The ID of the action to delete.
356
+
357
+ extra_headers: Send extra headers
358
+
359
+ extra_query: Add additional query parameters to the request
360
+
361
+ extra_body: Add additional JSON properties to the request
362
+
363
+ timeout: Override the client-level default timeout for this request, in seconds
364
+ """
365
+ if not id:
366
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
367
+ return self._delete(
368
+ f"/actions/{id}",
369
+ options=make_request_options(
370
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
371
+ ),
372
+ cast_to=ActionDeleteResponse,
373
+ )
374
+
375
+
376
+ class AsyncActionsResource(AsyncAPIResource):
377
+ @cached_property
378
+ def execute(self) -> AsyncExecuteResource:
379
+ return AsyncExecuteResource(self._client)
380
+
381
+ @cached_property
382
+ def with_raw_response(self) -> AsyncActionsResourceWithRawResponse:
383
+ """
384
+ This property can be used as a prefix for any HTTP method call to return
385
+ the raw response object instead of the parsed content.
386
+
387
+ For more information, see https://www.github.com/moderation-api/sdk-python#accessing-raw-response-data-eg-headers
388
+ """
389
+ return AsyncActionsResourceWithRawResponse(self)
390
+
391
+ @cached_property
392
+ def with_streaming_response(self) -> AsyncActionsResourceWithStreamingResponse:
393
+ """
394
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
395
+
396
+ For more information, see https://www.github.com/moderation-api/sdk-python#with_streaming_response
397
+ """
398
+ return AsyncActionsResourceWithStreamingResponse(self)
399
+
400
+ async def create(
401
+ self,
402
+ *,
403
+ name: str,
404
+ built_in: Optional[bool] | Omit = omit,
405
+ description: Optional[str] | Omit = omit,
406
+ filter_in_queue_ids: SequenceNotStr[str] | Omit = omit,
407
+ free_text: bool | Omit = omit,
408
+ key: Optional[str] | Omit = omit,
409
+ position: Literal["ALL_QUEUES", "SOME_QUEUES", "HIDDEN"] | Omit = omit,
410
+ possible_values: Iterable[action_create_params.PossibleValue] | Omit = omit,
411
+ queue_behaviour: Literal["REMOVE", "ADD", "NO_CHANGE"] | Omit = omit,
412
+ type: Optional[
413
+ Literal[
414
+ "AUTHOR_BLOCK",
415
+ "AUTHOR_BLOCK_TEMP",
416
+ "AUTHOR_UNBLOCK",
417
+ "AUTHOR_DELETE",
418
+ "AUTHOR_REPORT",
419
+ "AUTHOR_WARN",
420
+ "AUTHOR_CUSTOM",
421
+ "ITEM_REJECT",
422
+ "ITEM_ALLOW",
423
+ "ITEM_CUSTOM",
424
+ ]
425
+ ]
426
+ | Omit = omit,
427
+ value_required: bool | Omit = omit,
428
+ webhooks: Iterable[action_create_params.Webhook] | Omit = omit,
429
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
430
+ # The extra values given here take precedence over values defined on the client or passed to this method.
431
+ extra_headers: Headers | None = None,
432
+ extra_query: Query | None = None,
433
+ extra_body: Body | None = None,
434
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
435
+ ) -> ActionCreateResponse:
436
+ """
437
+ Create an action.
438
+
439
+ Args:
440
+ name: The name of the action.
441
+
442
+ built_in: Whether the action is a built-in action or a custom one.
443
+
444
+ description: The description of the action.
445
+
446
+ filter_in_queue_ids: The IDs of the queues the action is available in.
447
+
448
+ free_text: Whether the action allows any text to be entered as a value or if it must be one
449
+ of the possible values.
450
+
451
+ key: User defined key of the action.
452
+
453
+ position: Show the action in all queues, selected queues or no queues (to use via API
454
+ only).
455
+
456
+ possible_values: The possible values of the action. The user will be prompted to select one of
457
+ these values when executing the action.
458
+
459
+ queue_behaviour: Whether the action resolves and removes the item, unresolves and re-add it to
460
+ the queue, or does not change the resolve status.
461
+
462
+ type: The type of the action.
463
+
464
+ value_required: Whether the action requires a value to be executed.
465
+
466
+ webhooks: The action's webhooks.
467
+
468
+ extra_headers: Send extra headers
469
+
470
+ extra_query: Add additional query parameters to the request
471
+
472
+ extra_body: Add additional JSON properties to the request
473
+
474
+ timeout: Override the client-level default timeout for this request, in seconds
475
+ """
476
+ return await self._post(
477
+ "/actions",
478
+ body=await async_maybe_transform(
479
+ {
480
+ "name": name,
481
+ "built_in": built_in,
482
+ "description": description,
483
+ "filter_in_queue_ids": filter_in_queue_ids,
484
+ "free_text": free_text,
485
+ "key": key,
486
+ "position": position,
487
+ "possible_values": possible_values,
488
+ "queue_behaviour": queue_behaviour,
489
+ "type": type,
490
+ "value_required": value_required,
491
+ "webhooks": webhooks,
492
+ },
493
+ action_create_params.ActionCreateParams,
494
+ ),
495
+ options=make_request_options(
496
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
497
+ ),
498
+ cast_to=ActionCreateResponse,
499
+ )
500
+
501
+ async def retrieve(
502
+ self,
503
+ id: str,
504
+ *,
505
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
506
+ # The extra values given here take precedence over values defined on the client or passed to this method.
507
+ extra_headers: Headers | None = None,
508
+ extra_query: Query | None = None,
509
+ extra_body: Body | None = None,
510
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
511
+ ) -> ActionRetrieveResponse:
512
+ """
513
+ Get an action by ID.
514
+
515
+ Args:
516
+ id: The ID of the action to get.
517
+
518
+ extra_headers: Send extra headers
519
+
520
+ extra_query: Add additional query parameters to the request
521
+
522
+ extra_body: Add additional JSON properties to the request
523
+
524
+ timeout: Override the client-level default timeout for this request, in seconds
525
+ """
526
+ if not id:
527
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
528
+ return await self._get(
529
+ f"/actions/{id}",
530
+ options=make_request_options(
531
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
532
+ ),
533
+ cast_to=ActionRetrieveResponse,
534
+ )
535
+
536
+ async def update(
537
+ self,
538
+ id: str,
539
+ *,
540
+ built_in: Optional[bool] | Omit = omit,
541
+ description: Optional[str] | Omit = omit,
542
+ filter_in_queue_ids: SequenceNotStr[str] | Omit = omit,
543
+ free_text: bool | Omit = omit,
544
+ key: Optional[str] | Omit = omit,
545
+ name: str | Omit = omit,
546
+ position: Literal["ALL_QUEUES", "SOME_QUEUES", "HIDDEN"] | Omit = omit,
547
+ possible_values: Iterable[action_update_params.PossibleValue] | Omit = omit,
548
+ queue_behaviour: Literal["REMOVE", "ADD", "NO_CHANGE"] | Omit = omit,
549
+ type: Optional[
550
+ Literal[
551
+ "AUTHOR_BLOCK",
552
+ "AUTHOR_BLOCK_TEMP",
553
+ "AUTHOR_UNBLOCK",
554
+ "AUTHOR_DELETE",
555
+ "AUTHOR_REPORT",
556
+ "AUTHOR_WARN",
557
+ "AUTHOR_CUSTOM",
558
+ "ITEM_REJECT",
559
+ "ITEM_ALLOW",
560
+ "ITEM_CUSTOM",
561
+ ]
562
+ ]
563
+ | Omit = omit,
564
+ value_required: bool | Omit = omit,
565
+ webhooks: Iterable[action_update_params.Webhook] | Omit = omit,
566
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
567
+ # The extra values given here take precedence over values defined on the client or passed to this method.
568
+ extra_headers: Headers | None = None,
569
+ extra_query: Query | None = None,
570
+ extra_body: Body | None = None,
571
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
572
+ ) -> ActionUpdateResponse:
573
+ """
574
+ Update an action.
575
+
576
+ Args:
577
+ id: The ID of the action to update.
578
+
579
+ built_in: Whether the action is a built-in action or a custom one.
580
+
581
+ description: The description of the action.
582
+
583
+ filter_in_queue_ids: The IDs of the queues the action is available in.
584
+
585
+ free_text: Whether the action allows any text to be entered as a value or if it must be one
586
+ of the possible values.
587
+
588
+ key: User defined key of the action.
589
+
590
+ name: The name of the action.
591
+
592
+ position: Show the action in all queues, selected queues or no queues (to use via API
593
+ only).
594
+
595
+ possible_values: The possible values of the action. The user will be prompted to select one of
596
+ these values when executing the action.
597
+
598
+ queue_behaviour: Whether the action resolves and removes the item, unresolves and re-add it to
599
+ the queue, or does not change the resolve status.
600
+
601
+ type: The type of the action.
602
+
603
+ value_required: Whether the action requires a value to be executed.
604
+
605
+ webhooks: The action's webhooks.
606
+
607
+ extra_headers: Send extra headers
608
+
609
+ extra_query: Add additional query parameters to the request
610
+
611
+ extra_body: Add additional JSON properties to the request
612
+
613
+ timeout: Override the client-level default timeout for this request, in seconds
614
+ """
615
+ if not id:
616
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
617
+ return await self._put(
618
+ f"/actions/{id}",
619
+ body=await async_maybe_transform(
620
+ {
621
+ "built_in": built_in,
622
+ "description": description,
623
+ "filter_in_queue_ids": filter_in_queue_ids,
624
+ "free_text": free_text,
625
+ "key": key,
626
+ "name": name,
627
+ "position": position,
628
+ "possible_values": possible_values,
629
+ "queue_behaviour": queue_behaviour,
630
+ "type": type,
631
+ "value_required": value_required,
632
+ "webhooks": webhooks,
633
+ },
634
+ action_update_params.ActionUpdateParams,
635
+ ),
636
+ options=make_request_options(
637
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
638
+ ),
639
+ cast_to=ActionUpdateResponse,
640
+ )
641
+
642
+ async def list(
643
+ self,
644
+ *,
645
+ queue_id: str | Omit = omit,
646
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
647
+ # The extra values given here take precedence over values defined on the client or passed to this method.
648
+ extra_headers: Headers | None = None,
649
+ extra_query: Query | None = None,
650
+ extra_body: Body | None = None,
651
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
652
+ ) -> ActionListResponse:
653
+ """
654
+ List all available moderation actions for the authenticated organization.
655
+
656
+ Args:
657
+ extra_headers: Send extra headers
658
+
659
+ extra_query: Add additional query parameters to the request
660
+
661
+ extra_body: Add additional JSON properties to the request
662
+
663
+ timeout: Override the client-level default timeout for this request, in seconds
664
+ """
665
+ return await self._get(
666
+ "/actions",
667
+ options=make_request_options(
668
+ extra_headers=extra_headers,
669
+ extra_query=extra_query,
670
+ extra_body=extra_body,
671
+ timeout=timeout,
672
+ query=await async_maybe_transform({"queue_id": queue_id}, action_list_params.ActionListParams),
673
+ ),
674
+ cast_to=ActionListResponse,
675
+ )
676
+
677
+ async def delete(
678
+ self,
679
+ id: str,
680
+ *,
681
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
682
+ # The extra values given here take precedence over values defined on the client or passed to this method.
683
+ extra_headers: Headers | None = None,
684
+ extra_query: Query | None = None,
685
+ extra_body: Body | None = None,
686
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
687
+ ) -> ActionDeleteResponse:
688
+ """
689
+ Delete an action and all of its webhooks.
690
+
691
+ Args:
692
+ id: The ID of the action to delete.
693
+
694
+ extra_headers: Send extra headers
695
+
696
+ extra_query: Add additional query parameters to the request
697
+
698
+ extra_body: Add additional JSON properties to the request
699
+
700
+ timeout: Override the client-level default timeout for this request, in seconds
701
+ """
702
+ if not id:
703
+ raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
704
+ return await self._delete(
705
+ f"/actions/{id}",
706
+ options=make_request_options(
707
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
708
+ ),
709
+ cast_to=ActionDeleteResponse,
710
+ )
711
+
712
+
713
+ class ActionsResourceWithRawResponse:
714
+ def __init__(self, actions: ActionsResource) -> None:
715
+ self._actions = actions
716
+
717
+ self.create = to_raw_response_wrapper(
718
+ actions.create,
719
+ )
720
+ self.retrieve = to_raw_response_wrapper(
721
+ actions.retrieve,
722
+ )
723
+ self.update = to_raw_response_wrapper(
724
+ actions.update,
725
+ )
726
+ self.list = to_raw_response_wrapper(
727
+ actions.list,
728
+ )
729
+ self.delete = to_raw_response_wrapper(
730
+ actions.delete,
731
+ )
732
+
733
+ @cached_property
734
+ def execute(self) -> ExecuteResourceWithRawResponse:
735
+ return ExecuteResourceWithRawResponse(self._actions.execute)
736
+
737
+
738
+ class AsyncActionsResourceWithRawResponse:
739
+ def __init__(self, actions: AsyncActionsResource) -> None:
740
+ self._actions = actions
741
+
742
+ self.create = async_to_raw_response_wrapper(
743
+ actions.create,
744
+ )
745
+ self.retrieve = async_to_raw_response_wrapper(
746
+ actions.retrieve,
747
+ )
748
+ self.update = async_to_raw_response_wrapper(
749
+ actions.update,
750
+ )
751
+ self.list = async_to_raw_response_wrapper(
752
+ actions.list,
753
+ )
754
+ self.delete = async_to_raw_response_wrapper(
755
+ actions.delete,
756
+ )
757
+
758
+ @cached_property
759
+ def execute(self) -> AsyncExecuteResourceWithRawResponse:
760
+ return AsyncExecuteResourceWithRawResponse(self._actions.execute)
761
+
762
+
763
+ class ActionsResourceWithStreamingResponse:
764
+ def __init__(self, actions: ActionsResource) -> None:
765
+ self._actions = actions
766
+
767
+ self.create = to_streamed_response_wrapper(
768
+ actions.create,
769
+ )
770
+ self.retrieve = to_streamed_response_wrapper(
771
+ actions.retrieve,
772
+ )
773
+ self.update = to_streamed_response_wrapper(
774
+ actions.update,
775
+ )
776
+ self.list = to_streamed_response_wrapper(
777
+ actions.list,
778
+ )
779
+ self.delete = to_streamed_response_wrapper(
780
+ actions.delete,
781
+ )
782
+
783
+ @cached_property
784
+ def execute(self) -> ExecuteResourceWithStreamingResponse:
785
+ return ExecuteResourceWithStreamingResponse(self._actions.execute)
786
+
787
+
788
+ class AsyncActionsResourceWithStreamingResponse:
789
+ def __init__(self, actions: AsyncActionsResource) -> None:
790
+ self._actions = actions
791
+
792
+ self.create = async_to_streamed_response_wrapper(
793
+ actions.create,
794
+ )
795
+ self.retrieve = async_to_streamed_response_wrapper(
796
+ actions.retrieve,
797
+ )
798
+ self.update = async_to_streamed_response_wrapper(
799
+ actions.update,
800
+ )
801
+ self.list = async_to_streamed_response_wrapper(
802
+ actions.list,
803
+ )
804
+ self.delete = async_to_streamed_response_wrapper(
805
+ actions.delete,
806
+ )
807
+
808
+ @cached_property
809
+ def execute(self) -> AsyncExecuteResourceWithStreamingResponse:
810
+ return AsyncExecuteResourceWithStreamingResponse(self._actions.execute)