| 1 |
|
| 2 |
|
| 3 |
import typing |
| 4 |
from json.decoder import JSONDecodeError |
| 5 |
|
| 6 |
from ..core.api_error import ApiError |
| 7 |
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 8 |
from ..core.http_response import AsyncHttpResponse, HttpResponse |
| 9 |
from ..core.jsonable_encoder import encode_path_param |
| 10 |
from ..core.pagination import AsyncPager, SyncPager |
| 11 |
from ..core.parse_error import ParsingError |
| 12 |
from ..core.pydantic_utilities import parse_obj_as |
| 13 |
from ..core.request_options import RequestOptions |
| 14 |
from ..core.serialization import convert_and_respect_annotation_metadata |
| 15 |
from ..errors.bad_request_error import BadRequestError |
| 16 |
from ..errors.forbidden_error import ForbiddenError |
| 17 |
from ..errors.not_found_error import NotFoundError |
| 18 |
from ..errors.too_many_requests_error import TooManyRequestsError |
| 19 |
from ..errors.unauthorized_error import UnauthorizedError |
| 20 |
from ..types.create_form_response_content import CreateFormResponseContent |
| 21 |
from ..types.form_ending_node import FormEndingNode |
| 22 |
from ..types.form_ending_node_nullable import FormEndingNodeNullable |
| 23 |
from ..types.form_languages import FormLanguages |
| 24 |
from ..types.form_languages_nullable import FormLanguagesNullable |
| 25 |
from ..types.form_messages import FormMessages |
| 26 |
from ..types.form_messages_nullable import FormMessagesNullable |
| 27 |
from ..types.form_node_list import FormNodeList |
| 28 |
from ..types.form_node_list_nullable import FormNodeListNullable |
| 29 |
from ..types.form_start_node import FormStartNode |
| 30 |
from ..types.form_start_node_nullable import FormStartNodeNullable |
| 31 |
from ..types.form_style import FormStyle |
| 32 |
from ..types.form_style_nullable import FormStyleNullable |
| 33 |
from ..types.form_summary import FormSummary |
| 34 |
from ..types.form_translations import FormTranslations |
| 35 |
from ..types.form_translations_nullable import FormTranslationsNullable |
| 36 |
from ..types.forms_request_parameters_hydrate_enum import FormsRequestParametersHydrateEnum |
| 37 |
from ..types.get_form_response_content import GetFormResponseContent |
| 38 |
from ..types.list_forms_offset_paginated_response_content import ListFormsOffsetPaginatedResponseContent |
| 39 |
from ..types.update_form_response_content import UpdateFormResponseContent |
| 40 |
from pydantic import ValidationError |
| 41 |
|
| 42 |
|
| 43 |
OMIT = typing.cast(typing.Any, ...) |
| 44 |
|
| 45 |
|
| 46 |
class RawFormsClient: |
| 47 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 48 |
self._client_wrapper = client_wrapper |
| 49 |
|
| 50 |
def list( |
| 51 |
self, |
| 52 |
*, |
| 53 |
page: typing.Optional[int] = 0, |
| 54 |
per_page: typing.Optional[int] = 50, |
| 55 |
include_totals: typing.Optional[bool] = True, |
| 56 |
hydrate: typing.Optional[ |
| 57 |
typing.Union[FormsRequestParametersHydrateEnum, typing.Sequence[FormsRequestParametersHydrateEnum]] |
| 58 |
] = None, |
| 59 |
request_options: typing.Optional[RequestOptions] = None, |
| 60 |
) -> SyncPager[FormSummary, ListFormsOffsetPaginatedResponseContent]: |
| 61 |
""" |
| 62 |
Parameters |
| 63 |
---------- |
| 64 |
page : typing.Optional[int] |
| 65 |
Page index of the results to return. First page is 0. |
| 66 |
|
| 67 |
per_page : typing.Optional[int] |
| 68 |
Number of results per page. Defaults to 50. |
| 69 |
|
| 70 |
include_totals : typing.Optional[bool] |
| 71 |
Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). |
| 72 |
|
| 73 |
hydrate : typing.Optional[typing.Union[FormsRequestParametersHydrateEnum, typing.Sequence[FormsRequestParametersHydrateEnum]]] |
| 74 |
Query parameter to hydrate the response with additional data |
| 75 |
|
| 76 |
request_options : typing.Optional[RequestOptions] |
| 77 |
Request-specific configuration. |
| 78 |
|
| 79 |
Returns |
| 80 |
------- |
| 81 |
SyncPager[FormSummary, ListFormsOffsetPaginatedResponseContent] |
| 82 |
Forms successfully retrieved. |
| 83 |
""" |
| 84 |
page = page if page is not None else 0 |
| 85 |
|
| 86 |
_response = self._client_wrapper.httpx_client.request( |
| 87 |
"forms", |
| 88 |
method="GET", |
| 89 |
params={ |
| 90 |
"page": page, |
| 91 |
"per_page": per_page, |
| 92 |
"include_totals": include_totals, |
| 93 |
"hydrate": hydrate, |
| 94 |
}, |
| 95 |
request_options=request_options, |
| 96 |
) |
| 97 |
try: |
| 98 |
if 200 <= _response.status_code < 300: |
| 99 |
_parsed_response = typing.cast( |
| 100 |
ListFormsOffsetPaginatedResponseContent, |
| 101 |
parse_obj_as( |
| 102 |
type_=ListFormsOffsetPaginatedResponseContent, |
| 103 |
object_=_response.json(), |
| 104 |
), |
| 105 |
) |
| 106 |
_items = _parsed_response.forms |
| 107 |
_has_next = len(_items or []) > 0 |
| 108 |
_get_next = lambda: self.list( |
| 109 |
page=page + 1, |
| 110 |
per_page=per_page, |
| 111 |
include_totals=include_totals, |
| 112 |
hydrate=hydrate, |
| 113 |
request_options=request_options, |
| 114 |
) |
| 115 |
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 116 |
if _response.status_code == 400: |
| 117 |
raise BadRequestError( |
| 118 |
headers=dict(_response.headers), |
| 119 |
body=typing.cast( |
| 120 |
typing.Any, |
| 121 |
parse_obj_as( |
| 122 |
type_=typing.Any, |
| 123 |
object_=_response.json(), |
| 124 |
), |
| 125 |
), |
| 126 |
) |
| 127 |
if _response.status_code == 401: |
| 128 |
raise UnauthorizedError( |
| 129 |
headers=dict(_response.headers), |
| 130 |
body=typing.cast( |
| 131 |
typing.Any, |
| 132 |
parse_obj_as( |
| 133 |
type_=typing.Any, |
| 134 |
object_=_response.json(), |
| 135 |
), |
| 136 |
), |
| 137 |
) |
| 138 |
if _response.status_code == 403: |
| 139 |
raise ForbiddenError( |
| 140 |
headers=dict(_response.headers), |
| 141 |
body=typing.cast( |
| 142 |
typing.Any, |
| 143 |
parse_obj_as( |
| 144 |
type_=typing.Any, |
| 145 |
object_=_response.json(), |
| 146 |
), |
| 147 |
), |
| 148 |
) |
| 149 |
if _response.status_code == 429: |
| 150 |
raise TooManyRequestsError( |
| 151 |
headers=dict(_response.headers), |
| 152 |
body=typing.cast( |
| 153 |
typing.Any, |
| 154 |
parse_obj_as( |
| 155 |
type_=typing.Any, |
| 156 |
object_=_response.json(), |
| 157 |
), |
| 158 |
), |
| 159 |
) |
| 160 |
_response_json = _response.json() |
| 161 |
except JSONDecodeError: |
| 162 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 163 |
except ValidationError as e: |
| 164 |
raise ParsingError( |
| 165 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 166 |
) |
| 167 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 168 |
|
| 169 |
def create( |
| 170 |
self, |
| 171 |
*, |
| 172 |
name: str, |
| 173 |
messages: typing.Optional[FormMessages] = OMIT, |
| 174 |
languages: typing.Optional[FormLanguages] = OMIT, |
| 175 |
translations: typing.Optional[FormTranslations] = OMIT, |
| 176 |
nodes: typing.Optional[FormNodeList] = OMIT, |
| 177 |
start: typing.Optional[FormStartNode] = OMIT, |
| 178 |
ending: typing.Optional[FormEndingNode] = OMIT, |
| 179 |
style: typing.Optional[FormStyle] = OMIT, |
| 180 |
request_options: typing.Optional[RequestOptions] = None, |
| 181 |
) -> HttpResponse[CreateFormResponseContent]: |
| 182 |
""" |
| 183 |
Parameters |
| 184 |
---------- |
| 185 |
name : str |
| 186 |
|
| 187 |
messages : typing.Optional[FormMessages] |
| 188 |
|
| 189 |
languages : typing.Optional[FormLanguages] |
| 190 |
|
| 191 |
translations : typing.Optional[FormTranslations] |
| 192 |
|
| 193 |
nodes : typing.Optional[FormNodeList] |
| 194 |
|
| 195 |
start : typing.Optional[FormStartNode] |
| 196 |
|
| 197 |
ending : typing.Optional[FormEndingNode] |
| 198 |
|
| 199 |
style : typing.Optional[FormStyle] |
| 200 |
|
| 201 |
request_options : typing.Optional[RequestOptions] |
| 202 |
Request-specific configuration. |
| 203 |
|
| 204 |
Returns |
| 205 |
------- |
| 206 |
HttpResponse[CreateFormResponseContent] |
| 207 |
Form successfully created. |
| 208 |
""" |
| 209 |
_response = self._client_wrapper.httpx_client.request( |
| 210 |
"forms", |
| 211 |
method="POST", |
| 212 |
json={ |
| 213 |
"name": name, |
| 214 |
"messages": convert_and_respect_annotation_metadata( |
| 215 |
object_=messages, annotation=FormMessages, direction="write" |
| 216 |
), |
| 217 |
"languages": convert_and_respect_annotation_metadata( |
| 218 |
object_=languages, annotation=FormLanguages, direction="write" |
| 219 |
), |
| 220 |
"translations": translations, |
| 221 |
"nodes": convert_and_respect_annotation_metadata( |
| 222 |
object_=nodes, annotation=FormNodeList, direction="write" |
| 223 |
), |
| 224 |
"start": convert_and_respect_annotation_metadata( |
| 225 |
object_=start, annotation=FormStartNode, direction="write" |
| 226 |
), |
| 227 |
"ending": convert_and_respect_annotation_metadata( |
| 228 |
object_=ending, annotation=FormEndingNode, direction="write" |
| 229 |
), |
| 230 |
"style": convert_and_respect_annotation_metadata( |
| 231 |
object_=style, annotation=FormStyle, direction="write" |
| 232 |
), |
| 233 |
}, |
| 234 |
headers={ |
| 235 |
"content-type": "application/json", |
| 236 |
}, |
| 237 |
request_options=request_options, |
| 238 |
omit=OMIT, |
| 239 |
) |
| 240 |
try: |
| 241 |
if 200 <= _response.status_code < 300: |
| 242 |
_data = typing.cast( |
| 243 |
CreateFormResponseContent, |
| 244 |
parse_obj_as( |
| 245 |
type_=CreateFormResponseContent, |
| 246 |
object_=_response.json(), |
| 247 |
), |
| 248 |
) |
| 249 |
return HttpResponse(response=_response, data=_data) |
| 250 |
if _response.status_code == 400: |
| 251 |
raise BadRequestError( |
| 252 |
headers=dict(_response.headers), |
| 253 |
body=typing.cast( |
| 254 |
typing.Any, |
| 255 |
parse_obj_as( |
| 256 |
type_=typing.Any, |
| 257 |
object_=_response.json(), |
| 258 |
), |
| 259 |
), |
| 260 |
) |
| 261 |
if _response.status_code == 401: |
| 262 |
raise UnauthorizedError( |
| 263 |
headers=dict(_response.headers), |
| 264 |
body=typing.cast( |
| 265 |
typing.Any, |
| 266 |
parse_obj_as( |
| 267 |
type_=typing.Any, |
| 268 |
object_=_response.json(), |
| 269 |
), |
| 270 |
), |
| 271 |
) |
| 272 |
if _response.status_code == 403: |
| 273 |
raise ForbiddenError( |
| 274 |
headers=dict(_response.headers), |
| 275 |
body=typing.cast( |
| 276 |
typing.Any, |
| 277 |
parse_obj_as( |
| 278 |
type_=typing.Any, |
| 279 |
object_=_response.json(), |
| 280 |
), |
| 281 |
), |
| 282 |
) |
| 283 |
if _response.status_code == 429: |
| 284 |
raise TooManyRequestsError( |
| 285 |
headers=dict(_response.headers), |
| 286 |
body=typing.cast( |
| 287 |
typing.Any, |
| 288 |
parse_obj_as( |
| 289 |
type_=typing.Any, |
| 290 |
object_=_response.json(), |
| 291 |
), |
| 292 |
), |
| 293 |
) |
| 294 |
_response_json = _response.json() |
| 295 |
except JSONDecodeError: |
| 296 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 297 |
except ValidationError as e: |
| 298 |
raise ParsingError( |
| 299 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 300 |
) |
| 301 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 302 |
|
| 303 |
def get( |
| 304 |
self, |
| 305 |
id: str, |
| 306 |
*, |
| 307 |
hydrate: typing.Optional[ |
| 308 |
typing.Union[FormsRequestParametersHydrateEnum, typing.Sequence[FormsRequestParametersHydrateEnum]] |
| 309 |
] = None, |
| 310 |
request_options: typing.Optional[RequestOptions] = None, |
| 311 |
) -> HttpResponse[GetFormResponseContent]: |
| 312 |
""" |
| 313 |
Parameters |
| 314 |
---------- |
| 315 |
id : str |
| 316 |
The ID of the form to retrieve. |
| 317 |
|
| 318 |
hydrate : typing.Optional[typing.Union[FormsRequestParametersHydrateEnum, typing.Sequence[FormsRequestParametersHydrateEnum]]] |
| 319 |
Query parameter to hydrate the response with additional data |
| 320 |
|
| 321 |
request_options : typing.Optional[RequestOptions] |
| 322 |
Request-specific configuration. |
| 323 |
|
| 324 |
Returns |
| 325 |
------- |
| 326 |
HttpResponse[GetFormResponseContent] |
| 327 |
Form successfully retrieved. |
| 328 |
""" |
| 329 |
_response = self._client_wrapper.httpx_client.request( |
| 330 |
f"forms/{encode_path_param(id)}", |
| 331 |
method="GET", |
| 332 |
params={ |
| 333 |
"hydrate": hydrate, |
| 334 |
}, |
| 335 |
request_options=request_options, |
| 336 |
) |
| 337 |
try: |
| 338 |
if 200 <= _response.status_code < 300: |
| 339 |
_data = typing.cast( |
| 340 |
GetFormResponseContent, |
| 341 |
parse_obj_as( |
| 342 |
type_=GetFormResponseContent, |
| 343 |
object_=_response.json(), |
| 344 |
), |
| 345 |
) |
| 346 |
return HttpResponse(response=_response, data=_data) |
| 347 |
if _response.status_code == 400: |
| 348 |
raise BadRequestError( |
| 349 |
headers=dict(_response.headers), |
| 350 |
body=typing.cast( |
| 351 |
typing.Any, |
| 352 |
parse_obj_as( |
| 353 |
type_=typing.Any, |
| 354 |
object_=_response.json(), |
| 355 |
), |
| 356 |
), |
| 357 |
) |
| 358 |
if _response.status_code == 401: |
| 359 |
raise UnauthorizedError( |
| 360 |
headers=dict(_response.headers), |
| 361 |
body=typing.cast( |
| 362 |
typing.Any, |
| 363 |
parse_obj_as( |
| 364 |
type_=typing.Any, |
| 365 |
object_=_response.json(), |
| 366 |
), |
| 367 |
), |
| 368 |
) |
| 369 |
if _response.status_code == 403: |
| 370 |
raise ForbiddenError( |
| 371 |
headers=dict(_response.headers), |
| 372 |
body=typing.cast( |
| 373 |
typing.Any, |
| 374 |
parse_obj_as( |
| 375 |
type_=typing.Any, |
| 376 |
object_=_response.json(), |
| 377 |
), |
| 378 |
), |
| 379 |
) |
| 380 |
if _response.status_code == 404: |
| 381 |
raise NotFoundError( |
| 382 |
headers=dict(_response.headers), |
| 383 |
body=typing.cast( |
| 384 |
typing.Any, |
| 385 |
parse_obj_as( |
| 386 |
type_=typing.Any, |
| 387 |
object_=_response.json(), |
| 388 |
), |
| 389 |
), |
| 390 |
) |
| 391 |
if _response.status_code == 429: |
| 392 |
raise TooManyRequestsError( |
| 393 |
headers=dict(_response.headers), |
| 394 |
body=typing.cast( |
| 395 |
typing.Any, |
| 396 |
parse_obj_as( |
| 397 |
type_=typing.Any, |
| 398 |
object_=_response.json(), |
| 399 |
), |
| 400 |
), |
| 401 |
) |
| 402 |
_response_json = _response.json() |
| 403 |
except JSONDecodeError: |
| 404 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 405 |
except ValidationError as e: |
| 406 |
raise ParsingError( |
| 407 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 408 |
) |
| 409 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 410 |
|
| 411 |
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: |
| 412 |
""" |
| 413 |
Parameters |
| 414 |
---------- |
| 415 |
id : str |
| 416 |
The ID of the form to delete. |
| 417 |
|
| 418 |
request_options : typing.Optional[RequestOptions] |
| 419 |
Request-specific configuration. |
| 420 |
|
| 421 |
Returns |
| 422 |
------- |
| 423 |
HttpResponse[None] |
| 424 |
""" |
| 425 |
_response = self._client_wrapper.httpx_client.request( |
| 426 |
f"forms/{encode_path_param(id)}", |
| 427 |
method="DELETE", |
| 428 |
request_options=request_options, |
| 429 |
) |
| 430 |
try: |
| 431 |
if 200 <= _response.status_code < 300: |
| 432 |
return HttpResponse(response=_response, data=None) |
| 433 |
if _response.status_code == 400: |
| 434 |
raise BadRequestError( |
| 435 |
headers=dict(_response.headers), |
| 436 |
body=typing.cast( |
| 437 |
typing.Any, |
| 438 |
parse_obj_as( |
| 439 |
type_=typing.Any, |
| 440 |
object_=_response.json(), |
| 441 |
), |
| 442 |
), |
| 443 |
) |
| 444 |
if _response.status_code == 401: |
| 445 |
raise UnauthorizedError( |
| 446 |
headers=dict(_response.headers), |
| 447 |
body=typing.cast( |
| 448 |
typing.Any, |
| 449 |
parse_obj_as( |
| 450 |
type_=typing.Any, |
| 451 |
object_=_response.json(), |
| 452 |
), |
| 453 |
), |
| 454 |
) |
| 455 |
if _response.status_code == 403: |
| 456 |
raise ForbiddenError( |
| 457 |
headers=dict(_response.headers), |
| 458 |
body=typing.cast( |
| 459 |
typing.Any, |
| 460 |
parse_obj_as( |
| 461 |
type_=typing.Any, |
| 462 |
object_=_response.json(), |
| 463 |
), |
| 464 |
), |
| 465 |
) |
| 466 |
if _response.status_code == 429: |
| 467 |
raise TooManyRequestsError( |
| 468 |
headers=dict(_response.headers), |
| 469 |
body=typing.cast( |
| 470 |
typing.Any, |
| 471 |
parse_obj_as( |
| 472 |
type_=typing.Any, |
| 473 |
object_=_response.json(), |
| 474 |
), |
| 475 |
), |
| 476 |
) |
| 477 |
_response_json = _response.json() |
| 478 |
except JSONDecodeError: |
| 479 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 480 |
except ValidationError as e: |
| 481 |
raise ParsingError( |
| 482 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 483 |
) |
| 484 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 485 |
|
| 486 |
def update( |
| 487 |
self, |
| 488 |
id: str, |
| 489 |
*, |
| 490 |
name: typing.Optional[str] = OMIT, |
| 491 |
messages: typing.Optional[FormMessagesNullable] = OMIT, |
| 492 |
languages: typing.Optional[FormLanguagesNullable] = OMIT, |
| 493 |
translations: typing.Optional[FormTranslationsNullable] = OMIT, |
| 494 |
nodes: typing.Optional[FormNodeListNullable] = OMIT, |
| 495 |
start: typing.Optional[FormStartNodeNullable] = OMIT, |
| 496 |
ending: typing.Optional[FormEndingNodeNullable] = OMIT, |
| 497 |
style: typing.Optional[FormStyleNullable] = OMIT, |
| 498 |
request_options: typing.Optional[RequestOptions] = None, |
| 499 |
) -> HttpResponse[UpdateFormResponseContent]: |
| 500 |
""" |
| 501 |
Parameters |
| 502 |
---------- |
| 503 |
id : str |
| 504 |
The ID of the form to update. |
| 505 |
|
| 506 |
name : typing.Optional[str] |
| 507 |
|
| 508 |
messages : typing.Optional[FormMessagesNullable] |
| 509 |
|
| 510 |
languages : typing.Optional[FormLanguagesNullable] |
| 511 |
|
| 512 |
translations : typing.Optional[FormTranslationsNullable] |
| 513 |
|
| 514 |
nodes : typing.Optional[FormNodeListNullable] |
| 515 |
|
| 516 |
start : typing.Optional[FormStartNodeNullable] |
| 517 |
|
| 518 |
ending : typing.Optional[FormEndingNodeNullable] |
| 519 |
|
| 520 |
style : typing.Optional[FormStyleNullable] |
| 521 |
|
| 522 |
request_options : typing.Optional[RequestOptions] |
| 523 |
Request-specific configuration. |
| 524 |
|
| 525 |
Returns |
| 526 |
------- |
| 527 |
HttpResponse[UpdateFormResponseContent] |
| 528 |
Form successfully updated. |
| 529 |
""" |
| 530 |
_response = self._client_wrapper.httpx_client.request( |
| 531 |
f"forms/{encode_path_param(id)}", |
| 532 |
method="PATCH", |
| 533 |
json={ |
| 534 |
"name": name, |
| 535 |
"messages": convert_and_respect_annotation_metadata( |
| 536 |
object_=messages, annotation=FormMessagesNullable, direction="write" |
| 537 |
), |
| 538 |
"languages": convert_and_respect_annotation_metadata( |
| 539 |
object_=languages, annotation=FormLanguagesNullable, direction="write" |
| 540 |
), |
| 541 |
"translations": translations, |
| 542 |
"nodes": convert_and_respect_annotation_metadata( |
| 543 |
object_=nodes, annotation=FormNodeListNullable, direction="write" |
| 544 |
), |
| 545 |
"start": convert_and_respect_annotation_metadata( |
| 546 |
object_=start, annotation=FormStartNodeNullable, direction="write" |
| 547 |
), |
| 548 |
"ending": convert_and_respect_annotation_metadata( |
| 549 |
object_=ending, annotation=FormEndingNodeNullable, direction="write" |
| 550 |
), |
| 551 |
"style": convert_and_respect_annotation_metadata( |
| 552 |
object_=style, annotation=FormStyleNullable, direction="write" |
| 553 |
), |
| 554 |
}, |
| 555 |
headers={ |
| 556 |
"content-type": "application/json", |
| 557 |
}, |
| 558 |
request_options=request_options, |
| 559 |
omit=OMIT, |
| 560 |
) |
| 561 |
try: |
| 562 |
if 200 <= _response.status_code < 300: |
| 563 |
_data = typing.cast( |
| 564 |
UpdateFormResponseContent, |
| 565 |
parse_obj_as( |
| 566 |
type_=UpdateFormResponseContent, |
| 567 |
object_=_response.json(), |
| 568 |
), |
| 569 |
) |
| 570 |
return HttpResponse(response=_response, data=_data) |
| 571 |
if _response.status_code == 401: |
| 572 |
raise UnauthorizedError( |
| 573 |
headers=dict(_response.headers), |
| 574 |
body=typing.cast( |
| 575 |
typing.Any, |
| 576 |
parse_obj_as( |
| 577 |
type_=typing.Any, |
| 578 |
object_=_response.json(), |
| 579 |
), |
| 580 |
), |
| 581 |
) |
| 582 |
if _response.status_code == 403: |
| 583 |
raise ForbiddenError( |
| 584 |
headers=dict(_response.headers), |
| 585 |
body=typing.cast( |
| 586 |
typing.Any, |
| 587 |
parse_obj_as( |
| 588 |
type_=typing.Any, |
| 589 |
object_=_response.json(), |
| 590 |
), |
| 591 |
), |
| 592 |
) |
| 593 |
if _response.status_code == 429: |
| 594 |
raise TooManyRequestsError( |
| 595 |
headers=dict(_response.headers), |
| 596 |
body=typing.cast( |
| 597 |
typing.Any, |
| 598 |
parse_obj_as( |
| 599 |
type_=typing.Any, |
| 600 |
object_=_response.json(), |
| 601 |
), |
| 602 |
), |
| 603 |
) |
| 604 |
_response_json = _response.json() |
| 605 |
except JSONDecodeError: |
| 606 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 607 |
except ValidationError as e: |
| 608 |
raise ParsingError( |
| 609 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 610 |
) |
| 611 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 612 |
|
| 613 |
|
| 614 |
class AsyncRawFormsClient: |
| 615 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 616 |
self._client_wrapper = client_wrapper |
| 617 |
|
| 618 |
async def list( |
| 619 |
self, |
| 620 |
*, |
| 621 |
page: typing.Optional[int] = 0, |
| 622 |
per_page: typing.Optional[int] = 50, |
| 623 |
include_totals: typing.Optional[bool] = True, |
| 624 |
hydrate: typing.Optional[ |
| 625 |
typing.Union[FormsRequestParametersHydrateEnum, typing.Sequence[FormsRequestParametersHydrateEnum]] |
| 626 |
] = None, |
| 627 |
request_options: typing.Optional[RequestOptions] = None, |
| 628 |
) -> AsyncPager[FormSummary, ListFormsOffsetPaginatedResponseContent]: |
| 629 |
""" |
| 630 |
Parameters |
| 631 |
---------- |
| 632 |
page : typing.Optional[int] |
| 633 |
Page index of the results to return. First page is 0. |
| 634 |
|
| 635 |
per_page : typing.Optional[int] |
| 636 |
Number of results per page. Defaults to 50. |
| 637 |
|
| 638 |
include_totals : typing.Optional[bool] |
| 639 |
Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). |
| 640 |
|
| 641 |
hydrate : typing.Optional[typing.Union[FormsRequestParametersHydrateEnum, typing.Sequence[FormsRequestParametersHydrateEnum]]] |
| 642 |
Query parameter to hydrate the response with additional data |
| 643 |
|
| 644 |
request_options : typing.Optional[RequestOptions] |
| 645 |
Request-specific configuration. |
| 646 |
|
| 647 |
Returns |
| 648 |
------- |
| 649 |
AsyncPager[FormSummary, ListFormsOffsetPaginatedResponseContent] |
| 650 |
Forms successfully retrieved. |
| 651 |
""" |
| 652 |
page = page if page is not None else 0 |
| 653 |
|
| 654 |
_response = await self._client_wrapper.httpx_client.request( |
| 655 |
"forms", |
| 656 |
method="GET", |
| 657 |
params={ |
| 658 |
"page": page, |
| 659 |
"per_page": per_page, |
| 660 |
"include_totals": include_totals, |
| 661 |
"hydrate": hydrate, |
| 662 |
}, |
| 663 |
request_options=request_options, |
| 664 |
) |
| 665 |
try: |
| 666 |
if 200 <= _response.status_code < 300: |
| 667 |
_parsed_response = typing.cast( |
| 668 |
ListFormsOffsetPaginatedResponseContent, |
| 669 |
parse_obj_as( |
| 670 |
type_=ListFormsOffsetPaginatedResponseContent, |
| 671 |
object_=_response.json(), |
| 672 |
), |
| 673 |
) |
| 674 |
_items = _parsed_response.forms |
| 675 |
_has_next = len(_items or []) > 0 |
| 676 |
|
| 677 |
async def _get_next(): |
| 678 |
return await self.list( |
| 679 |
page=page + 1, |
| 680 |
per_page=per_page, |
| 681 |
include_totals=include_totals, |
| 682 |
hydrate=hydrate, |
| 683 |
request_options=request_options, |
| 684 |
) |
| 685 |
|
| 686 |
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 687 |
if _response.status_code == 400: |
| 688 |
raise BadRequestError( |
| 689 |
headers=dict(_response.headers), |
| 690 |
body=typing.cast( |
| 691 |
typing.Any, |
| 692 |
parse_obj_as( |
| 693 |
type_=typing.Any, |
| 694 |
object_=_response.json(), |
| 695 |
), |
| 696 |
), |
| 697 |
) |
| 698 |
if _response.status_code == 401: |
| 699 |
raise UnauthorizedError( |
| 700 |
headers=dict(_response.headers), |
| 701 |
body=typing.cast( |
| 702 |
typing.Any, |
| 703 |
parse_obj_as( |
| 704 |
type_=typing.Any, |
| 705 |
object_=_response.json(), |
| 706 |
), |
| 707 |
), |
| 708 |
) |
| 709 |
if _response.status_code == 403: |
| 710 |
raise ForbiddenError( |
| 711 |
headers=dict(_response.headers), |
| 712 |
body=typing.cast( |
| 713 |
typing.Any, |
| 714 |
parse_obj_as( |
| 715 |
type_=typing.Any, |
| 716 |
object_=_response.json(), |
| 717 |
), |
| 718 |
), |
| 719 |
) |
| 720 |
if _response.status_code == 429: |
| 721 |
raise TooManyRequestsError( |
| 722 |
headers=dict(_response.headers), |
| 723 |
body=typing.cast( |
| 724 |
typing.Any, |
| 725 |
parse_obj_as( |
| 726 |
type_=typing.Any, |
| 727 |
object_=_response.json(), |
| 728 |
), |
| 729 |
), |
| 730 |
) |
| 731 |
_response_json = _response.json() |
| 732 |
except JSONDecodeError: |
| 733 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 734 |
except ValidationError as e: |
| 735 |
raise ParsingError( |
| 736 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 737 |
) |
| 738 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 739 |
|
| 740 |
async def create( |
| 741 |
self, |
| 742 |
*, |
| 743 |
name: str, |
| 744 |
messages: typing.Optional[FormMessages] = OMIT, |
| 745 |
languages: typing.Optional[FormLanguages] = OMIT, |
| 746 |
translations: typing.Optional[FormTranslations] = OMIT, |
| 747 |
nodes: typing.Optional[FormNodeList] = OMIT, |
| 748 |
start: typing.Optional[FormStartNode] = OMIT, |
| 749 |
ending: typing.Optional[FormEndingNode] = OMIT, |
| 750 |
style: typing.Optional[FormStyle] = OMIT, |
| 751 |
request_options: typing.Optional[RequestOptions] = None, |
| 752 |
) -> AsyncHttpResponse[CreateFormResponseContent]: |
| 753 |
""" |
| 754 |
Parameters |
| 755 |
---------- |
| 756 |
name : str |
| 757 |
|
| 758 |
messages : typing.Optional[FormMessages] |
| 759 |
|
| 760 |
languages : typing.Optional[FormLanguages] |
| 761 |
|
| 762 |
translations : typing.Optional[FormTranslations] |
| 763 |
|
| 764 |
nodes : typing.Optional[FormNodeList] |
| 765 |
|
| 766 |
start : typing.Optional[FormStartNode] |
| 767 |
|
| 768 |
ending : typing.Optional[FormEndingNode] |
| 769 |
|
| 770 |
style : typing.Optional[FormStyle] |
| 771 |
|
| 772 |
request_options : typing.Optional[RequestOptions] |
| 773 |
Request-specific configuration. |
| 774 |
|
| 775 |
Returns |
| 776 |
------- |
| 777 |
AsyncHttpResponse[CreateFormResponseContent] |
| 778 |
Form successfully created. |
| 779 |
""" |
| 780 |
_response = await self._client_wrapper.httpx_client.request( |
| 781 |
"forms", |
| 782 |
method="POST", |
| 783 |
json={ |
| 784 |
"name": name, |
| 785 |
"messages": convert_and_respect_annotation_metadata( |
| 786 |
object_=messages, annotation=FormMessages, direction="write" |
| 787 |
), |
| 788 |
"languages": convert_and_respect_annotation_metadata( |
| 789 |
object_=languages, annotation=FormLanguages, direction="write" |
| 790 |
), |
| 791 |
"translations": translations, |
| 792 |
"nodes": convert_and_respect_annotation_metadata( |
| 793 |
object_=nodes, annotation=FormNodeList, direction="write" |
| 794 |
), |
| 795 |
"start": convert_and_respect_annotation_metadata( |
| 796 |
object_=start, annotation=FormStartNode, direction="write" |
| 797 |
), |
| 798 |
"ending": convert_and_respect_annotation_metadata( |
| 799 |
object_=ending, annotation=FormEndingNode, direction="write" |
| 800 |
), |
| 801 |
"style": convert_and_respect_annotation_metadata( |
| 802 |
object_=style, annotation=FormStyle, direction="write" |
| 803 |
), |
| 804 |
}, |
| 805 |
headers={ |
| 806 |
"content-type": "application/json", |
| 807 |
}, |
| 808 |
request_options=request_options, |
| 809 |
omit=OMIT, |
| 810 |
) |
| 811 |
try: |
| 812 |
if 200 <= _response.status_code < 300: |
| 813 |
_data = typing.cast( |
| 814 |
CreateFormResponseContent, |
| 815 |
parse_obj_as( |
| 816 |
type_=CreateFormResponseContent, |
| 817 |
object_=_response.json(), |
| 818 |
), |
| 819 |
) |
| 820 |
return AsyncHttpResponse(response=_response, data=_data) |
| 821 |
if _response.status_code == 400: |
| 822 |
raise BadRequestError( |
| 823 |
headers=dict(_response.headers), |
| 824 |
body=typing.cast( |
| 825 |
typing.Any, |
| 826 |
parse_obj_as( |
| 827 |
type_=typing.Any, |
| 828 |
object_=_response.json(), |
| 829 |
), |
| 830 |
), |
| 831 |
) |
| 832 |
if _response.status_code == 401: |
| 833 |
raise UnauthorizedError( |
| 834 |
headers=dict(_response.headers), |
| 835 |
body=typing.cast( |
| 836 |
typing.Any, |
| 837 |
parse_obj_as( |
| 838 |
type_=typing.Any, |
| 839 |
object_=_response.json(), |
| 840 |
), |
| 841 |
), |
| 842 |
) |
| 843 |
if _response.status_code == 403: |
| 844 |
raise ForbiddenError( |
| 845 |
headers=dict(_response.headers), |
| 846 |
body=typing.cast( |
| 847 |
typing.Any, |
| 848 |
parse_obj_as( |
| 849 |
type_=typing.Any, |
| 850 |
object_=_response.json(), |
| 851 |
), |
| 852 |
), |
| 853 |
) |
| 854 |
if _response.status_code == 429: |
| 855 |
raise TooManyRequestsError( |
| 856 |
headers=dict(_response.headers), |
| 857 |
body=typing.cast( |
| 858 |
typing.Any, |
| 859 |
parse_obj_as( |
| 860 |
type_=typing.Any, |
| 861 |
object_=_response.json(), |
| 862 |
), |
| 863 |
), |
| 864 |
) |
| 865 |
_response_json = _response.json() |
| 866 |
except JSONDecodeError: |
| 867 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 868 |
except ValidationError as e: |
| 869 |
raise ParsingError( |
| 870 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 871 |
) |
| 872 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 873 |
|
| 874 |
async def get( |
| 875 |
self, |
| 876 |
id: str, |
| 877 |
*, |
| 878 |
hydrate: typing.Optional[ |
| 879 |
typing.Union[FormsRequestParametersHydrateEnum, typing.Sequence[FormsRequestParametersHydrateEnum]] |
| 880 |
] = None, |
| 881 |
request_options: typing.Optional[RequestOptions] = None, |
| 882 |
) -> AsyncHttpResponse[GetFormResponseContent]: |
| 883 |
""" |
| 884 |
Parameters |
| 885 |
---------- |
| 886 |
id : str |
| 887 |
The ID of the form to retrieve. |
| 888 |
|
| 889 |
hydrate : typing.Optional[typing.Union[FormsRequestParametersHydrateEnum, typing.Sequence[FormsRequestParametersHydrateEnum]]] |
| 890 |
Query parameter to hydrate the response with additional data |
| 891 |
|
| 892 |
request_options : typing.Optional[RequestOptions] |
| 893 |
Request-specific configuration. |
| 894 |
|
| 895 |
Returns |
| 896 |
------- |
| 897 |
AsyncHttpResponse[GetFormResponseContent] |
| 898 |
Form successfully retrieved. |
| 899 |
""" |
| 900 |
_response = await self._client_wrapper.httpx_client.request( |
| 901 |
f"forms/{encode_path_param(id)}", |
| 902 |
method="GET", |
| 903 |
params={ |
| 904 |
"hydrate": hydrate, |
| 905 |
}, |
| 906 |
request_options=request_options, |
| 907 |
) |
| 908 |
try: |
| 909 |
if 200 <= _response.status_code < 300: |
| 910 |
_data = typing.cast( |
| 911 |
GetFormResponseContent, |
| 912 |
parse_obj_as( |
| 913 |
type_=GetFormResponseContent, |
| 914 |
object_=_response.json(), |
| 915 |
), |
| 916 |
) |
| 917 |
return AsyncHttpResponse(response=_response, data=_data) |
| 918 |
if _response.status_code == 400: |
| 919 |
raise BadRequestError( |
| 920 |
headers=dict(_response.headers), |
| 921 |
body=typing.cast( |
| 922 |
typing.Any, |
| 923 |
parse_obj_as( |
| 924 |
type_=typing.Any, |
| 925 |
object_=_response.json(), |
| 926 |
), |
| 927 |
), |
| 928 |
) |
| 929 |
if _response.status_code == 401: |
| 930 |
raise UnauthorizedError( |
| 931 |
headers=dict(_response.headers), |
| 932 |
body=typing.cast( |
| 933 |
typing.Any, |
| 934 |
parse_obj_as( |
| 935 |
type_=typing.Any, |
| 936 |
object_=_response.json(), |
| 937 |
), |
| 938 |
), |
| 939 |
) |
| 940 |
if _response.status_code == 403: |
| 941 |
raise ForbiddenError( |
| 942 |
headers=dict(_response.headers), |
| 943 |
body=typing.cast( |
| 944 |
typing.Any, |
| 945 |
parse_obj_as( |
| 946 |
type_=typing.Any, |
| 947 |
object_=_response.json(), |
| 948 |
), |
| 949 |
), |
| 950 |
) |
| 951 |
if _response.status_code == 404: |
| 952 |
raise NotFoundError( |
| 953 |
headers=dict(_response.headers), |
| 954 |
body=typing.cast( |
| 955 |
typing.Any, |
| 956 |
parse_obj_as( |
| 957 |
type_=typing.Any, |
| 958 |
object_=_response.json(), |
| 959 |
), |
| 960 |
), |
| 961 |
) |
| 962 |
if _response.status_code == 429: |
| 963 |
raise TooManyRequestsError( |
| 964 |
headers=dict(_response.headers), |
| 965 |
body=typing.cast( |
| 966 |
typing.Any, |
| 967 |
parse_obj_as( |
| 968 |
type_=typing.Any, |
| 969 |
object_=_response.json(), |
| 970 |
), |
| 971 |
), |
| 972 |
) |
| 973 |
_response_json = _response.json() |
| 974 |
except JSONDecodeError: |
| 975 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 976 |
except ValidationError as e: |
| 977 |
raise ParsingError( |
| 978 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 979 |
) |
| 980 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 981 |
|
| 982 |
async def delete( |
| 983 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 984 |
) -> AsyncHttpResponse[None]: |
| 985 |
""" |
| 986 |
Parameters |
| 987 |
---------- |
| 988 |
id : str |
| 989 |
The ID of the form to delete. |
| 990 |
|
| 991 |
request_options : typing.Optional[RequestOptions] |
| 992 |
Request-specific configuration. |
| 993 |
|
| 994 |
Returns |
| 995 |
------- |
| 996 |
AsyncHttpResponse[None] |
| 997 |
""" |
| 998 |
_response = await self._client_wrapper.httpx_client.request( |
| 999 |
f"forms/{encode_path_param(id)}", |
| 1000 |
method="DELETE", |
| 1001 |
request_options=request_options, |
| 1002 |
) |
| 1003 |
try: |
| 1004 |
if 200 <= _response.status_code < 300: |
| 1005 |
return AsyncHttpResponse(response=_response, data=None) |
| 1006 |
if _response.status_code == 400: |
| 1007 |
raise BadRequestError( |
| 1008 |
headers=dict(_response.headers), |
| 1009 |
body=typing.cast( |
| 1010 |
typing.Any, |
| 1011 |
parse_obj_as( |
| 1012 |
type_=typing.Any, |
| 1013 |
object_=_response.json(), |
| 1014 |
), |
| 1015 |
), |
| 1016 |
) |
| 1017 |
if _response.status_code == 401: |
| 1018 |
raise UnauthorizedError( |
| 1019 |
headers=dict(_response.headers), |
| 1020 |
body=typing.cast( |
| 1021 |
typing.Any, |
| 1022 |
parse_obj_as( |
| 1023 |
type_=typing.Any, |
| 1024 |
object_=_response.json(), |
| 1025 |
), |
| 1026 |
), |
| 1027 |
) |
| 1028 |
if _response.status_code == 403: |
| 1029 |
raise ForbiddenError( |
| 1030 |
headers=dict(_response.headers), |
| 1031 |
body=typing.cast( |
| 1032 |
typing.Any, |
| 1033 |
parse_obj_as( |
| 1034 |
type_=typing.Any, |
| 1035 |
object_=_response.json(), |
| 1036 |
), |
| 1037 |
), |
| 1038 |
) |
| 1039 |
if _response.status_code == 429: |
| 1040 |
raise TooManyRequestsError( |
| 1041 |
headers=dict(_response.headers), |
| 1042 |
body=typing.cast( |
| 1043 |
typing.Any, |
| 1044 |
parse_obj_as( |
| 1045 |
type_=typing.Any, |
| 1046 |
object_=_response.json(), |
| 1047 |
), |
| 1048 |
), |
| 1049 |
) |
| 1050 |
_response_json = _response.json() |
| 1051 |
except JSONDecodeError: |
| 1052 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1053 |
except ValidationError as e: |
| 1054 |
raise ParsingError( |
| 1055 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1056 |
) |
| 1057 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1058 |
|
| 1059 |
async def update( |
| 1060 |
self, |
| 1061 |
id: str, |
| 1062 |
*, |
| 1063 |
name: typing.Optional[str] = OMIT, |
| 1064 |
messages: typing.Optional[FormMessagesNullable] = OMIT, |
| 1065 |
languages: typing.Optional[FormLanguagesNullable] = OMIT, |
| 1066 |
translations: typing.Optional[FormTranslationsNullable] = OMIT, |
| 1067 |
nodes: typing.Optional[FormNodeListNullable] = OMIT, |
| 1068 |
start: typing.Optional[FormStartNodeNullable] = OMIT, |
| 1069 |
ending: typing.Optional[FormEndingNodeNullable] = OMIT, |
| 1070 |
style: typing.Optional[FormStyleNullable] = OMIT, |
| 1071 |
request_options: typing.Optional[RequestOptions] = None, |
| 1072 |
) -> AsyncHttpResponse[UpdateFormResponseContent]: |
| 1073 |
""" |
| 1074 |
Parameters |
| 1075 |
---------- |
| 1076 |
id : str |
| 1077 |
The ID of the form to update. |
| 1078 |
|
| 1079 |
name : typing.Optional[str] |
| 1080 |
|
| 1081 |
messages : typing.Optional[FormMessagesNullable] |
| 1082 |
|
| 1083 |
languages : typing.Optional[FormLanguagesNullable] |
| 1084 |
|
| 1085 |
translations : typing.Optional[FormTranslationsNullable] |
| 1086 |
|
| 1087 |
nodes : typing.Optional[FormNodeListNullable] |
| 1088 |
|
| 1089 |
start : typing.Optional[FormStartNodeNullable] |
| 1090 |
|
| 1091 |
ending : typing.Optional[FormEndingNodeNullable] |
| 1092 |
|
| 1093 |
style : typing.Optional[FormStyleNullable] |
| 1094 |
|
| 1095 |
request_options : typing.Optional[RequestOptions] |
| 1096 |
Request-specific configuration. |
| 1097 |
|
| 1098 |
Returns |
| 1099 |
------- |
| 1100 |
AsyncHttpResponse[UpdateFormResponseContent] |
| 1101 |
Form successfully updated. |
| 1102 |
""" |
| 1103 |
_response = await self._client_wrapper.httpx_client.request( |
| 1104 |
f"forms/{encode_path_param(id)}", |
| 1105 |
method="PATCH", |
| 1106 |
json={ |
| 1107 |
"name": name, |
| 1108 |
"messages": convert_and_respect_annotation_metadata( |
| 1109 |
object_=messages, annotation=FormMessagesNullable, direction="write" |
| 1110 |
), |
| 1111 |
"languages": convert_and_respect_annotation_metadata( |
| 1112 |
object_=languages, annotation=FormLanguagesNullable, direction="write" |
| 1113 |
), |
| 1114 |
"translations": translations, |
| 1115 |
"nodes": convert_and_respect_annotation_metadata( |
| 1116 |
object_=nodes, annotation=FormNodeListNullable, direction="write" |
| 1117 |
), |
| 1118 |
"start": convert_and_respect_annotation_metadata( |
| 1119 |
object_=start, annotation=FormStartNodeNullable, direction="write" |
| 1120 |
), |
| 1121 |
"ending": convert_and_respect_annotation_metadata( |
| 1122 |
object_=ending, annotation=FormEndingNodeNullable, direction="write" |
| 1123 |
), |
| 1124 |
"style": convert_and_respect_annotation_metadata( |
| 1125 |
object_=style, annotation=FormStyleNullable, direction="write" |
| 1126 |
), |
| 1127 |
}, |
| 1128 |
headers={ |
| 1129 |
"content-type": "application/json", |
| 1130 |
}, |
| 1131 |
request_options=request_options, |
| 1132 |
omit=OMIT, |
| 1133 |
) |
| 1134 |
try: |
| 1135 |
if 200 <= _response.status_code < 300: |
| 1136 |
_data = typing.cast( |
| 1137 |
UpdateFormResponseContent, |
| 1138 |
parse_obj_as( |
| 1139 |
type_=UpdateFormResponseContent, |
| 1140 |
object_=_response.json(), |
| 1141 |
), |
| 1142 |
) |
| 1143 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1144 |
if _response.status_code == 401: |
| 1145 |
raise UnauthorizedError( |
| 1146 |
headers=dict(_response.headers), |
| 1147 |
body=typing.cast( |
| 1148 |
typing.Any, |
| 1149 |
parse_obj_as( |
| 1150 |
type_=typing.Any, |
| 1151 |
object_=_response.json(), |
| 1152 |
), |
| 1153 |
), |
| 1154 |
) |
| 1155 |
if _response.status_code == 403: |
| 1156 |
raise ForbiddenError( |
| 1157 |
headers=dict(_response.headers), |
| 1158 |
body=typing.cast( |
| 1159 |
typing.Any, |
| 1160 |
parse_obj_as( |
| 1161 |
type_=typing.Any, |
| 1162 |
object_=_response.json(), |
| 1163 |
), |
| 1164 |
), |
| 1165 |
) |
| 1166 |
if _response.status_code == 429: |
| 1167 |
raise TooManyRequestsError( |
| 1168 |
headers=dict(_response.headers), |
| 1169 |
body=typing.cast( |
| 1170 |
typing.Any, |
| 1171 |
parse_obj_as( |
| 1172 |
type_=typing.Any, |
| 1173 |
object_=_response.json(), |
| 1174 |
), |
| 1175 |
), |
| 1176 |
) |
| 1177 |
_response_json = _response.json() |
| 1178 |
except JSONDecodeError: |
| 1179 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1180 |
except ValidationError as e: |
| 1181 |
raise ParsingError( |
| 1182 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1183 |
) |
| 1184 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |