hushscript 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 (187) hide show
  1. hushscript/__init__.py +97 -0
  2. hushscript/_client.py +687 -0
  3. hushscript/_clock.py +36 -0
  4. hushscript/_config.py +139 -0
  5. hushscript/_errors.py +563 -0
  6. hushscript/_guard.py +61 -0
  7. hushscript/_http.py +624 -0
  8. hushscript/_json.py +55 -0
  9. hushscript/_log.py +155 -0
  10. hushscript/_models.py +144 -0
  11. hushscript/_pacing.py +51 -0
  12. hushscript/_redact.py +140 -0
  13. hushscript/_response.py +67 -0
  14. hushscript/_retry.py +205 -0
  15. hushscript/_shape.py +197 -0
  16. hushscript/_shapes.py +248 -0
  17. hushscript/_version.py +1 -0
  18. hushscript/format.py +224 -0
  19. hushscript/generated/__init__.py +8 -0
  20. hushscript/generated/api/__init__.py +1 -0
  21. hushscript/generated/api/default/__init__.py +1 -0
  22. hushscript/generated/api/default/buy_minutes.py +248 -0
  23. hushscript/generated/api/default/claim_agent_account.py +238 -0
  24. hushscript/generated/api/default/complete_upload.py +238 -0
  25. hushscript/generated/api/default/create_agent_account_signup.py +261 -0
  26. hushscript/generated/api/default/create_setup_session.py +244 -0
  27. hushscript/generated/api/default/create_upload.py +225 -0
  28. hushscript/generated/api/default/get_account.py +169 -0
  29. hushscript/generated/api/default/get_job.py +198 -0
  30. hushscript/generated/api/default/get_org.py +169 -0
  31. hushscript/generated/api/default/get_transcript.py +226 -0
  32. hushscript/generated/api/default/get_transcription_context.py +173 -0
  33. hushscript/generated/api/default/get_upload_part_urls.py +246 -0
  34. hushscript/generated/api/default/heartbeat_upload.py +197 -0
  35. hushscript/generated/api/default/lift_transcript_hold.py +206 -0
  36. hushscript/generated/api/default/list_credit_ledger.py +229 -0
  37. hushscript/generated/api/default/list_deleted_transcripts.py +237 -0
  38. hushscript/generated/api/default/list_holds.py +233 -0
  39. hushscript/generated/api/default/list_jobs.py +249 -0
  40. hushscript/generated/api/default/list_org_audit.py +221 -0
  41. hushscript/generated/api/default/list_org_invoices.py +221 -0
  42. hushscript/generated/api/default/list_org_ledger.py +221 -0
  43. hushscript/generated/api/default/list_org_matters.py +247 -0
  44. hushscript/generated/api/default/list_org_members.py +221 -0
  45. hushscript/generated/api/default/list_org_transcripts.py +233 -0
  46. hushscript/generated/api/default/list_packs.py +169 -0
  47. hushscript/generated/api/default/list_saved_cards.py +169 -0
  48. hushscript/generated/api/default/list_transactions.py +225 -0
  49. hushscript/generated/api/default/list_transcripts.py +225 -0
  50. hushscript/generated/api/default/org_audit_csv.py +163 -0
  51. hushscript/generated/api/default/org_ledger_csv.py +163 -0
  52. hushscript/generated/api/default/org_usage_report.py +247 -0
  53. hushscript/generated/api/default/org_usage_report_csv.py +229 -0
  54. hushscript/generated/api/default/patch_org_member.py +237 -0
  55. hushscript/generated/api/default/place_transcript_hold.py +206 -0
  56. hushscript/generated/api/default/rotate_agent_credentials.py +177 -0
  57. hushscript/generated/api/default/schedule_org_custody.py +215 -0
  58. hushscript/generated/api/default/set_default_card.py +223 -0
  59. hushscript/generated/api/default/upload_part.py +249 -0
  60. hushscript/generated/catalog.py +138 -0
  61. hushscript/generated/client.py +282 -0
  62. hushscript/generated/errors.py +16 -0
  63. hushscript/generated/hints.py +28 -0
  64. hushscript/generated/models/__init__.py +193 -0
  65. hushscript/generated/models/account_response.py +114 -0
  66. hushscript/generated/models/active_hold.py +88 -0
  67. hushscript/generated/models/active_hold_kind.py +18 -0
  68. hushscript/generated/models/agent_claim_request.py +61 -0
  69. hushscript/generated/models/agent_claim_response.py +85 -0
  70. hushscript/generated/models/agent_credentials_rotate_response.py +101 -0
  71. hushscript/generated/models/agent_signup_request.py +118 -0
  72. hushscript/generated/models/agent_signup_request_agent.py +80 -0
  73. hushscript/generated/models/agent_signup_response.py +111 -0
  74. hushscript/generated/models/buy_minutes_body.py +89 -0
  75. hushscript/generated/models/card.py +132 -0
  76. hushscript/generated/models/cards_response.py +90 -0
  77. hushscript/generated/models/complete_upload_body.py +107 -0
  78. hushscript/generated/models/complete_upload_body_parts_type_0_item.py +69 -0
  79. hushscript/generated/models/context_dictionary.py +143 -0
  80. hushscript/generated/models/context_prompt_preset.py +118 -0
  81. hushscript/generated/models/create_setup_session_body.py +62 -0
  82. hushscript/generated/models/create_upload_body.py +254 -0
  83. hushscript/generated/models/create_upload_body_transcription_options_type_0.py +178 -0
  84. hushscript/generated/models/credit_ledger_entry.py +113 -0
  85. hushscript/generated/models/credit_ledger_response.py +90 -0
  86. hushscript/generated/models/deleted_transcript.py +148 -0
  87. hushscript/generated/models/deleted_transcript_cause.py +18 -0
  88. hushscript/generated/models/deleted_transcript_receipt_type_0.py +107 -0
  89. hushscript/generated/models/deleted_transcript_receipt_type_0_items_item.py +69 -0
  90. hushscript/generated/models/deleted_transcripts_response.py +90 -0
  91. hushscript/generated/models/dictionary_entry.py +123 -0
  92. hushscript/generated/models/dictionary_entry_category.py +37 -0
  93. hushscript/generated/models/error.py +155 -0
  94. hushscript/generated/models/error_details.py +94 -0
  95. hushscript/generated/models/get_upload_part_urls_response_200_type_0.py +108 -0
  96. hushscript/generated/models/heartbeat_upload_response_200.py +61 -0
  97. hushscript/generated/models/holds_response.py +90 -0
  98. hushscript/generated/models/job.py +309 -0
  99. hushscript/generated/models/job_failure_kind_type_1.py +16 -0
  100. hushscript/generated/models/job_failure_kind_type_2_type_1.py +16 -0
  101. hushscript/generated/models/job_failure_kind_type_3_type_1.py +16 -0
  102. hushscript/generated/models/job_list.py +90 -0
  103. hushscript/generated/models/lift_transcript_hold_response_200.py +61 -0
  104. hushscript/generated/models/list_jobs_active.py +17 -0
  105. hushscript/generated/models/list_org_matters_status.py +16 -0
  106. hushscript/generated/models/options_summary.py +135 -0
  107. hushscript/generated/models/org_audit_entry.py +105 -0
  108. hushscript/generated/models/org_audit_response.py +90 -0
  109. hushscript/generated/models/org_invoice.py +175 -0
  110. hushscript/generated/models/org_invoices_response.py +90 -0
  111. hushscript/generated/models/org_ledger_entry.py +155 -0
  112. hushscript/generated/models/org_ledger_response.py +90 -0
  113. hushscript/generated/models/org_matter.py +79 -0
  114. hushscript/generated/models/org_matter_status.py +16 -0
  115. hushscript/generated/models/org_matters_response.py +75 -0
  116. hushscript/generated/models/org_member.py +123 -0
  117. hushscript/generated/models/org_members_response.py +90 -0
  118. hushscript/generated/models/org_summary_response.py +482 -0
  119. hushscript/generated/models/org_transcript.py +103 -0
  120. hushscript/generated/models/org_transcripts_response.py +90 -0
  121. hushscript/generated/models/org_usage_report_csv_group_by.py +17 -0
  122. hushscript/generated/models/org_usage_report_group_by.py +17 -0
  123. hushscript/generated/models/org_usage_response.py +112 -0
  124. hushscript/generated/models/org_usage_response_group_by.py +17 -0
  125. hushscript/generated/models/org_usage_row.py +86 -0
  126. hushscript/generated/models/pack.py +107 -0
  127. hushscript/generated/models/packs_response.py +75 -0
  128. hushscript/generated/models/patch_org_member_body.py +102 -0
  129. hushscript/generated/models/patch_org_member_response_200.py +61 -0
  130. hushscript/generated/models/place_transcript_hold_response_200.py +61 -0
  131. hushscript/generated/models/presigned_part_url.py +69 -0
  132. hushscript/generated/models/purchase_response.py +76 -0
  133. hushscript/generated/models/schedule_org_custody_body.py +66 -0
  134. hushscript/generated/models/schedule_org_custody_body_custody.py +17 -0
  135. hushscript/generated/models/schedule_org_custody_response_200.py +69 -0
  136. hushscript/generated/models/set_default_card_body.py +61 -0
  137. hushscript/generated/models/set_default_card_response_200.py +61 -0
  138. hushscript/generated/models/setup_session_response.py +77 -0
  139. hushscript/generated/models/transaction.py +183 -0
  140. hushscript/generated/models/transactions_response.py +98 -0
  141. hushscript/generated/models/transcript_detail.py +194 -0
  142. hushscript/generated/models/transcript_detail_speaker_names.py +47 -0
  143. hushscript/generated/models/transcript_envelope.py +89 -0
  144. hushscript/generated/models/transcript_envelope_translations.py +62 -0
  145. hushscript/generated/models/transcript_language.py +75 -0
  146. hushscript/generated/models/transcript_list.py +90 -0
  147. hushscript/generated/models/transcript_list_row.py +152 -0
  148. hushscript/generated/models/transcript_list_row_insights_state.py +20 -0
  149. hushscript/generated/models/transcription_context_response.py +95 -0
  150. hushscript/generated/models/upload_complete_response.py +100 -0
  151. hushscript/generated/models/upload_create_response.py +148 -0
  152. hushscript/generated/models/upload_create_response_funding.py +16 -0
  153. hushscript/generated/models/upload_create_response_upload_type_0.py +108 -0
  154. hushscript/generated/models/upload_limits.py +86 -0
  155. hushscript/generated/models/upload_part_response_200.py +69 -0
  156. hushscript/generated/models/utterance.py +85 -0
  157. hushscript/generated/scopes.py +42 -0
  158. hushscript/generated/types.py +54 -0
  159. hushscript/money.py +79 -0
  160. hushscript/paginate.py +78 -0
  161. hushscript/py.typed +0 -0
  162. hushscript/resources/__init__.py +1 -0
  163. hushscript/resources/_params.py +33 -0
  164. hushscript/resources/account.py +121 -0
  165. hushscript/resources/agent.py +421 -0
  166. hushscript/resources/billing.py +567 -0
  167. hushscript/resources/jobs.py +105 -0
  168. hushscript/resources/transcripts.py +209 -0
  169. hushscript/transcribe/__init__.py +1 -0
  170. hushscript/transcribe/apipeline.py +234 -0
  171. hushscript/transcribe/aupload.py +197 -0
  172. hushscript/transcribe/heartbeat.py +78 -0
  173. hushscript/transcribe/pipeline.py +312 -0
  174. hushscript/transcribe/preflight.py +272 -0
  175. hushscript/transcribe/probe.py +185 -0
  176. hushscript/transcribe/resume.py +115 -0
  177. hushscript/transcribe/segment.py +23 -0
  178. hushscript/transcribe/session.py +34 -0
  179. hushscript/transcribe/sniff.py +30 -0
  180. hushscript/transcribe/source.py +218 -0
  181. hushscript/transcribe/upload.py +498 -0
  182. hushscript/transcribe/wait.py +124 -0
  183. hushscript/transcript.py +197 -0
  184. hushscript-1.0.0.dist-info/METADATA +502 -0
  185. hushscript-1.0.0.dist-info/RECORD +187 -0
  186. hushscript-1.0.0.dist-info/WHEEL +4 -0
  187. hushscript-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,215 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.error import Error
