access
access ¶
Access ¶
generate_share_account_payload ¶
generate_share_account_payload(
access_level: AccountAccess | AccountAccess_v1 | str,
user_id: int | None = None,
group_id: int | None = None,
use_v1_api: bool = False,
) -> dict
Orchestrator function to generate appropriate sharing payload.
This function determines which payload generation function to use based on: - The access_level type (v1 or v2 enum) - The use_v1_api flag - Whether a group_id is provided (forces v2)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_level
|
AccountAccess | AccountAccess_v1 | str
|
Access level enum or string |
required |
user_id
|
int | None
|
ID of the user to share with |
None
|
group_id
|
int | None
|
ID of the group to share with (forces v2 API) |
None
|
use_v1_api
|
bool
|
Force use of v1 API (ignored if group_id provided) |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary payload for appropriate share API |
Raises:
| Type | Description |
|---|---|
ValueError
|
If group_id provided with v1 access level or use_v1_api=True |
Example
V2 with user¶
payload = generate_share_account_payload( ... access_level=AccountAccess.CAN_VIEW, ... user_id=12345 ... )
V2 with group (auto-detects v2 needed)¶
payload = generate_share_account_payload( ... access_level=AccountAccess.CAN_VIEW, ... group_id=67890 ... )
V1 explicitly¶
payload = generate_share_account_payload( ... access_level=AccountAccess_v1.CAN_VIEW, ... user_id=12345 ... )
Source code in src/crew_dcs/routes/account/access.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
generate_share_account_v1_payload ¶
generate_share_account_v1_payload(
user_id: int, access_level: AccountAccess_v1
) -> dict
Generate v1 API sharing payload for users only.
V1 API limitations: - Only supports sharing with users (no groups) - Limited permission set: READ, WRITE, OWNER
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
int
|
ID of the user to share with |
required |
access_level
|
AccountAccess_v1
|
Access level (AccountAccess_v1 enum) |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary payload for v1 share API |
Example
payload = generate_share_account_v1_payload( ... user_id=12345, ... access_level=AccountAccess_v1.CAN_VIEW ... )
Returns: {"type": "USER", "id": 12345, "permissions": ["READ"]}¶
Source code in src/crew_dcs/routes/account/access.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
generate_share_account_v2_payload ¶
generate_share_account_v2_payload(
access_level: AccountAccess,
user_id: int | None = None,
group_id: int | None = None,
) -> dict
Generate v2 API sharing payload for users or groups.
V2 API features: - Supports both users and groups - Extended permissions: CAN_VIEW, CAN_EDIT, CAN_SHARE, OWNER, NO_ACCESS
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_level
|
AccountAccess
|
Access level (AccountAccess enum) |
required |
user_id
|
int | None
|
ID of the user to share with (mutually exclusive with group_id) |
None
|
group_id
|
int | None
|
ID of the group to share with (mutually exclusive with user_id) |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary payload for v2 share API |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither or both user_id and group_id are provided |
Example
payload = generate_share_account_v2_payload( ... access_level=AccountAccess.CAN_VIEW, ... user_id=12345 ... )
Returns: {"type": "USER", "id": "12345", "accessLevel": "CAN_VIEW"}¶
Source code in src/crew_dcs/routes/account/access.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
get_account_accesslist
async
¶
get_account_accesslist(
auth: DomoAuth,
account_id: str,
return_raw: bool = False,
*,
context: RouteContext | None = None,
**context_kwargs
) -> ResponseGetData
Get access list for an account.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
DomoAuth
|
Authentication object for API requests |
required |
account_id
|
str
|
ID of the account to get access list for |
required |
return_raw
|
bool
|
Return raw response without processing |
False
|
context
|
RouteContext | None
|
RouteContext for request configuration |
None
|
Returns:
| Type | Description |
|---|---|
ResponseGetData
|
ResponseGetData object containing account access list |
Raises:
| Type | Description |
|---|---|
AccountSharing_Error
|
If access list retrieval fails |
Source code in src/crew_dcs/routes/account/access.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
get_oauth_account_accesslist
async
¶
get_oauth_account_accesslist(
auth: DomoAuth,
account_id: str,
return_raw: bool = False,
*,
context: RouteContext | None = None,
**context_kwargs
) -> ResponseGetData
Get access list for an OAuth account.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
DomoAuth
|
Authentication object for API requests |
required |
account_id
|
str
|
ID of the OAuth account to get access list for |
required |
return_raw
|
bool
|
Return raw response without processing |
False
|
context
|
RouteContext | None
|
RouteContext for request configuration |
None
|
Returns:
| Type | Description |
|---|---|
ResponseGetData
|
ResponseGetData object containing OAuth account access list |
Raises:
| Type | Description |
|---|---|
AccountSharing_Error
|
If OAuth access list retrieval fails |
Source code in src/crew_dcs/routes/account/access.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
share_account
async
¶
share_account(
auth: DomoAuth,
account_id: str,
share_payload: dict | None = None,
access_level: (
Access | AccountAccess_v1 | str | None
) = None,
user_id: int | None = None,
group_id: int | None = None,
use_v1_api: bool = False,
return_raw: bool = False,
*,
context: RouteContext | None = None,
**context_kwargs
) -> ResponseGetData
Share account with users/groups using v2 API.
Note: This uses the v2 API which should be deployed to all Domo instances as of DP24.
Two ways to call this function: 1. Pass pre-built share_payload (legacy mode) 2. Pass access_level with user_id or group_id (generates payload automatically)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
DomoAuth
|
Authentication object for API requests |
required |
account_id
|
str
|
ID of the account to share |
required |
share_payload
|
dict | None
|
Pre-built sharing payload (optional, overrides other params) |
None
|
access_level
|
Access | AccountAccess_v1 | str | None
|
Access level enum or string (required if share_payload not provided) |
None
|
user_id
|
int | None
|
ID of user to share with (mutually exclusive with group_id) |
None
|
group_id
|
int | None
|
ID of group to share with (mutually exclusive with user_id) |
None
|
use_v1_api
|
bool
|
Force v1 API usage (ignored if group_id provided) |
False
|
return_raw
|
bool
|
Return raw response without processing |
False
|
context
|
RouteContext | None
|
RouteContext for request configuration |
None
|
Returns:
| Type | Description |
|---|---|
ResponseGetData
|
ResponseGetData object confirming sharing operation |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither share_payload nor access_level provided |
Account_AlreadyShared_Error
|
If account is already shared with target |
Account_Share_Error
|
If sharing operation fails |
Examples:
>>> # Using payload generator (new way)
>>> await share_account(
... auth=auth,
... account_id="123",
... access_level=ShareAccount_AccessLevel.CAN_VIEW,
... user_id=456
... )
>>> # Using pre-built payload (legacy way)
>>> payload = generate_share_account_v2_payload(
... access_level=ShareAccount_AccessLevel.CAN_VIEW,
... group_id=789
... )
>>> await share_account(
... auth=auth,
... account_id="123",
... share_payload=payload
... )
Source code in src/crew_dcs/routes/account/access.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 | |
share_account_v1
async
¶
share_account_v1(
auth: DomoAuth,
account_id: str,
share_payload: dict | None = None,
access_level: AccountAccess_v1 | str | None = None,
user_id: int | None = None,
return_raw: bool = False,
*,
context: RouteContext | None = None,
**context_kwargs
) -> ResponseGetData
Share account using legacy v1 API (users only).
Note: V1 API allows sharing with users ONLY. It does not support sharing with groups and has a more limited set of share rights (owner or read). See AccountAccess_v1 vs AccountAccess for differences.
Two ways to call this function: 1. Pass pre-built share_payload (legacy mode) 2. Pass access_level with user_id (generates payload automatically)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
DomoAuth
|
Authentication object for API requests |
required |
account_id
|
str
|
ID of the account to share |
required |
share_payload
|
dict | None
|
Pre-built sharing payload (optional, overrides other params) |
None
|
access_level
|
AccountAccess_v1 | str | None
|
Access level enum or string (required if share_payload not provided) |
None
|
user_id
|
int | None
|
ID of user to share with (required if share_payload not provided) |
None
|
return_raw
|
bool
|
Return raw response without processing |
False
|
context
|
RouteContext | None
|
RouteContext for request configuration |
None
|
Returns:
| Type | Description |
|---|---|
ResponseGetData
|
ResponseGetData object confirming sharing operation |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither share_payload nor (access_level and user_id) provided |
Account_AlreadyShared_Error
|
If account is already shared with user |
Account_Share_Error
|
If sharing operation fails |
Examples:
>>> # Using payload generator
>>> await share_account_v1(
... auth=auth,
... account_id="123",
... access_level=ShareAccount_V1_AccessLevel.CAN_VIEW,
... user_id=456
... )
Source code in src/crew_dcs/routes/account/access.py
536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | |
share_oauth_account
async
¶
share_oauth_account(
auth: DomoAuth,
account_id: str,
share_payload: dict | None = None,
access_level: Access | str | None = None,
user_id: int | None = None,
group_id: int | None = None,
return_raw: bool = False,
*,
context: RouteContext | None = None,
**context_kwargs
) -> ResponseGetData
Share OAuth account with users/groups.
Two ways to call this function: 1. Pass pre-built share_payload (legacy mode) 2. Pass access_level with user_id or group_id (generates payload automatically)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth
|
DomoAuth
|
Authentication object for API requests |
required |
account_id
|
str
|
ID of the OAuth account to share |
required |
share_payload
|
dict | None
|
Pre-built sharing payload (optional, overrides other params) |
None
|
access_level
|
Access | str | None
|
Access level enum or string (required if share_payload not provided) |
None
|
user_id
|
int | None
|
ID of user to share with (mutually exclusive with group_id) |
None
|
group_id
|
int | None
|
ID of group to share with (mutually exclusive with user_id) |
None
|
return_raw
|
bool
|
Return raw response without processing |
False
|
context
|
RouteContext | None
|
RouteContext for request configuration |
None
|
Returns:
| Type | Description |
|---|---|
ResponseGetData
|
ResponseGetData object confirming sharing operation |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither share_payload nor access_level provided |
Account_Share_Error
|
If OAuth sharing operation fails |
Examples:
>>> # Using payload generator
>>> await share_oauth_account(
... auth=auth,
... account_id="123",
... access_level=ShareAccount_AccessLevel.CAN_VIEW,
... group_id=789
... )
Source code in src/crew_dcs/routes/account/access.py
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 | |