Documentation

api.resources.available

Determine if resources are available to some user and available at a given time. It does not do 100% of the checks required to reserve something and for example skips checking scripts attached to resources.

For whether a user can reserve something or not, it does the following checks:

  • Checks that the resource is active and reservable
  • Checks that the user has necessary credentials, if necessary
  • Checks that the user is in the correct user group, if necessary

For the availability checks of the resource at a given time, it does the following checks:

  • Checks against weekly blocks
  • Checks against weekly slots
  • Checks against reservations for blocker resources
  • Checks against conflicting reservations
  • Checks to ensure that there are enough units available

The follow checks are NOT done:

  • Executing resource scripts
  • Checking if user has enough credit in their account
  • Checking if the duration is applicable for the resource based on resource time restrictions
  • Checking if the start or end times are applicable to the resource based on resource time restrictions
  • Checking if there is a rate available to the user that would allow them to book the resource
  • Checking for auto-denial based on actual usage or approver settings
  • Checking for forms and form response content
  • Checking if user has the necessary account number as required by a site
  • Checking if this can be included in some project
  • Resource loan specific checks

Arguments:

def api.resources.available(
  # Check for contradictory resources (blocker + blocked) in
  # the list of requested resource.
  check_self_blocks: bool = True,

  end: datetime = None, # Required
  
  # Ignore buffers when considering times.
  ignore_buffer: bool = False,
  
  # List of lists length 2, with resource ID first followed
  # by number of units. e.g.
  # [ [ "reservable_id", 1 ] ]
  # which would check for the availability of this resource
  # with 1 unit requested.
  # You can also use named units by having a list of lists
  # length 3 with a string at the end:
  # [ [ "reservable_id", 1, "named_unit_id" ] ]
  requested: list[list[str, dec or int]] or list[list[str, dec or int, str or None]] = None, # Required
  
  # Reservation ID to ignore when checking the availability
  # during some time.
  reservation_id: str or None = None,
  
  # Skip checking weekly blocks when checking the availability
  # during some time.
  skip_blackouts: bool = False,
  
  # Skip checking the times if the the resource is not available
  # to the user.
  skip_times_test_if_can_not_reserve: bool = True,
  
  start: datetime = None, # Required
  
  # User ID to check the resources for.
  user_id: str = None, # Required
):

Returns a dict in this form.

Example:

availability_dict = api.resources.available(
  end=datetime.from_unix(ts=2000),
  ignore_buffer=False,
  requested=[["reservable_1_id", 1], ["reservable_2_id", 1]],
  skip_blackouts=False,
  start=datetime.from_unix(ts=1000),
  user_id="user_id")