Skip to content

properties

properties

User Properties Management Routes

This module provides functionality for managing user properties and property-related operations in Domo instances. This includes user properties like display name, email, phone, department, role, as well as property-specific operations like password management, avatar management, landing page settings, and permission controls.

Functions:

Name Description
update_user

Update user properties via identity API

generate_patch_user_property_body

Generate request body for property updates

set_user_landing_page

Set user's default landing page

reset_password

Reset user password

request_password_reset

Request password reset via email

download_avatar

Download user avatar image

upload_avatar

Upload user avatar image

generate_avatar_bytestr

Generate base64 avatar string for uploads

user_is_allowed_direct_signon

Manage direct sign-on permissions

Classes:

Name Description
UserProperty_Type

Enum of available user property types

UserProperty

Class representing a user property with type and values

Exception Classes

ResetPasswordPasswordUsedErrorError: Raised when password was previously used DownloadAvatar_Error: Raised when avatar download fails

UserProperty

UserProperty(
    property_type: UserProperty_Type,
    values: str | list[str],
)

Represents a user property with its type and values.

Initialize a user property.

Parameters:

Name Type Description Default
property_type UserProperty_Type

The type of property from UserProperty_Type enum

required
values str | list[str]

The value(s) for the property (can be single value or list)

required
Source code in src/crew_dcs/routes/user/properties.py
88
89
90
91
92
93
94
95
96
def __init__(self, property_type: UserProperty_Type, values: str | list[str]):
    """Initialize a user property.

    Args:
        property_type: The type of property from UserProperty_Type enum
        values: The value(s) for the property (can be single value or list)
    """
    self.property_type = property_type
    self.values = self._value_to_list(values)

to_dict

to_dict()

Convert the property to dictionary format for API requests.

Returns:

Name Type Description
dict

Property in API format with key and values

Source code in src/crew_dcs/routes/user/properties.py
110
111
112
113
114
115
116
117
118
119
def to_dict(self):
    """Convert the property to dictionary format for API requests.

    Returns:
        dict: Property in API format with key and values
    """
    return {
        "key": self.property_type.value,
        "values": self._value_to_list(self.values),
    }

UserProperty_Type

Bases: DomoEnumMixin, Enum

Enumeration of available user property types.

download_avatar async

download_avatar(
    auth: DomoAuth,
    user_id: str,
    pixels: int = 300,
    folder_path="./images",
    img_name=None,
    is_download_image: bool = True,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
)

Download a user's avatar image.

Parameters:

Name Type Description Default
user_id str

ID of the user whose avatar to download

required
auth DomoAuth

Authentication object

required
pixels int

Size of the avatar in pixels (default: 300)

300
folder_path

Path to save the avatar image (default: "./images")

'./images'
img_name

Custom name for the image file (optional)

None
is_download_image bool

Whether to save image to disk (default: True)

True
return_raw bool

Return raw API response without processing

False
context RouteContext | None

RouteContext for request configuration

None
**context_kwargs

Additional context parameters (session, debug_api, etc.)

{}

Returns:

Type Description

ResponseGetData object containing avatar data

Raises:

Type Description
DownloadAvatar_Error

If avatar download fails

