FinOps Schedules
FinOps resource schedules: stop resources off-hours and start them again.
Access it as client.finops.schedules on a Strongly client, or the same path on AsyncStrongly with await. All methods exist on both with identical signatures.
Quick start
from strongly import Strongly
client = Strongly()
# List (auto-paginates as you iterate) # filters: search, status, scope_type, enabled
for finop in client.finops.schedules.list():
print(finop.id)
Methods
Core
list
list(*, search: str | None = None, status: str | None = None, scope_type: str | None = None, enabled: bool | None = None, limit: int | None = None) -> SyncPaginator[Schedule]
List the schedules, newest first.
Parameters
search(str | None, optional): Case-insensitive match on the schedule name.status(str | None, optional):active,pausedordisabled.scope_type(str | None, optional):platform,userorresource_group(the type in the schedule'sscope).enabled(bool | None, optional): Only enabled (True) or only disabled (False) schedules.limit(int | None, optional): The most schedules to return;Nonereturns every match.
Returns
SyncPaginator[Schedule]: The matching schedules, fetched a page at a time.
Raises
PermissionDeniedError: The key's user is not a platform administrator.
create
create(*, name: str, scope: Mapping[str, Any], schedule: Mapping[str, Any], description: str | None = None, organization_id: str | None = None, enabled: bool | None = None) -> Schedule
Create a schedule and return it.
Parameters
name(str): Schedule name (1-100 characters).scope(Mapping[str, Any]): Which resources it controls, with snake_case keys:{"type": "platform"}(every schedulable resource),{"type": "user", "user_id": ...}(the resources a user owns) or{"type": "resource_group", "resource_group_id": ...}(the members of a resource group). The organization-scoped types (resource,resource_type,tag,all) also needorganization_id.schedule(Mapping[str, Any]): When it acts:{"timezone": "America/New_York", "days_of_week": [1, 2, 3, 4, 5], "stop_time": "19:00", "start_time": "07:00"}.timezoneis an IANA name anddays_of_weekruns 1 (Monday) to 7 (Sunday); both are required. Times areHH:MMin that time zone; give at least one of them.description(str | None, optional): What the schedule is for (at most 500 characters).organization_id(str | None, optional): The organization an organization-scoped schedule acts in.enabled(bool | None, optional): Whether it runs; the API's default isTrue.
Returns
Schedule: The created schedule, with its next stop and start times.
Raises
ValidationError:name,scopeorscheduleis missing or malformed (an unknown time zone or scope type, a scope without the id its type needs).PermissionDeniedError: The key's user is not a platform administrator.
retrieve
retrieve(schedule_id: str) -> Schedule
Return a schedule, with its overrides and execution history.
Parameters
schedule_id(str): The schedule's id.
Returns
Schedule: The schedule.
Raises
NotFoundError: No schedule has this id.PermissionDeniedError: The key's user is not a platform administrator.
update
update(schedule_id: str, *, name: str | None = None, description: str | None = None, scope: Mapping[str, Any] | None = None, schedule: Mapping[str, Any] | None = None, enabled: bool | None = None) -> Schedule
Change a schedule and return it; only the fields given change.
Parameters
schedule_id(str): The schedule's id.name(str | None, optional): New name.description(str | None, optional): New description.scope(Mapping[str, Any] | None, optional): New scope, replacing the whole scope (shape as increate).schedule(Mapping[str, Any] | None, optional): New timing, replacing the whole timing (shape as increate).enabled(bool | None, optional): Whether it runs.
Returns
Schedule: The updated schedule.
Raises
ValidationError: A field is malformed.NotFoundError: No schedule has this id.PermissionDeniedError: The key's user is not a platform administrator.
delete
delete(schedule_id: str) -> None
Delete a schedule.
Parameters
schedule_id(str): The schedule's id.
Raises
NotFoundError: No schedule has this id.PermissionDeniedError: The key's user is not a platform administrator.
Lifecycle & actions
pause
pause(schedule_id: str) -> None
Pause a schedule: it stops and starts nothing until it is resumed.
Parameters
schedule_id(str): The schedule's id.
Raises
NotFoundError: No schedule has this id.PermissionDeniedError: The key's user is not a platform administrator.
resume
resume(schedule_id: str) -> None
Resume a paused schedule.
Parameters
schedule_id(str): The schedule's id.
Raises
NotFoundError: No schedule has this id.PermissionDeniedError: The key's user is not a platform administrator.
execute
execute(schedule_id: str, *, action: Literal['stop', 'start']) -> ScheduleExecutionLog
Run a schedule's stop or start now, whatever its timing.
The run is recorded in the schedule's history (see history).
Parameters
schedule_id(str): The schedule's id.action({"stop", "start"}): Stop or start the resources in the schedule's scope.
Returns
ScheduleExecutionLog: The run, as the schedule's history records it: what it did to each resource.
Raises
ValidationError:actionis neitherstopnorstart.NotFoundError: No schedule has this id.PermissionDeniedError: The key's user is not a platform administrator.
Other
create_override
create_override(schedule_id: str, *, resource_type: Literal['app', 'addon', 'workspace', 'self-hosted-model'], resource_id: str, skip_until: datetime, reason: str | None = None) -> ScheduleOverride
Keep one resource the schedule controls out of its stops until a time.
The schedule's starts still apply to it. The resource must be one
list_resources lists, and it may have one override per schedule
(change it with update_override).
Parameters
schedule_id(str): The schedule's id.resource_type({"app", "addon", "workspace", "self-hosted-model"}): The resource's type.resource_id(str): The resource's id.skip_until(datetime): When the override ends; give a timezone-aware time.reason(str | None, optional): Why the resource is kept running.
Returns
ScheduleOverride: The override.
Raises
ValidationError: The schedule does not control this resource, or a field is invalid.ConflictError: The resource already has an override on this schedule.NotFoundError: No schedule has this id.PermissionDeniedError: The key's user is not a platform administrator.
delete_override
delete_override(schedule_id: str, override_id: str) -> None
Delete an override, so the schedule's stops apply to its resource again.
Parameters
schedule_id(str): The schedule's id.override_id(str): The override's id,"<resource_type>:<resource_id>".
Raises
NotFoundError: The schedule or the override does not exist.PermissionDeniedError: The key's user is not a platform administrator.
history
history(schedule_id: str, *, limit: int | None = None) -> SyncPaginator[ScheduleExecutionLog]
List a schedule's stop and start runs, most recent first, a page at a time.
Parameters
schedule_id(str): The schedule's id.limit(int | None, optional): The most runs to return; every recorded run when omitted.
Returns
SyncPaginator[ScheduleExecutionLog]: The runs, read as you iterate.
Raises
NotFoundError: No schedule has this id.PermissionDeniedError: The key's user is not a platform administrator.
list_overrides
list_overrides(schedule_id: str, *, limit: int | None = None) -> SyncPaginator[ScheduleOverride]
List a schedule's overrides, the latest skip_until first.
Parameters
schedule_id(str): The schedule's id.limit(int | None, optional): The most overrides to return; every one when omitted.
Returns
SyncPaginator[ScheduleOverride]: The overrides, read as you iterate.
Raises
NotFoundError: No schedule has this id.PermissionDeniedError: The key's user is not a platform administrator.
list_resources
list_resources(schedule_id: str, *, limit: int | None = None) -> SyncPaginator[ScheduleResource]
List the resources a schedule controls now, a page at a time.
Each resource's skipped_until is set while an override keeps it out of
the schedule's stops.
Parameters
schedule_id(str): The schedule's id.limit(int | None, optional): The most resources to return; every one when omitted.
Returns
SyncPaginator[ScheduleResource]: The resources, read as you iterate.
Raises
NotFoundError: No schedule has this id.PermissionDeniedError: The key's user is not a platform administrator.
update_override
update_override(schedule_id: str, override_id: str, *, skip_until: datetime | None = None, reason: str | None = None) -> ScheduleOverride
Change an override's end time and/or reason; only the fields given change.
Parameters
schedule_id(str): The schedule's id.override_id(str): The override's id,"<resource_type>:<resource_id>".skip_until(datetime | None, optional): The new end time; give a timezone-aware time.reason(str | None, optional): The new reason.
Returns
ScheduleOverride: The override as it is now.
Raises
ValidationError: Neither field was given, or one is invalid.NotFoundError: The schedule or the override does not exist.PermissionDeniedError: The key's user is not a platform administrator.