original_docstring: Validates access rules according to access_type and access_level.
  
          :param access_rules: List of access rules to be validated.
          :param allowed_types: tuple of allowed type values.
          :param allowed_levels: tuple of allowed level values.
          
docstring: Validates access rules according to access_type and access_level.
docstring_tokens: Validates access rules according to access_type and access_level .
code: def validate_access_rules(access_rules, allowed_types, allowed_levels):
          """Validates access rules according to access_type and access_level.
  
          :param access_rules: List of access rules to be validated.
          :param allowed_types: tuple of allowed type values.
          :param allowed_levels: tuple of allowed level values.
          """
          for access in (access_rules or []):
              access_type = access['access_type']
              access_level = access['access_level']
              if access_type not in allowed_types:
                  reason = _("Only %s access type allowed.") % (
                      ', '.join(tuple(["'%s'" % x for x in allowed_types])))
                  raise exception.InvalidShareAccess(reason=reason)
              if access_level not in allowed_levels:
                  raise exception.InvalidShareAccessLevel(level=access_level)
code_tokens: def validate_access_rules ( access_rules , allowed_types , allowed_levels ) : for access in ( access_rules or [ ] ) : access_type = access [ 'access_type' ] access_level = access [ 'access_level' ] if access_type not in allowed_types : reason = _ ( "Only %s access type allowed." ) % ( ', ' . join ( tuple ( [ "'%s'" % x for x in allowed_types ] ) ) ) raise exception . InvalidShareAccess ( reason = reason ) if access_level not in allowed_levels : raise exception . InvalidShareAccessLevel ( level = access_level )
short_docstring: Validates access rules according to access_type and access_level.
short_docstring_tokens: Validates access rules according to access_type and access_level .
comment: """Validates access rules according to access_type and access_level.
  
          :param access_rules: List of access rules to be validated.
          :param allowed_types: tuple of allowed type values.
          :param allowed_levels: tuple of allowed level values.
          """