Source code in src/crew_dcs/routes/user/properties.py
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
448
449
450
451
452
453
454
455
456
457
458
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def download_avatar(
    auth: DomoAuth,
    user_id: str,
    pixels: int = 300,
    folder_path="./images",
    img_name=None,
    is_download_image: bool = True,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Download a user's avatar image.

    Args:
        user_id: ID of the user whose avatar to download
        auth: Authentication object
        pixels: Size of the avatar in pixels (default: 300)
        folder_path: Path to save the avatar image (default: "./images")
        img_name: Custom name for the image file (optional)
        is_download_image: Whether to save image to disk (default: True)
        return_raw: Return raw API response without processing
        context: RouteContext for request configuration
        **context_kwargs: Additional context parameters (session, debug_api, etc.)

    Returns:
        ResponseGetData object containing avatar data

    Raises:
        DownloadAvatar_Error: If avatar download fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/content/v1/avatar/USER/{user_id}?size={pixels}"

    res = await gd.get_data_stream(
        url=url,
        method="GET",
        auth=auth,
        headers={"accept": "image/png;charset=utf-8"},
        context=context,
    )

    if return_raw:
        return res

    if res.status != 200:
        raise DownloadAvatar_Error(user_id=user_id, res=res)

    if is_download_image is True:
        img_name = f"{user_id}.png" if img_name is None else img_name

        if not os.path.exists(folder_path):
            os.makedirs(folder_path)

        with open(f"{folder_path}/{img_name}", "wb") as file:
            file.write(res.response)

    return res

generate_avatar_bytestr

generate_avatar_bytestr(
    img_bytestr: bytes | str, img_type: str
) -> str

Generate base64 encoded avatar byte string for upload.

Parameters:

Name Type Description Default
img_bytestr bytes | str

Image data as bytes or base64 string

required
img_type str

Image type ('jpg' or 'png')

required

Returns:

Name Type Description
str str

Base64 encoded image string with data URI prefix

Source code in src/crew_dcs/routes/user/properties.py
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
def generate_avatar_bytestr(img_bytestr: bytes | str, img_type: str) -> str:
    """Generate base64 encoded avatar byte string for upload.

    Args:
        img_bytestr: Image data as bytes or base64 string
        img_type: Image type ('jpg' or 'png')

    Returns:
        str: Base64 encoded image string with data URI prefix
    """
    if isinstance(img_bytestr, str):
        img_bytestr = img_bytestr.encode("utf-8")

    if not images.isBase64(img_bytestr):
        img_bytestr = base64.b64encode(img_bytestr)

    img_bytestr = img_bytestr.decode("utf-8")

    html_encoding = f"data:image/{img_type};base64,"

    if not img_bytestr.startswith(html_encoding):
        img_bytestr = html_encoding + img_bytestr

    return img_bytestr

generate_patch_user_property_body

generate_patch_user_property_body(
    user_property_ls: list[UserProperty],
) -> dict

Generate request body for user property updates.

Parameters:

Name Type Description Default
user_property_ls list[UserProperty]

list of UserProperty objects to update

required

Returns:

Name Type Description
dict dict

Request body with attributes array for PATCH request

Source code in src/crew_dcs/routes/user/properties.py
122
123
124
125
126
127
128
129
130
131
132
133
def generate_patch_user_property_body(user_property_ls: list[UserProperty]) -> dict:
    """Generate request body for user property updates.

    Args:
        user_property_ls: list of UserProperty objects to update

    Returns:
        dict: Request body with attributes array for PATCH request
    """
    return {
        "attributes": [user_property.to_dict() for user_property in user_property_ls]
    }

request_password_reset async

request_password_reset(
    domo_instance: str,
    email: str,
    locale: str = "en-us",
    *,
    context: RouteContext | None = None,
    return_raw: bool = False,
    **context_kwargs
)

Request a password reset for a user via email.

Parameters:

Name Type Description Default
domo_instance str

Name of the Domo instance

required
email str

Email address of the user requesting password reset

required
locale str

Locale for the reset email (default: "en-us")

'en-us'
context RouteContext | None

Optional RouteContext for request configuration

None
return_raw bool

Return raw API response without processing

False
**context_kwargs

Additional context parameters (session, debug_api, etc.)

{}

Returns:

Type Description

ResponseGetData object confirming password reset request

Raises:

Type Description
User_CRUD_Error

If password reset request fails

Source code in src/crew_dcs/routes/user/properties.py
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
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
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def request_password_reset(
    domo_instance: str,
    email: str,
    locale: str = "en-us",
    *,
    context: RouteContext | None = None,
    return_raw: bool = False,
    **context_kwargs,
):
    """Request a password reset for a user via email.

    Args:
        domo_instance: Name of the Domo instance
        email: Email address of the user requesting password reset
        locale: Locale for the reset email (default: "en-us")
        context: Optional RouteContext for request configuration
        return_raw: Return raw API response without processing
        **context_kwargs: Additional context parameters (session, debug_api, etc.)

    Returns:
        ResponseGetData object confirming password reset request

    Raises:
        User_CRUD_Error: If password reset request fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{domo_instance}.domo.com/api/domoweb/auth/sendReset"

    params = {"email": email, "locale": locale}

    res = await gd.get_data(
        url=url,
        method="GET",
        params=params,
        auth=None,
        context=context,
    )

    if return_raw:
        return res

    if not res.is_success:
        raise User_CRUD_Error(
            operation="request_password_reset",
            res=res,
            message=f"unable to request password reset {res.response}",
        )

    return res

reset_password async

reset_password(
    auth: DomoAuth,
    user_id: str,
    new_password: str,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Reset a user's password.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
user_id str

ID of the user whose password to reset

required
new_password str

New password for the user

required
return_raw bool

Return raw API response without processing

False
context RouteContext | None

RouteContext for request configuration

None
**context_kwargs

Additional context parameters (session, debug_api, etc.)

{}

Returns:

Type Description
ResponseGetData

ResponseGetData object confirming password reset

Raises:

Type Description
User_CRUD_Error

If password reset fails

ResetPasswordPasswordUsedError

If password was previously used

Source code in src/crew_dcs/routes/user/properties.py
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def reset_password(
    auth: DomoAuth,
    user_id: str,
    new_password: str,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Reset a user's password.

    Args:
        auth: Authentication object
        user_id: ID of the user whose password to reset
        new_password: New password for the user
        return_raw: Return raw API response without processing
        context: RouteContext for request configuration
        **context_kwargs: Additional context parameters (session, debug_api, etc.)

    Returns:
        ResponseGetData object confirming password reset

    Raises:
        User_CRUD_Error: If password reset fails
        ResetPasswordPasswordUsedError: If password was previously used
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/identity/v1/password"

    body = {"domoUserId": user_id, "password": new_password}

    res = await gd.get_data(
        url=url,
        method="PUT",
        auth=auth,
        body=body,
        context=context,
    )

    if return_raw:
        return res

    if not res.is_success:
        raise User_CRUD_Error(
            operation="reset_password",
            user_id=user_id,
            res=res,
            message="unable to change password",
        )

    if (
        res.status == 200
        and res.response.get("description", None)
        == "Password has been used previously."
    ):
        raise ResetPasswordPasswordUsedError(
            user_id=user_id,
            res=res,
            message=res.response["description"].replace(".", ""),
        )

    return res

set_user_landing_page async

set_user_landing_page(
    auth: DomoAuth,
    user_id: str,
    page_id: str,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
)

Set a user's landing page.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
user_id str

ID of the user to update

required
page_id str

ID of the page to set as landing page

required
return_raw bool

Return raw API response without processing

False
context RouteContext | None

RouteContext for request configuration

None
**context_kwargs

Additional context parameters (session, debug_api, etc.)

{}

Returns:

Type Description

ResponseGetData object confirming the update

Raises:

Type Description
User_CRUD_Error

If landing page update fails

Source code in src/crew_dcs/routes/user/properties.py
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
229
230
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
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def set_user_landing_page(
    auth: DomoAuth,
    user_id: str,
    page_id: str,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Set a user's landing page.

    Args:
        auth: Authentication object
        user_id: ID of the user to update
        page_id: ID of the page to set as landing page
        return_raw: Return raw API response without processing
        context: RouteContext for request configuration
        **context_kwargs: Additional context parameters (session, debug_api, etc.)

    Returns:
        ResponseGetData object confirming the update

    Raises:
        User_CRUD_Error: If landing page update fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/content/v1/landings/target/DESKTOP/entity/PAGE/id/{page_id}/{user_id}"

    res = await gd.get_data(
        url=url,
        method="PUT",
        auth=auth,
        context=context,
    )

    if return_raw:
        return res

    if not res.is_success:
        raise User_CRUD_Error(
            operation="set_landing_page",
            user_id=user_id,
            res=res,
        )

    return res

update_user async

update_user(
    auth: DomoAuth,
    user_id: str,
    user_property_ls: list[UserProperty],
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
)

Update user properties via the identity API.

Parameters:

Name Type Description Default
user_id str

ID of the user to update

required
user_property_ls list[UserProperty]

list of UserProperty objects with updates

required
auth DomoAuth

Authentication object

required
return_raw bool

Return raw API response without processing

False
context RouteContext | None

RouteContext for request configuration

None
**context_kwargs

Additional context parameters (session, debug_api, etc.)

{}

Returns:

Type Description

ResponseGetData object confirming property updates

Raises:

Type Description
User_CRUD_Error

If property update fails

Source code in src/crew_dcs/routes/user/properties.py
136
137
138
139
140
141
142
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
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def update_user(
    auth: DomoAuth,
    user_id: str,
    user_property_ls: list[UserProperty],
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Update user properties via the identity API.

    Args:
        user_id: ID of the user to update
        user_property_ls: list of UserProperty objects with updates
        auth: Authentication object
        return_raw: Return raw API response without processing
        context: RouteContext for request configuration
        **context_kwargs: Additional context parameters (session, debug_api, etc.)

    Returns:
        ResponseGetData object confirming property updates

    Raises:
        User_CRUD_Error: If property update fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/identity/v1/users/{user_id}"

    body = {}

    if isinstance(user_property_ls, list):
        if isinstance(user_property_ls[0], UserProperty):
            body = generate_patch_user_property_body(user_property_ls)

        if isinstance(user_property_ls[0], dict):
            body = {"attributes": user_property_ls}

    if not body:
        raise ValueError(f"Invalid user_property_ls format {user_property_ls}")

    res = await gd.get_data(
        url=url,
        method="PATCH",
        auth=auth,
        body=body,
        context=context,
    )

    if return_raw:
        return res

    if not res.is_success:
        raise User_CRUD_Error(operation="update_properties", user_id=user_id, res=res)

    return res

upload_avatar async

upload_avatar(
    auth: DomoAuth,
    user_id: int,
    img_bytestr: bytes,
    img_type: str,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
)

Upload an avatar image for a user.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
user_id int

ID of the user to update avatar for

required
img_bytestr bytes

Image data as bytes

required
img_type str

Image type ('jpg' or 'png')

required
return_raw bool

Return raw API response without processing

False
context RouteContext | None

RouteContext for request configuration

None
**context_kwargs

Additional context parameters (session, debug_api, etc.)

{}

Returns:

Type Description

ResponseGetData object confirming avatar upload

Raises:

Type Description
User_CRUD_Error

If avatar upload fails

Source code in src/crew_dcs/routes/user/properties.py
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
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def upload_avatar(
    auth: DomoAuth,
    user_id: int,
    img_bytestr: bytes,
    img_type: str,  #'jpg or png'
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    """Upload an avatar image for a user.

    Args:
        auth: Authentication object
        user_id: ID of the user to update avatar for
        img_bytestr: Image data as bytes
        img_type: Image type ('jpg' or 'png')
        return_raw: Return raw API response without processing
        context: RouteContext for request configuration
        **context_kwargs: Additional context parameters (session, debug_api, etc.)

    Returns:
        ResponseGetData object confirming avatar upload

    Raises:
        User_CRUD_Error: If avatar upload fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/content/v1/avatar/bulk"

    body = {
        "base64Image": generate_avatar_bytestr(img_bytestr, img_type),
        "encodedImage": generate_avatar_bytestr(img_bytestr, img_type),
        "isOpen": False,
        "entityIds": [user_id],
        "entityType": "USER",
    }

    res = await gd.get_data(
        url=url,
        method="POST",
        body=body,
        auth=auth,
        context=context,
    )

    if return_raw:
        return res

    if not res.is_success:
        raise User_CRUD_Error(
            operation="upload_avatar",
            user_id=str(user_id),
            res=res,
        )

    return res

user_is_allowed_direct_signon async

user_is_allowed_direct_signon(
    auth: DomoAuth,
    user_ids: list[str],
    is_allow_dso: bool = True,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Manage direct sign-on permissions for users.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object

required
user_ids list[str]

list of user IDs to modify

required
is_allow_dso bool

Whether to allow direct sign-on (default: True)

True
return_raw bool

Return raw API response without processing

False
context RouteContext | None

RouteContext for request configuration

None
**context_kwargs

Additional context parameters (session, debug_api, etc.)

{}

Returns:

Type Description
ResponseGetData

ResponseGetData object confirming permission changes

Raises:

Type Description
User_CRUD_Error

If direct sign-on permission update fails

Source code in src/crew_dcs/routes/user/properties.py
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
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def user_is_allowed_direct_signon(
    auth: DomoAuth,
    user_ids: list[str],
    is_allow_dso: bool = True,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Manage direct sign-on permissions for users.

    Args:
        auth: Authentication object
        user_ids: list of user IDs to modify
        is_allow_dso: Whether to allow direct sign-on (default: True)
        return_raw: Return raw API response without processing
        context: RouteContext for request configuration
        **context_kwargs: Additional context parameters (session, debug_api, etc.)

    Returns:
        ResponseGetData object confirming permission changes

    Raises:
        User_CRUD_Error: If direct sign-on permission update fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/content/v3/users/directSignOn"
    params = {"value": is_allow_dso}

    res = await gd.get_data(
        url=url,
        method="PUT",
        auth=auth,
        params=params,
        body=user_ids if isinstance(user_ids, list) else [user_ids],
        context=context,
    )

    if return_raw:
        return res

    if not res.is_success:
        raise User_CRUD_Error(
            operation="set_direct_signon",
            res=res,
        )

    return res