def initialize(self, endpoint): static_endpoint = self.config.get('endpoint') if static_endpoint: endpoint = static_endpoint e = parse_endpoint(endpoint) self.client = pygrpc.client( endpoint=f'{e.get("hostname")}:{e.get("port")}', version='plugin')
def setUpClass(cls): super(TestProjectGroup, cls).setUpClass() endpoints = cls.config.get('ENDPOINTS', {}) cls.identity_v1 = pygrpc.client(endpoint=endpoints.get('identity', {}).get('v1'), version='v1') cls._create_domain() cls._create_domain_owner() cls._issue_owner_token()
def setUp(self): endpoints = self.config.get('ENDPOINTS', {}) self.identity_v1 = pygrpc.client(endpoint=endpoints.get('identity', {}).get('v1'), version='v1') self.domain = None self.owner_id = 'DomainOwner' self.owner_pw = utils.generate_password() self.owner = None self.owner_token = None
def _init_client(self): for k, v in self.config['endpoint'].items(): # parse endpoint e = parse_endpoint(v) self.protocol = e['scheme'] if self.protocol == 'grpc': # create grpc client self.client = pygrpc.client(endpoint="%s:%s" % (e['hostname'], e['port']), version=k) elif self.protocol == 'http': # TODO: pass
def __init__(self, transaction, config): super().__init__(transaction, config) if 'endpoint' not in self.config: raise ERROR_WRONG_CONFIGURATION(key='endpoint') if len(self.config['endpoint']) > 1: raise ERROR_WRONG_CONFIGURATION(key='too many endpoint') for (k, v) in self.config['endpoint'].items(): e = parse_endpoint(v) self.client = pygrpc.client(endpoint=f'{e.get("hostname")}:{e.get("port")}', version=k)
def __init__(self, transaction, config): super().__init__(transaction, config) if 'endpoint' not in self.config: raise ERROR_WRONG_CONFIGURATION(key='endpoint') if len(self.config['endpoint']) > 1: raise ERROR_WRONG_CONFIGURATION(key='too many endpoint') for version, uri in self.config['endpoint'].items(): e = parse_grpc_endpoint(uri) self.client = pygrpc.client(endpoint=e['endpoint'], ssl_enabled=e['ssl_enabled'])
def initialize(self, endpoint): """ Initialize based on endpoint Args: endpoint (message): endpoint message """ e = parse_grpc_endpoint(endpoint) self.client = pygrpc.client(endpoint=e['endpoint'], ssl_enabled=e['ssl_enabled'], max_message_length=1024*1024*32) if self.client is None: _LOGGER.error(f'[initialize] Cannot access gRPC server. ' f'(host: {e.get("hostname")}, port: {e.get("port")}, version: plugin)') raise ERROR_GRPC_CONFIGURATION(endpoint=endpoint)
def _init_client(self, service, resource): if service not in self.client: if service not in self.config: raise ERROR_INVALID_RESOURCE_TYPE( resource_type=f'{service}.{resource}') e = parse_endpoint(self.config[service]) if e.get('path') is None: raise ERROR_CONNECTOR_CONFIGURATION( backend=self.__class__.__name__) self.client[service] = pygrpc.client( endpoint=f'{e.get("hostname")}:{e.get("port")}')
def _init_client(self): self.client = {} for service, endpoint in self.config.items(): e = parse_endpoint(endpoint) # _LOGGER.debug(f'[_init_client] Load endpoint : {endpoint}') if e.get('path') is None: raise ERROR_CONNECTOR_CONFIGURATION( backend=self.__class__.__name__) version = e.get('path').replace('/', '') self.client[service] = pygrpc.client( endpoint=f'{e.get("hostname")}:{e.get("port")}', version=version)
def initialize(self, endpoint): _LOGGER.info(f'[initialize] endpoint: {endpoint}') endpoint = endpoint.replace('"', '') e = parse_endpoint(endpoint) protocol = e['scheme'] if protocol == 'grpc': self.client = pygrpc.client(endpoint="%s:%s" % (e['hostname'], e['port']), version='plugin') elif protocol == 'http': # TODO: pass if self.client is None: raise ERROR_GRPC_CONFIGURATION
def _get_client(service, api_version): endpoint = get_endpoint(service) if endpoint is None: raise Exception(f'Endpoint is not set. (service={service})') try: e = parse_endpoint(endpoint) client = pygrpc.client(endpoint=f'{e.get("hostname")}:{e.get("port")}', version=api_version, max_message_length=1024 * 1024 * 256) client.service = service client.api_version = api_version return client except Exception: raise ValueError(f'Endpoint is invalid. (endpoint={endpoint})')
def _get_resources_from_client(endpoints, api_version='v1'): resources = {} for service, endpoint in endpoints.items(): try: e = parse_endpoint(endpoint) client = pygrpc.client( endpoint=f'{e.get("hostname")}:{e.get("port")}', version=api_version) resources[service] = {} for api_resource, verb in client.api_resources.items(): resources[service][api_resource] = {'alias': [], 'verb': verb} except Exception: raise ValueError(f'Endpoint is invalid. (endpoint={endpoint})') return resources
def __init__(self, transaction, config, **kwargs): super().__init__(transaction, config, **kwargs) """ Overwrite configuration Remote Repository has different authentication. So do not use your token at meta. Use another authentication algorithm like token Args: conn: dict (endpoint, version, ...) """ #_LOGGER.debug("[RemoteRepositoryConnector] meta: %s" % self.transaction.meta) #_LOGGER.debug("[RemoteRepositoryConnector] self.conn: %s" % self.conn) e = parse_grpc_endpoint(self.conn['endpoint']) self.client = pygrpc.client(endpoint=e['endpoint'], ssl_enabled=e['ssl_enabled']) # Update meta (like domain_id) # TODO: change meta to marketplace token meta = self.transaction.get_connection_meta() new_meta = [] if 'credential' in self.conn: credential = self.conn['credential'] if 'token' in credential: # self.meta = [('token',credential['token'])] self._token = credential['token'] else: # TODO: raise ERROR raise ERROR_CONFIGURATION(key='credential') for (k, v) in meta: if k != 'token' and v is not None: new_meta.append((k, v)) elif k == 'token': new_meta.append(('token', self._token)) self.meta = new_meta # Update domain_id # This repository is not our domain. # find domain_id from token decoded_token = JWTUtil.unverified_decode(self._token) self.domain_id = decoded_token['did']
def initialize(self, endpoint): if endpoint is None: raise ERROR_GRPC_CONFIGURATION endpoint = endpoint.replace('"', '') e = parse_endpoint(endpoint) protocol = e['scheme'] if protocol == 'grpc': self.client = pygrpc.client(endpoint="%s:%s" % (e['hostname'], e['port']), version='plugin') elif protocol == 'http': # TODO: pass if self.client is None: _LOGGER.error( f'[initialize] Cannot access gRPC server. ' f'(host: {e.get("hostname")}, port: {e.get("port")}, version: plugin)' ) raise ERROR_GRPC_CONFIGURATION
def __init__(self, transaction, config): super().__init__(transaction, config) _LOGGER.debug("config: %s" % self.config) if 'endpoint' not in self.config: raise ERROR_WRONG_CONFIGURATION(key='endpoint') if len(self.config['endpoint']) > 1: raise ERROR_WRONG_CONFIGURATION(key='too many endpoint') for (k, v) in self.config['endpoint'].items(): # parse endpoint e = parse_endpoint(v) self.protocol = e['scheme'] if self.protocol == 'grpc': # create grpc client self.client = pygrpc.client(endpoint="%s:%s" % (e['hostname'], e['port']), version=k) elif self.protocol == 'http': # TODO: pass
def _init_client(self): for version, uri in self.config['endpoint'].items(): e = parse_endpoint(uri) self.client = pygrpc.client(endpoint=f'{e.get("hostname")}:{e.get("port")}', version=version)
def initialize(self, endpoint): e = parse_endpoint(endpoint) self.client = pygrpc.client( endpoint=f'{e.get("hostname")}:{e.get("port")}', version='plugin')
def _init_client(self): for version, uri in self.config['endpoint'].items(): e = parse_grpc_endpoint(uri) self.client = pygrpc.client(endpoint=e['endpoint'], ssl_enabled=e['ssl_enabled'])
def initialize(self, endpoint): _LOGGER.info(f'[initialize] endpoint: {endpoint}') e = parse_endpoint(endpoint) self.client = pygrpc.client(endpoint=f'{e.get("hostname")}:{e.get("port")}', version='plugin')
def _init_client(self): e = parse_grpc_endpoint(self._endpoints[self._service]) self._client = pygrpc.client(endpoint=e['endpoint'], ssl_enabled=e['ssl_enabled'])