9
+ from ...models.schedule_org_custody_body import ScheduleOrgCustodyBody
10
+ from ...models.schedule_org_custody_response_200 import ScheduleOrgCustodyResponse200
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ body: ScheduleOrgCustodyBody,
17
+ ) -> dict[str, Any]:
18
+ headers: dict[str, Any] = {}
19
+
20
+ _kwargs: dict[str, Any] = {
21
+ "method": "post",
22
+ "url": "/v1/org/custody",
23
+ }
24
+
25
+ _kwargs["json"] = body.to_dict()
26
+
27
+ headers["Content-Type"] = "application/json"
28
+
29
+ _kwargs["headers"] = headers
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: AuthenticatedClient | Client, response: httpx.Response
35
+ ) -> Error | ScheduleOrgCustodyResponse200 | None:
36
+ if response.status_code == 200:
37
+ response_200 = ScheduleOrgCustodyResponse200.from_dict(response.json())
38
+
39
+ return response_200
40
+
41
+ if response.status_code == 400:
42
+ response_400 = Error.from_dict(response.json())
43
+
44
+ return response_400
45
+
46
+ if response.status_code == 401:
47
+ response_401 = Error.from_dict(response.json())
48
+
49
+ return response_401
50
+
51
+ if response.status_code == 403:
52
+ response_403 = Error.from_dict(response.json())
53
+
54
+ return response_403
55
+
56
+ if response.status_code == 409:
57
+ response_409 = Error.from_dict(response.json())
58
+
59
+ return response_409
60
+
61
+ if response.status_code == 429:
62
+ response_429 = Error.from_dict(response.json())
63
+
64
+ return response_429
65
+
66
+ if response.status_code == 500:
67
+ response_500 = Error.from_dict(response.json())
68
+
69
+ return response_500
70
+
71
+ if client.raise_on_unexpected_status:
72
+ raise errors.UnexpectedStatus(response.status_code, response.content)
73
+ else:
74
+ return None
75
+
76
+
77
+ def _build_response(
78
+ *, client: AuthenticatedClient | Client, response: httpx.Response
79
+ ) -> Response[Error | ScheduleOrgCustodyResponse200]:
80
+ return Response(
81
+ status_code=HTTPStatus(response.status_code),
82
+ content=response.content,
83
+ headers=response.headers,
84
+ parsed=_parse_response(client=client, response=response),
85
+ )
86
+
87
+
88
+ def sync_detailed(
89
+ *,
90
+ client: AuthenticatedClient,
91
+ body: ScheduleOrgCustodyBody,
92
+ ) -> Response[Error | ScheduleOrgCustodyResponse200]:
93
+ """Schedule the private to firm custody switch
94
+
95
+ Org admin only. Schedules the workspace's custody mode to switch from private to firm a fixed notice
96
+ period from now, and mails every member. Nothing changes immediately: a daily background lane flips
97
+ the mode once the notice period expires. Only the value firm is accepted; a switch from firm back to
98
+ private is not supported here, since transcripts already stamped under firm custody would silently
99
+ change custodian.
100
+
101
+ Args:
102
+ body (ScheduleOrgCustodyBody):
103
+
104
+ Raises:
105
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
106
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
107
+
108
+ Returns:
109
+ Response[Error | ScheduleOrgCustodyResponse200]
110
+ """
111
+
112
+ kwargs = _get_kwargs(
113
+ body=body,
114
+ )
115
+
116
+ response = client.get_httpx_client().request(
117
+ **kwargs,
118
+ )
119
+
120
+ return _build_response(client=client, response=response)
121
+
122
+
123
+ def sync(
124
+ *,
125
+ client: AuthenticatedClient,
126
+ body: ScheduleOrgCustodyBody,
127
+ ) -> Error | ScheduleOrgCustodyResponse200 | None:
128
+ """Schedule the private to firm custody switch
129
+
130
+ Org admin only. Schedules the workspace's custody mode to switch from private to firm a fixed notice
131
+ period from now, and mails every member. Nothing changes immediately: a daily background lane flips
132
+ the mode once the notice period expires. Only the value firm is accepted; a switch from firm back to
133
+ private is not supported here, since transcripts already stamped under firm custody would silently
134
+ change custodian.
135
+
136
+ Args:
137
+ body (ScheduleOrgCustodyBody):
138
+
139
+ Raises:
140
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
141
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
142
+
143
+ Returns:
144
+ Error | ScheduleOrgCustodyResponse200
145
+ """
146
+
147
+ return sync_detailed(
148
+ client=client,
149
+ body=body,
150
+ ).parsed
151
+
152
+
153
+ async def asyncio_detailed(
154
+ *,
155
+ client: AuthenticatedClient,
156
+ body: ScheduleOrgCustodyBody,
157
+ ) -> Response[Error | ScheduleOrgCustodyResponse200]:
158
+ """Schedule the private to firm custody switch
159
+
160
+ Org admin only. Schedules the workspace's custody mode to switch from private to firm a fixed notice
161
+ period from now, and mails every member. Nothing changes immediately: a daily background lane flips
162
+ the mode once the notice period expires. Only the value firm is accepted; a switch from firm back to
163
+ private is not supported here, since transcripts already stamped under firm custody would silently
164
+ change custodian.
165
+
166
+ Args:
167
+ body (ScheduleOrgCustodyBody):
168
+
169
+ Raises:
170
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
171
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
172
+
173
+ Returns:
174
+ Response[Error | ScheduleOrgCustodyResponse200]
175
+ """
176
+
177
+ kwargs = _get_kwargs(
178
+ body=body,
179
+ )
180
+
181
+ response = await client.get_async_httpx_client().request(**kwargs)
182
+
183
+ return _build_response(client=client, response=response)
184
+
185
+
186
+ async def asyncio(
187
+ *,
188
+ client: AuthenticatedClient,
189
+ body: ScheduleOrgCustodyBody,
190
+ ) -> Error | ScheduleOrgCustodyResponse200 | None:
191
+ """Schedule the private to firm custody switch
192
+
193
+ Org admin only. Schedules the workspace's custody mode to switch from private to firm a fixed notice
194
+ period from now, and mails every member. Nothing changes immediately: a daily background lane flips
195
+ the mode once the notice period expires. Only the value firm is accepted; a switch from firm back to
196
+ private is not supported here, since transcripts already stamped under firm custody would silently
197
+ change custodian.
198
+
199
+ Args:
200
+ body (ScheduleOrgCustodyBody):
201
+
202
+ Raises:
203
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
204
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
205
+
206
+ Returns:
207
+ Error | ScheduleOrgCustodyResponse200
208
+ """
209
+
210
+ return (
211
+ await asyncio_detailed(
212
+ client=client,
213
+ body=body,
214
+ )
215
+ ).parsed
@@ -0,0 +1,223 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.error import Error
9
+ from ...models.set_default_card_body import SetDefaultCardBody
10
+ from ...models.set_default_card_response_200 import SetDefaultCardResponse200
11
+ from ...types import Response
12
+
13
+
14
+ def _get_kwargs(
15
+ *,
16
+ body: SetDefaultCardBody,
17
+ ) -> dict[str, Any]:
18
+ headers: dict[str, Any] = {}
19
+
20
+ _kwargs: dict[str, Any] = {
21
+ "method": "post",
22
+ "url": "/v1/billing/cards/default",
23
+ }
24
+
25
+ _kwargs["json"] = body.to_dict()
26
+
27
+ headers["Content-Type"] = "application/json"
28
+
29
+ _kwargs["headers"] = headers
30
+ return _kwargs
31
+
32
+
33
+ def _parse_response(
34
+ *, client: AuthenticatedClient | Client, response: httpx.Response
35
+ ) -> Error | SetDefaultCardResponse200 | None:
36
+ if response.status_code == 200:
37
+ response_200 = SetDefaultCardResponse200.from_dict(response.json())
38
+
39
+ return response_200
40
+
41
+ if response.status_code == 400:
42
+ response_400 = Error.from_dict(response.json())
43
+
44
+ return response_400
45
+
46
+ if response.status_code == 401:
47
+ response_401 = Error.from_dict(response.json())
48
+
49
+ return response_401
50
+
51
+ if response.status_code == 403:
52
+ response_403 = Error.from_dict(response.json())
53
+
54
+ return response_403
55
+
56
+ if response.status_code == 404:
57
+ response_404 = Error.from_dict(response.json())
58
+
59
+ return response_404
60
+
61
+ if response.status_code == 429:
62
+ response_429 = Error.from_dict(response.json())
63
+
64
+ return response_429
65
+
66
+ if response.status_code == 500:
67
+ response_500 = Error.from_dict(response.json())
68
+
69
+ return response_500
70
+
71
+ if client.raise_on_unexpected_status:
72
+ raise errors.UnexpectedStatus(response.status_code, response.content)
73
+ else:
74
+ return None
75
+
76
+
77
+ def _build_response(
78
+ *, client: AuthenticatedClient | Client, response: httpx.Response
79
+ ) -> Response[Error | SetDefaultCardResponse200]:
80
+ return Response(
81
+ status_code=HTTPStatus(response.status_code),
82
+ content=response.content,
83
+ headers=response.headers,
84
+ parsed=_parse_response(client=client, response=response),
85
+ )
86
+
87
+
88
+ def sync_detailed(
89
+ *,
90
+ client: AuthenticatedClient,
91
+ body: SetDefaultCardBody,
92
+ ) -> Response[Error | SetDefaultCardResponse200]:
93
+ """Switch which saved card Quick Buy charges
94
+
95
+ Sets the given payment method as the account's default, which is the card buy_minutes charges when a
96
+ caller sends its id as quick_payment_method_id. Use this to switch the default or to pick among
97
+ multiple eligible cards; buy_minutes only adopts one automatically when the account has no default
98
+ at all. The id must belong to a payment method already on file, from list_saved_cards; a well formed
99
+ id this account does not own answers not found, exactly like one that is not a payment method at
100
+ all. Needs the billing scope AND machine billing switched on for the account in the Hushscript app;
101
+ either one off is a pat_scope_missing (code 2023) refusal, whichever it was.
102
+
103
+ Args:
104
+ body (SetDefaultCardBody):
105
+
106
+ Raises:
107
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
108
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
109
+
110
+ Returns:
111
+ Response[Error | SetDefaultCardResponse200]
112
+ """
113
+
114
+ kwargs = _get_kwargs(
115
+ body=body,
116
+ )
117
+
118
+ response = client.get_httpx_client().request(
119
+ **kwargs,
120
+ )
121
+
122
+ return _build_response(client=client, response=response)
123
+
124
+
125
+ def sync(
126
+ *,
127
+ client: AuthenticatedClient,
128
+ body: SetDefaultCardBody,
129
+ ) -> Error | SetDefaultCardResponse200 | None:
130
+ """Switch which saved card Quick Buy charges
131
+
132
+ Sets the given payment method as the account's default, which is the card buy_minutes charges when a
133
+ caller sends its id as quick_payment_method_id. Use this to switch the default or to pick among
134
+ multiple eligible cards; buy_minutes only adopts one automatically when the account has no default
135
+ at all. The id must belong to a payment method already on file, from list_saved_cards; a well formed
136
+ id this account does not own answers not found, exactly like one that is not a payment method at
137
+ all. Needs the billing scope AND machine billing switched on for the account in the Hushscript app;
138
+ either one off is a pat_scope_missing (code 2023) refusal, whichever it was.
139
+
140
+ Args:
141
+ body (SetDefaultCardBody):
142
+
143
+ Raises:
144
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
145
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
146
+
147
+ Returns:
148
+ Error | SetDefaultCardResponse200
149
+ """
150
+
151
+ return sync_detailed(
152
+ client=client,
153
+ body=body,
154
+ ).parsed
155
+
156
+
157
+ async def asyncio_detailed(
158
+ *,
159
+ client: AuthenticatedClient,
160
+ body: SetDefaultCardBody,
161
+ ) -> Response[Error | SetDefaultCardResponse200]:
162
+ """Switch which saved card Quick Buy charges
163
+
164
+ Sets the given payment method as the account's default, which is the card buy_minutes charges when a
165
+ caller sends its id as quick_payment_method_id. Use this to switch the default or to pick among
166
+ multiple eligible cards; buy_minutes only adopts one automatically when the account has no default
167
+ at all. The id must belong to a payment method already on file, from list_saved_cards; a well formed
168
+ id this account does not own answers not found, exactly like one that is not a payment method at
169
+ all. Needs the billing scope AND machine billing switched on for the account in the Hushscript app;
170
+ either one off is a pat_scope_missing (code 2023) refusal, whichever it was.
171
+
172
+ Args:
173
+ body (SetDefaultCardBody):
174
+
175
+ Raises:
176
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
177
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
178
+
179
+ Returns:
180
+ Response[Error | SetDefaultCardResponse200]
181
+ """
182
+
183
+ kwargs = _get_kwargs(
184
+ body=body,
185
+ )
186
+
187
+ response = await client.get_async_httpx_client().request(**kwargs)
188
+
189
+ return _build_response(client=client, response=response)
190
+
191
+
192
+ async def asyncio(
193
+ *,
194
+ client: AuthenticatedClient,
195
+ body: SetDefaultCardBody,
196
+ ) -> Error | SetDefaultCardResponse200 | None:
197
+ """Switch which saved card Quick Buy charges
198
+
199
+ Sets the given payment method as the account's default, which is the card buy_minutes charges when a
200
+ caller sends its id as quick_payment_method_id. Use this to switch the default or to pick among
201
+ multiple eligible cards; buy_minutes only adopts one automatically when the account has no default
202
+ at all. The id must belong to a payment method already on file, from list_saved_cards; a well formed
203
+ id this account does not own answers not found, exactly like one that is not a payment method at
204
+ all. Needs the billing scope AND machine billing switched on for the account in the Hushscript app;
205
+ either one off is a pat_scope_missing (code 2023) refusal, whichever it was.
206
+
207
+ Args:
208
+ body (SetDefaultCardBody):
209
+
210
+ Raises:
211
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
212
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
213
+
214
+ Returns:
215
+ Error | SetDefaultCardResponse200
216
+ """
217
+
218
+ return (
219
+ await asyncio_detailed(
220
+ client=client,
221
+ body=body,
222
+ )
223
+ ).parsed
@@ -0,0 +1,249 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.error import Error
10
+ from ...models.upload_part_response_200 import UploadPartResponse200
11
+ from ...types import File, Response
12
+
13
+
14
+ def _get_kwargs(
15
+ job: str,
16
+ n: int,
17
+ *,
18
+ body: File,
19
+ ) -> dict[str, Any]:
20
+ headers: dict[str, Any] = {}
21
+
22
+ _kwargs: dict[str, Any] = {
23
+ "method": "put",
24
+ "url": "/v1/uploads/{job}/parts/{n}".format(
25
+ job=quote(str(job), safe=""),
26
+ n=quote(str(n), safe=""),
27
+ ),
28
+ }
29
+
30
+ _kwargs["content"] = body.payload
31
+ headers["Content-Type"] = "application/octet-stream"
32
+
33
+ _kwargs["headers"] = headers
34
+ return _kwargs
35
+
36
+
37
+ def _parse_response(
38
+ *, client: AuthenticatedClient | Client, response: httpx.Response
39
+ ) -> Error | UploadPartResponse200 | None:
40
+ if response.status_code == 200:
41
+ response_200 = UploadPartResponse200.from_dict(response.json())
42
+
43
+ return response_200
44
+
45
+ if response.status_code == 400:
46
+ response_400 = Error.from_dict(response.json())
47
+
48
+ return response_400
49
+
50
+ if response.status_code == 401:
51
+ response_401 = Error.from_dict(response.json())
52
+
53
+ return response_401
54
+
55
+ if response.status_code == 403:
56
+ response_403 = Error.from_dict(response.json())
57
+
58
+ return response_403
59
+
60
+ if response.status_code == 404:
61
+ response_404 = Error.from_dict(response.json())
62
+
63
+ return response_404
64
+
65
+ if response.status_code == 409:
66
+ response_409 = Error.from_dict(response.json())
67
+
68
+ return response_409
69
+
70
+ if response.status_code == 422:
71
+ response_422 = Error.from_dict(response.json())
72
+
73
+ return response_422
74
+
75
+ if response.status_code == 429:
76
+ response_429 = Error.from_dict(response.json())
77
+
78
+ return response_429
79
+
80
+ if response.status_code == 500:
81
+ response_500 = Error.from_dict(response.json())
82
+
83
+ return response_500
84
+
85
+ if client.raise_on_unexpected_status:
86
+ raise errors.UnexpectedStatus(response.status_code, response.content)
87
+ else:
88
+ return None
89
+
90
+
91
+ def _build_response(
92
+ *, client: AuthenticatedClient | Client, response: httpx.Response
93
+ ) -> Response[Error | UploadPartResponse200]:
94
+ return Response(
95
+ status_code=HTTPStatus(response.status_code),
96
+ content=response.content,
97
+ headers=response.headers,
98
+ parsed=_parse_response(client=client, response=response),
99
+ )
100
+
101
+
102
+ def sync_detailed(
103
+ job: str,
104
+ n: int,
105
+ *,
106
+ client: AuthenticatedClient,
107
+ body: File,
108
+ ) -> Response[Error | UploadPartResponse200]:
109
+ """Upload one part of a job's audio through this API
110
+
111
+ Sends one part's raw bytes to be written into the job's in-progress R2 multipart upload. Only needed
112
+ when direct-to-R2 presigned URLs are unavailable, or as a fallback for a part whose presigned PUT
113
+ failed. A repeated PUT of the same part number replaces that part rather than adding to the declared
114
+ total, so retries are always safe.
115
+
116
+ Args:
117
+ job (str):
118
+ n (int):
119
+ body (File):
120
+
121
+ Raises:
122
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
123
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
124
+
125
+ Returns:
126
+ Response[Error | UploadPartResponse200]
127
+ """
128
+
129
+ kwargs = _get_kwargs(
130
+ job=job,
131
+ n=n,
132
+ body=body,
133
+ )
134
+
135
+ response = client.get_httpx_client().request(
136
+ **kwargs,
137
+ )
138
+
139
+ return _build_response(client=client, response=response)
140
+
141
+
142
+ def sync(
143
+ job: str,
144
+ n: int,
145
+ *,
146
+ client: AuthenticatedClient,
147
+ body: File,
148
+ ) -> Error | UploadPartResponse200 | None:
149
+ """Upload one part of a job's audio through this API
150
+
151
+ Sends one part's raw bytes to be written into the job's in-progress R2 multipart upload. Only needed
152
+ when direct-to-R2 presigned URLs are unavailable, or as a fallback for a part whose presigned PUT
153
+ failed. A repeated PUT of the same part number replaces that part rather than adding to the declared
154
+ total, so retries are always safe.
155
+
156
+ Args:
157
+ job (str):
158
+ n (int):
159
+ body (File):
160
+
161
+ Raises:
162
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
163
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
164
+
165
+ Returns:
166
+ Error | UploadPartResponse200
167
+ """
168
+
169
+ return sync_detailed(
170
+ job=job,
171
+ n=n,
172
+ client=client,
173
+ body=body,
174
+ ).parsed
175
+
176
+
177
+ async def asyncio_detailed(
178
+ job: str,
179
+ n: int,
180
+ *,
181
+ client: AuthenticatedClient,
182
+ body: File,
183
+ ) -> Response[Error | UploadPartResponse200]:
184
+ """Upload one part of a job's audio through this API
185
+
186
+ Sends one part's raw bytes to be written into the job's in-progress R2 multipart upload. Only needed
187
+ when direct-to-R2 presigned URLs are unavailable, or as a fallback for a part whose presigned PUT
188
+ failed. A repeated PUT of the same part number replaces that part rather than adding to the declared
189
+ total, so retries are always safe.
190
+
191
+ Args:
192
+ job (str):
193
+ n (int):
194
+ body (File):
195
+
196
+ Raises:
197
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
198
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
199
+
200
+ Returns:
201
+ Response[Error | UploadPartResponse200]
202
+ """
203
+
204
+ kwargs = _get_kwargs(
205
+ job=job,
206
+ n=n,
207
+ body=body,
208
+ )
209
+
210
+ response = await client.get_async_httpx_client().request(**kwargs)
211
+
212
+ return _build_response(client=client, response=response)
213
+
214
+
215
+ async def asyncio(
216
+ job: str,
217
+ n: int,
218
+ *,
219
+ client: AuthenticatedClient,
220
+ body: File,
221
+ ) -> Error | UploadPartResponse200 | None:
222
+ """Upload one part of a job's audio through this API
223
+
224
+ Sends one part's raw bytes to be written into the job's in-progress R2 multipart upload. Only needed
225
+ when direct-to-R2 presigned URLs are unavailable, or as a fallback for a part whose presigned PUT
226
+ failed. A repeated PUT of the same part number replaces that part rather than adding to the declared
227
+ total, so retries are always safe.
228
+
229
+ Args:
230
+ job (str):
231
+ n (int):
232
+ body (File):
233
+
234
+ Raises:
235
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
236
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
237
+
238
+ Returns:
239
+ Error | UploadPartResponse200
240
+ """
241
+
242
+ return (
243
+ await asyncio_detailed(
244
+ job=job,
245
+ n=n,
246
+ client=client,
247
+ body=body,
248
+ )
249
+ ).parsed