Using Reservation API
Reservation API
Reservations provide a way to ensure a device is usable by a single user for a fixed duration starting at a given point in time. Normally, a device can be locked when it is free, but there is no guarantee that a specific device will be free at a given time. Reservations guarantee that a device will be free for the user that created the reservation. There are three types of reservations:
- Fixed - a reservation created for a future time with a predetermined duration
- Queued - a reservation created for the next available opening
- Quick start - an immediate reservation
A fixed reservation allows a user to schedule a reservation in the future, for example in 5 hours from now. A queued reservation allows a user to schedule a reservation for the next free slot that the device does not already have a reservation for. A quick start reservation is similar to a fixed reservation but is created for the current time.
Overview: Available API Routes
List Reservations
Sample request:
Sample response:
Create a Reservation
Create a reservation at a fixed time in the future.
Parameters
- <code class="dcode">"type" (string)</code>: The reservation type. One of:
- <code class="dcode">"fixed"</code>: A reservation at a fixed time.
- <code class="dcode">"queued"</code>: A reservation for the next available time slot.
- <code class="dcode">"quick_start"</code>: Try to create a 30 minute reservation starting now and fail if the reservation could not be started.
- <code class="dcode">"device_address" (string)</code>: The unique identifier for a device. Consists of <code class="dcode">{device_id}@{hostname}</code>, for example, <code class="dcode">"37deea48@proxy-us-mvo-5.headspin.io"</code>.
- <code class="Dcode">"duration" (float)</code>: Desired reservation duration in units of seconds.
- <code class="dcode">"start_time" (float)</code>: Desired reservation start time as a UNIX timestamp in seconds since the epoch.
- <code class="dcode">"end_time" (float)</code>: Desired reservation end time as a UNIX timestamp in seconds since the epoch.
Create a Quick Start Reservation
A quick start reservation attempts to immediately start a reservation for 30 minutes and fails if this cannot be achieved.
Required arguments: <code class="dcode">type</code>, <code class="dcode">device_address</code>
Sample request:
Sample response:
Create a Fixed Reservation
Schedule a reservation in the future.
Required arguments: <code class="dcode">type</code>, <code class="dcode">device_address</code>, <code class="dcode">start_time</code>, <code class="dcode">end_time</code>
Sample request to schedule a 10 minute reservation:
Sample response:
Create a Queued Reservation
Queued-type reservations are added to a queue if a reservation is currently active on the targeted device. Queued reservations must be confirmed within 5 minutes of the start time
Required arguments: <code class="dcode">type</code>, <code class="dcode">device_address</code>, <code class="dcode">duration</code>
Sample request:
Sample response:
Delete a Reservation
Delete a reservation whether active or pending.
Sample request:
Sample response:
Get Reservations Pending Confirmation
Enumerate reservations waiting on confirmation to begin. Note that the type of the reservation returned will always be queued.
Sample request:
Sample response:
Confirm a Pending Reservation
Confirm a reservation to start the reservation period.
Sample request:
Sample response: