Skip to content

DomoDatacenter

DomoDatacenter

DomoDatacenter dataclass

DomoDatacenter(auth: DomoAuth)

Bases: DomoBase

class for quering entities in the datacenter

get_accounts async

get_accounts(
    maximum: int | None = None,
    search_text: str | None = None,
    additional_filters_ls: list | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[Any]

search Domo Datacenter account api. Note: at the time of this writing 7/18/2023, the datacenter api does not support searching accounts by name

Source code in src/crew_dcs/classes/DomoDatacenter.py
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
168
169
170
171
172
173
174
175
176
async def get_accounts(
    self,
    maximum: int | None = None,  # maximum number of results to return
    # can accept one value or a list of values
    search_text: (
        str | None
    ) = None,  # will search for "search_text" in account.name (do not pass wildcards
    additional_filters_ls: list | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[Any]:
    """search Domo Datacenter account api.
    Note: at the time of this writing 7/18/2023, the datacenter api does not support searching accounts by name
    """

    from . import DomoAccount as dmac

    context = RouteContext.build_context(
        context=context,
        **context_kwargs,
    )

    additional_filters_ls = additional_filters_ls or []

    if search_text:
        # if search_text is provided, we will add a filter to the additional_filters_ls
        # this will not work with the datacenter api, but it is here for consistency with other search functions
        additional_filters_ls.append(
            generate_search_datacenter_filter(
                "displayName",
                search_text,
            )
        )

    json_list = await self.search_datacenter(
        maximum=maximum,
        entity_type=datacenter_routes.Datacenter_Enum.ACCOUNT.value,
        additional_filters_ls=additional_filters_ls,
        return_raw=return_raw,
        context=context,
    )

    if return_raw or len(json_list) == 0:
        return json_list

    if search_text:
        json_list = [
            obj
            for obj in json_list
            if search_text.lower() in obj.get("displayName", "").lower()
        ]

    domo_account_ls = [
        dmac.DomoAccount.from_dict(obj, auth=self.auth) for obj in json_list
    ]

    return domo_account_ls  # noqa: RET504

get_cards_admin_summary async

get_cards_admin_summary(
    auth: type[DomoAuth] = DomoAuth,
    page_ids: list[str] | None = None,
    card_search_text: str | None = None,
    page_search_text: str | None = None,
    maximum: int | None = None,
    return_raw: bool = False,
    debug_api: bool = False,
    debug_loop: bool = False,
    session: AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[Any]

search Domo Datacenter card api.

Note

page_search_text is filtered client-side, not by Domo's API -- see card_routes.search_cards_admin_summary for why (crew-dcs#1488).

Calls route

Source code in src/crew_dcs/classes/DomoDatacenter.py
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
async def get_cards_admin_summary(
    self,
    auth: type[DomoAuth] = DomoAuth,
    page_ids: list[str] | None = None,
    card_search_text: str | None = None,
    page_search_text: str | None = None,
    maximum: int | None = None,  # maximum number of results to return
    # can accept one value or a list of values
    return_raw: bool = False,
    debug_api: bool = False,
    debug_loop: bool = False,
    session: httpx.AsyncClient | None = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
) -> list[Any]:
    """search Domo Datacenter card api.

    Note:
        `page_search_text` is filtered client-side, not by Domo's API -- see
        `card_routes.search_cards_admin_summary` for why (crew-dcs#1488).
    """

    from ..routes import card as card_routes
    from . import DomoCard as dmc

    context = RouteContext.build_context(
        session=session,
        debug_api=debug_api,
        **context_kwargs,
    )

    search_body = card_routes.generate_body_search_cards_admin_summary(
        page_ids=page_ids,
        card_search_text=card_search_text,
    )

    res = await card_routes.search_cards_admin_summary(
        auth=self.auth,
        body=search_body,
        maximum=maximum,
        page_search_text=page_search_text,
        debug_loop=debug_loop,
        wait_sleep=5,
        context=context,
    )

    if return_raw or len(res.response) == 0:
        return res

    domo_account_ls = await dmce.gather_with_concurrency(
        n=60,
        *[dmc.DomoCard.from_dict(obj, auth=self.auth) for obj in res.response],  # noqa: B026
    )

    return domo_account_ls  # noqa: RET504

search_datacenter async

search_datacenter(
    maximum: int | None = None,
    body: dict | None = None,
    search_text: str | None = None,
    entity_type: str | list = "dataset",
    additional_filters_ls: list | None = None,
    return_raw: bool = False,
    session: AsyncClient | None = None,
    debug_api: bool = False,
    *,
    context: RouteContext | None = None,
) -> list[Any]

Calls route

Source code in src/crew_dcs/classes/DomoDatacenter.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
async def search_datacenter(
    self,
    maximum: int | None = None,  # maximum number of results to return
    body: (
        dict | None
    ) = None,  # either pass a body or generate a body in the function using search_text, entity_type, and additional_filters parameters
    search_text: str | None = None,
    # can accept one value or a list of values
    entity_type: str | list = "dataset",
    additional_filters_ls: list | None = None,
    return_raw: bool = False,
    session: httpx.AsyncClient | None = None,
    debug_api: bool = False,
    *,
    context: RouteContext | None = None,
) -> list[Any]:
    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        parent_class=self.__class__.__name__,
    )

    res = await datacenter_routes.search_datacenter(
        auth=self.auth,
        maximum=maximum,
        body=body,
        search_text=search_text,
        entity_type=entity_type,
        additional_filters_ls=additional_filters_ls,
        return_raw=return_raw,
        context=context,
    )

    if return_raw:
        return res

    return res.response