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
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
168
169
170
171
172
173
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).

Source code in src/crew_dcs/classes/DomoDatacenter.py
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
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