Skip to content

access_token

access_token

DomoAccessToken dataclass

DomoAccessToken(
    auth: DomoAuth,
    id: str,
    raw: dict,
    name: str = "",
    owner: Any = None,
    expiration_date: datetime | None = None,
    token: str = "",
)

Bases: DomoEntity

generate async classmethod

generate(
    duration_in_days: int,
    token_name: str,
    auth: DomoAuth,
    owner,
    debug_api: bool = False,
    session: AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoInstanceConfig/access_token.py
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
@classmethod
async def generate(
    cls,
    duration_in_days: int,
    token_name: str,
    auth: DomoAuth,
    owner,  # DomoUser
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    res = await access_token_routes.generate_access_token(
        user_id=owner.id,
        token_name=token_name,
        duration_in_days=duration_in_days,
        auth=auth,
        context=context,
    )

    if return_raw:
        return res

    return cls.from_dict(obj=res.response, auth=auth, owner=owner)

get_by_id async classmethod

get_by_id(
    auth: DomoAuth,
    id: str,
    session: AsyncClient | None = None,
    debug_api: bool = False,
    debug_num_stacks_to_drop: int = 2,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoInstanceConfig/access_token.py
 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
107
108
109
110
@classmethod
async def get_by_id(
    cls,
    auth: DomoAuth,
    id: str,
    session: httpx.AsyncClient | None = None,
    debug_api: bool = False,
    debug_num_stacks_to_drop: int = 2,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    res = await access_token_routes.get_access_token_by_id(
        auth=auth,
        id=id,
        context=context,
    )

    if return_raw:
        return res

    obj = res.response

    owner = await cls._get_owner(owner_id=obj["ownerId"], auth=auth)

    return cls.from_dict(obj=obj, auth=auth, owner=owner)

get_entity_by_id async classmethod

get_entity_by_id(auth: DomoAuth, entity_id: str, **kwargs)

Fetch a access token by ID; delegates to get_by_id.

Source code in src/crew_dcs/classes/DomoInstanceConfig/access_token.py
71
72
73
74
@classmethod
async def get_entity_by_id(cls, auth: DomoAuth, entity_id: str, **kwargs):
    """Fetch a access token by ID; delegates to ``get_by_id``."""
    return await cls.get_by_id(auth=auth, id=entity_id, **kwargs)

revoke async

revoke(
    debug_api: bool = False,
    session: AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoInstanceConfig/access_token.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
async def revoke(
    self,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    debug_num_stacks_to_drop: int = 2,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    return await access_token_routes.revoke_access_token(
        auth=self.auth,
        access_token_id=self.id,
        context=context,
    )

DomoAccessTokens dataclass

DomoAccessTokens(
    auth: DomoAuth,
    domo_access_tokens: list[DomoAccessToken] = list(),
)

Bases: DomoManager

get async

get(
    return_raw: bool = False,
    debug_api: bool = False,
    debug_num_stacks_to_drop=2,
    session: AsyncClient = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoInstanceConfig/access_token.py
216
217
218
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
async def get(
    self,
    return_raw: bool = False,
    debug_api: bool = False,
    debug_num_stacks_to_drop=2,
    session: httpx.AsyncClient = None,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
):
    context = RouteContext.build_context(
        context=context,
        session=session,
        debug_api=debug_api,
        debug_num_stacks_to_drop=debug_num_stacks_to_drop,
        **context_kwargs,
    )

    res = await access_token_routes.get_access_tokens(
        auth=self.auth,
        context=context,
    )

    if return_raw:
        return res

    return await dmce.gather_with_concurrency(
        *[
            DomoAccessToken.get_by_id(
                id=obj["id"],
                auth=self.auth,
                context=context,
            )
            for obj in res.response
        ],
        n=10,
    )