Skip to content

account_default

account_default

DomoAccount_Default dataclass

DomoAccount_Default(
    auth: DomoAuth,
    id: int,
    raw: dict,
    name: str = None,
    display_name: str = None,
    data_provider_type: str = None,
    created_dt: datetime = None,
    modified_dt: datetime = None,
    owners: list[Any] = None,
    is_admin_summary: bool = True,
    dataset_count: int = None,
    Config: DomoAccount_Config = None,
)

Bases: DomoEntity

display_url property

display_url

returns the URL to the account in Domo

create_account async classmethod

create_account(
    account_name: str,
    config: DomoAccount_Config,
    auth: DomoAuth,
    debug_api: bool = False,
    return_raw: bool = False,
    session: AsyncClient = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoAccount/account_default.py
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
@classmethod
async def create_account(
    cls,
    account_name: str,
    config: DomoAccount_Config,
    auth: DomoAuth,
    debug_api: bool = False,
    return_raw: bool = False,
    session: httpx.AsyncClient = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    res = await account_routes.create_account(
        account_name=account_name,
        data_provider_type=config.data_provider_type,
        auth=auth,
        config_body=config.to_dict(),
        context=context,
    )

    if return_raw:
        return res

    acc = await cls.get_by_id(
        auth=auth, account_id=res.response.get("id"), context=context
    )
    acc.Config = config
    return acc

delete_account async

delete_account(
    auth: DomoAuth = None,
    debug_api: bool = False,
    session: AsyncClient = None,
    debug_num_stacks_to_drop=2,
    parent_class=None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoAccount/account_default.py
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
448
449
450
451
452
async def delete_account(
    self,
    auth: DomoAuth = None,
    debug_api: bool = False,
    session: httpx.AsyncClient = None,
    debug_num_stacks_to_drop=2,
    parent_class=None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    auth = auth or self.auth

    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    res = await account_routes.delete_account(
        auth=auth,
        account_id=self.id,
        context=context,
    )

    if not res.is_success and self.is_admin_summary:
        raise Account_CanIModifyError(
            account_id=self.id, domo_instance=auth.domo_instance
        )

    return res

from_dict classmethod

from_dict(
    auth: DomoAuth,
    obj: dict[str, Any],
    is_admin_summary: bool = True,
    new_cls: Any = None,
    **kwargs,
)

converts data_v1_accounts API response into an accounts class object

Source code in src/crew_dcs/classes/DomoAccount/account_default.py
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
@classmethod
def from_dict(
    cls,
    auth: DomoAuth,
    obj: dict[str, Any],
    is_admin_summary: bool = True,
    new_cls: Any = None,
    **kwargs,
):
    """converts data_v1_accounts API response into an accounts class object"""

    return new_cls(
        id=obj.get("id") or obj.get("databaseId"),
        name=obj.get("name"),
        display_name=obj.get("displayName"),
        data_provider_type=obj.get("dataProviderId") or obj.get("dataProviderType"),
        created_dt=cd.convert_epoch_millisecond_to_datetime(
            obj.get("createdAt") or obj.get("createDate")
        ),
        modified_dt=cd.convert_epoch_millisecond_to_datetime(
            obj.get("modifiedAt") or obj.get("lastModified")
        ),
        auth=auth,
        is_admin_summary=is_admin_summary,
        owners=obj.get("owners"),
        dataset_count=obj.get("datasetCount"),
        raw=obj,
        **kwargs,
    )

get_by_id async classmethod

get_by_id(
    auth: DomoAuth,
    account_id: int,
    is_suppress_no_config: bool = True,
    session: AsyncClient = None,
    return_raw: bool = False,
    debug_api: bool = False,
    debug_num_stacks_to_drop=2,
    is_use_default_account_class=False,
    is_unmask=True,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

retrieves account metadata and attempts to retrieve config

Calls route

Source code in src/crew_dcs/classes/DomoAccount/account_default.py
278
279
280
281
282
283
284
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
@classmethod
async def get_by_id(
    cls,
    auth: DomoAuth,
    account_id: int,
    is_suppress_no_config: bool = True,
    session: httpx.AsyncClient = None,
    return_raw: bool = False,
    debug_api: bool = False,
    debug_num_stacks_to_drop=2,
    is_use_default_account_class=False,
    is_unmask=True,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """retrieves account metadata and attempts to retrieve config"""

    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    res = await account_routes.get_account_by_id(
        auth=auth,
        account_id=account_id,
        is_unmask=is_unmask,
        context=context,
    )

    if return_raw:
        return res

    obj = res.response

    acc = cls.from_dict(
        obj=obj,
        auth=auth,
        is_admin_summary=False,
        new_cls=cls,
    )

    await acc._get_config(
        context=context,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop + 1,
        is_suppress_no_config=is_suppress_no_config,
    )

    return acc

get_entity_by_id async classmethod

get_entity_by_id(entity_id, **kwargs)

Alias for get_by_id

Source code in src/crew_dcs/classes/DomoAccount/account_default.py
331
332
333
334
@classmethod
async def get_entity_by_id(cls, entity_id, **kwargs):
    """Alias for get_by_id"""
    return await cls.get_by_id(account_id=entity_id, **kwargs)

refresh async

refresh(
    auth: DomoAuth = None,
    is_suppress_no_config: bool = True,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> DomoAccount_Default

Reload entity properties from the API and refresh the account Config.

Thin wrapper that chains
  1. super().refresh() — calls get_entity_by_id (i.e. get_by_id) to reload all entity-level attributes (name, data_provider_type, owners, etc.).
  2. _get_config() — fetches and parses the account credential config.

Parameters:

Name Type Description Default
auth DomoAuth

Auth to use for config retrieval (defaults to self.auth).

None
is_suppress_no_config bool

Suppress errors when no DomoAccount_Config subclass is registered for the account's data_provider_type. Defaults to True so callers can inspect self.Config is None rather than catching exceptions.

True
debug_api bool

Enable API debug logging.

False
session AsyncClient | None

Optional reusable httpx.AsyncClient.

None
context RouteContext | None

Optional RouteContext.

None

Returns:

Type Description
DomoAccount_Default

Self, mutated in-place with refreshed data.

Source code in src/crew_dcs/classes/DomoAccount/account_default.py
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
async def refresh(
    self,
    auth: DomoAuth = None,
    is_suppress_no_config: bool = True,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> "DomoAccount_Default":
    """Reload entity properties from the API and refresh the account Config.

    Thin wrapper that chains:
      1. ``super().refresh()`` — calls ``get_entity_by_id`` (i.e. ``get_by_id``)
         to reload all entity-level attributes (name, data_provider_type, owners, etc.).
      2. ``_get_config()`` — fetches and parses the account credential config.

    Args:
        auth: Auth to use for config retrieval (defaults to ``self.auth``).
        is_suppress_no_config: Suppress errors when no ``DomoAccount_Config``
            subclass is registered for the account's ``data_provider_type``.
            Defaults to ``True`` so callers can inspect ``self.Config is None``
            rather than catching exceptions.
        debug_api: Enable API debug logging.
        session: Optional reusable ``httpx.AsyncClient``.
        context: Optional ``RouteContext``.

    Returns:
        Self, mutated in-place with refreshed data.
    """
    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        **context_kwargs,
    )

    await super().refresh(
        debug_api=debug_api,
        session=session,
        is_suppress_no_config=is_suppress_no_config,
    )

    await self._get_config(
        auth=auth or self.auth,
        is_suppress_no_config=is_suppress_no_config,
        debug_api=debug_api,
        session=session,
    )

    return self

share async

share(
    user_id: int | None = None,
    group_id: int | None = None,
    access_level: AccountAccess
    | AccountAccess_v1
    | str
    | None = None,
    session: AsyncClient | None = None,
    debug_api: bool = False,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Share this account with a user or group.

Parameters:

Name Type Description Default
user_id int | None

User ID to share with (mutually exclusive with group_id)

None
group_id int | None

Group ID to share with (mutually exclusive with user_id)

None
access_level AccountAccess | AccountAccess_v1 | str | None

Access level (AccessLevel enum)

None
session AsyncClient | None

HTTP client session (optional)

None
debug_api bool

Enable API debugging

False
return_raw bool

Return raw response without processing

False
context RouteContext | None

Optional RouteContext for API call configuration

None
**context_kwargs

Additional context parameters

{}

Returns:

Type Description

ResponseGetData if return_raw=True, else the updated account

Raises:

Type Description
ValueError

If neither user_id nor group_id is provided

AccountSharing_Error

If the sharing request fails

Example

from crew_dcs.routes.account import AccountAccess account = await DomoAccount.get_by_id(auth=auth, account_id="123") await account.share( ... user_id=456, ... access_level=AccountAccess.CAN_EDIT ... )

Calls route

Source code in src/crew_dcs/classes/DomoAccount/account_default.py
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
async def share(
    self,
    user_id: int | None = None,
    group_id: int | None = None,
    access_level: AccountAccess | AccountAccess_v1 | str | None = None,
    session: httpx.AsyncClient | None = None,
    debug_api: bool = False,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Share this account with a user or group.

    Args:
        user_id: User ID to share with (mutually exclusive with group_id)
        group_id: Group ID to share with (mutually exclusive with user_id)
        access_level: Access level (AccessLevel enum)
        session: HTTP client session (optional)
        debug_api: Enable API debugging
        return_raw: Return raw response without processing
        context: Optional RouteContext for API call configuration
        **context_kwargs: Additional context parameters

    Returns:
        ResponseGetData if return_raw=True, else the updated account

    Raises:
        ValueError: If neither user_id nor group_id is provided
        AccountSharing_Error: If the sharing request fails

    Example:
        >>> from crew_dcs.routes.account import AccountAccess
        >>> account = await DomoAccount.get_by_id(auth=auth, account_id="123")
        >>> await account.share(
        ...     user_id=456,
        ...     access_level=AccountAccess.CAN_EDIT
        ... )
    """
    if not user_id and not group_id:
        raise ValueError("Must provide either user_id or group_id")

    # This method could not execute on any path before: it imported
    # `AccessLevel` from routes.account (the enum is `AccountAccess`) and
    # called `.generate_payload()`, which is defined nowhere in the library.
    # The real builders live in routes/account/access.py.
    if not access_level:
        access_level = AccountAccess.CAN_VIEW

    if isinstance(access_level, str):
        access_level = AccountAccess.get(access_level)

    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        **context_kwargs,
    )

    share_payload = generate_share_account_payload(
        access_level=access_level,
        user_id=user_id,
        group_id=group_id,
    )

    res = await account_routes.share_account(
        auth=self.auth,
        account_id=self.id,
        share_payload=share_payload,
        return_raw=return_raw,
        context=context,
    )

    if return_raw:
        return res

    return self

update_config async

update_config(
    auth: DomoAuth = None,
    debug_api: bool = False,
    config: DomoAccount_Config = None,
    is_suppress_no_config=False,
    debug_num_stacks_to_drop=2,
    session: AsyncClient = None,
    return_raw: bool = False,
    is_update_config: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoAccount/account_default.py
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
async def update_config(
    self,
    auth: DomoAuth = None,
    debug_api: bool = False,
    config: DomoAccount_Config = None,
    is_suppress_no_config=False,
    debug_num_stacks_to_drop=2,
    session: httpx.AsyncClient = None,
    return_raw: bool = False,
    is_update_config: bool = False,  # if calling the Api, Domo will send encrypted values (astericks) in most cases it's best not to try to retrieve updated values from the API
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    auth = auth or self.auth

    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    if config:
        self.Config = config

    if not self.Config:
        raise AccountClass_CRUDError(
            cls_instance=self,
            message="unable to update account - no domo_account.Config not provided",
        )

    res = await account_routes.update_account_config(
        auth=auth,
        account_id=self.id,
        config_body=self.Config.to_dict(),
        context=context,
    )

    # await asyncio.sleep(3)

    # new_acc = await DomoAccount_Default.get_by_id(auth=auth, account_id=self.id)

    # self._update_self(new_class = new_acc, skip_props = ['Config'])

    if return_raw:
        return res

    if not res.is_success and self.is_admin_summary:
        raise Account_CanIModifyError(
            account_id=self.id, domo_instance=auth.domo_instance
        )

    if not is_update_config:
        return self.Config

    await asyncio.sleep(3)

    await self._get_config(
        context=context,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop + 1,
        is_suppress_no_config=is_suppress_no_config,
    )

    return self.Config

update_name async

update_name(
    account_name: str | None = None,
    auth: DomoAuth = None,
    debug_api: bool = False,
    session: AsyncClient = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoAccount/account_default.py
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
async def update_name(
    self,
    account_name: str | None = None,
    auth: DomoAuth = None,
    debug_api: bool = False,
    session: httpx.AsyncClient = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    auth = auth or self.auth

    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        **context_kwargs,
    )

    res = await account_routes.update_account_name(
        auth=auth,
        account_id=self.id,
        account_name=account_name or self.display_name or self.name,
        context=context,
    )

    if return_raw:
        return res

    if not res.is_success and self.is_admin_summary:
        raise Account_CanIModifyError(
            account_id=self.id, domo_instance=auth.domo_instance
        )

    new_acc = await DomoAccount_Default.get_by_id(
        auth=auth, account_id=self.id, context=context
    )

    self._update_self(new_class=new_acc, skip_props=["Config"])

    return self

    return self

upsert_target_account async

upsert_target_account(
    target_auth: DomoAuth,
    account_name: str | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

upsert an account in a target instance with self.Config

Source code in src/crew_dcs/classes/DomoAccount/account_default.py
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
async def upsert_target_account(
    self,
    target_auth: DomoAuth,  # valid auth for target destination
    account_name: str | None = None,  # defaults to self.display_name or self.name
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """
    upsert an account in a target instance with self.Config
    """
    from copy import deepcopy

    # Import here to avoid circular import
    from . import core

    context = RouteContext.build_context(context=context, **context_kwargs)

    account_name = account_name or self.display_name or self.name
    await logger.info(
        f"Upserting account {self.id} ({account_name}) to {target_auth.domo_instance}"
    )

    return await core.DomoAccounts.upsert_account(
        auth=target_auth,
        account_name=account_name,
        account_config=deepcopy(self.Config),
        data_provider_type=self.data_provider_type,
        context=context,
    )