Ejemplo n.º 1
0
    def __init__(self, client, url: URITemplate):
        self.client = client

        self.info_url = url.partial(info='info', resource=self.resource_name)

        # Setting a URIVariable to None doesn't remove it using .partial,
        # so reconstruct the URITemplate
        submit_url = url.expand(info=None, resource=self.resource_name)
        self.submit_url = URITemplate(submit_url + '{/id}')
Ejemplo n.º 2
0
        def inner_wrapper(f, *args, **kwargs):
            argspec = getfullargspec(func)
            uri = URITemplate(path)
            field, path_, query = {}, {}, {}

            # Parse each args and put them in the right place
            for n, (key, val) in enumerate(argspec.annotations.items(), 1):
                if val is Field:
                    field[key] = args[n]
                elif val is Path:
                    path_[key] = args[n]
                elif val is Query:
                    query[key] = args[n]

            option['data'] = field
            option['params'] = query

            url = args[0]._base_url + str(uri.partial(path_))
            result = args[0]._oauth._req(method, url, **option)
            if returns is None:
                return result
            return returns(result)