def _create_sub_resources(self, dev_mgr_uri, broker): resync_uri = uri_append_path(dev_mgr_uri, 'synchronize') self._resync_res = DeviceSynchronizeResource(resync_uri, broker) reconfigure_uri = uri_append_path(dev_mgr_uri, 'reconfigure') self._reconfigure_res = DeviceReconfigureResource(reconfigure_uri, broker) devices_uri = uri_append_path(dev_mgr_uri, 'devices') self._devices_res = DevicesResource(devices_uri, broker)
def _create_sub_resources(self, pg_mgr_uri, broker): install_uri = uri_append_path(pg_mgr_uri, 'install') self._install_res = InstallServiceResource(install_uri, broker) plugins_uri = uri_append_path(pg_mgr_uri, 'plugins') self._plugins_res = PluginsResource(plugins_uri, broker) reload_uri = uri_append_path(pg_mgr_uri, 'reload') self._reload_res = PluginReloadResource(reload_uri, broker)
def _create_sub_resources(self): dev_mgr_uri = uri_append_path(self._server_uri, 'dev_mgr') self._dev_mgr = DeviceManagerResource(dev_mgr_uri, self._broker) cfg_mgr_uri = uri_append_path(self._server_uri, 'cfg_mgr') self._cfg_mgr = ConfigManagerResource(cfg_mgr_uri, self._broker) pg_mgr_uri = uri_append_path(self._server_uri, 'pg_mgr') self._pg_mgr = PluginManagerResource(pg_mgr_uri, self._broker) config_uri = uri_append_path(self._server_uri, 'configure') self._config_res = ConfigureServiceResource(config_uri, self._broker)
def render_GET(self, request): plugins = {} for pg_id in self._pg_mgr: href = uri_append_path(request.path, pg_id) links = [{u'rel': u'pg.plugin', 'href': href}] plugins[pg_id] = {u'links': links} content = {u'plugins': plugins} return json_dumps(content)
def _add_new_oip(self, oip, request): # add a new child to this resource, and return the location # of the child path = self._id_gen.next() def on_delete(): try: del self.children[path] except KeyError: logger.warning('ID "%s" has already been removed' % path) op_in_progress_res = OperationInProgressResource(oip, on_delete) self.putChild(path, op_in_progress_res) return uri_append_path(request.path, path)
def render_GET(self, request): description_list = self._get_localized_description_list() params = [] for id_, description in description_list: value = self._cfg_srv.get(id_) href = uri_append_path(request.path, id_) params.append({u'id': id_, u'description': description, u'value': value, u'links': [{u'rel': REL_CONFIGURE_PARAM, u'href': href}]}) content = {u'params': params} return json_dumps(content)
def _add_new_oip(self, oip, request): # add a new child to this resource, and return the location # of the child path = next(self._id_gen) def on_delete(): try: del self.children[path] except KeyError: logger.warning('ID "%s" has already been removed' % path) op_in_progress_res = OperationInProgressResource(oip, on_delete) self.putChild(path, op_in_progress_res) return uri_append_path(request.path, path)
def render_GET(self, request): description_list = self._get_localized_description_list() params = [] for id_, description in description_list: value = self._cfg_srv.get(id_) href = uri_append_path(request.path, id_) params.append({ u'id': id_, u'description': description, u'value': value, u'links': [{ u'rel': REL_CONFIGURE_PARAM, u'href': href }] }) content = {u'params': params} return json_dumps(content)
def _create_sub_resources(self, install_srv_uri, broker): install_uri = uri_append_path(install_srv_uri, 'install') self._install_res = InstallResource(install_uri, broker) uninstall_uri = uri_append_path(install_srv_uri, 'uninstall') self._uninstall_res = UninstallResource(uninstall_uri, broker) installed_uri = uri_append_path(install_srv_uri, 'installed') self._installed_res = InstalledResource(installed_uri, broker) installable_uri = uri_append_path(install_srv_uri, 'installable') self._installable_res = InstallableResource(installable_uri, broker) upgrade_uri = uri_append_path(install_srv_uri, 'upgrade') self._upgrade_res = UpgradeResource(upgrade_uri, broker) update_uri = uri_append_path(install_srv_uri, 'update') self._update_res = UpdateResource(update_uri, broker)
def get(self, id): param_uri = uri_append_path(self._config_uri, id) return ConfigureParameterResource(param_uri, self._broker)
def on_callback(id): location = uri_append_path(request.path, str(id)) request.setHeader('Location', location) data = json_dumps({u'id': id}) deferred_respond_ok(request, data, http.CREATED)
def _build_links(self, base_uri): links = [] for rel, path, _ in self._links: href = uri_append_path(base_uri, path) links.append({u'rel': rel, u'href': href}) return links
def get(self, id): plugin_uri = uri_append_path(self._plugins_uri, id) return PluginResource(plugin_uri, self._broker)
def device_res(self, id): device_uri = uri_append_path(self._devices_uri, id) return DeviceResource(device_uri, self._broker)
def raw_config_res(self, id): raw_config_uri = uri_append_path(self._configs_uri, id, 'raw') return RawConfigResource(raw_config_uri, self._broker)
def config_res(self, id): config_uri = uri_append_path(self._configs_uri, id) return ConfigResource(config_uri, self._broker)
def _create_sub_resources(self, cfg_mgr_uri, broker): configs_uri = uri_append_path(cfg_mgr_uri, 'configs') self._configs_res = ConfigsResource(configs_uri, broker) autocreate_uri = uri_append_path(cfg_mgr_uri, 'autocreate') self._autocreate_res = AutocreateConfigResource(autocreate_uri, broker)