コード例 #1
0
 def __init__(self, oip, on_delete=None):
     """
     oip -- an operation in progress object
     on_delete -- either None or a callable taking no argument
     """
     AuthResource.__init__(self)
     self._oip = oip
     self._on_delete = on_delete
コード例 #2
0
 def __init__(self, pg_mgr):
     AuthResource.__init__(self)
     self._pg_mgr = pg_mgr
     self._childs = dict((pg_id, PluginResource(pg))
                         for (pg_id, pg) in six.iteritems(self._pg_mgr))
     # observe plugin loading/unloading and keep a reference to the weakly
     # referenced observer
     self._obs = BasePluginManagerObserver(self._on_plugin_load,
                                           self._on_plugin_unload)
     pg_mgr.attach(self._obs)
コード例 #3
0
    def __init__(self, links):
        """
        links -- a list of tuple (rel, path, resource)

        For example:
        links = [(u'foo', 'foo_sub_uri', server.Data('text/plain', 'foo'),
                 (u'bar', 'bar_sub_uri', server.Data('text/plain', 'bar')]
        IntermediaryResource(links)

        The difference between this resource and a plain Resource is that a
        GET request will yield something.

        """
        AuthResource.__init__(self)
        self._links = links
        self._register_childs()
コード例 #4
0
ファイル: main.py プロジェクト: wazo-platform/wazo-provd
    def startService(self):
        app = self._prov_service.app
        dhcp_request_processing_service = self._dhcp_process_service.dhcp_request_processing_service
        server_resource = new_authenticated_server_resource(
            app, dhcp_request_processing_service)
        logger.info('Authentication is required for REST API')
        # /{version}
        root_resource = AuthResource()
        root_resource.putChild(API_VERSION, server_resource)

        # /{version}/api/api.yml
        api_resource = UnsecuredResource()
        api_resource.putChild(
            'api.yml', ResponseFile(sibpath(__file__, 'rest/api/api.yml')))
        server_resource.putChild('api', api_resource)

        rest_site = Site(root_resource)

        port = self._config['rest_api']['port']
        interface = self._config['rest_api']['ip']
        if interface == '*':
            interface = ''
        logger.info('Binding HTTP REST API service to "%s:%s"', interface,
                    port)
        if self._config['rest_api']['ssl']:
            logger.warning(
                'Using service SSL configuration is deprecated. Please use NGINX instead.'
            )
            context_factory = ssl.DefaultOpenSSLContextFactory(
                self._config['rest_api']['ssl_keyfile'],
                self._config['rest_api']['ssl_certfile'])
            self._tcp_server = internet.SSLServer(port,
                                                  rest_site,
                                                  context_factory,
                                                  interface=interface)
        else:
            self._tcp_server = internet.TCPServer(port,
                                                  rest_site,
                                                  interface=interface)
        self._tcp_server.startService()
        Service.startService(self)
コード例 #5
0
 def __init__(self, app, id):
     AuthResource.__init__(self)
     self._app = app
     self.device_id = id
コード例 #6
0
 def __init__(self, app):
     AuthResource.__init__(self)
     self._app = app
コード例 #7
0
 def __init__(self, app, dhcp_request_processing_service):
     AuthResource.__init__(self)
     self._app = app
     self._dhcp_req_processing_srv = dhcp_request_processing_service
コード例 #8
0
 def __init__(self, install_srv, method_name):
     AuthResource.__init__(self)
     self._install_srv = install_srv
     self._method_name = method_name
コード例 #9
0
 def __init__(self, install_srv, plugin_id):
     AuthResource.__init__(self)
     self._install_srv = install_srv
     self.plugin_id = plugin_id
コード例 #10
0
 def __init__(self):
     AuthResource.__init__(self)
     self._id_gen = new_id_generator()
コード例 #11
0
 def __init__(self, cfg_srv, key):
     AuthResource.__init__(self)
     # key is not necessary to be valid
     self._cfg_srv = cfg_srv
     self.param_id = key
コード例 #12
0
 def __init__(self, cfg_srv):
     """
     cfg_srv -- an object providing the IConfigureService interface
     """
     AuthResource.__init__(self)
     self._cfg_srv = cfg_srv
コード例 #13
0
 def __init__(self, plugin):
     AuthResource.__init__(self)
     self._plugin = plugin
     self.plugin_id = plugin.id
コード例 #14
0
 def getChild(self, path, request):
     try:
         return self._childs[path]
     except KeyError:
         return AuthResource.getChild(self, path, request)
コード例 #15
0
 def getChild(self, path, request):
     if path == 'raw':
         return RawConfigResource(self._app, self.config_id)
     else:
         return AuthResource.getChild(self, path, request)
コード例 #16
0
 def __init__(self, app, id):
     AuthResource.__init__(self)
     self._app = app
     self.config_id = id