Reservation Methods

class netlab.api.ReservationApiMixin
reservation_cancel(*, res_id, **kwargs)

Cancel a reservation in NETLAB+ prior to reservation being started.

NOTE - if you wish to end a reservation that is already started use reservation_post.

Parameters

res_id (int) – Reservation unique identifier.

Returns

The change succeeded.

Return type

‘OK’

reservation_extend(*, res_id, **kwargs)

Request a 30 minute lab reservation extension.

Parameters

res_id (int) – Reservation identifier.

Returns

Returns an object with the following properties:

Return type

dict

Properties

status

Status code.

reason

Textual message that is suitable for display (English).

Status Codes

OK

The reservation was extended.

CLASS_LIMIT_EXCEEDED

Reservation cannot be extended because of cls_ext_slots_per_res setting limit.

COMMUNITY_LIMIT_EXCEEDED

Reservation cannot be extended because of com_ext_slots_per_res setting limit.

TIME_SLOT_UNAVAILABLE

The next time slot is occupied by another reservation.

POD_ACTIVE_MAX

Maximum number of pods in use.

RESERVATION_ALREADY_COMPLETED

The reservation has already completed and cannot be extended.

E_ACCESS_DENIED

Student/learner cannot extend ILT reservation.

STATE_NOT_ACTIVE_LAB

Reservation is not in the active lab state.

TOO_EARLY

Cannot extend before T-00:15:59 minutes/seconds.

TOO_LATE

Cannot extend after T-00:00:10 seconds.

Restrictions For All Users

  • An extension cannot be made before T-00:15:59 from the reservation post time. This is about 26 minutes from the blocked end time and 16 minutes of the usable time remaining.

  • The next 30 minute time slot must not be already scheduled by another reservation.

  • The extension cannot exceed maximum pods in use limit and/or proactive resource awareness settings.

Restrictions for Students and Teams

  • The number of extensions that a student or team can request are limited by community and class settings.

  • For backward setting compatibility, communities and classes do not allow extensions to be made by students or teams by default.

    • The administrator must specifically allow extensions for students and teams per community via the com_ext_slots_per_res setting.

    • The instructor must specifically allow extensions for students and teams per class via the cls_ext_slots_per_res setting.

    • The number of extensions that a student or team can request in a single reservation will be the more restrictive of the two settings.

  • A student (or instructor learner) may not extend an ILT reservation. Only a lead instructor can do that.

reservation_get(*, res_id, **kwargs)

Get parameters of a reservation.

Parameters

res_id (int) – Reservation identifier.

Returns

On success, returns an object with the following properties:

Return type

dict

Properties

acc_com_id

Community identifier.

acc_full_name

Account display name.

acc_id

Account identifier.

cls_div_id

Community identifier.

cls_id

Class identifier.

cls_name

Class name.

ex_id

Lab exercise identifier.

ex_name

Lab exercise name.

pod_desc

Pod description.

pod_id

Unique pod identifier.

pod_name

Pod name.

pt_desc

Pod type description.

pt_id

Pod type identifier.

pt_name

Account email.

res_acc_id

Account ID.

res_active_time

Active reservation timestamp.

res_asm_data

???

res_attend_time

Time reservation was attended.

res_cls_id

Class identifier.

res_com_id

Community identifier.

res_config

Initial configuration.

res_done

Reservation is done.

res_end

Timestamp scheduled end of reservation.

res_ex_id

Reservation lab exercise identifier.

res_flags

???

res_id

Reservation identifier.

res_init_fail

Count of failures during initialization.

res_is_active

Reservation is active.

res_minutes

Count of minutes for reservation.

res_pod_id

Reservation pod identifier.

res_post_time

Timestamp of actual end of reservation.

res_preload_time

Timestamp UTC lab will preload.

res_pt_id

Reservation pod type identifier.

res_remaining_dhms

Days, hours, min, sec remaining if pod is in ACTIVE_LOAD or ACTIVE_INIT state.

res_remaining_sec

Seconds remaining if pod is in ACTIVE_LOAD or ACTIVE_LAB state.

res_start

Timestamp to start reservation.

res_team

Reservation team setting.

res_type

Reservation type. netlab.enums.ReservationType

res_uuid

Reservation unique identifier.

sched_image

Location of the scheduler image.

reservation_make(*, type, pod_id, cls_id=None, end_time, start_time=None, acc_id=None, reserver_id=None, tz_id=None, tz_olson=None, pt_id=None, ex_id, init_config=<InitConfig.NONE: 'N'>, **kwargs)
Parameters
  • type (ReservationType) – Type of reservation.

  • pod_id (int) – Pod identifier.

  • cls_id (int) – Class identifier. Not required where type is ‘INSTRUCTOR’.

  • end_time (datetime.datetime) – Local time end of reservation. This must be on a half hour slot boundary.

  • start_time (datetime.datetime) – Local time start of reservation. If not specified it will use the current datetime.

  • tz_id (int) – Timezone identifier.

  • tz_olson (str) – IANA timezone name. If not specified, the timezone of the user identified by acc_id will be used.

  • pt_id (int) – Pod type identifier.

  • ex_id (int) – Exercise identifier (required).

  • acc_id (int) – Account identifier for the reservation. Defaults to reserver_id.

  • init_config (InitConfig) – Initial configuration.

  • reserver_id (int) – Reserver identifier. Defaults to the request user. An admin can use a reserver_id to make reservations for others.

Returns

On success, returns an object with the following properties:

Return type

dict

Properties

res_id

Reservation identifier.

res_start_utc

Reservation start in UTC.

res_end_utc

Reservation end in UTC.

res_minutes

Reservation time in minutes

