def jt_aggregate(func, is_create=False, has_pk=False):
def helper(kwargs, obj):<EOL><INDENT>"""<STR_LIT>"""<EOL>unified_job_template = None<EOL>for item in UNIFIED_JT:<EOL><INDENT>if kwargs.get(item, None) is not None:<EOL><INDENT>jt_id = kwargs.pop(item)<EOL>if unified_job_template is None:<EOL><INDENT>unified_job_template = (item, jt_id)<EOL><DEDENT>else:<EOL><INDENT>raise exc.UsageError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT><DEDENT><DEDENT>if unified_job_template is not None:<EOL><INDENT>kwargs['<STR_LIT>'] = unified_job_template[<NUM_LIT:1>]<EOL>obj.identity = tuple(list(obj.identity) + ['<STR_LIT>'])<EOL>return '<STR_LIT:/>'.join([UNIFIED_JT[unified_job_template[<NUM_LIT:0>]],<EOL>str(unified_job_template[<NUM_LIT:1>]), '<STR_LIT>'])<EOL><DEDENT>elif is_create:<EOL><INDENT>raise exc.UsageError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>def decorator_without_pk(obj, *args, **kwargs):<EOL><INDENT>old_endpoint = obj.endpoint<EOL>new_endpoint = helper(kwargs, obj)<EOL>if is_create:<EOL><INDENT>obj.endpoint = new_endpoint<EOL><DEDENT>result = func(obj, *args, **kwargs)<EOL>obj.endpoint = old_endpoint<EOL>return result<EOL><DEDENT>def decorator_with_pk(obj, pk=None, *args, **kwargs):<EOL><INDENT>old_endpoint = obj.endpoint<EOL>new_endpoint = helper(kwargs, obj)<EOL>if is_create:<EOL><INDENT>obj.endpoint = new_endpoint<EOL><DEDENT>result = func(obj, pk=pk, *args, **kwargs)<EOL>obj.endpoint = old_endpoint<EOL>return result<EOL><DEDENT>decorator = decorator_with_pk if has_pk else decorator_without_pk<EOL>for item in CLICK_ATTRS:<EOL><INDENT>setattr(decorator, item, getattr(func, item, []))<EOL><DEDENT>decorator.__doc__ = func.__doc__<EOL>return decorator<EOL>
Decorator to aggregate unified_jt-related fields.

    Args:
        func: The CURD method to be decorated.
        is_create: Boolean flag showing whether this method is create.
        has_pk: Boolean flag showing whether this method uses pk as argument.

    Returns:
        A function with necessary click-related attributes whose keyworded
        arguments are aggregated.

    Raises:
        exc.UsageError: Either more than one unified jt fields are
            provided, or none is provided when is_create flag is set.