"""Fill in a module description here"""

# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/LocalAccount/shortcut_fn.ipynb.

# %% auto 0
__all__ = ['Shortcut_NoAccount', 'share_domo_account_with_domo_group']

# %% ../../nbs/LocalAccount/shortcut_fn.ipynb 2
from typing import List
import asyncio

import domolibrary_execution.utils.domojupyter as dxdj
import domolibrary_execution.client.ExecutionError.py as dxee

import domolibrary.client.DomoAuth as dmda
import domolibrary.classes.DomoGroup as dmdg
import domolibrary.classes.DomoAccount as dmacc
# import domolibrary.client.DomoError as dmde


# import domolibrary.utils.chunk_execution as dmce



# %% ../../nbs/LocalAccount/shortcut_fn.ipynb 8
class Shortcut_NoAccount(dxee.ExecutionError):
    def __init__(self, account_name, domo_instance):
        super().__init__(
            f"unable to retrieve account - {account_name} from {domo_instance}"
        )


async def share_domo_account_with_domo_group(
    auth: dmda.DomoAuth, 
    account_name : str,
    group_name: str,
    is_search_system_accounts : bool = True
                                 ):
    
    domo_group = await dmdg.DomoGroups.upsert(auth = auth,
                                              group_name = group_name,
                                             is_search_system_accounts = is_search_system_accounts)
    
    domo_account = await search_domo_account_by_name(auth = auth, account_name = account_name)

    return await domo_account.share(group_id=share_domo_group.id, auth=auth)