reservation_post(*, res_id, **kwargs)

Ends a reservation that has already started.

Parameters

res_id (int) – Reservation identifier.

Returns

The change succeeded.

Return type

‘OK’

reservation_query(*, scope=<ReservationScope.ALL: 'ALL'>, min_time=None, max_time=None, com_id=None, cls_id=None, pod_id=None, active=None, **kwargs)

Return a list of reservations filtered on criteria.

Parameters
Returns

On success, returns an object with the following properties:

Return type

list[dict]

Properties

acc_com_id

Community identifier.

acc_full_name

Account display name.

acc_id

Account identifier.

cls_div_id

Community identifier.

cls_id

Class identifier.

cls_name

Class name.

ex_id

Lab exercise identifier.

ex_name

Lab exercise name.

pod_desc

Pod description.

pod_id

Unique pod identifier.

pod_name

Pod name.

pt_desc

Pod type description.

pt_id

Pod type identifier.

pt_name

Account email.

res_acc_id

Account identifier.

res_active_time

Active reservation timestamp.

res_attend_time

Time reservation was attended.

res_cls_id

Class identifier.

res_com_id

Community identifier.

res_config

Initial configuration.

res_done

Reservation is done.

res_end

Timestamp scheduled end of reservation.

res_ex_id

Reservation lab exercise identifier.

res_flags

Reservation hex code for pod state.

res_id

Reservation identifier.

res_init_fail

Count of failures during initialization.

res_is_active

Reservation is active.

res_minutes

Count of minutes for reservation.

res_pod_id

Reservation pod identifier.

res_post_time

Timestamp of actual end of reservation.

res_pt_id

Reservation pod type identifier.

res_start

Timestamp to start reservation.

res_team

Reservation team setting.

res_type

Type of reservation. netlab.enums.ReservationType

res_uuid

Reservation unique identifier.

sched_image

Location of the scheduler image.

reservation_summary(**kwargs)

This method allows you to retrieve a summary of all reservations.

Returns

On success, returns an object with the following properties:

Return type

dict

Properties

active_reservations

Count of active reservations.

completed_reservations

Count of completed reservations.

future_reservations

Count of future reservations.

pods_in_use

Count of pods in use.

total_reservations

Count of total reservations.

reservation_time_delta(*, end, start=None, tz_id=None, tz_olson=None, **kwargs)

This method returns time between two timestamps with optional timezone offset.

Parameters
  • end (datetime.datetime) – End time. This must be on a half hour increment.

  • start (datetime.datetime) – Start time. Defaults to now if not specified.

  • tz_id (int) – Timezone identifier.

  • tz_olson (str) – Timezone olson.

Returns

On success, returns an object with the following properties:

Return type

dict

Properties

days

Number of days to increase/decrease.

hours

Number of hours to increase/decrease.

minutes

Number of minutes to increase/decrease.

months

Number of months to increase/decrease.

reservation_time_now(*, tz_id=None, tz_olson=None, **kwargs)

This method returns the current NETLAB time.

Parameters
  • tz_id (int) – Timezone identifier.

  • tz_olson (str) –

Returns

On success, returns an object with the following properties:

Return type

dict

Properties

local

Local date time.

local_am_pm

AM/PM indicator.

local_day

Local day of the month.

local_day_of_week

Local day of the week.

local_hmap

Local time and am/pm.

local_hms

Local time.

local_hour_12

Local 12 Hour time.

local_hour_24

Local 24 Hour time.

local_minute

Local minute time.

local_second

Local second time.

local_year

Local year.

local_ymd

Local YYYY-MM-DD.

tz_id

Timezone identifier.

tz_is_dst

Timezone is in Daylight Savings Time.

tz_name

Name of the timezone.

tz_olson

Timezone olson.

utc

Coordinated Universal Time.

reservation_time_offset(*, time=None, op=None, tz_id_in=None, tz_olson_in=None, tz_id_out=None, tz_olson_out=None, slot_roundup=False, years=None, months=None, weeks=None, days=None, hours=None, minutes=None, seconds=None, **kwargs)

This method returns the current time with a timezone offset.

Parameters
  • time (datetime) – Time input.

  • op (str) – Operator. “+” rounds up. “-” rounds down.

  • tz_id_in (int) – Timezone identifier input.

  • tz_olson_in (str) – Timezone olson input.

  • tz_id_out (int) – Timezone identifier output.

  • tz_olson_out (str) – Timezone olson output.

  • slot_roundup (bool) – Round up to nearest slot. i.e. 30 min interval. Defaults to False.

  • years (int) – Number of years to increase/decrease.

  • months (int) – Number of months to increase/decrease.

  • weeks (int) – Number of weeks to increase/decrease.

  • days (int) – Number of days to increase/decrease.

  • hours (int) – Number of hours to increase/decrease.

  • minutes (int) – Number of minutes to increase/decrease.

  • seconds (int) – Number of seconds to increase/decrease.

Returns

On success, returns an object with the following properties:

Return type

dict

Properties

days

int

hours

int

minutes

int

months

int

time_in_local

datetime

time_in_utc

datetime

time_out_local

datetime

time_out_utc

datetime

tz_id_in

int

tz_id_out

int

tz_olson_in

str

tz_olson_out

str

static reservation_timeslot_adjuster(*, user_time, round_low=False)

Round a datetime to the nearest half hour, which is required for some times in netlab.

Parameters
  • user_time (datetime.datetime) – Must be a datetime object. Adjusted for fulfilling time slot if not already time slot acceptable.

  • round_low (bool) – True: rounds time in minutes down to the low timeslot. False: rounds time up to next timeslot.

Returns

Datetime rounded to half hour.

Return type

datetime.datetime