Skip to content

allowlist

allowlist

DomoAllowlist dataclass

DomoAllowlist(
    auth: DomoAuth,
    allowlist: list[str] = list(),
    is_filter_all_traffic_enabled: bool | None = None,
    raw: dict = dict(),
)

A class for managing the Domo instance IP allowlist configuration.

This class provides methods to get, set, add, and remove IP addresses/CIDR ranges from the instance allowlist, as well as manage the filter all traffic setting.

Note: Unlike most Domo entities, the allowlist is a singleton configuration per instance and does not have an 'id' field.

display_url property

display_url: str

Return the URL to the allowlist configuration page in Domo.

add_ips async

add_ips(
    ip_address_ls: str,
    is_suppress_errors: bool = False,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> list[str]

adds an IP or CIDR to the allowlist

Source code in src/crew_dcs/classes/DomoInstanceConfig/allowlist.py
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
async def add_ips(
    self,
    ip_address_ls: str,
    is_suppress_errors: bool = False,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[str]:
    """
    adds an IP or CIDR to the allowlist
    """
    base_context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        parent_class=self.__class__.__name__,
        **context_kwargs,
    )
    context = RouteContext.build_context(context=context or base_context)

    new_allowlist = await self.get(context=context)

    for ip in ip_address_ls:
        if ip in new_allowlist:
            continue

        new_allowlist.append(ip)

    return await self.set(
        ip_address_ls=new_allowlist,
        context=context,
        is_suppress_errors=is_suppress_errors,
    )

from_dict classmethod

from_dict(
    auth: DomoAuth, obj: dict[str, Any]
) -> DomoAllowlist

Create a DomoAllowlist instance from a dictionary representation.

Parameters:

Name Type Description Default
auth DomoAuth

Authentication object for API requests

required
obj dict[str, Any]

Dictionary containing allowlist data

required

Returns:

Type Description
DomoAllowlist

DomoAllowlist instance

Source code in src/crew_dcs/classes/DomoInstanceConfig/allowlist.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@classmethod
def from_dict(cls, auth: DomoAuth, obj: dict[str, Any]) -> "DomoAllowlist":
    """Create a DomoAllowlist instance from a dictionary representation.

    Args:
        auth: Authentication object for API requests
        obj: Dictionary containing allowlist data

    Returns:
        DomoAllowlist instance
    """
    return cls(
        auth=auth,
        allowlist=obj.get("allowlist") or obj.get("addresses", []),
        is_filter_all_traffic_enabled=obj.get("is_filter_all_traffic_enabled"),
        raw=obj,
    )

get async

get(
    return_raw: bool = False,
    debug_api: bool = False,
    debug_num_stacks_to_drop=2,
    session: AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> list[str]

retrieves the allowlist for an instance

Source code in src/crew_dcs/classes/DomoInstanceConfig/allowlist.py
 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
 99
100
101
102
103
104
105
106
async def get(
    self,
    return_raw: bool = False,
    debug_api: bool = False,
    debug_num_stacks_to_drop=2,
    session: httpx.AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[str]:
    """
    retrieves the allowlist for an instance
    """
    base_context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        parent_class=self.__class__.__name__,
        **context_kwargs,
    )
    context = RouteContext.build_context(context=context or base_context)

    res = await allowlist_routes.get_allowlist(
        auth=self.auth,
        return_raw=return_raw,
        context=context,
    )

    if return_raw:
        return res

    self.allowlist = [str(s) for s in res.response]

    return self.allowlist

get_is_filter_all_traffic_enabled async

get_is_filter_all_traffic_enabled(
    debug_api: bool = False,
    return_raw: bool = False,
    session: AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> bool

retrieves whether the "filter all traffic" setting is enabled

Source code in src/crew_dcs/classes/DomoInstanceConfig/allowlist.py
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
257
async def get_is_filter_all_traffic_enabled(
    self,
    debug_api: bool = False,
    return_raw: bool = False,
    session: httpx.AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> bool:
    """
    retrieves whether the "filter all traffic" setting is enabled
    """
    base_context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        parent_class=self.__class__.__name__,
        **context_kwargs,
    )
    context = RouteContext.build_context(context=context or base_context)

    res = await allowlist_routes.get_allowlist_is_filter_all_traffic_enabled(
        auth=self.auth,
        return_raw=return_raw,
        context=context,
    )

    if return_raw:
        return res

    self.is_filter_all_traffic_enabled = bool(res.response["is_enabled"])

    return self.is_filter_all_traffic_enabled

remove_ips async

remove_ips(
    ip_address_ls: str,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    is_suppress_errors: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> list[str]

removes an IP or CIDR to the allowlist

Source code in src/crew_dcs/classes/DomoInstanceConfig/allowlist.py
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
222
223
224
async def remove_ips(
    self,
    ip_address_ls: str,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    is_suppress_errors: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[str]:
    """
    removes an IP or CIDR to the allowlist
    """
    base_context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        parent_class=self.__class__.__name__,
        **context_kwargs,
    )
    context = RouteContext.build_context(context=context or base_context)

    allowlist = await self.get(context=context)

    for ip in ip_address_ls:
        if ip not in allowlist:
            continue

        allowlist.remove(ip)

    return await self.set(
        ip_address_ls=allowlist,
        context=context,
        is_suppress_errors=is_suppress_errors,
    )

toggle_is_filter_all_traffic_enabled async

toggle_is_filter_all_traffic_enabled(
    is_enabled: bool,
    debug_api: bool = False,
    return_raw: bool = False,
    session: AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs
) -> bool

retrieves whether the "filter all traffic" setting is enabled

Source code in src/crew_dcs/classes/DomoInstanceConfig/allowlist.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
async def toggle_is_filter_all_traffic_enabled(
    self,
    is_enabled: bool,
    debug_api: bool = False,
    return_raw: bool = False,
    session: httpx.AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> bool:
    """
    retrieves whether the "filter all traffic" setting is enabled
    """
    base_context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        parent_class=self.__class__.__name__,
        **context_kwargs,
    )
    context = RouteContext.build_context(context=context or base_context)

    await self.get_is_filter_all_traffic_enabled(context=context)

    if self.is_filter_all_traffic_enabled == is_enabled:
        await logger.debug("no action required")

        return bool(self.is_filter_all_traffic_enabled)

    res = await allowlist_routes.toggle_allowlist_is_filter_all_traffic_enabled(
        auth=self.auth,
        is_enabled=is_enabled,
        return_raw=return_raw,
        context=context,
    )

    if return_raw:
        return res

    self.is_filter_all_traffic_enabled = res.response["is_enabled"]

    return bool(self.is_filter_all_traffic_enabled)

    return bool(self.is_filter_all_traffic_enabled)