| 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.action_version import ActionVersion |
| 9 |
from ...types.deploy_action_version_request_content import DeployActionVersionRequestContent |
| 10 |
from ...types.deploy_action_version_response_content import DeployActionVersionResponseContent |
| 11 |
from ...types.get_action_version_response_content import GetActionVersionResponseContent |
| 12 |
from ...types.list_action_versions_paginated_response_content import ListActionVersionsPaginatedResponseContent |
| 13 |
from .raw_client import AsyncRawVersionsClient, RawVersionsClient |
| 14 |
|
| 15 |
|
| 16 |
OMIT = typing.cast(typing.Any, ...) |
| 17 |
|
| 18 |
|
| 19 |
class VersionsClient: |
| 20 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 21 |
self._raw_client = RawVersionsClient(client_wrapper=client_wrapper) |
| 22 |
|
| 23 |
@property |
| 24 |
def with_raw_response(self) -> RawVersionsClient: |
| 25 |
""" |
| 26 |
Retrieves a raw implementation of this client that returns raw responses. |
| 27 |
|
| 28 |
Returns |
| 29 |
------- |
| 30 |
RawVersionsClient |
| 31 |
""" |
| 32 |
return self._raw_client |
| 33 |
|
| 34 |
def list( |
| 35 |
self, |
| 36 |
action_id: str, |
| 37 |
*, |
| 38 |
page: typing.Optional[int] = 0, |
| 39 |
per_page: typing.Optional[int] = 50, |
| 40 |
request_options: typing.Optional[RequestOptions] = None, |
| 41 |
) -> SyncPager[ActionVersion, ListActionVersionsPaginatedResponseContent]: |
| 42 |
""" |
| 43 |
Retrieve all of an action's versions. An action version is created whenever an action is deployed. An action version is immutable, once created. |
| 44 |
|
| 45 |
Parameters |
| 46 |
---------- |
| 47 |
action_id : str |
| 48 |
The ID of the action. |
| 49 |
|
| 50 |
page : typing.Optional[int] |
| 51 |
Use this field to request a specific page of the list results. |
| 52 |
|
| 53 |
per_page : typing.Optional[int] |
| 54 |
This field specify the maximum number of results to be returned by the server. 20 by default |
| 55 |
|
| 56 |
request_options : typing.Optional[RequestOptions] |
| 57 |
Request-specific configuration. |
| 58 |
|
| 59 |
Returns |
| 60 |
------- |
| 61 |
SyncPager[ActionVersion, ListActionVersionsPaginatedResponseContent] |
| 62 |
The action versions were retrieved. |
| 63 |
|
| 64 |
Examples |
| 65 |
-------- |
| 66 |
from auth0 import Auth0 |
| 67 |
|
| 68 |
client = Auth0( |
| 69 |
token="YOUR_TOKEN", |
| 70 |
) |
| 71 |
response = client.actions.versions.list( |
| 72 |
action_id="actionId", |
| 73 |
page=1, |
| 74 |
per_page=1, |
| 75 |
) |
| 76 |
for item in response: |
| 77 |
yield item |
| 78 |
# alternatively, you can paginate page-by-page |
| 79 |
for page in response.iter_pages(): |
| 80 |
yield page |
| 81 |
""" |
| 82 |
return self._raw_client.list(action_id, page=page, per_page=per_page, request_options=request_options) |
| 83 |
|
| 84 |
def get( |
| 85 |
self, action_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 86 |
) -> GetActionVersionResponseContent: |
| 87 |
""" |
| 88 |
Retrieve a specific version of an action. An action version is created whenever an action is deployed. An action version is immutable, once created. |
| 89 |
|
| 90 |
Parameters |
| 91 |
---------- |
| 92 |
action_id : str |
| 93 |
The ID of the action. |
| 94 |
|
| 95 |
id : str |
| 96 |
The ID of the action version. |
| 97 |
|
| 98 |
request_options : typing.Optional[RequestOptions] |
| 99 |
Request-specific configuration. |
| 100 |
|
| 101 |
Returns |
| 102 |
------- |
| 103 |
GetActionVersionResponseContent |
| 104 |
The action version was retrieved. |
| 105 |
|
| 106 |
Examples |
| 107 |
-------- |
| 108 |
from auth0 import Auth0 |
| 109 |
|
| 110 |
client = Auth0( |
| 111 |
token="YOUR_TOKEN", |
| 112 |
) |
| 113 |
client.actions.versions.get( |
| 114 |
action_id="actionId", |
| 115 |
id="id", |
| 116 |
) |
| 117 |
""" |
| 118 |
_response = self._raw_client.get(action_id, id, request_options=request_options) |
| 119 |
return _response.data |
| 120 |
|
| 121 |
def deploy( |
| 122 |
self, |
| 123 |
action_id: str, |
| 124 |
id: str, |
| 125 |
*, |
| 126 |
request: typing.Optional[DeployActionVersionRequestContent] = None, |
| 127 |
request_options: typing.Optional[RequestOptions] = None, |
| 128 |
) -> DeployActionVersionResponseContent: |
| 129 |
""" |
| 130 |
Performs the equivalent of a roll-back of an action to an earlier, specified version. Creates a new, deployed action version that is identical to the specified version. If this action is currently bound to a trigger, the system will begin executing the newly-created version immediately. |
| 131 |
|
| 132 |
Parameters |
| 133 |
---------- |
| 134 |
action_id : str |
| 135 |
The ID of an action. |
| 136 |
|
| 137 |
id : str |
| 138 |
The ID of an action version. |
| 139 |
|
| 140 |
request : typing.Optional[DeployActionVersionRequestContent] |
| 141 |
|
| 142 |
request_options : typing.Optional[RequestOptions] |
| 143 |
Request-specific configuration. |
| 144 |
|
| 145 |
Returns |
| 146 |
------- |
| 147 |
DeployActionVersionResponseContent |
| 148 |
Request to create action version was accepted. |
| 149 |
|
| 150 |
Examples |
| 151 |
-------- |
| 152 |
from auth0 import Auth0, DeployActionVersionRequestContent |
| 153 |
|
| 154 |
client = Auth0( |
| 155 |
token="YOUR_TOKEN", |
| 156 |
) |
| 157 |
client.actions.versions.deploy( |
| 158 |
action_id="actionId", |
| 159 |
id="id", |
| 160 |
request=DeployActionVersionRequestContent(), |
| 161 |
) |
| 162 |
""" |
| 163 |
_response = self._raw_client.deploy(action_id, id, request=request, request_options=request_options) |
| 164 |
return _response.data |
| 165 |
|
| 166 |
|
| 167 |
class AsyncVersionsClient: |
| 168 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 169 |
self._raw_client = AsyncRawVersionsClient(client_wrapper=client_wrapper) |
| 170 |
|
| 171 |
@property |
| 172 |
def with_raw_response(self) -> AsyncRawVersionsClient: |
| 173 |
""" |
| 174 |
Retrieves a raw implementation of this client that returns raw responses. |
| 175 |
|
| 176 |
Returns |
| 177 |
------- |
| 178 |
AsyncRawVersionsClient |
| 179 |
""" |
| 180 |
return self._raw_client |
| 181 |
|
| 182 |
async def list( |
| 183 |
self, |
| 184 |
action_id: str, |
| 185 |
*, |
| 186 |
page: typing.Optional[int] = 0, |
| 187 |
per_page: typing.Optional[int] = 50, |
| 188 |
request_options: typing.Optional[RequestOptions] = None, |
| 189 |
) -> AsyncPager[ActionVersion, ListActionVersionsPaginatedResponseContent]: |
| 190 |
""" |
| 191 |
Retrieve all of an action's versions. An action version is created whenever an action is deployed. An action version is immutable, once created. |
| 192 |
|
| 193 |
Parameters |
| 194 |
---------- |
| 195 |
action_id : str |
| 196 |
The ID of the action. |
| 197 |
|
| 198 |
page : typing.Optional[int] |
| 199 |
Use this field to request a specific page of the list results. |
| 200 |
|
| 201 |
per_page : typing.Optional[int] |
| 202 |
This field specify the maximum number of results to be returned by the server. 20 by default |
| 203 |
|
| 204 |
request_options : typing.Optional[RequestOptions] |
| 205 |
Request-specific configuration. |
| 206 |
|
| 207 |
Returns |
| 208 |
------- |
| 209 |
AsyncPager[ActionVersion, ListActionVersionsPaginatedResponseContent] |
| 210 |
The action versions were retrieved. |
| 211 |
|
| 212 |
Examples |
| 213 |
-------- |
| 214 |
import asyncio |
| 215 |
|
| 216 |
from auth0 import AsyncAuth0 |
| 217 |
|
| 218 |
client = AsyncAuth0( |
| 219 |
token="YOUR_TOKEN", |
| 220 |
) |
| 221 |
|
| 222 |
|
| 223 |
async def main() -> None: |
| 224 |
response = await client.actions.versions.list( |
| 225 |
action_id="actionId", |
| 226 |
page=1, |
| 227 |
per_page=1, |
| 228 |
) |
| 229 |
async for item in response: |
| 230 |
yield item |
| 231 |
|
| 232 |
# alternatively, you can paginate page-by-page |
| 233 |
async for page in response.iter_pages(): |
| 234 |
yield page |
| 235 |
|
| 236 |
|
| 237 |
asyncio.run(main()) |
| 238 |
""" |
| 239 |
return await self._raw_client.list(action_id, page=page, per_page=per_page, request_options=request_options) |
| 240 |
|
| 241 |
async def get( |
| 242 |
self, action_id: str, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 243 |
) -> GetActionVersionResponseContent: |
| 244 |
""" |
| 245 |
Retrieve a specific version of an action. An action version is created whenever an action is deployed. An action version is immutable, once created. |
| 246 |
|
| 247 |
Parameters |
| 248 |
---------- |
| 249 |
action_id : str |
| 250 |
The ID of the action. |
| 251 |
|
| 252 |
id : str |
| 253 |
The ID of the action version. |
| 254 |
|
| 255 |
request_options : typing.Optional[RequestOptions] |
| 256 |
Request-specific configuration. |
| 257 |
|
| 258 |
Returns |
| 259 |
------- |
| 260 |
GetActionVersionResponseContent |
| 261 |
The action version was retrieved. |
| 262 |
|
| 263 |
Examples |
| 264 |
-------- |
| 265 |
import asyncio |
| 266 |
|
| 267 |
from auth0 import AsyncAuth0 |
| 268 |
|
| 269 |
client = AsyncAuth0( |
| 270 |
token="YOUR_TOKEN", |
| 271 |
) |
| 272 |
|
| 273 |
|
| 274 |
async def main() -> None: |
| 275 |
await client.actions.versions.get( |
| 276 |
action_id="actionId", |
| 277 |
id="id", |
| 278 |
) |
| 279 |
|
| 280 |
|
| 281 |
asyncio.run(main()) |
| 282 |
""" |
| 283 |
_response = await self._raw_client.get(action_id, id, request_options=request_options) |
| 284 |
return _response.data |
| 285 |
|
| 286 |
async def deploy( |
| 287 |
self, |
| 288 |
action_id: str, |
| 289 |
id: str, |
| 290 |
*, |
| 291 |
request: typing.Optional[DeployActionVersionRequestContent] = None, |
| 292 |
request_options: typing.Optional[RequestOptions] = None, |
| 293 |
) -> DeployActionVersionResponseContent: |
| 294 |
""" |
| 295 |
Performs the equivalent of a roll-back of an action to an earlier, specified version. Creates a new, deployed action version that is identical to the specified version. If this action is currently bound to a trigger, the system will begin executing the newly-created version immediately. |
| 296 |
|
| 297 |
Parameters |
| 298 |
---------- |
| 299 |
action_id : str |
| 300 |
The ID of an action. |
| 301 |
|
| 302 |
id : str |
| 303 |
The ID of an action version. |
| 304 |
|
| 305 |
request : typing.Optional[DeployActionVersionRequestContent] |
| 306 |
|
| 307 |
request_options : typing.Optional[RequestOptions] |
| 308 |
Request-specific configuration. |
| 309 |
|
| 310 |
Returns |
| 311 |
------- |
| 312 |
DeployActionVersionResponseContent |
| 313 |
Request to create action version was accepted. |
| 314 |
|
| 315 |
Examples |
| 316 |
-------- |
| 317 |
import asyncio |
| 318 |
|
| 319 |
from auth0 import AsyncAuth0, DeployActionVersionRequestContent |
| 320 |
|
| 321 |
client = AsyncAuth0( |
| 322 |
token="YOUR_TOKEN", |
| 323 |
) |
| 324 |
|
| 325 |
|
| 326 |
async def main() -> None: |
| 327 |
await client.actions.versions.deploy( |
| 328 |
action_id="actionId", |
| 329 |
id="id", |
| 330 |
request=DeployActionVersionRequestContent(), |
| 331 |
) |
| 332 |
|
| 333 |
|
| 334 |
asyncio.run(main()) |
| 335 |
""" |
| 336 |
_response = await self._raw_client.deploy(action_id, id, request=request, request_options=request_options) |
| 337 |
return _response.data |