def _register_endpoint_discovery(self, client, endpoint_url, config):
        if endpoint_url is not None:
            # Don't register any handlers in the case of a custom endpoint url
            return
        # Only attach handlers if the service supports discovery
        if client.meta.service_model.endpoint_discovery_operation is None:
            return
        events = client.meta.events
        service_id = client.meta.service_model.service_id.hyphenize()
        enabled = False
        if config and config.endpoint_discovery_enabled is not None:
            enabled = config.endpoint_discovery_enabled
        elif self._config_store:
            enabled = self._config_store.get_config_variable(
                'endpoint_discovery_enabled')

        enabled = self._normalize_endpoint_discovery_config(enabled)
        if enabled and self._requires_endpoint_discovery(client, enabled):
            discover = enabled is True
            manager = EndpointDiscoveryManager(client, always_discover=discover)
            handler = EndpointDiscoveryHandler(manager)
            handler.register(events, service_id)
        else:
            events.register('before-parameter-build',
                            block_endpoint_discovery_required_operations)
Esempio n. 2
0
 def setUp(self):
     super(TestEndpointDiscoveryHandler, self).setUp()
     self.manager = mock.Mock(spec=EndpointDiscoveryManager)
     self.handler = EndpointDiscoveryHandler(self.manager)
     self.service_model = ServiceModel(self.service_description)