Thin wrapper around api_handler from `indicoio.utils.api` to add in stored keyword argument to the JSON body
548907
def _api_handler(self, *args, **kwargs):
        
        keyword_arguments = {}
        keyword_arguments.update(self.keywords)
        keyword_arguments.update(kwargs)
        return api_handler(*args, **keyword_arguments)
164730
def jsonp_wrap(callback_key='callback'):
    

    def decorator_fn(f):

        @wraps(f)
        def jsonp_output_decorator(*args, **kwargs):
            task_data = _get_data_from_args(args)
            data = task_data.get_data()

            if callback_key not in data:
                raise KeyError(
                    'Missing required parameter "{0}" for task.'.format(
                        callback_key))

            callback = data[callback_key]
            jsonp = f(*args, **kwargs)
            if isinstance(JobContext.get_current_context(), WebJobContext):
                JobContext.get_current_context().add_responder(
                    MimeSetterWebTaskResponder('application/javascript'))
            jsonp = "{callback}({data})".format(callback=callback, data=jsonp)

            return jsonp

        return jsonp_output_decorator

    return decorator_fn
661675
def _make_api_call(self, method, url, json_params=None):
        
        if self.verbose is True:
            print "\ncrossbarhttp: Request: %s %s" % (method, url)

        if json_params is not None:
            encoded_params = json.dumps(json_params)
            headers = {'Content-Type': 'application/json'}
        else:
            encoded_params = None
            headers = {}

        if encoded_params is not None and self.verbose is True:
            print "crossbarhttp: Params: " + encoded_params

        if self.key is not None and self.secret is not None and encoded_params is not None:
            signature, nonce, timestamp = self._compute_signature(encoded_params)
            params = urllib.urlencode({
                "timestamp": timestamp,
                "seq": str(self.sequence),
                "nonce": nonce,
                "signature": signature,
                "key": self.key
            })
            if self.verbose is True:
                print "crossbarhttp: Signature Params: " + params
            url += "?" + params

        # TODO: I can't figure out what this is.  Guessing it is a number you increment on every call
        self.sequence += 1

        try:
            request = urllib2.Request(url, encoded_params, headers)
            request.get_method = lambda: method
            response = urllib2.urlopen(request).read()
            if self.verbose is True:
                print "crossbarhttp: Response: " + response

            return json.loads(response)

        except urllib2.HTTPError, e:
            if e.code == 400:
                raise ClientMissingParams(str(e))
            elif e.code == 401:
                raise ClientSignatureError(str(e))
            else:
                raise ClientBadUrl(str(e))
        except urllib2.URLError, e:
            raise ClientBadHost(str(e))
982178
def query_params(*es_query_params):
    

    def _wrapper(func):
        @wraps(func)
        def _wrapped(*args, **kwargs):
            params = {}
            if "params" in kwargs:
                params = kwargs.pop("params").copy()
            for p in es_query_params + GLOBAL_PARAMS:
                if p in kwargs:
                    v = kwargs.pop(p)
                    if v is not None:
                        params[p] = _escape(v)

            # don't treat ignore and request_timeout as other params to avoid escaping
            for p in ("ignore", "request_timeout"):
                if p in kwargs:
                    params[p] = kwargs.pop(p)
            return func(*args, params=params, **kwargs)

        return _wrapped

    return _wrapper
104015
def _make_api_call(self, api_method, **kwargs):
        '''
        '''
        api_url = '/'.join((self.api_base_url, api_method))
        parameters = dict()
        parameters.update(self.default_parameters)
        parameters.update(kwargs)
        post_params = urlencode(parameters).encode('utf-8')
        response = self.opener.open(api_url, post_params)
        return json.loads(response.read().decode('utf-8'))
1194459
def make_payload(base, method, params):
    
    payload = {
        'jsonrpc': '2.0',
        'method': '{base}APING/v1.0/{method}'.format(**locals()),
        'params': utils.serialize_dict(params),
        'id': 1,
    }
    return payload
423895
def _input_handler_decorator(self, data):
        
        input_handler = getattr(self, self.__InputHandler)
        input_parts = [
            self.Parameters['taxonomy_file'],
            input_handler(data),
            self.Parameters['training_set_id'],
            self.Parameters['taxonomy_version'],
            self.Parameters['modification_info'],
            self.ModelDir,
        ]
        return self._commandline_join(input_parts)
1069813
function(api, handler) {

        if( 0 === arguments.length )
            throw new Error('utils.handler.register needs arguments');

        if( ! _.isObject(api) )
            throw new Error('utils.handler.register needs an espressojs API');

        if( ! (handler instanceof Handler) )
            throw new Error('utils.handler.register needs a Handler');

        // Add it to _ids
        api._ids[ handler.getPattern().getExpression().toString() ] = handler;

        // Add it to _names if any
        var name = handler.getOption('name');

        if( _.isString(name) && ! _.isEmpty(name) )
            api._names[ name ] = handler;
    }
