Skip to content

scheduler_policies

scheduler_policies

DomoScheduler_Policies dataclass

DomoScheduler_Policies(
    auth: DomoAuth,
    policies: list[DomoScheduler_Policy] = list(),
)

Bases: DomoBase

Instance setting: the scheduler policies of a Domo instance, built from auth.

delete async

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

Calls route

Source code in src/crew_dcs/classes/DomoInstanceConfig/scheduler_policies.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
async def delete(
    self,
    policy_id: str,
    debug_api: bool = False,
    debug_num_stacks_to_drop: int = 2,
    session: httpx.AsyncClient | None = 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 instance_config_routes.delete_scheduler_policy(
        auth=self.auth,
        policy_id=policy_id,
        context=context,
    )
    return res.is_success

get async

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

Calls route

Source code in src/crew_dcs/classes/DomoInstanceConfig/scheduler_policies.py
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
async def get(
    self,
    debug_api: bool = False,
    session: httpx.AsyncClient | None = None,
    return_raw: bool = False,
    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,
    )

    res = await instance_config_routes.get_scheduler_policies(
        auth=self.auth,
        return_raw=return_raw,
        context=context,
    )
    self.policies = [DomoScheduler_Policy.from_dict(p) for p in res.response]
    await logger.debug(f"scheduler policies: {self.policies}")
    return self.policies

upsert async

upsert(
    policy: DomoScheduler_Policy,
    debug_api: bool = False,
    debug_num_stacks_to_drop: int = 2,
    session: AsyncClient | None = None,
    return_raw: bool = False,
    *,
    context: RouteContext | None = None,
    **context_kwargs,
)

Calls route

Source code in src/crew_dcs/classes/DomoInstanceConfig/scheduler_policies.py
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
177
178
179
180
181
182
183
184
185
186
187
188
189
async def upsert(
    self,
    policy: DomoScheduler_Policy,
    debug_api: bool = False,
    debug_num_stacks_to_drop: int = 2,
    session: httpx.AsyncClient | None = None,
    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,
    )

    create_policy = (not policy.id or not str(policy.id).strip()) or (
        policy.id not in {p.id for p in self.policies}
    )
    # If the policy is not yet created, create it
    if create_policy:
        await logger.info(f"Creating scheduler policy: {policy.name}")
        res = await instance_config_routes.create_scheduler_policy(
            auth=self.auth,
            create_body=policy.to_dict(),
            return_raw=return_raw,
            context=context,
        )
        policy = DomoScheduler_Policy.from_dict(res.response)
        self.policies.append(policy)
        return policy
    await logger.info(f"Updating scheduler policy: {policy.name}")
    idx = self.policies.index(policy)
    res = await instance_config_routes.update_scheduler_policy(
        auth=self.auth,
        policy_id=policy.id,
        update_body=policy.to_dict(),
        return_raw=return_raw,
        context=context,
    )
    policy = DomoScheduler_Policy.from_dict(res.response)
    self.policies[idx] = policy
    return policy