How to use the rbtools.api.decorators.request_method_decorator function in RBTools

To help you get started, we’ve selected a few RBTools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reviewboard / rbtools / rbtools / api / resource.py View on Github external
@request_method_decorator
def _delete(resource, *args, **kwargs):
    """Generate a DELETE request on a resource."""
    return HttpRequest(resource._links['delete']['href'], method='DELETE',
                       query_args=kwargs)
github reviewboard / rbtools / rbtools / api / resource.py View on Github external
    @request_method_decorator
    def get_next(self, **kwargs):
        if 'next' not in self._links:
            raise StopIteration()

        return HttpRequest(self._links['next']['href'], query_args=kwargs)
github reviewboard / rbtools / rbtools / api / resource.py View on Github external
    @request_method_decorator
    def upload_screenshot(self, filename, content, caption=None, **kwargs):
        """Uploads a new screenshot.

        The content argument should contain the body of the screenshot
        to be uploaded, in string format.
        """
        request = HttpRequest(self._url, method=b'POST', query_args=kwargs)
        request.add_file('path', filename, content)

        if caption:
            request.add_field('caption', caption)

        return request
github reviewboard / rbtools / rbtools / api / resource.py View on Github external
    @request_method_decorator
    def get_patch(self, **kwargs):
        """Retrieves the actual diff file contents."""
        request = HttpRequest(self._url, query_args=kwargs)
        request.headers['Accept'] = 'text/x-patch'
        return request
github reviewboard / rbtools / rbtools / api / resource.py View on Github external
@request_method_decorator
def _update(resource, data=None, query_args={}, *args, **kwargs):
    """Generate a PUT request on a resource.

    Unlike other methods, any additional query args must be passed in
    using the 'query_args' parameter, since kwargs is used for the
    fields which will be sent.

    Review Board expects ``extra_data`` fields to be sent as
    ``extra_data.field_name``, which cannot be passed as a raw literal in
    Python. Fields like this would have to be added to a dict and splatted.
    However, this function also accepts keyword arguments of the form
    ``extra_data__field_name``, which will be rewritten to fields of the form
    ``extra_data.field_name``.
    """
    request = HttpRequest(resource._links['update']['href'], method='PUT',
                          query_args=query_args)
github reviewboard / rbtools / rbtools / api / resource.py View on Github external
    @request_method_decorator
    def upload_diff(self, diff, parent_diff=None, base_dir=None,
                    base_commit_id=None, **kwargs):
        """Upload a diff to the resource.

        The diff and parent_diff arguments should be strings containing the
        diff output.
        """
        return self.prepare_upload_diff_request(
            diff,
            parent_diff=parent_diff,
            base_dir=base_dir,
            base_commit_id=base_commit_id,
            **kwargs)
github reviewboard / rbtools / rbtools / api / resource.py View on Github external
    @request_method_decorator
    def validate_diff(self, repository, diff, parent_diff=None, base_dir=None,
                      base_commit_id=None, **kwargs):
        """Validate a diff."""
        request = self.prepare_upload_diff_request(
            diff,
            parent_diff=parent_diff,
            base_dir=base_dir,
            base_commit_id=base_commit_id,
            **kwargs)

        request.add_field('repository', repository)

        if base_commit_id:
            request.add_field('base_commit_id', base_commit_id)

        return request
github reviewboard / rbtools / rbtools / api / resource.py View on Github external
    @request_method_decorator
    def get_prev(self, **kwargs):
        if 'prev' not in self._links:
            raise StopIteration()

        return HttpRequest(self._links['prev']['href'], query_args=kwargs)
github reviewboard / rbtools / rbtools / api / resource.py View on Github external
    @request_method_decorator
    def get_self(self, **kwargs):
        """Generate an GET request for the resource list.

        This will return an HttpRequest to retrieve the list resource
        which this resource is a count for. Any query arguments used
        in the request for the count will still be present, only the
        'counts-only' argument will be removed
        """
        # TODO: Fix this. It is generating a new request
        # for a URL with 'counts-only' set to False, but
        # RB treats the  argument being set to any value
        # as true.
        kwargs.update({'counts_only': False})
        return HttpRequest(self._url, query_args=kwargs)
github reviewboard / rbtools / rbtools / api / resource.py View on Github external
    @request_method_decorator
    def _get_url(self, url, **kwargs):
        return HttpRequest(url, query_args=kwargs)