Skip to content

authentication_policies

authentication_policies

GetPasswordExpirationError

GetPasswordExpirationError(
    res: ResponseGetData, message: str | None = None
)

Bases: Config_GET_Error

Raised when retrieving the password expiration policy fails.

Source code in src/crew_dcs/routes/instance_config/authentication_policies.py
227
228
229
230
def __init__(self, res: rgd.ResponseGetData, message: str | None = None):
    if not message:
        message = f"Failed to retrieve {_PASSWORD_EXPIRATION_POLICY_KEY}."
    super().__init__(res=res, message=message)

GetPasswordReuseHistoryError

GetPasswordReuseHistoryError(
    res: ResponseGetData, message: str | None = None
)

Bases: Config_GET_Error

Raised when retrieving password reuse history policy fails.

Source code in src/crew_dcs/routes/instance_config/authentication_policies.py
38
39
40
41
def __init__(self, res: rgd.ResponseGetData, message: str | None = None):
    if not message:
        message = "Failed to retrieve domo.policy.password_reuse_history."
    super().__init__(res=res, message=message)

get_password_expiration async

get_password_expiration(
    auth: DomoAuth,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Get the password expiration policy setting.

Returns the number of days before a password expires. A value of 0 means passwords never expire.

Parameters:

Name Type Description Default
auth DomoAuth

DomoAuth authentication object

required
return_raw bool

If True, return raw ResponseGetData object

False

Returns:

Type Description
ResponseGetData

ResponseGetData with the expiration days (int) in the response field,

ResponseGetData

or raw ResponseGetData if return_raw=True

Raises:

Type Description
GetPasswordExpirationError

If the API call fails

Source code in src/crew_dcs/routes/instance_config/authentication_policies.py
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
283
284
285
286
287
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def get_password_expiration(
    auth: DomoAuth,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Get the password expiration policy setting.

    Returns the number of days before a password expires.
    A value of 0 means passwords never expire.

    Args:
        auth: DomoAuth authentication object
        return_raw: If True, return raw ResponseGetData object

    Returns:
        ResponseGetData with the expiration days (int) in the response field,
        or raw ResponseGetData if return_raw=True

    Raises:
        GetPasswordExpirationError: If the API call fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/content/v1/customer-states/{_PASSWORD_EXPIRATION_POLICY_KEY}"

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

    if return_raw:
        return res

    if not res.is_success:
        raise GetPasswordExpirationError(res=res)

    if isinstance(res.response, dict) and "value" in res.response:
        try:
            res.response = int(res.response["value"])
        except (ValueError, TypeError):
            res.response = res.response["value"]

    return res

get_password_reuse_history async

get_password_reuse_history(
    auth: DomoAuth,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Get the password reuse history policy setting.

This determines how many previous passwords are remembered and cannot be reused.

Parameters:

Name Type Description Default
auth DomoAuth

DomoAuth authentication object

required
return_raw bool

If True, return raw ResponseGetData object

False

Returns:

Type Description
ResponseGetData

ResponseGetData with the password reuse history value (int) in response field,

ResponseGetData

or raw ResponseGetData if return_raw=True

Raises:

Type Description
GetPasswordReuseHistoryError

If the API call fails

Source code in src/crew_dcs/routes/instance_config/authentication_policies.py
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(
        entity_extractor=DomoEntityExtractor(),
        result_processor=DomoEntityResultProcessor(),
    ),
)
async def get_password_reuse_history(
    auth: DomoAuth,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Get the password reuse history policy setting.

    This determines how many previous passwords are remembered and cannot be reused.

    Args:
        auth: DomoAuth authentication object
        return_raw: If True, return raw ResponseGetData object

    Returns:
        ResponseGetData with the password reuse history value (int) in response field,
        or raw ResponseGetData if return_raw=True

    Raises:
        GetPasswordReuseHistoryError: If the API call fails
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/content/v1/customer-states/domo.policy.password_reuse_history"

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

    if return_raw:
        return res

    if not res.is_success:
        raise GetPasswordReuseHistoryError(res=res)

    # Parse the value from the response
    if isinstance(res.response, dict) and "value" in res.response:
        try:
            res.response = int(res.response["value"])
        except (ValueError, TypeError):
            res.response = res.response["value"]

    return res

set_password_expiration async

set_password_expiration(
    auth: DomoAuth,
    expiration_days: int,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Set the password expiration policy.

Parameters:

Name Type Description Default
auth DomoAuth

DomoAuth authentication object

required
expiration_days int

Number of days before passwords expire. Use 0 to disable expiration, 365 for annual expiration.

required
return_raw bool

If True, return raw ResponseGetData object

False

Returns:

Type Description
ResponseGetData

ResponseGetData with the updated expiration days value

Raises:

Type Description
Config_CRUD_Error

If the update (PUT) API call fails.

GetPasswordExpirationError

If fetching the updated password expiration value fails after a successful update.

Example

Set annual password expiration

await set_password_expiration(auth=auth, expiration_days=365)

Disable password expiration

await set_password_expiration(auth=auth, expiration_days=0)

Source code in src/crew_dcs/routes/instance_config/authentication_policies.py
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(result_processor=ResponseGetDataProcessor()),
)
async def set_password_expiration(
    auth: DomoAuth,
    expiration_days: int,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Set the password expiration policy.

    Args:
        auth: DomoAuth authentication object
        expiration_days: Number of days before passwords expire.
                         Use 0 to disable expiration, 365 for annual expiration.
        return_raw: If True, return raw ResponseGetData object

    Returns:
        ResponseGetData with the updated expiration days value

    Raises:
        Config_CRUD_Error: If the update (PUT) API call fails.
        GetPasswordExpirationError: If fetching the updated password
            expiration value fails after a successful update.

    Example:
        # Set annual password expiration
        await set_password_expiration(auth=auth, expiration_days=365)

        # Disable password expiration
        await set_password_expiration(auth=auth, expiration_days=0)
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/content/v1/customer-states/{_PASSWORD_EXPIRATION_POLICY_KEY}"

    body = {
        "name": _PASSWORD_EXPIRATION_POLICY_KEY,
        "value": str(expiration_days),
    }

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

    if return_raw:
        return res

    if not res.is_success:
        raise Config_CRUD_Error(res=res)

    return await get_password_expiration(
        auth=auth,
        context=context,
    )

set_password_reuse_history async

set_password_reuse_history(
    auth: DomoAuth,
    history_count: int,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Set the password reuse history policy setting.

This determines how many previous passwords are remembered and cannot be reused. Setting history_count to 0 disables password reuse history checking entirely.

Parameters:

Name Type Description Default
auth DomoAuth

DomoAuth authentication object

required
history_count int

Number of previous passwords to remember (0-10). Set to 0 to disable password reuse history checking.

required
return_raw bool

If True, return raw ResponseGetData object

False

Returns:

Type Description
ResponseGetData

ResponseGetData with the updated password reuse history value in response field

Raises:

Type Description
Config_CRUD_Error

If the update (PUT) API call fails.

GetPasswordReuseHistoryError

If fetching the updated password reuse history value fails after a successful update.

Example

Disable password reuse history

await set_password_reuse_history(auth=auth, history_count=0)

Remember last 5 passwords

await set_password_reuse_history(auth=auth, history_count=5)

Source code in src/crew_dcs/routes/instance_config/authentication_policies.py
101
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
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
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(result_processor=ResponseGetDataProcessor()),
)
async def set_password_reuse_history(
    auth: DomoAuth,
    history_count: int,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Set the password reuse history policy setting.

    This determines how many previous passwords are remembered and cannot be reused.
    Setting history_count to 0 disables password reuse history checking entirely.

    Args:
        auth: DomoAuth authentication object
        history_count: Number of previous passwords to remember (0-10).
                      Set to 0 to disable password reuse history checking.
        return_raw: If True, return raw ResponseGetData object

    Returns:
        ResponseGetData with the updated password reuse history value in response field

    Raises:
        Config_CRUD_Error: If the update (PUT) API call fails.
        GetPasswordReuseHistoryError: If fetching the updated password
            reuse history value fails after a successful update.

    Example:
        # Disable password reuse history
        await set_password_reuse_history(auth=auth, history_count=0)

        # Remember last 5 passwords
        await set_password_reuse_history(auth=auth, history_count=5)
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    url = f"https://{auth.domo_instance}.domo.com/api/content/v1/customer-states/domo.policy.password_reuse_history"

    body = {
        "name": "domo.policy.password_reuse_history",
        "value": str(history_count),
    }

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

    if return_raw:
        return res

    if not res.is_success:
        raise Config_CRUD_Error(res=res)

    # Return the updated value
    return await get_password_reuse_history(
        auth=auth,
        context=context,
    )

toggle_password_reuse_history async

toggle_password_reuse_history(
    auth: DomoAuth,
    is_enable_history: bool,
    history_count: int = 10,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> ResponseGetData

Enable or disable password reuse history checking.

When enabled, the specified number of previous passwords are remembered and cannot be reused. When disabled, users can reuse any previous password.

Parameters:

Name Type Description Default
auth DomoAuth

DomoAuth authentication object

required
is_enable_history bool

If True, enable history checking with history_count. If False, disable history checking (sets to 0).

required
history_count int

Number of previous passwords to remember when enabling (default: 10). Ignored when is_enable_history=False.

10
return_raw bool

If True, return raw ResponseGetData object

False

Returns:

Type Description
ResponseGetData

ResponseGetData with the updated password reuse history value

Raises:

Type Description
Config_CRUD_Error

If the API call fails

Example

Disable password reuse history checking

await toggle_password_reuse_history(auth=auth, is_enable_history=False)

Enable with default (remember last 10 passwords)

await toggle_password_reuse_history(auth=auth, is_enable_history=True)

Enable with custom count (remember last 5 passwords)

await toggle_password_reuse_history(auth=auth, is_enable_history=True, history_count=5)

Source code in src/crew_dcs/routes/instance_config/authentication_policies.py
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
@gd.route_function
@log_call(
    level_name="route",
    config=LogDecoratorConfig(result_processor=ResponseGetDataProcessor()),
)
async def toggle_password_reuse_history(
    auth: DomoAuth,
    is_enable_history: bool,
    history_count: int = 10,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> rgd.ResponseGetData:
    """Enable or disable password reuse history checking.

    When enabled, the specified number of previous passwords are remembered and
    cannot be reused. When disabled, users can reuse any previous password.

    Args:
        auth: DomoAuth authentication object
        is_enable_history: If True, enable history checking with history_count.
                          If False, disable history checking (sets to 0).
        history_count: Number of previous passwords to remember when enabling (default: 10).
                      Ignored when is_enable_history=False.
        return_raw: If True, return raw ResponseGetData object

    Returns:
        ResponseGetData with the updated password reuse history value

    Raises:
        Config_CRUD_Error: If the API call fails

    Example:
        # Disable password reuse history checking
        await toggle_password_reuse_history(auth=auth, is_enable_history=False)

        # Enable with default (remember last 10 passwords)
        await toggle_password_reuse_history(auth=auth, is_enable_history=True)

        # Enable with custom count (remember last 5 passwords)
        await toggle_password_reuse_history(auth=auth, is_enable_history=True, history_count=5)
    """
    context = RouteContext.build_context(context=context, **context_kwargs)

    count = history_count if is_enable_history else 0
    return await set_password_reuse_history(
        auth=auth,
        history_count=count,
        return_raw=return_raw,
        context=context,
    )