146676
def post_loader(*decorator_args, serializer):
    
    def wrapped(fn):
        @wraps(fn)
        def decorated(*args, **kwargs):
            return fn(*serializer.load(request.get_json()))
        return decorated

    if decorator_args and callable(decorator_args[0]):
        return wrapped(decorator_args[0])
    return wrapped
975940
def add_handler(self, f):
        
        if f.__name__.startswith('rpc_'):
            raise ValueError("Server method names cannot start with rpc_.")
        self._json_rpc_methods[f.__name__] = f
        return f
1165360
def build_api_object(uo=None, api_key=None, uo_id=None, uo_type=None):
        
        if uo is not None:
            api_key = uo.resolve_api_key() if uo.resolve_api_key() is not None else api_key
            uo_id = uo.uo_id if uo.uo_id is not None else uo_id
            uo_type = uo.uo_type if uo.uo_type is not None else uo_type

        if uo_type is None or uo_type == EBConsts.INVALID_KEY_TYPE:
            uo_type = 0

        return "%s%010x%010x" % (api_key, uo_id, uo_type)
860203
def create_api_call_func(api, verb):
    

    # Scopes some local context in which we can build
    # request functions with reflection that primed with
    # some static parameters.
    def api_call_func(self, **kwargs):

        request = api.request_classes[verb](**kwargs)
        params = dict([ (k,v) for k,v in request.items() if v is not None ])


        if HTTPVerb.GET == verb:
            raw_response = requests.get(api.url, params=params, **self.reqargs)

        elif HTTPVerb.POST == verb:
            raw_response = requests.post(api.url, data=params, **self.reqargs)

        else:
            raise RuntimeError('{} is not a handled http verb'.format(verb))

        if raw_response.status_code != HTTPStatus.OK:
            raw_response.raise_for_status()

        # The object hook will convert all dictionaries from the json
        # objects in the response to a . attribute access
        ResponseClass = api.response_classes[verb]
        try:
            response = raw_response.json(object_hook=lambda obj: ResponseClass(obj))
        except ValueError as e:
            response = ResponseClass({'content' : raw_response.content})

        return response

    method_name = api_method_name(verb, api)

    api_call_func.__name__ = method_name
    api_call_func.__doc__ = '{}\n{}'.format(
        method_name, ''.join(api.request_classes[verb].__doc__.splitlines(True)[1:]))

    return api_call_func
1081596
def info(self, cloud=None, api_key=None, version=None, **kwargs):
        
        url_params = {"batch": False, "api_key": api_key, "version": version, "method": "info"}
        return self._api_handler(None, cloud=cloud, api="custom", url_params=url_params, **kwargs)
417900
def json_post(methodname, rtype, key):
    """"""
    return compose(
        reusable,
        map_return(registry(rtype), itemgetter(key)),
        basic_interaction,
        map_yield(partial(_json_as_post, methodname)),
        oneyield,
    )
151945
def api_payload(self):
        
        if not self._api_payload:
            raise NotImplementedError()
        payload = {}
        for attr_name in self._api_payload:
            value = getattr(self, attr_name, None)
            if value is not None:
                payload[attr_name] = value
        return payload
176219
function ko(fn, isParamHandler) {
	// handlers and middlewares may have safeguard properties to be skipped
	if ('$$koified' in fn) {
		return fn;
	}

	let handler = function (req, res, next) {
		let argsLength = arguments.length;
		let args = new Array(argsLength);

		for (let i = 0; i < argsLength; i++) {
			args[i] = arguments[i];
		}

		return ko.ifyHandler(fn, args);
	};

	let errHandler = function (err, req, res, next) {
		let argsLength = arguments.length;
		let args = new Array(argsLength);

		for (let i = 0; i < argsLength; i++) {
			args[i] = arguments[i];
		}

		return ko.ifyHandler(fn, args, true);
	};

	let paramHandler = function (req, res, next, val) {
		let argsLength = arguments.length;
		let args = new Array(argsLength);

		for (let i = 0; i < argsLength; i++) {
			args[i] = arguments[i];
		}

		return ko.ifyHandler(fn, args);
	};

	let wrapper;

	// the way Express distinguishes error handlers from regular ones
	if (fn.length === 4) {
		wrapper = isParamHandler ? paramHandler : errHandler;
	} else {
		wrapper = handler;
	}

	// safeguard
	Object.defineProperty(wrapper, '$$koified', {
		configurable: true,
		writable: true,
		value: true
	});

	return wrapper;
}
840132
def create_swagger_json_handler(app, **kwargs):
    

    spec = get_swagger_spec(app)
    _add_blueprint_specs(app, spec)
    spec_dict = spec.swagger_definition(**kwargs)
    encoded_spec = json.dumps(spec_dict).encode("UTF-8")

    async def swagger(request):
        return HTTPResponse(
            body_bytes=encoded_spec,
            headers={
                "Access-Control-Allow-Origin": "*"
            },
            content_type="application/json",
        )

    return swagger