'Call proxy method. We need to add the rule_cls, obtained from the
self.rule_objects dictionary, to the incoming args.  The context is
passed to proxy method as first argument; the remaining args will
follow rule_cls.
Some of the incoming method calls have the policy rule name as one of
the keys in the kwargs.  For instance, the incoming kwargs for the
create_policy_bandwidth_limit_rule take this form:
{ \'bandwidth_limit_rule\': {
u\'bandwidth_limit_rule\':
{ \'max_burst_kbps\': 0,
u\'max_kbps\': u\'100\',
\'tenant_id\': u\'a8a31c9434ff431cb789c809777505ec\'}
\'policy_id\': u\'46985da5-9684-402e-b0d7-b7adac909c3a\'
We need to generalize this structure for all rule types so will
(effectively) rename the rule-specific keyword (e.g., in the above, the
first occurrence of \'bandwidth_limit_rule\') to be \'rule_data\'.
:param method_name: the name of the method to call
:type method_name: str
:param rule_cls: the rule class, which is sent as an argument to the
proxy method
:type rule_cls: a class from the rule_object (qos.objects.rule) module'

def _call_proxy_method(self, method_name, rule_cls):

    def _make_call(method_name, rule_cls, *args, **kwargs):
        context = args[0]
        args_list = list(args[1:])
        params = kwargs
        rule_data_name = (rule_cls.rule_type + '_rule')
        if (rule_data_name in params):
            params['rule_data'] = params.pop(rule_data_name)
        return getattr(self, method_name)(context, rule_cls, *args_list, **params)
    return (lambda *args, **kwargs: _make_call(method_name, rule_cls, *args, **kwargs))
