def get(self, provider, read_filter, operation='CONFIG'): if provider is None: raise _YServiceError("Service Provider cannot be None") if read_filter is None: raise _YServiceError("Get filter cannot be None") filters = read_filter if isinstance(read_filter, EntityCollection): filters = read_filter.entities() top_filters = _get_top_level_entity(filters, provider.get_session().get_root_schema()) with _handle_error(): top_result = self._gs.get(provider, top_filters, operation) result = _get_child_entity_from_top(top_result, filters) if isinstance(read_filter, EntityCollection): result = Config(result) return result
def read_config(self, provider, read_filter=None): if provider is None: raise YServiceError("provider cannot be None") if read_filter is None: with _handle_error(): return _read_entities(provider) filters = read_filter if isinstance(read_filter, EntityCollection): filters = read_filter.entities() top_filters = _get_top_level_entity(filters, provider.get_session().get_root_schema()) with _handle_error(): read_top_entity = self._crud.read_config(provider, top_filters) read_entity = _get_child_entity_from_top(read_top_entity, filters) if isinstance(read_filter, EntityCollection): read_entity = Config(read_entity) return read_entity
def read_config(self, provider, read_filter=None): if provider is None: raise YServiceError("provider cannot be None") if read_filter is None: with _handle_error(): return _read_entities(provider) filters = read_filter if isinstance(read_filter, EntityCollection): filters = read_filter.entities() top_filters = _get_top_level_entity(filters, provider.get_session().get_root_schema()) with _handle_error(): read_top_entity = self._crud.read_config(provider, top_filters) read_entity = _get_child_entity_from_top(read_top_entity, filters) if isinstance(read_filter, EntityCollection): read_entity = Config(read_entity) return read_entity
def get(self, provider, read_filter=None): if provider is None: raise _YServiceError("provider cannot be None") if read_filter is None: with _handle_error(): return _read_entities(provider, get_config=False) filters = read_filter if isinstance(read_filter, EntityCollection): filters = read_filter.entities() top_filters = _get_top_level_entity(filters, provider.get_session().get_root_schema()) with _handle_error(): top_result = self._ns.get(provider, top_filters) result = _get_child_entity_from_top(top_result, filters) if isinstance(read_filter, EntityCollection): result = Config(result) return result
def get_config(self, provider, source=Datastore.running, read_filter=None): if None in (provider, source): raise _YServiceError("provider and source cannot be None") if read_filter is None: with _handle_error(): return _read_entities(provider, True, source) filters = read_filter if isinstance(read_filter, EntityCollection): filters = read_filter.entities() top_filters = _get_top_level_entity(filters, provider.get_session().get_root_schema()) with _handle_error(): top_result = self._ns.get_config(provider, source, top_filters) result = _get_child_entity_from_top(top_result, filters) if isinstance(read_filter, EntityCollection): result = Config(result) return result
def _ns_get(provider, source, read_filter, ns_call): is_config = (source is not None) if read_filter is None: with _handle_error(): return _read_entities(provider, get_config=is_config) filters = read_filter if isinstance(read_filter, EntityCollection): filters = read_filter.entities() _set_nontop_entity_filter(filters, YFilter.read) top_filters = _get_top_level_entity(filters, provider.get_session().get_root_schema()) with _handle_error(): if is_config: top_result = ns_call(provider, source, top_filters) else: top_result = ns_call(provider, top_filters) result = _get_child_entity_from_top(top_result, filters) if isinstance(read_filter, EntityCollection): result = Config(result) return result
def get(self, provider, read_filter, operation='CONFIG'): if provider is None: raise _YServiceError("Service Provider cannot be None") if read_filter is None: raise _YServiceError("Get filter cannot be None") filters = read_filter if isinstance(read_filter, EntityCollection): filters = read_filter.entities() _set_nontop_entity_filter(filters, YFilter.read) top_filters = _get_top_level_entity( filters, provider.get_session().get_root_schema()) with _handle_error(): top_result = self._gs.get(provider, top_filters, operation) result = _get_child_entity_from_top(top_result, filters) if isinstance(read_filter, EntityCollection): result = Config(result) return result
def _crud_read(provider, read_filter, is_config, crud_call): if provider is None: raise YServiceError("provider cannot be None") if read_filter is None: with _handle_error(): return _read_entities(provider, get_config=is_config) filters = read_filter if isinstance(read_filter, EntityCollection): filters = read_filter.entities() _set_nontop_entity_filter(filters, YFilter.read) top_filters = _get_top_level_entity( filters, provider.get_session().get_root_schema()) with _handle_error(): read_top_entity = crud_call(provider, top_filters) read_entity = _get_child_entity_from_top(read_top_entity, filters) if isinstance(read_filter, EntityCollection): read_entity = Config(read_entity) return read_entity