| 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.parse_error import ParsingError |
| 11 |
from ...core.pydantic_utilities import parse_obj_as |
| 12 |
from ...core.request_options import RequestOptions |
| 13 |
from ...errors.bad_request_error import BadRequestError |
| 14 |
from ...errors.conflict_error import ConflictError |
| 15 |
from ...errors.forbidden_error import ForbiddenError |
| 16 |
from ...errors.not_found_error import NotFoundError |
| 17 |
from ...errors.too_many_requests_error import TooManyRequestsError |
| 18 |
from ...errors.unauthorized_error import UnauthorizedError |
| 19 |
from ...types.create_hook_secret_request_content import CreateHookSecretRequestContent |
| 20 |
from ...types.delete_hook_secret_request_content import DeleteHookSecretRequestContent |
| 21 |
from ...types.get_hook_secret_response_content import GetHookSecretResponseContent |
| 22 |
from ...types.update_hook_secret_request_content import UpdateHookSecretRequestContent |
| 23 |
from pydantic import ValidationError |
| 24 |
|
| 25 |
|
| 26 |
OMIT = typing.cast(typing.Any, ...) |
| 27 |
|
| 28 |
|
| 29 |
class RawSecretsClient: |
| 30 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 31 |
self._client_wrapper = client_wrapper |
| 32 |
|
| 33 |
def get( |
| 34 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 35 |
) -> HttpResponse[GetHookSecretResponseContent]: |
| 36 |
""" |
| 37 |
Retrieve a hook's secrets by the ID of the hook. |
| 38 |
|
| 39 |
Parameters |
| 40 |
---------- |
| 41 |
id : str |
| 42 |
ID of the hook to retrieve secrets from. |
| 43 |
|
| 44 |
request_options : typing.Optional[RequestOptions] |
| 45 |
Request-specific configuration. |
| 46 |
|
| 47 |
Returns |
| 48 |
------- |
| 49 |
HttpResponse[GetHookSecretResponseContent] |
| 50 |
Hook secrets successfully retrieved. |
| 51 |
""" |
| 52 |
_response = self._client_wrapper.httpx_client.request( |
| 53 |
f"hooks/{encode_path_param(id)}/secrets", |
| 54 |
method="GET", |
| 55 |
request_options=request_options, |
| 56 |
) |
| 57 |
try: |
| 58 |
if 200 <= _response.status_code < 300: |
| 59 |
_data = typing.cast( |
| 60 |
GetHookSecretResponseContent, |
| 61 |
parse_obj_as( |
| 62 |
type_=GetHookSecretResponseContent, |
| 63 |
object_=_response.json(), |
| 64 |
), |
| 65 |
) |
| 66 |
return HttpResponse(response=_response, data=_data) |
| 67 |
if _response.status_code == 400: |
| 68 |
raise BadRequestError( |
| 69 |
headers=dict(_response.headers), |
| 70 |
body=typing.cast( |
| 71 |
typing.Any, |
| 72 |
parse_obj_as( |
| 73 |
type_=typing.Any, |
| 74 |
object_=_response.json(), |
| 75 |
), |
| 76 |
), |
| 77 |
) |
| 78 |
if _response.status_code == 401: |
| 79 |
raise UnauthorizedError( |
| 80 |
headers=dict(_response.headers), |
| 81 |
body=typing.cast( |
| 82 |
typing.Any, |
| 83 |
parse_obj_as( |
| 84 |
type_=typing.Any, |
| 85 |
object_=_response.json(), |
| 86 |
), |
| 87 |
), |
| 88 |
) |
| 89 |
if _response.status_code == 403: |
| 90 |
raise ForbiddenError( |
| 91 |
headers=dict(_response.headers), |
| 92 |
body=typing.cast( |
| 93 |
typing.Any, |
| 94 |
parse_obj_as( |
| 95 |
type_=typing.Any, |
| 96 |
object_=_response.json(), |
| 97 |
), |
| 98 |
), |
| 99 |
) |
| 100 |
if _response.status_code == 404: |
| 101 |
raise NotFoundError( |
| 102 |
headers=dict(_response.headers), |
| 103 |
body=typing.cast( |
| 104 |
typing.Any, |
| 105 |
parse_obj_as( |
| 106 |
type_=typing.Any, |
| 107 |
object_=_response.json(), |
| 108 |
), |
| 109 |
), |
| 110 |
) |
| 111 |
if _response.status_code == 429: |
| 112 |
raise TooManyRequestsError( |
| 113 |
headers=dict(_response.headers), |
| 114 |
body=typing.cast( |
| 115 |
typing.Any, |
| 116 |
parse_obj_as( |
| 117 |
type_=typing.Any, |
| 118 |
object_=_response.json(), |
| 119 |
), |
| 120 |
), |
| 121 |
) |
| 122 |
_response_json = _response.json() |
| 123 |
except JSONDecodeError: |
| 124 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 125 |
except ValidationError as e: |
| 126 |
raise ParsingError( |
| 127 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 128 |
) |
| 129 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 130 |
|
| 131 |
def create( |
| 132 |
self, |
| 133 |
id: str, |
| 134 |
*, |
| 135 |
request: CreateHookSecretRequestContent, |
| 136 |
request_options: typing.Optional[RequestOptions] = None, |
| 137 |
) -> HttpResponse[None]: |
| 138 |
""" |
| 139 |
Add one or more secrets to an existing hook. Accepts an object of key-value pairs, where the key is the name of the secret. A hook can have a maximum of 20 secrets. |
| 140 |
|
| 141 |
Parameters |
| 142 |
---------- |
| 143 |
id : str |
| 144 |
The id of the hook to retrieve |
| 145 |
|
| 146 |
request : CreateHookSecretRequestContent |
| 147 |
|
| 148 |
request_options : typing.Optional[RequestOptions] |
| 149 |
Request-specific configuration. |
| 150 |
|
| 151 |
Returns |
| 152 |
------- |
| 153 |
HttpResponse[None] |
| 154 |
""" |
| 155 |
_response = self._client_wrapper.httpx_client.request( |
| 156 |
f"hooks/{encode_path_param(id)}/secrets", |
| 157 |
method="POST", |
| 158 |
json=request, |
| 159 |
request_options=request_options, |
| 160 |
omit=OMIT, |
| 161 |
) |
| 162 |
try: |
| 163 |
if 200 <= _response.status_code < 300: |
| 164 |
return HttpResponse(response=_response, data=None) |
| 165 |
if _response.status_code == 400: |
| 166 |
raise BadRequestError( |
| 167 |
headers=dict(_response.headers), |
| 168 |
body=typing.cast( |
| 169 |
typing.Any, |
| 170 |
parse_obj_as( |
| 171 |
type_=typing.Any, |
| 172 |
object_=_response.json(), |
| 173 |
), |
| 174 |
), |
| 175 |
) |
| 176 |
if _response.status_code == 401: |
| 177 |
raise UnauthorizedError( |
| 178 |
headers=dict(_response.headers), |
| 179 |
body=typing.cast( |
| 180 |
typing.Any, |
| 181 |
parse_obj_as( |
| 182 |
type_=typing.Any, |
| 183 |
object_=_response.json(), |
| 184 |
), |
| 185 |
), |
| 186 |
) |
| 187 |
if _response.status_code == 403: |
| 188 |
raise ForbiddenError( |
| 189 |
headers=dict(_response.headers), |
| 190 |
body=typing.cast( |
| 191 |
typing.Any, |
| 192 |
parse_obj_as( |
| 193 |
type_=typing.Any, |
| 194 |
object_=_response.json(), |
| 195 |
), |
| 196 |
), |
| 197 |
) |
| 198 |
if _response.status_code == 409: |
| 199 |
raise ConflictError( |
| 200 |
headers=dict(_response.headers), |
| 201 |
body=typing.cast( |
| 202 |
typing.Any, |
| 203 |
parse_obj_as( |
| 204 |
type_=typing.Any, |
| 205 |
object_=_response.json(), |
| 206 |
), |
| 207 |
), |
| 208 |
) |
| 209 |
if _response.status_code == 429: |
| 210 |
raise TooManyRequestsError( |
| 211 |
headers=dict(_response.headers), |
| 212 |
body=typing.cast( |
| 213 |
typing.Any, |
| 214 |
parse_obj_as( |
| 215 |
type_=typing.Any, |
| 216 |
object_=_response.json(), |
| 217 |
), |
| 218 |
), |
| 219 |
) |
| 220 |
_response_json = _response.json() |
| 221 |
except JSONDecodeError: |
| 222 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 223 |
except ValidationError as e: |
| 224 |
raise ParsingError( |
| 225 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 226 |
) |
| 227 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 228 |
|
| 229 |
def delete( |
| 230 |
self, |
| 231 |
id: str, |
| 232 |
*, |
| 233 |
request: DeleteHookSecretRequestContent, |
| 234 |
request_options: typing.Optional[RequestOptions] = None, |
| 235 |
) -> HttpResponse[None]: |
| 236 |
""" |
| 237 |
Delete one or more existing secrets for a given hook. Accepts an array of secret names to delete. |
| 238 |
|
| 239 |
Parameters |
| 240 |
---------- |
| 241 |
id : str |
| 242 |
ID of the hook whose secrets to delete. |
| 243 |
|
| 244 |
request : DeleteHookSecretRequestContent |
| 245 |
|
| 246 |
request_options : typing.Optional[RequestOptions] |
| 247 |
Request-specific configuration. |
| 248 |
|
| 249 |
Returns |
| 250 |
------- |
| 251 |
HttpResponse[None] |
| 252 |
""" |
| 253 |
_response = self._client_wrapper.httpx_client.request( |
| 254 |
f"hooks/{encode_path_param(id)}/secrets", |
| 255 |
method="DELETE", |
| 256 |
json=request, |
| 257 |
request_options=request_options, |
| 258 |
omit=OMIT, |
| 259 |
) |
| 260 |
try: |
| 261 |
if 200 <= _response.status_code < 300: |
| 262 |
return HttpResponse(response=_response, data=None) |
| 263 |
if _response.status_code == 400: |
| 264 |
raise BadRequestError( |
| 265 |
headers=dict(_response.headers), |
| 266 |
body=typing.cast( |
| 267 |
typing.Any, |
| 268 |
parse_obj_as( |
| 269 |
type_=typing.Any, |
| 270 |
object_=_response.json(), |
| 271 |
), |
| 272 |
), |
| 273 |
) |
| 274 |
if _response.status_code == 401: |
| 275 |
raise UnauthorizedError( |
| 276 |
headers=dict(_response.headers), |
| 277 |
body=typing.cast( |
| 278 |
typing.Any, |
| 279 |
parse_obj_as( |
| 280 |
type_=typing.Any, |
| 281 |
object_=_response.json(), |
| 282 |
), |
| 283 |
), |
| 284 |
) |
| 285 |
if _response.status_code == 403: |
| 286 |
raise ForbiddenError( |
| 287 |
headers=dict(_response.headers), |
| 288 |
body=typing.cast( |
| 289 |
typing.Any, |
| 290 |
parse_obj_as( |
| 291 |
type_=typing.Any, |
| 292 |
object_=_response.json(), |
| 293 |
), |
| 294 |
), |
| 295 |
) |
| 296 |
if _response.status_code == 429: |
| 297 |
raise TooManyRequestsError( |
| 298 |
headers=dict(_response.headers), |
| 299 |
body=typing.cast( |
| 300 |
typing.Any, |
| 301 |
parse_obj_as( |
| 302 |
type_=typing.Any, |
| 303 |
object_=_response.json(), |
| 304 |
), |
| 305 |
), |
| 306 |
) |
| 307 |
_response_json = _response.json() |
| 308 |
except JSONDecodeError: |
| 309 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 310 |
except ValidationError as e: |
| 311 |
raise ParsingError( |
| 312 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 313 |
) |
| 314 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 315 |
|
| 316 |
def update( |
| 317 |
self, |
| 318 |
id: str, |
| 319 |
*, |
| 320 |
request: UpdateHookSecretRequestContent, |
| 321 |
request_options: typing.Optional[RequestOptions] = None, |
| 322 |
) -> HttpResponse[None]: |
| 323 |
""" |
| 324 |
Update one or more existing secrets for an existing hook. Accepts an object of key-value pairs, where the key is the name of the existing secret. |
| 325 |
|
| 326 |
Parameters |
| 327 |
---------- |
| 328 |
id : str |
| 329 |
ID of the hook whose secrets to update. |
| 330 |
|
| 331 |
request : UpdateHookSecretRequestContent |
| 332 |
|
| 333 |
request_options : typing.Optional[RequestOptions] |
| 334 |
Request-specific configuration. |
| 335 |
|
| 336 |
Returns |
| 337 |
------- |
| 338 |
HttpResponse[None] |
| 339 |
""" |
| 340 |
_response = self._client_wrapper.httpx_client.request( |
| 341 |
f"hooks/{encode_path_param(id)}/secrets", |
| 342 |
method="PATCH", |
| 343 |
json=request, |
| 344 |
request_options=request_options, |
| 345 |
omit=OMIT, |
| 346 |
) |
| 347 |
try: |
| 348 |
if 200 <= _response.status_code < 300: |
| 349 |
return HttpResponse(response=_response, data=None) |
| 350 |
if _response.status_code == 400: |
| 351 |
raise BadRequestError( |
| 352 |
headers=dict(_response.headers), |
| 353 |
body=typing.cast( |
| 354 |
typing.Any, |
| 355 |
parse_obj_as( |
| 356 |
type_=typing.Any, |
| 357 |
object_=_response.json(), |
| 358 |
), |
| 359 |
), |
| 360 |
) |
| 361 |
if _response.status_code == 401: |
| 362 |
raise UnauthorizedError( |
| 363 |
headers=dict(_response.headers), |
| 364 |
body=typing.cast( |
| 365 |
typing.Any, |
| 366 |
parse_obj_as( |
| 367 |
type_=typing.Any, |
| 368 |
object_=_response.json(), |
| 369 |
), |
| 370 |
), |
| 371 |
) |
| 372 |
if _response.status_code == 403: |
| 373 |
raise ForbiddenError( |
| 374 |
headers=dict(_response.headers), |
| 375 |
body=typing.cast( |
| 376 |
typing.Any, |
| 377 |
parse_obj_as( |
| 378 |
type_=typing.Any, |
| 379 |
object_=_response.json(), |
| 380 |
), |
| 381 |
), |
| 382 |
) |
| 383 |
if _response.status_code == 404: |
| 384 |
raise NotFoundError( |
| 385 |
headers=dict(_response.headers), |
| 386 |
body=typing.cast( |
| 387 |
typing.Any, |
| 388 |
parse_obj_as( |
| 389 |
type_=typing.Any, |
| 390 |
object_=_response.json(), |
| 391 |
), |
| 392 |
), |
| 393 |
) |
| 394 |
if _response.status_code == 409: |
| 395 |
raise ConflictError( |
| 396 |
headers=dict(_response.headers), |
| 397 |
body=typing.cast( |
| 398 |
typing.Any, |
| 399 |
parse_obj_as( |
| 400 |
type_=typing.Any, |
| 401 |
object_=_response.json(), |
| 402 |
), |
| 403 |
), |
| 404 |
) |
| 405 |
if _response.status_code == 429: |
| 406 |
raise TooManyRequestsError( |
| 407 |
headers=dict(_response.headers), |
| 408 |
body=typing.cast( |
| 409 |
typing.Any, |
| 410 |
parse_obj_as( |
| 411 |
type_=typing.Any, |
| 412 |
object_=_response.json(), |
| 413 |
), |
| 414 |
), |
| 415 |
) |
| 416 |
_response_json = _response.json() |
| 417 |
except JSONDecodeError: |
| 418 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 419 |
except ValidationError as e: |
| 420 |
raise ParsingError( |
| 421 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 422 |
) |
| 423 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 424 |
|
| 425 |
|
| 426 |
class AsyncRawSecretsClient: |
| 427 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 428 |
self._client_wrapper = client_wrapper |
| 429 |
|
| 430 |
async def get( |
| 431 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 432 |
) -> AsyncHttpResponse[GetHookSecretResponseContent]: |
| 433 |
""" |
| 434 |
Retrieve a hook's secrets by the ID of the hook. |
| 435 |
|
| 436 |
Parameters |
| 437 |
---------- |
| 438 |
id : str |
| 439 |
ID of the hook to retrieve secrets from. |
| 440 |
|
| 441 |
request_options : typing.Optional[RequestOptions] |
| 442 |
Request-specific configuration. |
| 443 |
|
| 444 |
Returns |
| 445 |
------- |
| 446 |
AsyncHttpResponse[GetHookSecretResponseContent] |
| 447 |
Hook secrets successfully retrieved. |
| 448 |
""" |
| 449 |
_response = await self._client_wrapper.httpx_client.request( |
| 450 |
f"hooks/{encode_path_param(id)}/secrets", |
| 451 |
method="GET", |
| 452 |
request_options=request_options, |
| 453 |
) |
| 454 |
try: |
| 455 |
if 200 <= _response.status_code < 300: |
| 456 |
_data = typing.cast( |
| 457 |
GetHookSecretResponseContent, |
| 458 |
parse_obj_as( |
| 459 |
type_=GetHookSecretResponseContent, |
| 460 |
object_=_response.json(), |
| 461 |
), |
| 462 |
) |
| 463 |
return AsyncHttpResponse(response=_response, data=_data) |
| 464 |
if _response.status_code == 400: |
| 465 |
raise BadRequestError( |
| 466 |
headers=dict(_response.headers), |
| 467 |
body=typing.cast( |
| 468 |
typing.Any, |
| 469 |
parse_obj_as( |
| 470 |
type_=typing.Any, |
| 471 |
object_=_response.json(), |
| 472 |
), |
| 473 |
), |
| 474 |
) |
| 475 |
if _response.status_code == 401: |
| 476 |
raise UnauthorizedError( |
| 477 |
headers=dict(_response.headers), |
| 478 |
body=typing.cast( |
| 479 |
typing.Any, |
| 480 |
parse_obj_as( |
| 481 |
type_=typing.Any, |
| 482 |
object_=_response.json(), |
| 483 |
), |
| 484 |
), |
| 485 |
) |
| 486 |
if _response.status_code == 403: |
| 487 |
raise ForbiddenError( |
| 488 |
headers=dict(_response.headers), |
| 489 |
body=typing.cast( |
| 490 |
typing.Any, |
| 491 |
parse_obj_as( |
| 492 |
type_=typing.Any, |
| 493 |
object_=_response.json(), |
| 494 |
), |
| 495 |
), |
| 496 |
) |
| 497 |
if _response.status_code == 404: |
| 498 |
raise NotFoundError( |
| 499 |
headers=dict(_response.headers), |
| 500 |
body=typing.cast( |
| 501 |
typing.Any, |
| 502 |
parse_obj_as( |
| 503 |
type_=typing.Any, |
| 504 |
object_=_response.json(), |
| 505 |
), |
| 506 |
), |
| 507 |
) |
| 508 |
if _response.status_code == 429: |
| 509 |
raise TooManyRequestsError( |
| 510 |
headers=dict(_response.headers), |
| 511 |
body=typing.cast( |
| 512 |
typing.Any, |
| 513 |
parse_obj_as( |
| 514 |
type_=typing.Any, |
| 515 |
object_=_response.json(), |
| 516 |
), |
| 517 |
), |
| 518 |
) |
| 519 |
_response_json = _response.json() |
| 520 |
except JSONDecodeError: |
| 521 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 522 |
except ValidationError as e: |
| 523 |
raise ParsingError( |
| 524 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 525 |
) |
| 526 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 527 |
|
| 528 |
async def create( |
| 529 |
self, |
| 530 |
id: str, |
| 531 |
*, |
| 532 |
request: CreateHookSecretRequestContent, |
| 533 |
request_options: typing.Optional[RequestOptions] = None, |
| 534 |
) -> AsyncHttpResponse[None]: |
| 535 |
""" |
| 536 |
Add one or more secrets to an existing hook. Accepts an object of key-value pairs, where the key is the name of the secret. A hook can have a maximum of 20 secrets. |
| 537 |
|
| 538 |
Parameters |
| 539 |
---------- |
| 540 |
id : str |
| 541 |
The id of the hook to retrieve |
| 542 |
|
| 543 |
request : CreateHookSecretRequestContent |
| 544 |
|
| 545 |
request_options : typing.Optional[RequestOptions] |
| 546 |
Request-specific configuration. |
| 547 |
|
| 548 |
Returns |
| 549 |
------- |
| 550 |
AsyncHttpResponse[None] |
| 551 |
""" |
| 552 |
_response = await self._client_wrapper.httpx_client.request( |
| 553 |
f"hooks/{encode_path_param(id)}/secrets", |
| 554 |
method="POST", |
| 555 |
json=request, |
| 556 |
request_options=request_options, |
| 557 |
omit=OMIT, |
| 558 |
) |
| 559 |
try: |
| 560 |
if 200 <= _response.status_code < 300: |
| 561 |
return AsyncHttpResponse(response=_response, data=None) |
| 562 |
if _response.status_code == 400: |
| 563 |
raise BadRequestError( |
| 564 |
headers=dict(_response.headers), |
| 565 |
body=typing.cast( |
| 566 |
typing.Any, |
| 567 |
parse_obj_as( |
| 568 |
type_=typing.Any, |
| 569 |
object_=_response.json(), |
| 570 |
), |
| 571 |
), |
| 572 |
) |
| 573 |
if _response.status_code == 401: |
| 574 |
raise UnauthorizedError( |
| 575 |
headers=dict(_response.headers), |
| 576 |
body=typing.cast( |
| 577 |
typing.Any, |
| 578 |
parse_obj_as( |
| 579 |
type_=typing.Any, |
| 580 |
object_=_response.json(), |
| 581 |
), |
| 582 |
), |
| 583 |
) |
| 584 |
if _response.status_code == 403: |
| 585 |
raise ForbiddenError( |
| 586 |
headers=dict(_response.headers), |
| 587 |
body=typing.cast( |
| 588 |
typing.Any, |
| 589 |
parse_obj_as( |
| 590 |
type_=typing.Any, |
| 591 |
object_=_response.json(), |
| 592 |
), |
| 593 |
), |
| 594 |
) |
| 595 |
if _response.status_code == 409: |
| 596 |
raise ConflictError( |
| 597 |
headers=dict(_response.headers), |
| 598 |
body=typing.cast( |
| 599 |
typing.Any, |
| 600 |
parse_obj_as( |
| 601 |
type_=typing.Any, |
| 602 |
object_=_response.json(), |
| 603 |
), |
| 604 |
), |
| 605 |
) |
| 606 |
if _response.status_code == 429: |
| 607 |
raise TooManyRequestsError( |
| 608 |
headers=dict(_response.headers), |
| 609 |
body=typing.cast( |
| 610 |
typing.Any, |
| 611 |
parse_obj_as( |
| 612 |
type_=typing.Any, |
| 613 |
object_=_response.json(), |
| 614 |
), |
| 615 |
), |
| 616 |
) |
| 617 |
_response_json = _response.json() |
| 618 |
except JSONDecodeError: |
| 619 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 620 |
except ValidationError as e: |
| 621 |
raise ParsingError( |
| 622 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 623 |
) |
| 624 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 625 |
|
| 626 |
async def delete( |
| 627 |
self, |
| 628 |
id: str, |
| 629 |
*, |
| 630 |
request: DeleteHookSecretRequestContent, |
| 631 |
request_options: typing.Optional[RequestOptions] = None, |
| 632 |
) -> AsyncHttpResponse[None]: |
| 633 |
""" |
| 634 |
Delete one or more existing secrets for a given hook. Accepts an array of secret names to delete. |
| 635 |
|
| 636 |
Parameters |
| 637 |
---------- |
| 638 |
id : str |
| 639 |
ID of the hook whose secrets to delete. |
| 640 |
|
| 641 |
request : DeleteHookSecretRequestContent |
| 642 |
|
| 643 |
request_options : typing.Optional[RequestOptions] |
| 644 |
Request-specific configuration. |
| 645 |
|
| 646 |
Returns |
| 647 |
------- |
| 648 |
AsyncHttpResponse[None] |
| 649 |
""" |
| 650 |
_response = await self._client_wrapper.httpx_client.request( |
| 651 |
f"hooks/{encode_path_param(id)}/secrets", |
| 652 |
method="DELETE", |
| 653 |
json=request, |
| 654 |
request_options=request_options, |
| 655 |
omit=OMIT, |
| 656 |
) |
| 657 |
try: |
| 658 |
if 200 <= _response.status_code < 300: |
| 659 |
return AsyncHttpResponse(response=_response, data=None) |
| 660 |
if _response.status_code == 400: |
| 661 |
raise BadRequestError( |
| 662 |
headers=dict(_response.headers), |
| 663 |
body=typing.cast( |
| 664 |
typing.Any, |
| 665 |
parse_obj_as( |
| 666 |
type_=typing.Any, |
| 667 |
object_=_response.json(), |
| 668 |
), |
| 669 |
), |
| 670 |
) |
| 671 |
if _response.status_code == 401: |
| 672 |
raise UnauthorizedError( |
| 673 |
headers=dict(_response.headers), |
| 674 |
body=typing.cast( |
| 675 |
typing.Any, |
| 676 |
parse_obj_as( |
| 677 |
type_=typing.Any, |
| 678 |
object_=_response.json(), |
| 679 |
), |
| 680 |
), |
| 681 |
) |
| 682 |
if _response.status_code == 403: |
| 683 |
raise ForbiddenError( |
| 684 |
headers=dict(_response.headers), |
| 685 |
body=typing.cast( |
| 686 |
typing.Any, |
| 687 |
parse_obj_as( |
| 688 |
type_=typing.Any, |
| 689 |
object_=_response.json(), |
| 690 |
), |
| 691 |
), |
| 692 |
) |
| 693 |
if _response.status_code == 429: |
| 694 |
raise TooManyRequestsError( |
| 695 |
headers=dict(_response.headers), |
| 696 |
body=typing.cast( |
| 697 |
typing.Any, |
| 698 |
parse_obj_as( |
| 699 |
type_=typing.Any, |
| 700 |
object_=_response.json(), |
| 701 |
), |
| 702 |
), |
| 703 |
) |
| 704 |
_response_json = _response.json() |
| 705 |
except JSONDecodeError: |
| 706 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 707 |
except ValidationError as e: |
| 708 |
raise ParsingError( |
| 709 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 710 |
) |
| 711 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 712 |
|
| 713 |
async def update( |
| 714 |
self, |
| 715 |
id: str, |
| 716 |
*, |
| 717 |
request: UpdateHookSecretRequestContent, |
| 718 |
request_options: typing.Optional[RequestOptions] = None, |
| 719 |
) -> AsyncHttpResponse[None]: |
| 720 |
""" |
| 721 |
Update one or more existing secrets for an existing hook. Accepts an object of key-value pairs, where the key is the name of the existing secret. |
| 722 |
|
| 723 |
Parameters |
| 724 |
---------- |
| 725 |
id : str |
| 726 |
ID of the hook whose secrets to update. |
| 727 |
|
| 728 |
request : UpdateHookSecretRequestContent |
| 729 |
|
| 730 |
request_options : typing.Optional[RequestOptions] |
| 731 |
Request-specific configuration. |
| 732 |
|
| 733 |
Returns |
| 734 |
------- |
| 735 |
AsyncHttpResponse[None] |
| 736 |
""" |
| 737 |
_response = await self._client_wrapper.httpx_client.request( |
| 738 |
f"hooks/{encode_path_param(id)}/secrets", |
| 739 |
method="PATCH", |
| 740 |
json=request, |
| 741 |
request_options=request_options, |
| 742 |
omit=OMIT, |
| 743 |
) |
| 744 |
try: |
| 745 |
if 200 <= _response.status_code < 300: |
| 746 |
return AsyncHttpResponse(response=_response, data=None) |
| 747 |
if _response.status_code == 400: |
| 748 |
raise BadRequestError( |
| 749 |
headers=dict(_response.headers), |
| 750 |
body=typing.cast( |
| 751 |
typing.Any, |
| 752 |
parse_obj_as( |
| 753 |
type_=typing.Any, |
| 754 |
object_=_response.json(), |
| 755 |
), |
| 756 |
), |
| 757 |
) |
| 758 |
if _response.status_code == 401: |
| 759 |
raise UnauthorizedError( |
| 760 |
headers=dict(_response.headers), |
| 761 |
body=typing.cast( |
| 762 |
typing.Any, |
| 763 |
parse_obj_as( |
| 764 |
type_=typing.Any, |
| 765 |
object_=_response.json(), |
| 766 |
), |
| 767 |
), |
| 768 |
) |
| 769 |
if _response.status_code == 403: |
| 770 |
raise ForbiddenError( |
| 771 |
headers=dict(_response.headers), |
| 772 |
body=typing.cast( |
| 773 |
typing.Any, |
| 774 |
parse_obj_as( |
| 775 |
type_=typing.Any, |
| 776 |
object_=_response.json(), |
| 777 |
), |
| 778 |
), |
| 779 |
) |
| 780 |
if _response.status_code == 404: |
| 781 |
raise NotFoundError( |
| 782 |
headers=dict(_response.headers), |
| 783 |
body=typing.cast( |
| 784 |
typing.Any, |
| 785 |
parse_obj_as( |
| 786 |
type_=typing.Any, |
| 787 |
object_=_response.json(), |
| 788 |
), |
| 789 |
), |
| 790 |
) |
| 791 |
if _response.status_code == 409: |
| 792 |
raise ConflictError( |
| 793 |
headers=dict(_response.headers), |
| 794 |
body=typing.cast( |
| 795 |
typing.Any, |
| 796 |
parse_obj_as( |
| 797 |
type_=typing.Any, |
| 798 |
object_=_response.json(), |
| 799 |
), |
| 800 |
), |
| 801 |
) |
| 802 |
if _response.status_code == 429: |
| 803 |
raise TooManyRequestsError( |
| 804 |
headers=dict(_response.headers), |
| 805 |
body=typing.cast( |
| 806 |
typing.Any, |
| 807 |
parse_obj_as( |
| 808 |
type_=typing.Any, |
| 809 |
object_=_response.json(), |
| 810 |
), |
| 811 |
), |
| 812 |
) |
| 813 |
_response_json = _response.json() |
| 814 |
except JSONDecodeError: |
| 815 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 816 |
except ValidationError as e: |
| 817 |
raise ParsingError( |
| 818 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 819 |
) |
| 820 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |