Beispiel #1
0
    def multiple(parameters):
        """Retrieve a single extension by key or all extensions.

           key : KEY : string

           Retrieve only the extension with the given key.  This is equivalent
           to accessing /api/v1/extensions/EXTENSION_ID with that extension's
           numeric id.  When used, other parameters are ignored.

           installed_by : INSTALLED_BY : integer or string

           Retrieve only extensions installed by the specified user.  The user
           can be identified by numeric id or username."""

        key_parameter = parameters.getQueryParameter("key")
        if key_parameter:
            return api.extension.fetch(parameters.critic, key=key_parameter)

        installed_by = jsonapi.from_parameter("v1/users", "installed_by",
                                              parameters)

        return api.extension.fetchAll(parameters.critic,
                                      publisher=jsonapi.deduce(
                                          "v1/users", parameters),
                                      installed_by=installed_by)
Beispiel #2
0
    def multiple(parameters):
        """Retrieve a single extension by key or all extensions.

           key : KEY : string

           Retrieve only the extension with the given key.  This is equivalent
           to accessing /api/v1/extensions/EXTENSION_ID with that extension's
           numeric id.  When used, other parameters are ignored.

           installed_by : INSTALLED_BY : integer or string

           Retrieve only extensions installed by the specified user.  The user
           can be identified by numeric id or username."""

        key_parameter = parameters.getQueryParameter("key")
        if key_parameter:
            return api.extension.fetch(parameters.critic, key=key_parameter)

        installed_by = jsonapi.from_parameter(
            "v1/users", "installed_by", parameters)

        return api.extension.fetchAll(
            parameters.critic,
            publisher=jsonapi.deduce("v1/users", parameters),
            installed_by=installed_by)
Beispiel #3
0
    def multiple(parameters):
        """Retrieve all reviewable file changes in a review.

           review : REVIEW_ID : -

           Retrieve the reviewable changes in the specified review.

           changeset : CHANGESET_ID : -

           Retrieve the reviewable changes in the specified changeset.

           file : FILE : -

           Retrieve the reviewable changes in the specified file only.

           assignee : USER : -

           Retrieve reviewable changes assigned to the specified user only.

           state : STATE : "pending" or "reviewed"

           Retrieve reviewable changes in the specified state only."""

        review = jsonapi.deduce("v1/reviews", parameters)
        changeset = jsonapi.deduce("v1/changesets", parameters)

        if not review:
            raise jsonapi.UsageError("Missing required parameter: review")

        file = jsonapi.from_parameter("v1/files", "file", parameters)
        assignee = jsonapi.from_parameter("v1/users", "assignee", parameters)
        state_parameter = parameters.getQueryParameter("state")

        if state_parameter is None:
            is_reviewed = None
        else:
            if state_parameter not in ("pending", "reviewed"):
                raise jsonapi.UsageError(
                    "Invalid parameter value: state=%r "
                    "(value values are 'pending' and 'reviewed')" %
                    state_parameter)
            is_reviewed = state_parameter == "reviewed"

        return api.reviewablefilechange.fetchAll(parameters.critic, review,
                                                 changeset, file, assignee,
                                                 is_reviewed)
Beispiel #4
0
    def multiple(parameters):
        """Retrieve all reviewable file changes in a review.

           review : REVIEW_ID : -

           Retrieve the reviewable changes in the specified review.

           changeset : CHANGESET_ID : -

           Retrieve the reviewable changes in the specified changeset.

           file : FILE : -

           Retrieve the reviewable changes in the specified file only.

           assignee : USER : -

           Retrieve reviewable changes assigned to the specified user only.

           state : STATE : "pending" or "reviewed"

           Retrieve reviewable changes in the specified state only."""

        review = jsonapi.deduce("v1/reviews", parameters)
        changeset = jsonapi.deduce("v1/changesets", parameters)

        if not review:
            raise jsonapi.UsageError("Missing required parameter: review")

        file = jsonapi.from_parameter("v1/files", "file", parameters)
        assignee = jsonapi.from_parameter("v1/users", "assignee", parameters)
        state_parameter = parameters.getQueryParameter("state")

        if state_parameter is None:
            is_reviewed = None
        else:
            if state_parameter not in ("pending", "reviewed"):
                raise jsonapi.UsageError(
                    "Invalid parameter value: state=%r "
                    "(value values are 'pending' and 'reviewed')"
                    % state_parameter)
            is_reviewed = state_parameter == "reviewed"

        return api.reviewablefilechange.fetchAll(
            parameters.critic, review, changeset, file, assignee, is_reviewed)
Beispiel #5
0
    def multiple(parameters):
        """Retrieve all batches in the system (or review.)

           review : REVIEW_ID : integer

           Retrieve only batches in the specified review.  Can only be used if a
           review is not specified in the resource path.

           author : AUTHOR : integer or string

           Retrieve only batches authored by the specified user, identified by
           the user's unique numeric id or user name.

           unpublished : UNPUBLISHED : 'yes'

           Retrieve a single batch representing the current user's unpublished
           changes to a review. Must be combined with `review` and cannot be
           combined with `author`."""

        critic = parameters.critic

        review = jsonapi.deduce("v1/reviews", parameters)
        author = jsonapi.from_parameter("v1/users", "author", parameters)

        unpublished_parameter = parameters.getQueryParameter("unpublished")
        if unpublished_parameter is not None:
            if unpublished_parameter == "yes":
                if author is not None:
                    raise jsonapi.UsageError(
                        "Parameters 'author' and 'unpublished' cannot be "
                        "combined")
                return api.batch.fetchUnpublished(critic, review)
            else:
                raise jsonapi.UsageError(
                    "Invalid 'unpublished' parameter: %r (must be 'yes')"
                    % unpublished_parameter)

        return api.batch.fetchAll(critic, review=review, author=author)
Beispiel #6
0
    def multiple(parameters):
        """Retrieve all comments in the system (or review.)

           with_reply : REPLY_ID : integer

           Retrieve only the comment to which the specified reply is a reply.
           This is equivalent to accessing /api/v1/comments/COMMENT_ID with that
           comment's numeric id.  When used, any other parameters are ignored.

           review : REVIEW_ID : integer

           Retrieve only comments in the specified review.  Can only be used if
           a review is not specified in the resource path.

           author : AUTHOR : integer or string

           Retrieve only comments authored by the specified user, identified by
           the user's unique numeric id or user name.

           comment_type : TYPE : -

           Retrieve only comments of the specified type.  Valid values are:
           <code>issue</code> and <code>note</code>.

           state : STATE : -

           Retrieve only issues in the specified state.  Valid values are:
           <code>open</code>, <code>addressed</code> and <code>resolved</code>.

           location_type : LOCATION : -

           Retrieve only comments in the specified type of location.  Valid
           values are: <code>general</code>, <code>commit-message</code> and
           <code>file-version</code>.

           changeset : CHANGESET_ID : integer

           Retrieve only comments visible in the specified changeset. Can not be
           combined with the <code>commit</code> parameter.

           commit : COMMIT : integer or string

           Retrieve only comments visible in the specified commit, either in its
           commit message or in the commit's version of a file. Combine with the
           <code>location_type</code> parameter to select only one of those
           possibilities. Can not be combined with the <code>changeset</code>
           parameter."""

        critic = parameters.critic

        reply = jsonapi.from_parameter("v1/replies", "with_reply", parameters)
        if reply:
            return reply.comment

        review = jsonapi.deduce("v1/reviews", parameters)
        author = jsonapi.from_parameter("v1/users", "author", parameters)

        comment_type_parameter = parameters.getQueryParameter("comment_type")
        if comment_type_parameter:
            if comment_type_parameter not in api.comment.Comment.TYPE_VALUES:
                raise jsonapi.UsageError("Invalid comment-type parameter: %r" %
                                         comment_type_parameter)
            comment_type = comment_type_parameter
        else:
            comment_type = None

        state_parameter = parameters.getQueryParameter("state")
        if state_parameter:
            if state_parameter not in api.comment.Issue.STATE_VALUES:
                raise jsonapi.UsageError("Invalid state parameter: %r" %
                                         state_parameter)
            state = state_parameter
        else:
            state = None

        location_type_parameter = parameters.getQueryParameter("location_type")
        if location_type_parameter:
            if location_type_parameter not in api.comment.Location.TYPE_VALUES:
                raise jsonapi.UsageError(
                    "Invalid location-type parameter: %r" %
                    location_type_parameter)
            location_type = location_type_parameter
        else:
            location_type = None

        changeset = jsonapi.deduce("v1/changesets", parameters)
        commit = jsonapi.deduce("v1/commits", parameters)

        if changeset and commit:
            raise jsonapi.UsageError(
                "Incompatible parameters: changeset and commit")

        return api.comment.fetchAll(critic,
                                    review=review,
                                    author=author,
                                    comment_type=comment_type,
                                    state=state,
                                    location_type=location_type,
                                    changeset=changeset,
                                    commit=commit)
