def has_services_access(service_ids): """Returns a mapping {service_id: has_access}. has_access is True if current requester can read service configs. """ assert isinstance(service_ids, list) if not service_ids: return {} if _check_acl_cfg('service_access_group'): return {sid: True for sid in service_ids} service_id_set = set(service_ids) cfgs = { s.id: s for s in services.get_services_async().get_result() if s.id in service_id_set } has_access = _has_access([cfgs.get(sid) for sid in service_ids]) return dict(zip(service_ids, has_access))
def validate_config_async(config_set, path, content, ctx=None): """Validates a config against built-in and external validators. External validators are defined in validation.cfg, see proto/service_config.proto. Returns: components.config.validation_context.Result. """ ctx = ctx or validation.Context() # Check the config against built-in validators, # defined using validation.self_rule. validation.validate(config_set, path, content, ctx=ctx) all_services = yield services.get_services_async() futures = [] for service in all_services: futures.append(_validate_by_service_async(service, config_set, path, content, ctx)) yield futures raise ndb.Return(ctx.result())
def validate_config_async(config_set, path, content, ctx=None): """Validates a config against built-in and external validators. External validators are defined in validation.cfg, see proto/service_config.proto. Returns: components.config.validation_context.Result. """ ctx = ctx or validation.Context() # Check the config against built-in validators, # defined using validation.self_rule. validation.validate(config_set, path, content, ctx=ctx) all_services = yield services.get_services_async() futures = [] for service in all_services: futures.append( _validate_by_service_async(service, config_set, path, content, ctx)) yield futures raise ndb.Return(ctx.result())
def has_services_access(service_ids): """Returns a mapping {service_id: has_access}. has_access is True if current requester can read service configs. """ assert isinstance(service_ids, list) if not service_ids: return {} for sid in service_ids: assert isinstance(sid, basestring) assert sid super_group = get_acl_cfg().service_access_group if is_admin() or super_group and auth.is_group_member(super_group): return {sid: True for sid in service_ids} service_id_set = set(service_ids) cfgs = { s.id: s for s in services.get_services_async().get_result() if s.id in service_id_set } has_access = _has_access([cfgs.get(sid) for sid in service_ids]) return dict(zip(service_ids, has_access))