Skip to main content

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, paused or disabled.
  • scope_type (str | None, optional): platform, user or resource_group (the type in the schedule's scope).
  • enabled (bool | None, optional): Only enabled (True) or only disabled (False) schedules.
  • limit (int | None, optional): The most schedules to return; None returns 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 need organization_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"}. timezone is an IANA name and days_of_week runs 1 (Monday) to 7 (Sunday); both are required. Times are HH:MM in 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 is True.

Returns

  • Schedule: The created schedule, with its next stop and start times.

Raises

  • ValidationError: name, scope or schedule is 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 in create).
  • schedule (Mapping[str, Any] | None, optional): New timing, replacing the whole timing (shape as in create).
  • 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: action is neither stop nor start.
  • NotFoundError: No schedule has this id.
  • PermissionDeniedError: The key's user is not a platform administrator.

Other​

history​

history(schedule_id: str, *, limit: int | None = None) -> list[ScheduleExecutionLog]

Return a schedule's stop and start runs, most recent first.

Parameters

  • schedule_id (str): The schedule's id.
  • limit (int | None, optional): The most runs to return; None returns every recorded run.

Returns

  • list[ScheduleExecutionLog]: The runs.

Raises

  • NotFoundError: No schedule has this id.
  • PermissionDeniedError: The key's user is not a platform administrator.