Beispiel #7
0
 def get_commit(name):
     return jsonapi.from_parameter("v1/commits", name, parameters)
Beispiel #8
0
    def multiple(parameters):
        """Retrieve all comments in the system (or review.)

           with_reply : REPLY_ID : integer

           Retrieve only the comment to which the specified reply is a reply.
           This is equivalent to accessing /api/v1/comments/COMMENT_ID with that
           comment's numeric id.  When used, any other parameters are ignored.

           review : REVIEW_ID : integer

           Retrieve only comments in the specified review.  Can only be used if
           a review is not specified in the resource path.

           author : AUTHOR : integer or string

           Retrieve only comments authored by the specified user, identified by
           the user's unique numeric id or user name.

           comment_type : TYPE : -

           Retrieve only comments of the specified type.  Valid values are:
           <code>issue</code> and <code>note</code>.

           state : STATE : -

           Retrieve only issues in the specified state.  Valid values are:
           <code>open</code>, <code>addressed</code> and <code>resolved</code>.

           location_type : LOCATION : -

           Retrieve only comments in the specified type of location.  Valid
           values are: <code>general</code>, <code>commit-message</code> and
           <code>file-version</code>.

           changeset : CHANGESET_ID : integer

           Retrieve only comments visible in the specified changeset. Can not be
           combined with the <code>commit</code> parameter.

           commit : COMMIT : integer or string

           Retrieve only comments visible in the specified commit, either in its
           commit message or in the commit's version of a file. Combine with the
           <code>location_type</code> parameter to select only one of those
           possibilities. Can not be combined with the <code>changeset</code>
           parameter."""

        critic = parameters.critic

        reply = jsonapi.from_parameter("v1/replies", "with_reply", parameters)
        if reply:
            return reply.comment

        review = jsonapi.deduce("v1/reviews", parameters)
        author = jsonapi.from_parameter("v1/users", "author", parameters)

        comment_type_parameter = parameters.getQueryParameter("comment_type")
        if comment_type_parameter:
            if comment_type_parameter not in api.comment.Comment.TYPE_VALUES:
                raise jsonapi.UsageError("Invalid comment-type parameter: %r"
                                         % comment_type_parameter)
            comment_type = comment_type_parameter
        else:
            comment_type = None

        state_parameter = parameters.getQueryParameter("state")
        if state_parameter:
            if state_parameter not in api.comment.Issue.STATE_VALUES:
                raise jsonapi.UsageError(
                    "Invalid state parameter: %r" % state_parameter)
            state = state_parameter
        else:
            state = None

        location_type_parameter = parameters.getQueryParameter("location_type")
        if location_type_parameter:
            if location_type_parameter not in api.comment.Location.TYPE_VALUES:
                raise jsonapi.UsageError("Invalid location-type parameter: %r"
                                         % location_type_parameter)
            location_type = location_type_parameter
        else:
            location_type = None

        changeset = jsonapi.deduce("v1/changesets", parameters)
        commit = jsonapi.deduce("v1/commits", parameters)

        if changeset and commit:
            raise jsonapi.UsageError(
                "Incompatible parameters: changeset and commit")

        return api.comment.fetchAll(critic, review=review, author=author,
                                    comment_type=comment_type, state=state,
                                    location_type=location_type,
                                    changeset=changeset, commit=commit)