| 1 |
|
| 2 |
|
| 3 |
import typing |
| 4 |
|
| 5 |
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 6 |
from ..core.pagination import AsyncPager, SyncPager |
| 7 |
from ..core.request_options import RequestOptions |
| 8 |
from ..types.create_rate_limit_policy_response_content import CreateRateLimitPolicyResponseContent |
| 9 |
from ..types.get_rate_limit_policy_response_content import GetRateLimitPolicyResponseContent |
| 10 |
from ..types.list_rate_limit_policies_paginated_response_content import ListRateLimitPoliciesPaginatedResponseContent |
| 11 |
from ..types.patch_rate_limit_policy_configuration_request_content import ( |
| 12 |
PatchRateLimitPolicyConfigurationRequestContent, |
| 13 |
) |
| 14 |
from ..types.rate_limit_policy import RateLimitPolicy |
| 15 |
from ..types.rate_limit_policy_configuration import RateLimitPolicyConfiguration |
| 16 |
from ..types.rate_limit_policy_consumer_enum import RateLimitPolicyConsumerEnum |
| 17 |
from ..types.rate_limit_policy_resource_enum import RateLimitPolicyResourceEnum |
| 18 |
from ..types.update_rate_limit_policy_response_content import UpdateRateLimitPolicyResponseContent |
| 19 |
from .raw_client import AsyncRawRateLimitPoliciesClient, RawRateLimitPoliciesClient |
| 20 |
|
| 21 |
|
| 22 |
OMIT = typing.cast(typing.Any, ...) |
| 23 |
|
| 24 |
|
| 25 |
class RateLimitPoliciesClient: |
| 26 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 27 |
self._raw_client = RawRateLimitPoliciesClient(client_wrapper=client_wrapper) |
| 28 |
|
| 29 |
@property |
| 30 |
def with_raw_response(self) -> RawRateLimitPoliciesClient: |
| 31 |
""" |
| 32 |
Retrieves a raw implementation of this client that returns raw responses. |
| 33 |
|
| 34 |
Returns |
| 35 |
------- |
| 36 |
RawRateLimitPoliciesClient |
| 37 |
""" |
| 38 |
return self._raw_client |
| 39 |
|
| 40 |
def list( |
| 41 |
self, |
| 42 |
*, |
| 43 |
resource: typing.Optional[RateLimitPolicyResourceEnum] = None, |
| 44 |
consumer: typing.Optional[RateLimitPolicyConsumerEnum] = None, |
| 45 |
consumer_selector: typing.Optional[str] = None, |
| 46 |
take: typing.Optional[int] = 50, |
| 47 |
from_: typing.Optional[str] = None, |
| 48 |
request_options: typing.Optional[RequestOptions] = None, |
| 49 |
) -> SyncPager[RateLimitPolicy, ListRateLimitPoliciesPaginatedResponseContent]: |
| 50 |
""" |
| 51 |
Parameters |
| 52 |
---------- |
| 53 |
resource : typing.Optional[RateLimitPolicyResourceEnum] |
| 54 |
The API protected by the Rate Limit Policy. |
| 55 |
|
| 56 |
consumer : typing.Optional[RateLimitPolicyConsumerEnum] |
| 57 |
The consumer to which the rate limit policy applies. |
| 58 |
|
| 59 |
consumer_selector : typing.Optional[str] |
| 60 |
Identifier or category within the consumer to which the policy applies. Supported values: `client_id:<client_id>` to target a specific client by ID, `client_id:<cimd_uri>` to target a CIMD client by URI, `cimd_clients` to target all CIMD clients, `third_party_clients` to target all third-party clients, or `default` to apply the policy to any consumer identifier not otherwise explicitly targeted. |
| 61 |
|
| 62 |
take : typing.Optional[int] |
| 63 |
Number of results per page. Defaults to 50. |
| 64 |
|
| 65 |
from_ : typing.Optional[str] |
| 66 |
Cursor for pagination. |
| 67 |
|
| 68 |
request_options : typing.Optional[RequestOptions] |
| 69 |
Request-specific configuration. |
| 70 |
|
| 71 |
Returns |
| 72 |
------- |
| 73 |
SyncPager[RateLimitPolicy, ListRateLimitPoliciesPaginatedResponseContent] |
| 74 |
Rate limit policies retrieved successfully. |
| 75 |
|
| 76 |
Examples |
| 77 |
-------- |
| 78 |
from auth0 import Auth0 |
| 79 |
|
| 80 |
client = Auth0( |
| 81 |
token="YOUR_TOKEN", |
| 82 |
) |
| 83 |
response = client.rate_limit_policies.list( |
| 84 |
resource="oauth_authentication_api", |
| 85 |
consumer="client", |
| 86 |
consumer_selector="consumer_selector", |
| 87 |
take=1, |
| 88 |
from_="from", |
| 89 |
) |
| 90 |
for item in response: |
| 91 |
yield item |
| 92 |
# alternatively, you can paginate page-by-page |
| 93 |
for page in response.iter_pages(): |
| 94 |
yield page |
| 95 |
""" |
| 96 |
return self._raw_client.list( |
| 97 |
resource=resource, |
| 98 |
consumer=consumer, |
| 99 |
consumer_selector=consumer_selector, |
| 100 |
take=take, |
| 101 |
from_=from_, |
| 102 |
request_options=request_options, |
| 103 |
) |
| 104 |
|
| 105 |
def create( |
| 106 |
self, |
| 107 |
*, |
| 108 |
resource: RateLimitPolicyResourceEnum, |
| 109 |
consumer: RateLimitPolicyConsumerEnum, |
| 110 |
consumer_selector: str, |
| 111 |
configuration: RateLimitPolicyConfiguration, |
| 112 |
request_options: typing.Optional[RequestOptions] = None, |
| 113 |
) -> CreateRateLimitPolicyResponseContent: |
| 114 |
""" |
| 115 |
Parameters |
| 116 |
---------- |
| 117 |
resource : RateLimitPolicyResourceEnum |
| 118 |
|
| 119 |
consumer : RateLimitPolicyConsumerEnum |
| 120 |
|
| 121 |
consumer_selector : str |
| 122 |
Identifier or category within the consumer to which the policy applies. Supported values: `client_id:<client_id>` to target a specific client by ID, `client_id:<cimd_uri>` to target a CIMD client by URI, `cimd_clients` to target all CIMD clients, `third_party_clients` to target all third-party clients, or `default` to apply the policy to any consumer identifier not otherwise explicitly targeted. |
| 123 |
|
| 124 |
configuration : RateLimitPolicyConfiguration |
| 125 |
|
| 126 |
request_options : typing.Optional[RequestOptions] |
| 127 |
Request-specific configuration. |
| 128 |
|
| 129 |
Returns |
| 130 |
------- |
| 131 |
CreateRateLimitPolicyResponseContent |
| 132 |
Rate limit policy successfully created. |
| 133 |
|
| 134 |
Examples |
| 135 |
-------- |
| 136 |
from auth0 import Auth0, RateLimitPolicyConfigurationZero |
| 137 |
|
| 138 |
client = Auth0( |
| 139 |
token="YOUR_TOKEN", |
| 140 |
) |
| 141 |
client.rate_limit_policies.create( |
| 142 |
resource="oauth_authentication_api", |
| 143 |
consumer="client", |
| 144 |
consumer_selector="consumer_selector", |
| 145 |
configuration=RateLimitPolicyConfigurationZero( |
| 146 |
action="allow", |
| 147 |
), |
| 148 |
) |
| 149 |
""" |
| 150 |
_response = self._raw_client.create( |
| 151 |
resource=resource, |
| 152 |
consumer=consumer, |
| 153 |
consumer_selector=consumer_selector, |
| 154 |
configuration=configuration, |
| 155 |
request_options=request_options, |
| 156 |
) |
| 157 |
return _response.data |
| 158 |
|
| 159 |
def get( |
| 160 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 161 |
) -> GetRateLimitPolicyResponseContent: |
| 162 |
""" |
| 163 |
Parameters |
| 164 |
---------- |
| 165 |
id : str |
| 166 |
Unique identifier for the Rate Limit Policy. |
| 167 |
|
| 168 |
request_options : typing.Optional[RequestOptions] |
| 169 |
Request-specific configuration. |
| 170 |
|
| 171 |
Returns |
| 172 |
------- |
| 173 |
GetRateLimitPolicyResponseContent |
| 174 |
Rate limit policy retrieved successfully. |
| 175 |
|
| 176 |
Examples |
| 177 |
-------- |
| 178 |
from auth0 import Auth0 |
| 179 |
|
| 180 |
client = Auth0( |
| 181 |
token="YOUR_TOKEN", |
| 182 |
) |
| 183 |
client.rate_limit_policies.get( |
| 184 |
id="id", |
| 185 |
) |
| 186 |
""" |
| 187 |
_response = self._raw_client.get(id, request_options=request_options) |
| 188 |
return _response.data |
| 189 |
|
| 190 |
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: |
| 191 |
""" |
| 192 |
Parameters |
| 193 |
---------- |
| 194 |
id : str |
| 195 |
Unique identifier for the Rate Limit Policy. |
| 196 |
|
| 197 |
request_options : typing.Optional[RequestOptions] |
| 198 |
Request-specific configuration. |
| 199 |
|
| 200 |
Returns |
| 201 |
------- |
| 202 |
None |
| 203 |
|
| 204 |
Examples |
| 205 |
-------- |
| 206 |
from auth0 import Auth0 |
| 207 |
|
| 208 |
client = Auth0( |
| 209 |
token="YOUR_TOKEN", |
| 210 |
) |
| 211 |
client.rate_limit_policies.delete( |
| 212 |
id="id", |
| 213 |
) |
| 214 |
""" |
| 215 |
_response = self._raw_client.delete(id, request_options=request_options) |
| 216 |
return _response.data |
| 217 |
|
| 218 |
def update( |
| 219 |
self, |
| 220 |
id: str, |
| 221 |
*, |
| 222 |
configuration: PatchRateLimitPolicyConfigurationRequestContent, |
| 223 |
request_options: typing.Optional[RequestOptions] = None, |
| 224 |
) -> UpdateRateLimitPolicyResponseContent: |
| 225 |
""" |
| 226 |
Parameters |
| 227 |
---------- |
| 228 |
id : str |
| 229 |
Unique identifier for the Rate Limit Policy. |
| 230 |
|
| 231 |
configuration : PatchRateLimitPolicyConfigurationRequestContent |
| 232 |
|
| 233 |
request_options : typing.Optional[RequestOptions] |
| 234 |
Request-specific configuration. |
| 235 |
|
| 236 |
Returns |
| 237 |
------- |
| 238 |
UpdateRateLimitPolicyResponseContent |
| 239 |
Rate limit policy successfully updated. |
| 240 |
|
| 241 |
Examples |
| 242 |
-------- |
| 243 |
from auth0 import Auth0, PatchRateLimitPolicyConfigurationRequestContentZero |
| 244 |
|
| 245 |
client = Auth0( |
| 246 |
token="YOUR_TOKEN", |
| 247 |
) |
| 248 |
client.rate_limit_policies.update( |
| 249 |
id="id", |
| 250 |
configuration=PatchRateLimitPolicyConfigurationRequestContentZero( |
| 251 |
action="allow", |
| 252 |
), |
| 253 |
) |
| 254 |
""" |
| 255 |
_response = self._raw_client.update(id, configuration=configuration, request_options=request_options) |
| 256 |
return _response.data |
| 257 |
|
| 258 |
|
| 259 |
class AsyncRateLimitPoliciesClient: |
| 260 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 261 |
self._raw_client = AsyncRawRateLimitPoliciesClient(client_wrapper=client_wrapper) |
| 262 |
|
| 263 |
@property |
| 264 |
def with_raw_response(self) -> AsyncRawRateLimitPoliciesClient: |
| 265 |
""" |
| 266 |
Retrieves a raw implementation of this client that returns raw responses. |
| 267 |
|
| 268 |
Returns |
| 269 |
------- |
| 270 |
AsyncRawRateLimitPoliciesClient |
| 271 |
""" |
| 272 |
return self._raw_client |
| 273 |
|
| 274 |
async def list( |
| 275 |
self, |
| 276 |
*, |
| 277 |
resource: typing.Optional[RateLimitPolicyResourceEnum] = None, |
| 278 |
consumer: typing.Optional[RateLimitPolicyConsumerEnum] = None, |
| 279 |
consumer_selector: typing.Optional[str] = None, |
| 280 |
take: typing.Optional[int] = 50, |
| 281 |
from_: typing.Optional[str] = None, |
| 282 |
request_options: typing.Optional[RequestOptions] = None, |
| 283 |
) -> AsyncPager[RateLimitPolicy, ListRateLimitPoliciesPaginatedResponseContent]: |
| 284 |
""" |
| 285 |
Parameters |
| 286 |
---------- |
| 287 |
resource : typing.Optional[RateLimitPolicyResourceEnum] |
| 288 |
The API protected by the Rate Limit Policy. |
| 289 |
|
| 290 |
consumer : typing.Optional[RateLimitPolicyConsumerEnum] |
| 291 |
The consumer to which the rate limit policy applies. |
| 292 |
|
| 293 |
consumer_selector : typing.Optional[str] |
| 294 |
Identifier or category within the consumer to which the policy applies. Supported values: `client_id:<client_id>` to target a specific client by ID, `client_id:<cimd_uri>` to target a CIMD client by URI, `cimd_clients` to target all CIMD clients, `third_party_clients` to target all third-party clients, or `default` to apply the policy to any consumer identifier not otherwise explicitly targeted. |
| 295 |
|
| 296 |
take : typing.Optional[int] |
| 297 |
Number of results per page. Defaults to 50. |
| 298 |
|
| 299 |
from_ : typing.Optional[str] |
| 300 |
Cursor for pagination. |
| 301 |
|
| 302 |
request_options : typing.Optional[RequestOptions] |
| 303 |
Request-specific configuration. |
| 304 |
|
| 305 |
Returns |
| 306 |
------- |
| 307 |
AsyncPager[RateLimitPolicy, ListRateLimitPoliciesPaginatedResponseContent] |
| 308 |
Rate limit policies retrieved successfully. |
| 309 |
|
| 310 |
Examples |
| 311 |
-------- |
| 312 |
import asyncio |
| 313 |
|
| 314 |
from auth0 import AsyncAuth0 |
| 315 |
|
| 316 |
client = AsyncAuth0( |
| 317 |
token="YOUR_TOKEN", |
| 318 |
) |
| 319 |
|
| 320 |
|
| 321 |
async def main() -> None: |
| 322 |
response = await client.rate_limit_policies.list( |
| 323 |
resource="oauth_authentication_api", |
| 324 |
consumer="client", |
| 325 |
consumer_selector="consumer_selector", |
| 326 |
take=1, |
| 327 |
from_="from", |
| 328 |
) |
| 329 |
async for item in response: |
| 330 |
yield item |
| 331 |
|
| 332 |
# alternatively, you can paginate page-by-page |
| 333 |
async for page in response.iter_pages(): |
| 334 |
yield page |
| 335 |
|
| 336 |
|
| 337 |
asyncio.run(main()) |
| 338 |
""" |
| 339 |
return await self._raw_client.list( |
| 340 |
resource=resource, |
| 341 |
consumer=consumer, |
| 342 |
consumer_selector=consumer_selector, |
| 343 |
take=take, |
| 344 |
from_=from_, |
| 345 |
request_options=request_options, |
| 346 |
) |
| 347 |
|
| 348 |
async def create( |
| 349 |
self, |
| 350 |
*, |
| 351 |
resource: RateLimitPolicyResourceEnum, |
| 352 |
consumer: RateLimitPolicyConsumerEnum, |
| 353 |
consumer_selector: str, |
| 354 |
configuration: RateLimitPolicyConfiguration, |
| 355 |
request_options: typing.Optional[RequestOptions] = None, |
| 356 |
) -> CreateRateLimitPolicyResponseContent: |
| 357 |
""" |
| 358 |
Parameters |
| 359 |
---------- |
| 360 |
resource : RateLimitPolicyResourceEnum |
| 361 |
|
| 362 |
consumer : RateLimitPolicyConsumerEnum |
| 363 |
|
| 364 |
consumer_selector : str |
| 365 |
Identifier or category within the consumer to which the policy applies. Supported values: `client_id:<client_id>` to target a specific client by ID, `client_id:<cimd_uri>` to target a CIMD client by URI, `cimd_clients` to target all CIMD clients, `third_party_clients` to target all third-party clients, or `default` to apply the policy to any consumer identifier not otherwise explicitly targeted. |
| 366 |
|
| 367 |
configuration : RateLimitPolicyConfiguration |
| 368 |
|
| 369 |
request_options : typing.Optional[RequestOptions] |
| 370 |
Request-specific configuration. |
| 371 |
|
| 372 |
Returns |
| 373 |
------- |
| 374 |
CreateRateLimitPolicyResponseContent |
| 375 |
Rate limit policy successfully created. |
| 376 |
|
| 377 |
Examples |
| 378 |
-------- |
| 379 |
import asyncio |
| 380 |
|
| 381 |
from auth0 import AsyncAuth0, RateLimitPolicyConfigurationZero |
| 382 |
|
| 383 |
client = AsyncAuth0( |
| 384 |
token="YOUR_TOKEN", |
| 385 |
) |
| 386 |
|
| 387 |
|
| 388 |
async def main() -> None: |
| 389 |
await client.rate_limit_policies.create( |
| 390 |
resource="oauth_authentication_api", |
| 391 |
consumer="client", |
| 392 |
consumer_selector="consumer_selector", |
| 393 |
configuration=RateLimitPolicyConfigurationZero( |
| 394 |
action="allow", |
| 395 |
), |
| 396 |
) |
| 397 |
|
| 398 |
|
| 399 |
asyncio.run(main()) |
| 400 |
""" |
| 401 |
_response = await self._raw_client.create( |
| 402 |
resource=resource, |
| 403 |
consumer=consumer, |
| 404 |
consumer_selector=consumer_selector, |
| 405 |
configuration=configuration, |
| 406 |
request_options=request_options, |
| 407 |
) |
| 408 |
return _response.data |
| 409 |
|
| 410 |
async def get( |
| 411 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 412 |
) -> GetRateLimitPolicyResponseContent: |
| 413 |
""" |
| 414 |
Parameters |
| 415 |
---------- |
| 416 |
id : str |
| 417 |
Unique identifier for the Rate Limit Policy. |
| 418 |
|
| 419 |
request_options : typing.Optional[RequestOptions] |
| 420 |
Request-specific configuration. |
| 421 |
|
| 422 |
Returns |
| 423 |
------- |
| 424 |
GetRateLimitPolicyResponseContent |
| 425 |
Rate limit policy retrieved successfully. |
| 426 |
|
| 427 |
Examples |
| 428 |
-------- |
| 429 |
import asyncio |
| 430 |
|
| 431 |
from auth0 import AsyncAuth0 |
| 432 |
|
| 433 |
client = AsyncAuth0( |
| 434 |
token="YOUR_TOKEN", |
| 435 |
) |
| 436 |
|
| 437 |
|
| 438 |
async def main() -> None: |
| 439 |
await client.rate_limit_policies.get( |
| 440 |
id="id", |
| 441 |
) |
| 442 |
|
| 443 |
|
| 444 |
asyncio.run(main()) |
| 445 |
""" |
| 446 |
_response = await self._raw_client.get(id, request_options=request_options) |
| 447 |
return _response.data |
| 448 |
|
| 449 |
async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: |
| 450 |
""" |
| 451 |
Parameters |
| 452 |
---------- |
| 453 |
id : str |
| 454 |
Unique identifier for the Rate Limit Policy. |
| 455 |
|
| 456 |
request_options : typing.Optional[RequestOptions] |
| 457 |
Request-specific configuration. |
| 458 |
|
| 459 |
Returns |
| 460 |
------- |
| 461 |
None |
| 462 |
|
| 463 |
Examples |
| 464 |
-------- |
| 465 |
import asyncio |
| 466 |
|
| 467 |
from auth0 import AsyncAuth0 |
| 468 |
|
| 469 |
client = AsyncAuth0( |
| 470 |
token="YOUR_TOKEN", |
| 471 |
) |
| 472 |
|
| 473 |
|
| 474 |
async def main() -> None: |
| 475 |
await client.rate_limit_policies.delete( |
| 476 |
id="id", |
| 477 |
) |
| 478 |
|
| 479 |
|
| 480 |
asyncio.run(main()) |
| 481 |
""" |
| 482 |
_response = await self._raw_client.delete(id, request_options=request_options) |
| 483 |
return _response.data |
| 484 |
|
| 485 |
async def update( |
| 486 |
self, |
| 487 |
id: str, |
| 488 |
*, |
| 489 |
configuration: PatchRateLimitPolicyConfigurationRequestContent, |
| 490 |
request_options: typing.Optional[RequestOptions] = None, |
| 491 |
) -> UpdateRateLimitPolicyResponseContent: |
| 492 |
""" |
| 493 |
Parameters |
| 494 |
---------- |
| 495 |
id : str |
| 496 |
Unique identifier for the Rate Limit Policy. |
| 497 |
|
| 498 |
configuration : PatchRateLimitPolicyConfigurationRequestContent |
| 499 |
|
| 500 |
request_options : typing.Optional[RequestOptions] |
| 501 |
Request-specific configuration. |
| 502 |
|
| 503 |
Returns |
| 504 |
------- |
| 505 |
UpdateRateLimitPolicyResponseContent |
| 506 |
Rate limit policy successfully updated. |
| 507 |
|
| 508 |
Examples |
| 509 |
-------- |
| 510 |
import asyncio |
| 511 |
|
| 512 |
from auth0 import ( |
| 513 |
AsyncAuth0, |
| 514 |
PatchRateLimitPolicyConfigurationRequestContentZero, |
| 515 |
) |
| 516 |
|
| 517 |
client = AsyncAuth0( |
| 518 |
token="YOUR_TOKEN", |
| 519 |
) |
| 520 |
|
| 521 |
|
| 522 |
async def main() -> None: |
| 523 |
await client.rate_limit_policies.update( |
| 524 |
id="id", |
| 525 |
configuration=PatchRateLimitPolicyConfigurationRequestContentZero( |
| 526 |
action="allow", |
| 527 |
), |
| 528 |
) |
| 529 |
|
| 530 |
|
| 531 |
asyncio.run(main()) |
| 532 |
""" |
| 533 |
_response = await self._raw_client.update(id, configuration=configuration, request_options=request_options) |
| 534 |
return _response.data |