def __init__(self, auth, logger): """ Initialise FCP API Interface. :param auth: dictionary containing auth details :param logger: reference to a logger """ self.client = clients.get_client(auth, logger=logger) self.logger = logger self.logger.debug('REST API initialised with auth: %s', auth)
def _put_client_in_kwargs(client_name, kwargs): """Consolidate authentication information and insert client into kwargs.""" if client_name in kwargs and not isinstance(kwargs[client_name], RESTClient): raise NonRecoverableError('Incorrect client class exists.') ctx = _get_ctx(kwargs) auth = None if ctx.type == context.NODE_INSTANCE: auth = ctx.node.properties.get(PROP_CLIENT_CONFIG) elif ctx.type == context.RELATIONSHIP_INSTANCE: auth = ctx.source.node.properties.get(PROP_CLIENT_CONFIG) if not auth: auth = ctx.target.node.properties.get(PROP_CLIENT_CONFIG) if PROP_CLIENT_CONFIG in kwargs: try: auth = auth.copy() auth.update(kwargs[PROP_CLIENT_CONFIG]) except AttributeError: auth = kwargs[PROP_CLIENT_CONFIG] kwargs[client_name] = get_client(auth, logger=ctx.logger)
def __init__(self, auth, logger): """Initialise FCP API Interface.""" self.client = clients.get_client(auth, logger=logger) self.logger = logger self.logger.debug('REST API initialised with auth: %s', auth)