| 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.conflict_error import ConflictError |
| 17 |
from ..errors.forbidden_error import ForbiddenError |
| 18 |
from ..errors.internal_server_error import InternalServerError |
| 19 |
from ..errors.not_found_error import NotFoundError |
| 20 |
from ..errors.too_many_requests_error import TooManyRequestsError |
| 21 |
from ..errors.unauthorized_error import UnauthorizedError |
| 22 |
from ..types.get_network_acls_response_content import GetNetworkAclsResponseContent |
| 23 |
from ..types.list_network_acls_offset_paginated_response_content import ListNetworkAclsOffsetPaginatedResponseContent |
| 24 |
from ..types.network_acl_rule import NetworkAclRule |
| 25 |
from ..types.network_acls_response_content import NetworkAclsResponseContent |
| 26 |
from ..types.set_network_acls_response_content import SetNetworkAclsResponseContent |
| 27 |
from ..types.update_network_acl_response_content import UpdateNetworkAclResponseContent |
| 28 |
from pydantic import ValidationError |
| 29 |
|
| 30 |
|
| 31 |
OMIT = typing.cast(typing.Any, ...) |
| 32 |
|
| 33 |
|
| 34 |
class RawNetworkAclsClient: |
| 35 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 36 |
self._client_wrapper = client_wrapper |
| 37 |
|
| 38 |
def list( |
| 39 |
self, |
| 40 |
*, |
| 41 |
page: typing.Optional[int] = 0, |
| 42 |
per_page: typing.Optional[int] = 50, |
| 43 |
include_totals: typing.Optional[bool] = True, |
| 44 |
request_options: typing.Optional[RequestOptions] = None, |
| 45 |
) -> SyncPager[NetworkAclsResponseContent, ListNetworkAclsOffsetPaginatedResponseContent]: |
| 46 |
""" |
| 47 |
Get all access control list entries for your client. |
| 48 |
|
| 49 |
Parameters |
| 50 |
---------- |
| 51 |
page : typing.Optional[int] |
| 52 |
Use this field to request a specific page of the list results. |
| 53 |
|
| 54 |
per_page : typing.Optional[int] |
| 55 |
The amount of results per page. |
| 56 |
|
| 57 |
include_totals : typing.Optional[bool] |
| 58 |
Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). |
| 59 |
|
| 60 |
request_options : typing.Optional[RequestOptions] |
| 61 |
Request-specific configuration. |
| 62 |
|
| 63 |
Returns |
| 64 |
------- |
| 65 |
SyncPager[NetworkAclsResponseContent, ListNetworkAclsOffsetPaginatedResponseContent] |
| 66 |
Network access control list successfully retrieved. |
| 67 |
""" |
| 68 |
page = page if page is not None else 0 |
| 69 |
|
| 70 |
_response = self._client_wrapper.httpx_client.request( |
| 71 |
"network-acls", |
| 72 |
method="GET", |
| 73 |
params={ |
| 74 |
"page": page, |
| 75 |
"per_page": per_page, |
| 76 |
"include_totals": include_totals, |
| 77 |
}, |
| 78 |
request_options=request_options, |
| 79 |
) |
| 80 |
try: |
| 81 |
if 200 <= _response.status_code < 300: |
| 82 |
_parsed_response = typing.cast( |
| 83 |
ListNetworkAclsOffsetPaginatedResponseContent, |
| 84 |
parse_obj_as( |
| 85 |
type_=ListNetworkAclsOffsetPaginatedResponseContent, |
| 86 |
object_=_response.json(), |
| 87 |
), |
| 88 |
) |
| 89 |
_items = _parsed_response.network_acls |
| 90 |
_has_next = len(_items or []) > 0 |
| 91 |
_get_next = lambda: self.list( |
| 92 |
page=page + 1, |
| 93 |
per_page=per_page, |
| 94 |
include_totals=include_totals, |
| 95 |
request_options=request_options, |
| 96 |
) |
| 97 |
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 98 |
if _response.status_code == 401: |
| 99 |
raise UnauthorizedError( |
| 100 |
headers=dict(_response.headers), |
| 101 |
body=typing.cast( |
| 102 |
typing.Any, |
| 103 |
parse_obj_as( |
| 104 |
type_=typing.Any, |
| 105 |
object_=_response.json(), |
| 106 |
), |
| 107 |
), |
| 108 |
) |
| 109 |
if _response.status_code == 403: |
| 110 |
raise ForbiddenError( |
| 111 |
headers=dict(_response.headers), |
| 112 |
body=typing.cast( |
| 113 |
typing.Any, |
| 114 |
parse_obj_as( |
| 115 |
type_=typing.Any, |
| 116 |
object_=_response.json(), |
| 117 |
), |
| 118 |
), |
| 119 |
) |
| 120 |
if _response.status_code == 404: |
| 121 |
raise NotFoundError( |
| 122 |
headers=dict(_response.headers), |
| 123 |
body=typing.cast( |
| 124 |
typing.Any, |
| 125 |
parse_obj_as( |
| 126 |
type_=typing.Any, |
| 127 |
object_=_response.json(), |
| 128 |
), |
| 129 |
), |
| 130 |
) |
| 131 |
if _response.status_code == 429: |
| 132 |
raise TooManyRequestsError( |
| 133 |
headers=dict(_response.headers), |
| 134 |
body=typing.cast( |
| 135 |
typing.Any, |
| 136 |
parse_obj_as( |
| 137 |
type_=typing.Any, |
| 138 |
object_=_response.json(), |
| 139 |
), |
| 140 |
), |
| 141 |
) |
| 142 |
_response_json = _response.json() |
| 143 |
except JSONDecodeError: |
| 144 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 145 |
except ValidationError as e: |
| 146 |
raise ParsingError( |
| 147 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 148 |
) |
| 149 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 150 |
|
| 151 |
def create( |
| 152 |
self, |
| 153 |
*, |
| 154 |
description: str, |
| 155 |
active: bool, |
| 156 |
rule: NetworkAclRule, |
| 157 |
priority: typing.Optional[float] = OMIT, |
| 158 |
request_options: typing.Optional[RequestOptions] = None, |
| 159 |
) -> HttpResponse[None]: |
| 160 |
""" |
| 161 |
Create a new access control list for your client. |
| 162 |
|
| 163 |
Parameters |
| 164 |
---------- |
| 165 |
description : str |
| 166 |
|
| 167 |
active : bool |
| 168 |
Indicates whether or not this access control list is actively being used |
| 169 |
|
| 170 |
rule : NetworkAclRule |
| 171 |
|
| 172 |
priority : typing.Optional[float] |
| 173 |
Indicates the order in which the ACL will be evaluated relative to other ACL rules. |
| 174 |
|
| 175 |
request_options : typing.Optional[RequestOptions] |
| 176 |
Request-specific configuration. |
| 177 |
|
| 178 |
Returns |
| 179 |
------- |
| 180 |
HttpResponse[None] |
| 181 |
""" |
| 182 |
_response = self._client_wrapper.httpx_client.request( |
| 183 |
"network-acls", |
| 184 |
method="POST", |
| 185 |
json={ |
| 186 |
"description": description, |
| 187 |
"active": active, |
| 188 |
"priority": priority, |
| 189 |
"rule": convert_and_respect_annotation_metadata( |
| 190 |
object_=rule, annotation=NetworkAclRule, direction="write" |
| 191 |
), |
| 192 |
}, |
| 193 |
headers={ |
| 194 |
"content-type": "application/json", |
| 195 |
}, |
| 196 |
request_options=request_options, |
| 197 |
omit=OMIT, |
| 198 |
) |
| 199 |
try: |
| 200 |
if 200 <= _response.status_code < 300: |
| 201 |
return HttpResponse(response=_response, data=None) |
| 202 |
if _response.status_code == 400: |
| 203 |
raise BadRequestError( |
| 204 |
headers=dict(_response.headers), |
| 205 |
body=typing.cast( |
| 206 |
typing.Any, |
| 207 |
parse_obj_as( |
| 208 |
type_=typing.Any, |
| 209 |
object_=_response.json(), |
| 210 |
), |
| 211 |
), |
| 212 |
) |
| 213 |
if _response.status_code == 401: |
| 214 |
raise UnauthorizedError( |
| 215 |
headers=dict(_response.headers), |
| 216 |
body=typing.cast( |
| 217 |
typing.Any, |
| 218 |
parse_obj_as( |
| 219 |
type_=typing.Any, |
| 220 |
object_=_response.json(), |
| 221 |
), |
| 222 |
), |
| 223 |
) |
| 224 |
if _response.status_code == 403: |
| 225 |
raise ForbiddenError( |
| 226 |
headers=dict(_response.headers), |
| 227 |
body=typing.cast( |
| 228 |
typing.Any, |
| 229 |
parse_obj_as( |
| 230 |
type_=typing.Any, |
| 231 |
object_=_response.json(), |
| 232 |
), |
| 233 |
), |
| 234 |
) |
| 235 |
if _response.status_code == 409: |
| 236 |
raise ConflictError( |
| 237 |
headers=dict(_response.headers), |
| 238 |
body=typing.cast( |
| 239 |
typing.Any, |
| 240 |
parse_obj_as( |
| 241 |
type_=typing.Any, |
| 242 |
object_=_response.json(), |
| 243 |
), |
| 244 |
), |
| 245 |
) |
| 246 |
if _response.status_code == 429: |
| 247 |
raise TooManyRequestsError( |
| 248 |
headers=dict(_response.headers), |
| 249 |
body=typing.cast( |
| 250 |
typing.Any, |
| 251 |
parse_obj_as( |
| 252 |
type_=typing.Any, |
| 253 |
object_=_response.json(), |
| 254 |
), |
| 255 |
), |
| 256 |
) |
| 257 |
if _response.status_code == 500: |
| 258 |
raise InternalServerError( |
| 259 |
headers=dict(_response.headers), |
| 260 |
body=typing.cast( |
| 261 |
typing.Any, |
| 262 |
parse_obj_as( |
| 263 |
type_=typing.Any, |
| 264 |
object_=_response.json(), |
| 265 |
), |
| 266 |
), |
| 267 |
) |
| 268 |
_response_json = _response.json() |
| 269 |
except JSONDecodeError: |
| 270 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 271 |
except ValidationError as e: |
| 272 |
raise ParsingError( |
| 273 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 274 |
) |
| 275 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 276 |
|
| 277 |
def get( |
| 278 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 279 |
) -> HttpResponse[GetNetworkAclsResponseContent]: |
| 280 |
""" |
| 281 |
Get a specific access control list entry for your client. |
| 282 |
|
| 283 |
Parameters |
| 284 |
---------- |
| 285 |
id : str |
| 286 |
The id of the access control list to retrieve. |
| 287 |
|
| 288 |
request_options : typing.Optional[RequestOptions] |
| 289 |
Request-specific configuration. |
| 290 |
|
| 291 |
Returns |
| 292 |
------- |
| 293 |
HttpResponse[GetNetworkAclsResponseContent] |
| 294 |
Network access control list successfully retrieved. |
| 295 |
""" |
| 296 |
_response = self._client_wrapper.httpx_client.request( |
| 297 |
f"network-acls/{encode_path_param(id)}", |
| 298 |
method="GET", |
| 299 |
request_options=request_options, |
| 300 |
) |
| 301 |
try: |
| 302 |
if 200 <= _response.status_code < 300: |
| 303 |
_data = typing.cast( |
| 304 |
GetNetworkAclsResponseContent, |
| 305 |
parse_obj_as( |
| 306 |
type_=GetNetworkAclsResponseContent, |
| 307 |
object_=_response.json(), |
| 308 |
), |
| 309 |
) |
| 310 |
return HttpResponse(response=_response, data=_data) |
| 311 |
if _response.status_code == 401: |
| 312 |
raise UnauthorizedError( |
| 313 |
headers=dict(_response.headers), |
| 314 |
body=typing.cast( |
| 315 |
typing.Any, |
| 316 |
parse_obj_as( |
| 317 |
type_=typing.Any, |
| 318 |
object_=_response.json(), |
| 319 |
), |
| 320 |
), |
| 321 |
) |
| 322 |
if _response.status_code == 403: |
| 323 |
raise ForbiddenError( |
| 324 |
headers=dict(_response.headers), |
| 325 |
body=typing.cast( |
| 326 |
typing.Any, |
| 327 |
parse_obj_as( |
| 328 |
type_=typing.Any, |
| 329 |
object_=_response.json(), |
| 330 |
), |
| 331 |
), |
| 332 |
) |
| 333 |
if _response.status_code == 404: |
| 334 |
raise NotFoundError( |
| 335 |
headers=dict(_response.headers), |
| 336 |
body=typing.cast( |
| 337 |
typing.Any, |
| 338 |
parse_obj_as( |
| 339 |
type_=typing.Any, |
| 340 |
object_=_response.json(), |
| 341 |
), |
| 342 |
), |
| 343 |
) |
| 344 |
if _response.status_code == 429: |
| 345 |
raise TooManyRequestsError( |
| 346 |
headers=dict(_response.headers), |
| 347 |
body=typing.cast( |
| 348 |
typing.Any, |
| 349 |
parse_obj_as( |
| 350 |
type_=typing.Any, |
| 351 |
object_=_response.json(), |
| 352 |
), |
| 353 |
), |
| 354 |
) |
| 355 |
_response_json = _response.json() |
| 356 |
except JSONDecodeError: |
| 357 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 358 |
except ValidationError as e: |
| 359 |
raise ParsingError( |
| 360 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 361 |
) |
| 362 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 363 |
|
| 364 |
def set( |
| 365 |
self, |
| 366 |
id: str, |
| 367 |
*, |
| 368 |
description: str, |
| 369 |
active: bool, |
| 370 |
rule: NetworkAclRule, |
| 371 |
priority: typing.Optional[float] = OMIT, |
| 372 |
request_options: typing.Optional[RequestOptions] = None, |
| 373 |
) -> HttpResponse[SetNetworkAclsResponseContent]: |
| 374 |
""" |
| 375 |
Update existing access control list for your client. |
| 376 |
|
| 377 |
Parameters |
| 378 |
---------- |
| 379 |
id : str |
| 380 |
The id of the ACL to update. |
| 381 |
|
| 382 |
description : str |
| 383 |
|
| 384 |
active : bool |
| 385 |
Indicates whether or not this access control list is actively being used |
| 386 |
|
| 387 |
rule : NetworkAclRule |
| 388 |
|
| 389 |
priority : typing.Optional[float] |
| 390 |
Indicates the order in which the ACL will be evaluated relative to other ACL rules. |
| 391 |
|
| 392 |
request_options : typing.Optional[RequestOptions] |
| 393 |
Request-specific configuration. |
| 394 |
|
| 395 |
Returns |
| 396 |
------- |
| 397 |
HttpResponse[SetNetworkAclsResponseContent] |
| 398 |
Network ACL properties successfully updated |
| 399 |
""" |
| 400 |
_response = self._client_wrapper.httpx_client.request( |
| 401 |
f"network-acls/{encode_path_param(id)}", |
| 402 |
method="PUT", |
| 403 |
json={ |
| 404 |
"description": description, |
| 405 |
"active": active, |
| 406 |
"priority": priority, |
| 407 |
"rule": convert_and_respect_annotation_metadata( |
| 408 |
object_=rule, annotation=NetworkAclRule, direction="write" |
| 409 |
), |
| 410 |
}, |
| 411 |
headers={ |
| 412 |
"content-type": "application/json", |
| 413 |
}, |
| 414 |
request_options=request_options, |
| 415 |
omit=OMIT, |
| 416 |
) |
| 417 |
try: |
| 418 |
if 200 <= _response.status_code < 300: |
| 419 |
_data = typing.cast( |
| 420 |
SetNetworkAclsResponseContent, |
| 421 |
parse_obj_as( |
| 422 |
type_=SetNetworkAclsResponseContent, |
| 423 |
object_=_response.json(), |
| 424 |
), |
| 425 |
) |
| 426 |
return HttpResponse(response=_response, data=_data) |
| 427 |
if _response.status_code == 400: |
| 428 |
raise BadRequestError( |
| 429 |
headers=dict(_response.headers), |
| 430 |
body=typing.cast( |
| 431 |
typing.Any, |
| 432 |
parse_obj_as( |
| 433 |
type_=typing.Any, |
| 434 |
object_=_response.json(), |
| 435 |
), |
| 436 |
), |
| 437 |
) |
| 438 |
if _response.status_code == 401: |
| 439 |
raise UnauthorizedError( |
| 440 |
headers=dict(_response.headers), |
| 441 |
body=typing.cast( |
| 442 |
typing.Any, |
| 443 |
parse_obj_as( |
| 444 |
type_=typing.Any, |
| 445 |
object_=_response.json(), |
| 446 |
), |
| 447 |
), |
| 448 |
) |
| 449 |
if _response.status_code == 403: |
| 450 |
raise ForbiddenError( |
| 451 |
headers=dict(_response.headers), |
| 452 |
body=typing.cast( |
| 453 |
typing.Any, |
| 454 |
parse_obj_as( |
| 455 |
type_=typing.Any, |
| 456 |
object_=_response.json(), |
| 457 |
), |
| 458 |
), |
| 459 |
) |
| 460 |
if _response.status_code == 404: |
| 461 |
raise NotFoundError( |
| 462 |
headers=dict(_response.headers), |
| 463 |
body=typing.cast( |
| 464 |
typing.Any, |
| 465 |
parse_obj_as( |
| 466 |
type_=typing.Any, |
| 467 |
object_=_response.json(), |
| 468 |
), |
| 469 |
), |
| 470 |
) |
| 471 |
if _response.status_code == 429: |
| 472 |
raise TooManyRequestsError( |
| 473 |
headers=dict(_response.headers), |
| 474 |
body=typing.cast( |
| 475 |
typing.Any, |
| 476 |
parse_obj_as( |
| 477 |
type_=typing.Any, |
| 478 |
object_=_response.json(), |
| 479 |
), |
| 480 |
), |
| 481 |
) |
| 482 |
_response_json = _response.json() |
| 483 |
except JSONDecodeError: |
| 484 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 485 |
except ValidationError as e: |
| 486 |
raise ParsingError( |
| 487 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 488 |
) |
| 489 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 490 |
|
| 491 |
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> HttpResponse[None]: |
| 492 |
""" |
| 493 |
Delete existing access control list for your client. |
| 494 |
|
| 495 |
Parameters |
| 496 |
---------- |
| 497 |
id : str |
| 498 |
The id of the ACL to delete |
| 499 |
|
| 500 |
request_options : typing.Optional[RequestOptions] |
| 501 |
Request-specific configuration. |
| 502 |
|
| 503 |
Returns |
| 504 |
------- |
| 505 |
HttpResponse[None] |
| 506 |
""" |
| 507 |
_response = self._client_wrapper.httpx_client.request( |
| 508 |
f"network-acls/{encode_path_param(id)}", |
| 509 |
method="DELETE", |
| 510 |
request_options=request_options, |
| 511 |
) |
| 512 |
try: |
| 513 |
if 200 <= _response.status_code < 300: |
| 514 |
return HttpResponse(response=_response, data=None) |
| 515 |
if _response.status_code == 400: |
| 516 |
raise BadRequestError( |
| 517 |
headers=dict(_response.headers), |
| 518 |
body=typing.cast( |
| 519 |
typing.Any, |
| 520 |
parse_obj_as( |
| 521 |
type_=typing.Any, |
| 522 |
object_=_response.json(), |
| 523 |
), |
| 524 |
), |
| 525 |
) |
| 526 |
if _response.status_code == 401: |
| 527 |
raise UnauthorizedError( |
| 528 |
headers=dict(_response.headers), |
| 529 |
body=typing.cast( |
| 530 |
typing.Any, |
| 531 |
parse_obj_as( |
| 532 |
type_=typing.Any, |
| 533 |
object_=_response.json(), |
| 534 |
), |
| 535 |
), |
| 536 |
) |
| 537 |
if _response.status_code == 403: |
| 538 |
raise ForbiddenError( |
| 539 |
headers=dict(_response.headers), |
| 540 |
body=typing.cast( |
| 541 |
typing.Any, |
| 542 |
parse_obj_as( |
| 543 |
type_=typing.Any, |
| 544 |
object_=_response.json(), |
| 545 |
), |
| 546 |
), |
| 547 |
) |
| 548 |
if _response.status_code == 404: |
| 549 |
raise NotFoundError( |
| 550 |
headers=dict(_response.headers), |
| 551 |
body=typing.cast( |
| 552 |
typing.Any, |
| 553 |
parse_obj_as( |
| 554 |
type_=typing.Any, |
| 555 |
object_=_response.json(), |
| 556 |
), |
| 557 |
), |
| 558 |
) |
| 559 |
if _response.status_code == 429: |
| 560 |
raise TooManyRequestsError( |
| 561 |
headers=dict(_response.headers), |
| 562 |
body=typing.cast( |
| 563 |
typing.Any, |
| 564 |
parse_obj_as( |
| 565 |
type_=typing.Any, |
| 566 |
object_=_response.json(), |
| 567 |
), |
| 568 |
), |
| 569 |
) |
| 570 |
_response_json = _response.json() |
| 571 |
except JSONDecodeError: |
| 572 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 573 |
except ValidationError as e: |
| 574 |
raise ParsingError( |
| 575 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 576 |
) |
| 577 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 578 |
|
| 579 |
def update( |
| 580 |
self, |
| 581 |
id: str, |
| 582 |
*, |
| 583 |
description: typing.Optional[str] = OMIT, |
| 584 |
active: typing.Optional[bool] = OMIT, |
| 585 |
priority: typing.Optional[float] = OMIT, |
| 586 |
rule: typing.Optional[NetworkAclRule] = OMIT, |
| 587 |
request_options: typing.Optional[RequestOptions] = None, |
| 588 |
) -> HttpResponse[UpdateNetworkAclResponseContent]: |
| 589 |
""" |
| 590 |
Update existing access control list for your client. |
| 591 |
|
| 592 |
Parameters |
| 593 |
---------- |
| 594 |
id : str |
| 595 |
The id of the ACL to update. |
| 596 |
|
| 597 |
description : typing.Optional[str] |
| 598 |
|
| 599 |
active : typing.Optional[bool] |
| 600 |
Indicates whether or not this access control list is actively being used |
| 601 |
|
| 602 |
priority : typing.Optional[float] |
| 603 |
Indicates the order in which the ACL will be evaluated relative to other ACL rules. |
| 604 |
|
| 605 |
rule : typing.Optional[NetworkAclRule] |
| 606 |
|
| 607 |
request_options : typing.Optional[RequestOptions] |
| 608 |
Request-specific configuration. |
| 609 |
|
| 610 |
Returns |
| 611 |
------- |
| 612 |
HttpResponse[UpdateNetworkAclResponseContent] |
| 613 |
Network ACL properties successfully updated |
| 614 |
""" |
| 615 |
_response = self._client_wrapper.httpx_client.request( |
| 616 |
f"network-acls/{encode_path_param(id)}", |
| 617 |
method="PATCH", |
| 618 |
json={ |
| 619 |
"description": description, |
| 620 |
"active": active, |
| 621 |
"priority": priority, |
| 622 |
"rule": convert_and_respect_annotation_metadata( |
| 623 |
object_=rule, annotation=NetworkAclRule, direction="write" |
| 624 |
), |
| 625 |
}, |
| 626 |
headers={ |
| 627 |
"content-type": "application/json", |
| 628 |
}, |
| 629 |
request_options=request_options, |
| 630 |
omit=OMIT, |
| 631 |
) |
| 632 |
try: |
| 633 |
if 200 <= _response.status_code < 300: |
| 634 |
_data = typing.cast( |
| 635 |
UpdateNetworkAclResponseContent, |
| 636 |
parse_obj_as( |
| 637 |
type_=UpdateNetworkAclResponseContent, |
| 638 |
object_=_response.json(), |
| 639 |
), |
| 640 |
) |
| 641 |
return HttpResponse(response=_response, data=_data) |
| 642 |
if _response.status_code == 400: |
| 643 |
raise BadRequestError( |
| 644 |
headers=dict(_response.headers), |
| 645 |
body=typing.cast( |
| 646 |
typing.Any, |
| 647 |
parse_obj_as( |
| 648 |
type_=typing.Any, |
| 649 |
object_=_response.json(), |
| 650 |
), |
| 651 |
), |
| 652 |
) |
| 653 |
if _response.status_code == 401: |
| 654 |
raise UnauthorizedError( |
| 655 |
headers=dict(_response.headers), |
| 656 |
body=typing.cast( |
| 657 |
typing.Any, |
| 658 |
parse_obj_as( |
| 659 |
type_=typing.Any, |
| 660 |
object_=_response.json(), |
| 661 |
), |
| 662 |
), |
| 663 |
) |
| 664 |
if _response.status_code == 403: |
| 665 |
raise ForbiddenError( |
| 666 |
headers=dict(_response.headers), |
| 667 |
body=typing.cast( |
| 668 |
typing.Any, |
| 669 |
parse_obj_as( |
| 670 |
type_=typing.Any, |
| 671 |
object_=_response.json(), |
| 672 |
), |
| 673 |
), |
| 674 |
) |
| 675 |
if _response.status_code == 404: |
| 676 |
raise NotFoundError( |
| 677 |
headers=dict(_response.headers), |
| 678 |
body=typing.cast( |
| 679 |
typing.Any, |
| 680 |
parse_obj_as( |
| 681 |
type_=typing.Any, |
| 682 |
object_=_response.json(), |
| 683 |
), |
| 684 |
), |
| 685 |
) |
| 686 |
if _response.status_code == 429: |
| 687 |
raise TooManyRequestsError( |
| 688 |
headers=dict(_response.headers), |
| 689 |
body=typing.cast( |
| 690 |
typing.Any, |
| 691 |
parse_obj_as( |
| 692 |
type_=typing.Any, |
| 693 |
object_=_response.json(), |
| 694 |
), |
| 695 |
), |
| 696 |
) |
| 697 |
_response_json = _response.json() |
| 698 |
except JSONDecodeError: |
| 699 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 700 |
except ValidationError as e: |
| 701 |
raise ParsingError( |
| 702 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 703 |
) |
| 704 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 705 |
|
| 706 |
|
| 707 |
class AsyncRawNetworkAclsClient: |
| 708 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 709 |
self._client_wrapper = client_wrapper |
| 710 |
|
| 711 |
async def list( |
| 712 |
self, |
| 713 |
*, |
| 714 |
page: typing.Optional[int] = 0, |
| 715 |
per_page: typing.Optional[int] = 50, |
| 716 |
include_totals: typing.Optional[bool] = True, |
| 717 |
request_options: typing.Optional[RequestOptions] = None, |
| 718 |
) -> AsyncPager[NetworkAclsResponseContent, ListNetworkAclsOffsetPaginatedResponseContent]: |
| 719 |
""" |
| 720 |
Get all access control list entries for your client. |
| 721 |
|
| 722 |
Parameters |
| 723 |
---------- |
| 724 |
page : typing.Optional[int] |
| 725 |
Use this field to request a specific page of the list results. |
| 726 |
|
| 727 |
per_page : typing.Optional[int] |
| 728 |
The amount of results per page. |
| 729 |
|
| 730 |
include_totals : typing.Optional[bool] |
| 731 |
Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). |
| 732 |
|
| 733 |
request_options : typing.Optional[RequestOptions] |
| 734 |
Request-specific configuration. |
| 735 |
|
| 736 |
Returns |
| 737 |
------- |
| 738 |
AsyncPager[NetworkAclsResponseContent, ListNetworkAclsOffsetPaginatedResponseContent] |
| 739 |
Network access control list successfully retrieved. |
| 740 |
""" |
| 741 |
page = page if page is not None else 0 |
| 742 |
|
| 743 |
_response = await self._client_wrapper.httpx_client.request( |
| 744 |
"network-acls", |
| 745 |
method="GET", |
| 746 |
params={ |
| 747 |
"page": page, |
| 748 |
"per_page": per_page, |
| 749 |
"include_totals": include_totals, |
| 750 |
}, |
| 751 |
request_options=request_options, |
| 752 |
) |
| 753 |
try: |
| 754 |
if 200 <= _response.status_code < 300: |
| 755 |
_parsed_response = typing.cast( |
| 756 |
ListNetworkAclsOffsetPaginatedResponseContent, |
| 757 |
parse_obj_as( |
| 758 |
type_=ListNetworkAclsOffsetPaginatedResponseContent, |
| 759 |
object_=_response.json(), |
| 760 |
), |
| 761 |
) |
| 762 |
_items = _parsed_response.network_acls |
| 763 |
_has_next = len(_items or []) > 0 |
| 764 |
|
| 765 |
async def _get_next(): |
| 766 |
return await self.list( |
| 767 |
page=page + 1, |
| 768 |
per_page=per_page, |
| 769 |
include_totals=include_totals, |
| 770 |
request_options=request_options, |
| 771 |
) |
| 772 |
|
| 773 |
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next, response=_parsed_response) |
| 774 |
if _response.status_code == 401: |
| 775 |
raise UnauthorizedError( |
| 776 |
headers=dict(_response.headers), |
| 777 |
body=typing.cast( |
| 778 |
typing.Any, |
| 779 |
parse_obj_as( |
| 780 |
type_=typing.Any, |
| 781 |
object_=_response.json(), |
| 782 |
), |
| 783 |
), |
| 784 |
) |
| 785 |
if _response.status_code == 403: |
| 786 |
raise ForbiddenError( |
| 787 |
headers=dict(_response.headers), |
| 788 |
body=typing.cast( |
| 789 |
typing.Any, |
| 790 |
parse_obj_as( |
| 791 |
type_=typing.Any, |
| 792 |
object_=_response.json(), |
| 793 |
), |
| 794 |
), |
| 795 |
) |
| 796 |
if _response.status_code == 404: |
| 797 |
raise NotFoundError( |
| 798 |
headers=dict(_response.headers), |
| 799 |
body=typing.cast( |
| 800 |
typing.Any, |
| 801 |
parse_obj_as( |
| 802 |
type_=typing.Any, |
| 803 |
object_=_response.json(), |
| 804 |
), |
| 805 |
), |
| 806 |
) |
| 807 |
if _response.status_code == 429: |
| 808 |
raise TooManyRequestsError( |
| 809 |
headers=dict(_response.headers), |
| 810 |
body=typing.cast( |
| 811 |
typing.Any, |
| 812 |
parse_obj_as( |
| 813 |
type_=typing.Any, |
| 814 |
object_=_response.json(), |
| 815 |
), |
| 816 |
), |
| 817 |
) |
| 818 |
_response_json = _response.json() |
| 819 |
except JSONDecodeError: |
| 820 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 821 |
except ValidationError as e: |
| 822 |
raise ParsingError( |
| 823 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 824 |
) |
| 825 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 826 |
|
| 827 |
async def create( |
| 828 |
self, |
| 829 |
*, |
| 830 |
description: str, |
| 831 |
active: bool, |
| 832 |
rule: NetworkAclRule, |
| 833 |
priority: typing.Optional[float] = OMIT, |
| 834 |
request_options: typing.Optional[RequestOptions] = None, |
| 835 |
) -> AsyncHttpResponse[None]: |
| 836 |
""" |
| 837 |
Create a new access control list for your client. |
| 838 |
|
| 839 |
Parameters |
| 840 |
---------- |
| 841 |
description : str |
| 842 |
|
| 843 |
active : bool |
| 844 |
Indicates whether or not this access control list is actively being used |
| 845 |
|
| 846 |
rule : NetworkAclRule |
| 847 |
|
| 848 |
priority : typing.Optional[float] |
| 849 |
Indicates the order in which the ACL will be evaluated relative to other ACL rules. |
| 850 |
|
| 851 |
request_options : typing.Optional[RequestOptions] |
| 852 |
Request-specific configuration. |
| 853 |
|
| 854 |
Returns |
| 855 |
------- |
| 856 |
AsyncHttpResponse[None] |
| 857 |
""" |
| 858 |
_response = await self._client_wrapper.httpx_client.request( |
| 859 |
"network-acls", |
| 860 |
method="POST", |
| 861 |
json={ |
| 862 |
"description": description, |
| 863 |
"active": active, |
| 864 |
"priority": priority, |
| 865 |
"rule": convert_and_respect_annotation_metadata( |
| 866 |
object_=rule, annotation=NetworkAclRule, direction="write" |
| 867 |
), |
| 868 |
}, |
| 869 |
headers={ |
| 870 |
"content-type": "application/json", |
| 871 |
}, |
| 872 |
request_options=request_options, |
| 873 |
omit=OMIT, |
| 874 |
) |
| 875 |
try: |
| 876 |
if 200 <= _response.status_code < 300: |
| 877 |
return AsyncHttpResponse(response=_response, data=None) |
| 878 |
if _response.status_code == 400: |
| 879 |
raise BadRequestError( |
| 880 |
headers=dict(_response.headers), |
| 881 |
body=typing.cast( |
| 882 |
typing.Any, |
| 883 |
parse_obj_as( |
| 884 |
type_=typing.Any, |
| 885 |
object_=_response.json(), |
| 886 |
), |
| 887 |
), |
| 888 |
) |
| 889 |
if _response.status_code == 401: |
| 890 |
raise UnauthorizedError( |
| 891 |
headers=dict(_response.headers), |
| 892 |
body=typing.cast( |
| 893 |
typing.Any, |
| 894 |
parse_obj_as( |
| 895 |
type_=typing.Any, |
| 896 |
object_=_response.json(), |
| 897 |
), |
| 898 |
), |
| 899 |
) |
| 900 |
if _response.status_code == 403: |
| 901 |
raise ForbiddenError( |
| 902 |
headers=dict(_response.headers), |
| 903 |
body=typing.cast( |
| 904 |
typing.Any, |
| 905 |
parse_obj_as( |
| 906 |
type_=typing.Any, |
| 907 |
object_=_response.json(), |
| 908 |
), |
| 909 |
), |
| 910 |
) |
| 911 |
if _response.status_code == 409: |
| 912 |
raise ConflictError( |
| 913 |
headers=dict(_response.headers), |
| 914 |
body=typing.cast( |
| 915 |
typing.Any, |
| 916 |
parse_obj_as( |
| 917 |
type_=typing.Any, |
| 918 |
object_=_response.json(), |
| 919 |
), |
| 920 |
), |
| 921 |
) |
| 922 |
if _response.status_code == 429: |
| 923 |
raise TooManyRequestsError( |
| 924 |
headers=dict(_response.headers), |
| 925 |
body=typing.cast( |
| 926 |
typing.Any, |
| 927 |
parse_obj_as( |
| 928 |
type_=typing.Any, |
| 929 |
object_=_response.json(), |
| 930 |
), |
| 931 |
), |
| 932 |
) |
| 933 |
if _response.status_code == 500: |
| 934 |
raise InternalServerError( |
| 935 |
headers=dict(_response.headers), |
| 936 |
body=typing.cast( |
| 937 |
typing.Any, |
| 938 |
parse_obj_as( |
| 939 |
type_=typing.Any, |
| 940 |
object_=_response.json(), |
| 941 |
), |
| 942 |
), |
| 943 |
) |
| 944 |
_response_json = _response.json() |
| 945 |
except JSONDecodeError: |
| 946 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 947 |
except ValidationError as e: |
| 948 |
raise ParsingError( |
| 949 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 950 |
) |
| 951 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 952 |
|
| 953 |
async def get( |
| 954 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 955 |
) -> AsyncHttpResponse[GetNetworkAclsResponseContent]: |
| 956 |
""" |
| 957 |
Get a specific access control list entry for your client. |
| 958 |
|
| 959 |
Parameters |
| 960 |
---------- |
| 961 |
id : str |
| 962 |
The id of the access control list to retrieve. |
| 963 |
|
| 964 |
request_options : typing.Optional[RequestOptions] |
| 965 |
Request-specific configuration. |
| 966 |
|
| 967 |
Returns |
| 968 |
------- |
| 969 |
AsyncHttpResponse[GetNetworkAclsResponseContent] |
| 970 |
Network access control list successfully retrieved. |
| 971 |
""" |
| 972 |
_response = await self._client_wrapper.httpx_client.request( |
| 973 |
f"network-acls/{encode_path_param(id)}", |
| 974 |
method="GET", |
| 975 |
request_options=request_options, |
| 976 |
) |
| 977 |
try: |
| 978 |
if 200 <= _response.status_code < 300: |
| 979 |
_data = typing.cast( |
| 980 |
GetNetworkAclsResponseContent, |
| 981 |
parse_obj_as( |
| 982 |
type_=GetNetworkAclsResponseContent, |
| 983 |
object_=_response.json(), |
| 984 |
), |
| 985 |
) |
| 986 |
return AsyncHttpResponse(response=_response, data=_data) |
| 987 |
if _response.status_code == 401: |
| 988 |
raise UnauthorizedError( |
| 989 |
headers=dict(_response.headers), |
| 990 |
body=typing.cast( |
| 991 |
typing.Any, |
| 992 |
parse_obj_as( |
| 993 |
type_=typing.Any, |
| 994 |
object_=_response.json(), |
| 995 |
), |
| 996 |
), |
| 997 |
) |
| 998 |
if _response.status_code == 403: |
| 999 |
raise ForbiddenError( |
| 1000 |
headers=dict(_response.headers), |
| 1001 |
body=typing.cast( |
| 1002 |
typing.Any, |
| 1003 |
parse_obj_as( |
| 1004 |
type_=typing.Any, |
| 1005 |
object_=_response.json(), |
| 1006 |
), |
| 1007 |
), |
| 1008 |
) |
| 1009 |
if _response.status_code == 404: |
| 1010 |
raise NotFoundError( |
| 1011 |
headers=dict(_response.headers), |
| 1012 |
body=typing.cast( |
| 1013 |
typing.Any, |
| 1014 |
parse_obj_as( |
| 1015 |
type_=typing.Any, |
| 1016 |
object_=_response.json(), |
| 1017 |
), |
| 1018 |
), |
| 1019 |
) |
| 1020 |
if _response.status_code == 429: |
| 1021 |
raise TooManyRequestsError( |
| 1022 |
headers=dict(_response.headers), |
| 1023 |
body=typing.cast( |
| 1024 |
typing.Any, |
| 1025 |
parse_obj_as( |
| 1026 |
type_=typing.Any, |
| 1027 |
object_=_response.json(), |
| 1028 |
), |
| 1029 |
), |
| 1030 |
) |
| 1031 |
_response_json = _response.json() |
| 1032 |
except JSONDecodeError: |
| 1033 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1034 |
except ValidationError as e: |
| 1035 |
raise ParsingError( |
| 1036 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1037 |
) |
| 1038 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1039 |
|
| 1040 |
async def set( |
| 1041 |
self, |
| 1042 |
id: str, |
| 1043 |
*, |
| 1044 |
description: str, |
| 1045 |
active: bool, |
| 1046 |
rule: NetworkAclRule, |
| 1047 |
priority: typing.Optional[float] = OMIT, |
| 1048 |
request_options: typing.Optional[RequestOptions] = None, |
| 1049 |
) -> AsyncHttpResponse[SetNetworkAclsResponseContent]: |
| 1050 |
""" |
| 1051 |
Update existing access control list for your client. |
| 1052 |
|
| 1053 |
Parameters |
| 1054 |
---------- |
| 1055 |
id : str |
| 1056 |
The id of the ACL to update. |
| 1057 |
|
| 1058 |
description : str |
| 1059 |
|
| 1060 |
active : bool |
| 1061 |
Indicates whether or not this access control list is actively being used |
| 1062 |
|
| 1063 |
rule : NetworkAclRule |
| 1064 |
|
| 1065 |
priority : typing.Optional[float] |
| 1066 |
Indicates the order in which the ACL will be evaluated relative to other ACL rules. |
| 1067 |
|
| 1068 |
request_options : typing.Optional[RequestOptions] |
| 1069 |
Request-specific configuration. |
| 1070 |
|
| 1071 |
Returns |
| 1072 |
------- |
| 1073 |
AsyncHttpResponse[SetNetworkAclsResponseContent] |
| 1074 |
Network ACL properties successfully updated |
| 1075 |
""" |
| 1076 |
_response = await self._client_wrapper.httpx_client.request( |
| 1077 |
f"network-acls/{encode_path_param(id)}", |
| 1078 |
method="PUT", |
| 1079 |
json={ |
| 1080 |
"description": description, |
| 1081 |
"active": active, |
| 1082 |
"priority": priority, |
| 1083 |
"rule": convert_and_respect_annotation_metadata( |
| 1084 |
object_=rule, annotation=NetworkAclRule, direction="write" |
| 1085 |
), |
| 1086 |
}, |
| 1087 |
headers={ |
| 1088 |
"content-type": "application/json", |
| 1089 |
}, |
| 1090 |
request_options=request_options, |
| 1091 |
omit=OMIT, |
| 1092 |
) |
| 1093 |
try: |
| 1094 |
if 200 <= _response.status_code < 300: |
| 1095 |
_data = typing.cast( |
| 1096 |
SetNetworkAclsResponseContent, |
| 1097 |
parse_obj_as( |
| 1098 |
type_=SetNetworkAclsResponseContent, |
| 1099 |
object_=_response.json(), |
| 1100 |
), |
| 1101 |
) |
| 1102 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1103 |
if _response.status_code == 400: |
| 1104 |
raise BadRequestError( |
| 1105 |
headers=dict(_response.headers), |
| 1106 |
body=typing.cast( |
| 1107 |
typing.Any, |
| 1108 |
parse_obj_as( |
| 1109 |
type_=typing.Any, |
| 1110 |
object_=_response.json(), |
| 1111 |
), |
| 1112 |
), |
| 1113 |
) |
| 1114 |
if _response.status_code == 401: |
| 1115 |
raise UnauthorizedError( |
| 1116 |
headers=dict(_response.headers), |
| 1117 |
body=typing.cast( |
| 1118 |
typing.Any, |
| 1119 |
parse_obj_as( |
| 1120 |
type_=typing.Any, |
| 1121 |
object_=_response.json(), |
| 1122 |
), |
| 1123 |
), |
| 1124 |
) |
| 1125 |
if _response.status_code == 403: |
| 1126 |
raise ForbiddenError( |
| 1127 |
headers=dict(_response.headers), |
| 1128 |
body=typing.cast( |
| 1129 |
typing.Any, |
| 1130 |
parse_obj_as( |
| 1131 |
type_=typing.Any, |
| 1132 |
object_=_response.json(), |
| 1133 |
), |
| 1134 |
), |
| 1135 |
) |
| 1136 |
if _response.status_code == 404: |
| 1137 |
raise NotFoundError( |
| 1138 |
headers=dict(_response.headers), |
| 1139 |
body=typing.cast( |
| 1140 |
typing.Any, |
| 1141 |
parse_obj_as( |
| 1142 |
type_=typing.Any, |
| 1143 |
object_=_response.json(), |
| 1144 |
), |
| 1145 |
), |
| 1146 |
) |
| 1147 |
if _response.status_code == 429: |
| 1148 |
raise TooManyRequestsError( |
| 1149 |
headers=dict(_response.headers), |
| 1150 |
body=typing.cast( |
| 1151 |
typing.Any, |
| 1152 |
parse_obj_as( |
| 1153 |
type_=typing.Any, |
| 1154 |
object_=_response.json(), |
| 1155 |
), |
| 1156 |
), |
| 1157 |
) |
| 1158 |
_response_json = _response.json() |
| 1159 |
except JSONDecodeError: |
| 1160 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1161 |
except ValidationError as e: |
| 1162 |
raise ParsingError( |
| 1163 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1164 |
) |
| 1165 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1166 |
|
| 1167 |
async def delete( |
| 1168 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 1169 |
) -> AsyncHttpResponse[None]: |
| 1170 |
""" |
| 1171 |
Delete existing access control list for your client. |
| 1172 |
|
| 1173 |
Parameters |
| 1174 |
---------- |
| 1175 |
id : str |
| 1176 |
The id of the ACL to delete |
| 1177 |
|
| 1178 |
request_options : typing.Optional[RequestOptions] |
| 1179 |
Request-specific configuration. |
| 1180 |
|
| 1181 |
Returns |
| 1182 |
------- |
| 1183 |
AsyncHttpResponse[None] |
| 1184 |
""" |
| 1185 |
_response = await self._client_wrapper.httpx_client.request( |
| 1186 |
f"network-acls/{encode_path_param(id)}", |
| 1187 |
method="DELETE", |
| 1188 |
request_options=request_options, |
| 1189 |
) |
| 1190 |
try: |
| 1191 |
if 200 <= _response.status_code < 300: |
| 1192 |
return AsyncHttpResponse(response=_response, data=None) |
| 1193 |
if _response.status_code == 400: |
| 1194 |
raise BadRequestError( |
| 1195 |
headers=dict(_response.headers), |
| 1196 |
body=typing.cast( |
| 1197 |
typing.Any, |
| 1198 |
parse_obj_as( |
| 1199 |
type_=typing.Any, |
| 1200 |
object_=_response.json(), |
| 1201 |
), |
| 1202 |
), |
| 1203 |
) |
| 1204 |
if _response.status_code == 401: |
| 1205 |
raise UnauthorizedError( |
| 1206 |
headers=dict(_response.headers), |
| 1207 |
body=typing.cast( |
| 1208 |
typing.Any, |
| 1209 |
parse_obj_as( |
| 1210 |
type_=typing.Any, |
| 1211 |
object_=_response.json(), |
| 1212 |
), |
| 1213 |
), |
| 1214 |
) |
| 1215 |
if _response.status_code == 403: |
| 1216 |
raise ForbiddenError( |
| 1217 |
headers=dict(_response.headers), |
| 1218 |
body=typing.cast( |
| 1219 |
typing.Any, |
| 1220 |
parse_obj_as( |
| 1221 |
type_=typing.Any, |
| 1222 |
object_=_response.json(), |
| 1223 |
), |
| 1224 |
), |
| 1225 |
) |
| 1226 |
if _response.status_code == 404: |
| 1227 |
raise NotFoundError( |
| 1228 |
headers=dict(_response.headers), |
| 1229 |
body=typing.cast( |
| 1230 |
typing.Any, |
| 1231 |
parse_obj_as( |
| 1232 |
type_=typing.Any, |
| 1233 |
object_=_response.json(), |
| 1234 |
), |
| 1235 |
), |
| 1236 |
) |
| 1237 |
if _response.status_code == 429: |
| 1238 |
raise TooManyRequestsError( |
| 1239 |
headers=dict(_response.headers), |
| 1240 |
body=typing.cast( |
| 1241 |
typing.Any, |
| 1242 |
parse_obj_as( |
| 1243 |
type_=typing.Any, |
| 1244 |
object_=_response.json(), |
| 1245 |
), |
| 1246 |
), |
| 1247 |
) |
| 1248 |
_response_json = _response.json() |
| 1249 |
except JSONDecodeError: |
| 1250 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1251 |
except ValidationError as e: |
| 1252 |
raise ParsingError( |
| 1253 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1254 |
) |
| 1255 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |
| 1256 |
|
| 1257 |
async def update( |
| 1258 |
self, |
| 1259 |
id: str, |
| 1260 |
*, |
| 1261 |
description: typing.Optional[str] = OMIT, |
| 1262 |
active: typing.Optional[bool] = OMIT, |
| 1263 |
priority: typing.Optional[float] = OMIT, |
| 1264 |
rule: typing.Optional[NetworkAclRule] = OMIT, |
| 1265 |
request_options: typing.Optional[RequestOptions] = None, |
| 1266 |
) -> AsyncHttpResponse[UpdateNetworkAclResponseContent]: |
| 1267 |
""" |
| 1268 |
Update existing access control list for your client. |
| 1269 |
|
| 1270 |
Parameters |
| 1271 |
---------- |
| 1272 |
id : str |
| 1273 |
The id of the ACL to update. |
| 1274 |
|
| 1275 |
description : typing.Optional[str] |
| 1276 |
|
| 1277 |
active : typing.Optional[bool] |
| 1278 |
Indicates whether or not this access control list is actively being used |
| 1279 |
|
| 1280 |
priority : typing.Optional[float] |
| 1281 |
Indicates the order in which the ACL will be evaluated relative to other ACL rules. |
| 1282 |
|
| 1283 |
rule : typing.Optional[NetworkAclRule] |
| 1284 |
|
| 1285 |
request_options : typing.Optional[RequestOptions] |
| 1286 |
Request-specific configuration. |
| 1287 |
|
| 1288 |
Returns |
| 1289 |
------- |
| 1290 |
AsyncHttpResponse[UpdateNetworkAclResponseContent] |
| 1291 |
Network ACL properties successfully updated |
| 1292 |
""" |
| 1293 |
_response = await self._client_wrapper.httpx_client.request( |
| 1294 |
f"network-acls/{encode_path_param(id)}", |
| 1295 |
method="PATCH", |
| 1296 |
json={ |
| 1297 |
"description": description, |
| 1298 |
"active": active, |
| 1299 |
"priority": priority, |
| 1300 |
"rule": convert_and_respect_annotation_metadata( |
| 1301 |
object_=rule, annotation=NetworkAclRule, direction="write" |
| 1302 |
), |
| 1303 |
}, |
| 1304 |
headers={ |
| 1305 |
"content-type": "application/json", |
| 1306 |
}, |
| 1307 |
request_options=request_options, |
| 1308 |
omit=OMIT, |
| 1309 |
) |
| 1310 |
try: |
| 1311 |
if 200 <= _response.status_code < 300: |
| 1312 |
_data = typing.cast( |
| 1313 |
UpdateNetworkAclResponseContent, |
| 1314 |
parse_obj_as( |
| 1315 |
type_=UpdateNetworkAclResponseContent, |
| 1316 |
object_=_response.json(), |
| 1317 |
), |
| 1318 |
) |
| 1319 |
return AsyncHttpResponse(response=_response, data=_data) |
| 1320 |
if _response.status_code == 400: |
| 1321 |
raise BadRequestError( |
| 1322 |
headers=dict(_response.headers), |
| 1323 |
body=typing.cast( |
| 1324 |
typing.Any, |
| 1325 |
parse_obj_as( |
| 1326 |
type_=typing.Any, |
| 1327 |
object_=_response.json(), |
| 1328 |
), |
| 1329 |
), |
| 1330 |
) |
| 1331 |
if _response.status_code == 401: |
| 1332 |
raise UnauthorizedError( |
| 1333 |
headers=dict(_response.headers), |
| 1334 |
body=typing.cast( |
| 1335 |
typing.Any, |
| 1336 |
parse_obj_as( |
| 1337 |
type_=typing.Any, |
| 1338 |
object_=_response.json(), |
| 1339 |
), |
| 1340 |
), |
| 1341 |
) |
| 1342 |
if _response.status_code == 403: |
| 1343 |
raise ForbiddenError( |
| 1344 |
headers=dict(_response.headers), |
| 1345 |
body=typing.cast( |
| 1346 |
typing.Any, |
| 1347 |
parse_obj_as( |
| 1348 |
type_=typing.Any, |
| 1349 |
object_=_response.json(), |
| 1350 |
), |
| 1351 |
), |
| 1352 |
) |
| 1353 |
if _response.status_code == 404: |
| 1354 |
raise NotFoundError( |
| 1355 |
headers=dict(_response.headers), |
| 1356 |
body=typing.cast( |
| 1357 |
typing.Any, |
| 1358 |
parse_obj_as( |
| 1359 |
type_=typing.Any, |
| 1360 |
object_=_response.json(), |
| 1361 |
), |
| 1362 |
), |
| 1363 |
) |
| 1364 |
if _response.status_code == 429: |
| 1365 |
raise TooManyRequestsError( |
| 1366 |
headers=dict(_response.headers), |
| 1367 |
body=typing.cast( |
| 1368 |
typing.Any, |
| 1369 |
parse_obj_as( |
| 1370 |
type_=typing.Any, |
| 1371 |
object_=_response.json(), |
| 1372 |
), |
| 1373 |
), |
| 1374 |
) |
| 1375 |
_response_json = _response.json() |
| 1376 |
except JSONDecodeError: |
| 1377 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) |
| 1378 |
except ValidationError as e: |
| 1379 |
raise ParsingError( |
| 1380 |
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e |
| 1381 |
) |
| 1382 |
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) |