def _get_offset_param(params): """Extract offset id from request's dictionary (defaults to 0) or fail.""" offset = params.pop('offset', 0) return api_utils.validate_integer(offset, 'offset', 0, constants.DB_MAX_INT)
def _validate_quota_set(quota_set): bad_keys = [] for key, value in quota_set.items(): if (key not in QUOTAS and key not in GROUP_QUOTAS and key not in NON_QUOTA_KEYS): bad_keys.append(key) continue if key in NON_QUOTA_KEYS: continue api_utils.validate_integer(value, key, min_value=-1, max_value=db.MAX_INT) if len(bad_keys) > 0: msg = _("Bad key(s) in quota set: %s") % ", ".join(bad_keys) raise exception.InvalidInput(reason=msg) return True