Skip to content

Account

Account

DomoJupyter_Account dataclass

DomoJupyter_Account(
    dj_workspace: Any,
    account_id: int,
    alias: str,
    is_exists: bool = False,
    domo_account: DomoAccount = None,
    creds: str | dict = None,
)

Bases: DomoBase

regenerate_failed_password async

regenerate_failed_password(
    domojupyter_fn: Callable,
    debug_api: bool = False,
    new_password: str | None = None,
    target_account_name: str | None = None,
    target_auth: DomoAuth = None,
    is_deploy_account_to_target_instance: bool = True,
    is_force_reset: bool = False,
) -> DomoAccount

tests credentials for target_user -- will reset password or access token

Source code in src/crew_dcs/classes/DomoJupyter/Account.py
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
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
async def regenerate_failed_password(
    self,
    domojupyter_fn: Callable,
    debug_api: bool = False,
    new_password: str
    | None = None,  # only used if current password does not validate will autogenerate if no passwordd provided
    target_account_name: str | None = None,
    target_auth: DomoAuth = None,
    is_deploy_account_to_target_instance: bool = True,
    is_force_reset: bool = False,
) -> dmac.DomoAccount:
    """
    tests credentials for target_user -- will reset password or access token
    """

    creds = self.read_creds(domojupyter_fn=domojupyter_fn)

    if target_auth:
        self.domo_account.target_auth = target_auth
        self.domo_account.target_instance = target_auth.domo_instance

    if not self.domo_account.target_auth:
        await self.domo_account.test_auths()

    await logger.debug(
        f"Phase 0: read creds - {json.dumps(creds)} and test against {self.domo_account.target_auth.domo_instance}"
    )

    if not self.domo_account.target_user:
        await self.domo_account.get_target_user()

        await logger.debug(
            f"Phase 0.5: get_target_user {self.domo_account.target_user.display_name} from {self.domo_account.target_user.auth.domo_instance}"
        )

    if not self.domo_account.target_user:
        raise dmac.DAC_NoTargetUser(self.domo_account)

    await self.domo_account.test_full_auth()

    if self.domo_account.is_valid_full_auth and not is_force_reset:
        return self.domo_account

    new_password = new_password or dmxkcd.generate_domo_password()

    await logger.debug(
        f"Phase 1: Password Invalid on {self.alias} - for user {self.domo_account.target_user.display_name} - reseting password {new_password}"
    )

    await self.domo_account.set_target_user_password(
        new_password=new_password, debug_api=debug_api
    )

    if is_deploy_account_to_target_instance:
        await self.domo_account.upsert_target_account(
            account_name=target_account_name or self.domo_account.name,
            debug_api=debug_api,
        )

    return self.domo_account

regenerate_failed_token async

regenerate_failed_token(
    domojupyter_fn: Callable,
    debug_api: bool = False,
    target_account_name: str | None = None,
    target_auth: DomoAuth = None,
    is_deploy_account_to_target_instance: bool = True,
    is_force_reset: bool = False,
) -> dict

tests credentials for target_user -- will reset password or access token

Source code in src/crew_dcs/classes/DomoJupyter/Account.py
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
async def regenerate_failed_token(
    self,
    domojupyter_fn: Callable,
    debug_api: bool = False,
    target_account_name: str | None = None,
    target_auth: DomoAuth = None,
    is_deploy_account_to_target_instance: bool = True,
    is_force_reset: bool = False,
) -> dict:
    """
    tests credentials for target_user -- will reset password or access token
    """

    creds = self.read_creds(domojupyter_fn=domojupyter_fn)

    if target_auth:
        self.domo_account.target_auth = target_auth
        self.domo_account.target_instance = target_auth.domo_instance

    if not self.domo_account.target_auth:
        await self.domo_account.test_auths()
    await logger.debug(
        f"Phase 0: read creds - {json.dumps(creds)} and test against {self.domo_account.target_auth.domo_instance}"
    )

    await self.domo_account.test_token_auth()

    if self.domo_account.is_valid_token_auth and not is_force_reset:
        return self.domo_account

    await logger.debug(
        f"Phase 1: Invalid token on {self.alias} - regenerating token"
    )

    await self.domo_account.reset_access_token(
        token_name=target_account_name or self.domo_account.name,
        debug_api=debug_api,
    )

    if is_deploy_account_to_target_instance:
        await self.domo_account.upsert_target_account(
            account_name=target_account_name or self.domo_account.name,
            debug_api=debug_api,
        )

    return self.domo_account