Skip to content

_request

_request

The one request helper shared by the publish routes (private to the package).

publish_request async

publish_request(
    auth: DomoAuth,
    path: str,
    *,
    method: str = "GET",
    body: Any = None,
    params: dict | None = None,
    timeout: int | None = None,
    return_raw: bool = False,
    context: RouteContext | None = None,
    error: type[RouteError] = GET_Publish_Error,
) -> ResponseGetData

Send one request to /api/publish/v2/{path} and raise on a failed response.

body, params and timeout reach get_data only when given, so each route sends the same request it sent before the helper existed.

Parameters:

Name Type Description Default
auth DomoAuth

Authenticated Domo session.

required
path str

Path below /api/publish/v2/, without a leading slash.

required
method str

HTTP verb.

'GET'
body Any

JSON body for writes.

None
params dict | None

Query parameters.

None
timeout int | None

Request timeout in seconds.

None
return_raw bool

Return the response even when it is not a success.

False
context RouteContext | None

Route context passed through to get_data.

None
error type[RouteError]

Error class raised on a failed response; called with the response.

GET_Publish_Error

Returns:

Type Description
ResponseGetData

The response from Domo.

Raises:

Type Description
RouteError

error (GET_Publish_Error by default) when the response is not a success and return_raw is False.

Source code in src/crew_dcs/routes/publish/_request.py
17
18
19
20
21
22
23
24
25
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
64
65
66
67
68
69
70
71
72
73
async def publish_request(
    auth: DomoAuth,
    path: str,
    *,
    method: str = "GET",
    body: Any = None,
    params: dict | None = None,
    timeout: int | None = None,
    return_raw: bool = False,
    context: RouteContext | None = None,
    error: type[RouteError] = GET_Publish_Error,
) -> rgd.ResponseGetData:
    """Send one request to ``/api/publish/v2/{path}`` and raise on a failed response.

    ``body``, ``params`` and ``timeout`` reach ``get_data`` only when given, so
    each route sends the same request it sent before the helper existed.

    Args:
        auth: Authenticated Domo session.
        path: Path below ``/api/publish/v2/``, without a leading slash.
        method: HTTP verb.
        body: JSON body for writes.
        params: Query parameters.
        timeout: Request timeout in seconds.
        return_raw: Return the response even when it is not a success.
        context: Route context passed through to ``get_data``.
        error: Error class raised on a failed response; called with the response.

    Returns:
        The response from Domo.

    Raises:
        RouteError: ``error`` (``GET_Publish_Error`` by default) when the response
            is not a success and ``return_raw`` is False.
    """
    request_kwargs: dict[str, Any] = {
        "auth": auth,
        "method": method,
        "url": f"https://{auth.domo_instance}.domo.com/api/publish/v2/{path}",
        "context": context,
    }
    if body is not None:
        request_kwargs["body"] = body
    if params is not None:
        request_kwargs["params"] = params
    if timeout is not None:
        request_kwargs["timeout"] = timeout

    res = await gd.get_data(**request_kwargs)

    if return_raw:
        return res

    if not res.is_success:
        raise error(res)

    return res