| 1 |
|
| 2 |
|
| 3 |
import typing |
| 4 |
|
| 5 |
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper |
| 6 |
from ..core.request_options import RequestOptions |
| 7 |
from ..types.get_session_response_content import GetSessionResponseContent |
| 8 |
from ..types.session_metadata import SessionMetadata |
| 9 |
from ..types.update_session_response_content import UpdateSessionResponseContent |
| 10 |
from .raw_client import AsyncRawSessionsClient, RawSessionsClient |
| 11 |
|
| 12 |
|
| 13 |
OMIT = typing.cast(typing.Any, ...) |
| 14 |
|
| 15 |
|
| 16 |
class SessionsClient: |
| 17 |
def __init__(self, *, client_wrapper: SyncClientWrapper): |
| 18 |
self._raw_client = RawSessionsClient(client_wrapper=client_wrapper) |
| 19 |
|
| 20 |
@property |
| 21 |
def with_raw_response(self) -> RawSessionsClient: |
| 22 |
""" |
| 23 |
Retrieves a raw implementation of this client that returns raw responses. |
| 24 |
|
| 25 |
Returns |
| 26 |
------- |
| 27 |
RawSessionsClient |
| 28 |
""" |
| 29 |
return self._raw_client |
| 30 |
|
| 31 |
def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetSessionResponseContent: |
| 32 |
""" |
| 33 |
Retrieve session information. |
| 34 |
|
| 35 |
Parameters |
| 36 |
---------- |
| 37 |
id : str |
| 38 |
ID of session to retrieve |
| 39 |
|
| 40 |
request_options : typing.Optional[RequestOptions] |
| 41 |
Request-specific configuration. |
| 42 |
|
| 43 |
Returns |
| 44 |
------- |
| 45 |
GetSessionResponseContent |
| 46 |
The session was retrieved |
| 47 |
|
| 48 |
Examples |
| 49 |
-------- |
| 50 |
from auth0 import Auth0 |
| 51 |
|
| 52 |
client = Auth0( |
| 53 |
token="YOUR_TOKEN", |
| 54 |
) |
| 55 |
client.sessions.get( |
| 56 |
id="id", |
| 57 |
) |
| 58 |
""" |
| 59 |
_response = self._raw_client.get(id, request_options=request_options) |
| 60 |
return _response.data |
| 61 |
|
| 62 |
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: |
| 63 |
""" |
| 64 |
Delete a session by ID. |
| 65 |
|
| 66 |
Parameters |
| 67 |
---------- |
| 68 |
id : str |
| 69 |
ID of the session to delete. |
| 70 |
|
| 71 |
request_options : typing.Optional[RequestOptions] |
| 72 |
Request-specific configuration. |
| 73 |
|
| 74 |
Returns |
| 75 |
------- |
| 76 |
None |
| 77 |
|
| 78 |
Examples |
| 79 |
-------- |
| 80 |
from auth0 import Auth0 |
| 81 |
|
| 82 |
client = Auth0( |
| 83 |
token="YOUR_TOKEN", |
| 84 |
) |
| 85 |
client.sessions.delete( |
| 86 |
id="id", |
| 87 |
) |
| 88 |
""" |
| 89 |
_response = self._raw_client.delete(id, request_options=request_options) |
| 90 |
return _response.data |
| 91 |
|
| 92 |
def update( |
| 93 |
self, |
| 94 |
id: str, |
| 95 |
*, |
| 96 |
session_metadata: typing.Optional[SessionMetadata] = OMIT, |
| 97 |
request_options: typing.Optional[RequestOptions] = None, |
| 98 |
) -> UpdateSessionResponseContent: |
| 99 |
""" |
| 100 |
Update session information. |
| 101 |
|
| 102 |
Parameters |
| 103 |
---------- |
| 104 |
id : str |
| 105 |
ID of the session to update. |
| 106 |
|
| 107 |
session_metadata : typing.Optional[SessionMetadata] |
| 108 |
Metadata associated with the session. Pass null or {} to remove all session_metadata. |
| 109 |
|
| 110 |
request_options : typing.Optional[RequestOptions] |
| 111 |
Request-specific configuration. |
| 112 |
|
| 113 |
Returns |
| 114 |
------- |
| 115 |
UpdateSessionResponseContent |
| 116 |
Session successfully updated. |
| 117 |
|
| 118 |
Examples |
| 119 |
-------- |
| 120 |
from auth0 import Auth0 |
| 121 |
|
| 122 |
client = Auth0( |
| 123 |
token="YOUR_TOKEN", |
| 124 |
) |
| 125 |
client.sessions.update( |
| 126 |
id="id", |
| 127 |
) |
| 128 |
""" |
| 129 |
_response = self._raw_client.update(id, session_metadata=session_metadata, request_options=request_options) |
| 130 |
return _response.data |
| 131 |
|
| 132 |
def revoke(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: |
| 133 |
""" |
| 134 |
Revokes a session by ID and all associated refresh tokens. |
| 135 |
|
| 136 |
Parameters |
| 137 |
---------- |
| 138 |
id : str |
| 139 |
ID of the session to revoke. |
| 140 |
|
| 141 |
request_options : typing.Optional[RequestOptions] |
| 142 |
Request-specific configuration. |
| 143 |
|
| 144 |
Returns |
| 145 |
------- |
| 146 |
None |
| 147 |
|
| 148 |
Examples |
| 149 |
-------- |
| 150 |
from auth0 import Auth0 |
| 151 |
|
| 152 |
client = Auth0( |
| 153 |
token="YOUR_TOKEN", |
| 154 |
) |
| 155 |
client.sessions.revoke( |
| 156 |
id="id", |
| 157 |
) |
| 158 |
""" |
| 159 |
_response = self._raw_client.revoke(id, request_options=request_options) |
| 160 |
return _response.data |
| 161 |
|
| 162 |
|
| 163 |
class AsyncSessionsClient: |
| 164 |
def __init__(self, *, client_wrapper: AsyncClientWrapper): |
| 165 |
self._raw_client = AsyncRawSessionsClient(client_wrapper=client_wrapper) |
| 166 |
|
| 167 |
@property |
| 168 |
def with_raw_response(self) -> AsyncRawSessionsClient: |
| 169 |
""" |
| 170 |
Retrieves a raw implementation of this client that returns raw responses. |
| 171 |
|
| 172 |
Returns |
| 173 |
------- |
| 174 |
AsyncRawSessionsClient |
| 175 |
""" |
| 176 |
return self._raw_client |
| 177 |
|
| 178 |
async def get( |
| 179 |
self, id: str, *, request_options: typing.Optional[RequestOptions] = None |
| 180 |
) -> GetSessionResponseContent: |
| 181 |
""" |
| 182 |
Retrieve session information. |
| 183 |
|
| 184 |
Parameters |
| 185 |
---------- |
| 186 |
id : str |
| 187 |
ID of session to retrieve |
| 188 |
|
| 189 |
request_options : typing.Optional[RequestOptions] |
| 190 |
Request-specific configuration. |
| 191 |
|
| 192 |
Returns |
| 193 |
------- |
| 194 |
GetSessionResponseContent |
| 195 |
The session was retrieved |
| 196 |
|
| 197 |
Examples |
| 198 |
-------- |
| 199 |
import asyncio |
| 200 |
|
| 201 |
from auth0 import AsyncAuth0 |
| 202 |
|
| 203 |
client = AsyncAuth0( |
| 204 |
token="YOUR_TOKEN", |
| 205 |
) |
| 206 |
|
| 207 |
|
| 208 |
async def main() -> None: |
| 209 |
await client.sessions.get( |
| 210 |
id="id", |
| 211 |
) |
| 212 |
|
| 213 |
|
| 214 |
asyncio.run(main()) |
| 215 |
""" |
| 216 |
_response = await self._raw_client.get(id, request_options=request_options) |
| 217 |
return _response.data |
| 218 |
|
| 219 |
async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: |
| 220 |
""" |
| 221 |
Delete a session by ID. |
| 222 |
|
| 223 |
Parameters |
| 224 |
---------- |
| 225 |
id : str |
| 226 |
ID of the session to delete. |
| 227 |
|
| 228 |
request_options : typing.Optional[RequestOptions] |
| 229 |
Request-specific configuration. |
| 230 |
|
| 231 |
Returns |
| 232 |
------- |
| 233 |
None |
| 234 |
|
| 235 |
Examples |
| 236 |
-------- |
| 237 |
import asyncio |
| 238 |
|
| 239 |
from auth0 import AsyncAuth0 |
| 240 |
|
| 241 |
client = AsyncAuth0( |
| 242 |
token="YOUR_TOKEN", |
| 243 |
) |
| 244 |
|
| 245 |
|
| 246 |
async def main() -> None: |
| 247 |
await client.sessions.delete( |
| 248 |
id="id", |
| 249 |
) |
| 250 |
|
| 251 |
|
| 252 |
asyncio.run(main()) |
| 253 |
""" |
| 254 |
_response = await self._raw_client.delete(id, request_options=request_options) |
| 255 |
return _response.data |
| 256 |
|
| 257 |
async def update( |
| 258 |
self, |
| 259 |
id: str, |
| 260 |
*, |
| 261 |
session_metadata: typing.Optional[SessionMetadata] = OMIT, |
| 262 |
request_options: typing.Optional[RequestOptions] = None, |
| 263 |
) -> UpdateSessionResponseContent: |
| 264 |
""" |
| 265 |
Update session information. |
| 266 |
|
| 267 |
Parameters |
| 268 |
---------- |
| 269 |
id : str |
| 270 |
ID of the session to update. |
| 271 |
|
| 272 |
session_metadata : typing.Optional[SessionMetadata] |
| 273 |
Metadata associated with the session. Pass null or {} to remove all session_metadata. |
| 274 |
|
| 275 |
request_options : typing.Optional[RequestOptions] |
| 276 |
Request-specific configuration. |
| 277 |
|
| 278 |
Returns |
| 279 |
------- |
| 280 |
UpdateSessionResponseContent |
| 281 |
Session successfully updated. |
| 282 |
|
| 283 |
Examples |
| 284 |
-------- |
| 285 |
import asyncio |
| 286 |
|
| 287 |
from auth0 import AsyncAuth0 |
| 288 |
|
| 289 |
client = AsyncAuth0( |
| 290 |
token="YOUR_TOKEN", |
| 291 |
) |
| 292 |
|
| 293 |
|
| 294 |
async def main() -> None: |
| 295 |
await client.sessions.update( |
| 296 |
id="id", |
| 297 |
) |
| 298 |
|
| 299 |
|
| 300 |
asyncio.run(main()) |
| 301 |
""" |
| 302 |
_response = await self._raw_client.update( |
| 303 |
id, session_metadata=session_metadata, request_options=request_options |
| 304 |
) |
| 305 |
return _response.data |
| 306 |
|
| 307 |
async def revoke(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None: |
| 308 |
""" |
| 309 |
Revokes a session by ID and all associated refresh tokens. |
| 310 |
|
| 311 |
Parameters |
| 312 |
---------- |
| 313 |
id : str |
| 314 |
ID of the session to revoke. |
| 315 |
|
| 316 |
request_options : typing.Optional[RequestOptions] |
| 317 |
Request-specific configuration. |
| 318 |
|
| 319 |
Returns |
| 320 |
------- |
| 321 |
None |
| 322 |
|
| 323 |
Examples |
| 324 |
-------- |
| 325 |
import asyncio |
| 326 |
|
| 327 |
from auth0 import AsyncAuth0 |
| 328 |
|
| 329 |
client = AsyncAuth0( |
| 330 |
token="YOUR_TOKEN", |
| 331 |
) |
| 332 |
|
| 333 |
|
| 334 |
async def main() -> None: |
| 335 |
await client.sessions.revoke( |
| 336 |
id="id", |
| 337 |
) |
| 338 |
|
| 339 |
|
| 340 |
asyncio.run(main()) |
| 341 |
""" |
| 342 |
_response = await self._raw_client.revoke(id, request_options=request_options) |
| 343 |
return _response.data |