Class: Infrawrench::SchedulesNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs

Overview

client.schedules

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ SchedulesNamespace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SchedulesNamespace.

Parameters:



5141
5142
5143
# File 'lib/infrawrench/client.rb', line 5141

def initialize(transport)
  @transport = transport
end

Instance Method Details

#create(org_id: nil, body: nil, request_options: nil) ⇒ Hash

Create a sleep/wake schedule

Attach an off-at/on-at weekly window to a resource. The resource's type must declare lifecycle start/stop actions (see the resource type metadata); one schedule per resource. Times are wall-clock in the given IANA timezone and remain correct across DST. Audit-logged.

Requires permission: resources:write.

POST /api/org/orgId/schedules

Raises on 400: Bad request

Raises on 404: Not found

Raises on 409: The resource already has a schedule

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • body (Hash, nil) (defaults to: nil)

    Request body, shaped as SleepScheduleCreate.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • body: (sleep_schedule_create, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as SleepSchedule — see sig/infrawrench/sdk.rbs.

Raises:



5168
5169
5170
5171
5172
5173
5174
5175
5176
# File 'lib/infrawrench/client.rb', line 5168

def create(org_id: nil, body: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/org/{orgId}/schedules",
    path_params: { "orgId" => org_id },
    body: body,
    request_options: request_options
  )
end

#delete(schedule_id:, org_id: nil, request_options: nil) ⇒ nil

Delete a schedule

Remove the schedule. The resource is left in whatever state it is in. Audit-logged.

Requires permission: resources:write.

DELETE /api/org/orgId/schedules/scheduleId

Raises on 404: Not found

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • schedule_id (String)
  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • schedule_id: (String)
  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (nil)

    This endpoint returns no content.

Raises:



5195
5196
5197
5198
5199
5200
5201
5202
5203
# File 'lib/infrawrench/client.rb', line 5195

def delete(schedule_id:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "DELETE",
    path: "/api/org/{orgId}/schedules/{scheduleId}",
    path_params: { "orgId" => org_id, "scheduleId" => schedule_id },
    accept: :empty,
    request_options: request_options
  )
end

#get(org_id: nil, request_options: nil) ⇒ Hash

List sleep/wake schedules

Every schedule in the organization with its next transition, last run outcome and a projected monthly saving computed from trailing per-resource spend and the weekly off-hours fraction. Schedules attach to resources whose plugin declares lifecycle start/stop actions; the poller executes due transitions server-side.

Requires permission: resources:read.

GET /api/org/orgId/schedules

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as SleepScheduleList — see sig/infrawrench/sdk.rbs.

Raises:



5222
5223
5224
5225
5226
5227
5228
5229
# File 'lib/infrawrench/client.rb', line 5222

def get(org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/schedules",
    path_params: { "orgId" => org_id },
    request_options: request_options
  )
end

#preview(org_id: nil, body: nil, request_options: nil) ⇒ Hash

Preview a schedule's projected saving

Quote a timing against a resource before saving: the weekly off-hours fraction, the resource's trailing spend normalized to a month, the projected monthly saving, and the next few transitions. Makes no provider API calls and changes nothing.

Requires permission: resources:read.

POST /api/org/orgId/schedules/preview

Raises on 400: Bad request

Raises on 404: Not found

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • body (Hash, nil) (defaults to: nil)

    Request body, shaped as SleepSchedulePreviewRequest.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • body: (sleep_schedule_preview_request, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as SleepSchedulePreview — see sig/infrawrench/sdk.rbs.

Raises:



5253
5254
5255
5256
5257
5258
5259
5260
5261
# File 'lib/infrawrench/client.rb', line 5253

def preview(org_id: nil, body: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/org/{orgId}/schedules/preview",
    path_params: { "orgId" => org_id },
    body: body,
    request_options: request_options
  )
end

#update(schedule_id:, org_id: nil, body: nil, request_options: nil) ⇒ Hash

Update or pause a schedule

Edit the timing and/or toggle paused. Any change recomputes the next transition; pausing clears it. Audit-logged.

Requires permission: resources:write.

PUT /api/org/orgId/schedules/scheduleId

Raises on 400: Bad request

Raises on 404: Not found

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • schedule_id (String)
  • body (Hash, nil) (defaults to: nil)

    Request body, shaped as SleepScheduleUpdate.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • schedule_id: (String)
  • org_id: (String, nil) (defaults to: nil)
  • body: (sleep_schedule_update, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as SleepSchedule — see sig/infrawrench/sdk.rbs.

Raises:



5283
5284
5285
5286
5287
5288
5289
5290
5291
# File 'lib/infrawrench/client.rb', line 5283

def update(schedule_id:, org_id: nil, body: nil, request_options: nil)
  @transport.request(
    http_method: "PUT",
    path: "/api/org/{orgId}/schedules/{scheduleId}",
    path_params: { "orgId" => org_id, "scheduleId" => schedule_id },
    body: body,
    request_options: request_options
  )
end