Schedules

A Schedule is a named, reusable weekday-and-time schedule shared by scheduled resources across a Site.

List Schedules

SDK Method

Schedule.list()

Return Object

Schedule[]

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Additional Arguments

Example Request

import Schedule from 'files.com/lib/models/Schedule';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const schedules = await Schedule.list();
  for (const schedule of schedules) {
    // Operate on schedule
  }
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Show Schedule

SDK Method

Schedule.find()

Return Object

Schedule

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
id
int64
Required
Schedule ID.

Example Request

import Schedule from 'files.com/lib/models/Schedule';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const schedule = await Schedule.find(id);
  // Operate on schedule
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Create Schedule

SDK Method

Schedule.create()

Return Object

Schedule

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
name
string
Required
Schedule name.
schedule_days_of_week
array(int64)
Required
0-based weekdays used by the Schedule. 0 is Sunday.
schedule_times_of_day
array(string)
Required
Times of day in HH:MM format (24-hour).
schedule_time_zone
string
Time zone for scheduled times. If not set, times are interpreted as UTC.
holiday_region
string
Optional holiday region on which linked resources do not run.

Example Request

import Schedule from 'files.com/lib/models/Schedule';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const schedule = await Schedule.create({
    name: "Weekday overnight",
    schedule_days_of_week: [1,2,3,4,5],
    schedule_times_of_day: ["01:00"],
  });
  // Operate on schedule
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Update Schedule

SDK Method

schedule.update()

Return Object

Schedule

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
name
string
Schedule name.
schedule_days_of_week
array(int64)
0-based weekdays used by the Schedule. 0 is Sunday.
schedule_times_of_day
array(string)
Times of day in HH:MM format (24-hour).
schedule_time_zone
string
Time zone for scheduled times. If not set, times are interpreted as UTC.
holiday_region
string
Optional holiday region on which linked resources do not run.

Example Request

import Schedule from 'files.com/lib/models/Schedule';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  // Find the schedule object by its id.
  const schedule = await Schedule.find(id);
  await schedule.update({
    name: "Weekday overnight",
  });
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Delete Schedule

SDK Method

schedule.delete()

Return Object

No return value.

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Example Request

import Schedule from 'files.com/lib/models/Schedule';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  // Find the schedule object by its id.
  const schedule = await Schedule.find(id);
  await schedule.delete();
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

The Schedule Object

Some of the methods above return a Schedule object. The attributes of this object are listed below.

AttributeDescription
id
int64
Schedule ID.
name
string
Schedule name.
schedule_days_of_week
array(int64)
0-based weekdays used by the Schedule. 0 is Sunday.
schedule_times_of_day
array(string)
Times of day in HH:MM format (24-hour).
schedule_time_zone
string
Time zone for scheduled times. If not set, times are interpreted as UTC.
holiday_region
string
Optional holiday region on which linked resources do not run.
human_readable_schedule
string
Human-readable Schedule description.
created_at
date-time
Creation time.
updated_at
date-time
Last update time.