rest Package

rest Package

Interface to the Gerrit REST API.

class pygerrit.rest.GerritRestAPI(url, auth=None, verify=True)[source]

Bases: object

Interface to the Gerrit REST API.

Parameters:
  • url (str) – The full URL to the server, including the http(s):// prefix. If auth is given, url will be automatically adjusted to include Gerrit’s authentication suffix.
  • auth – (optional) Authentication handler. Must be derived from requests.auth.AuthBase.
  • verify (boolean) – (optional) Set to False to disable verification of SSL certificates.
delete(endpoint, **kwargs)[source]

Send HTTP DELETE to the endpoint.

Parameters:endpoint (str) – The endpoint to send to.
Returns:JSON decoded result.
Raises :requests.RequestException on timeout or connection error.
get(endpoint, **kwargs)[source]

Send HTTP GET to the endpoint.

Parameters:endpoint (str) – The endpoint to send to.
Returns:JSON decoded result.
Raises :requests.RequestException on timeout or connection error.
make_url(endpoint)[source]

Make the full url for the endpoint.

Parameters:endpoint (str) – The endpoint.
Returns:The full url.
post(endpoint, **kwargs)[source]

Send HTTP POST to the endpoint.

Parameters:endpoint (str) – The endpoint to send to.
Returns:JSON decoded result.
Raises :requests.RequestException on timeout or connection error.
put(endpoint, **kwargs)[source]

Send HTTP PUT to the endpoint.

Parameters:endpoint (str) – The endpoint to send to.
Returns:JSON decoded result.
Raises :requests.RequestException on timeout or connection error.
review(change_id, revision, review)[source]

Submit a review.

Parameters:
  • change_id (str) – The change ID.
  • revision (str) – The revision.
  • review (str) – The review details as a GerritReview.
Returns:

JSON decoded result.

Raises :

requests.RequestException on timeout or connection error.

class pygerrit.rest.GerritReview(message=None, labels=None, comments=None)[source]

Bases: object

Encapsulation of a Gerrit review.

Parameters:
  • message (str) – (optional) Cover message.
  • labels (dict) – (optional) Review labels.
  • comments (dict) – (optional) Inline comments.
add_comments(comments)[source]

Add inline comments.

Parameters:comments (dict) – Comments to add.

Usage:

add_comments([{'filename': 'Makefile',
               'line': 10,
               'message': 'inline message'}])

add_comments([{'filename': 'Makefile',
               'range': {'start_line': 0,
                         'start_character': 1,
                         'end_line': 0,
                         'end_character': 5},
               'message': 'inline message'}])
add_labels(labels)[source]

Add labels.

Parameters:labels (dict) – Labels to add, for example

Usage:

add_labels({'Verified': 1,
            'Code-Review': -1})
set_message(message)[source]

Set review cover message.

Parameters:message (str) – Cover message.

auth Module

Authentication handlers.

class pygerrit.rest.auth.HTTPBasicAuthFromNetrc(url)[source]

Bases: requests.auth.HTTPBasicAuth

HTTP Basic Auth with netrc credentials.

class pygerrit.rest.auth.HTTPDigestAuthFromNetrc(url)[source]

Bases: requests.auth.HTTPDigestAuth

HTTP Digest Auth with netrc credentials.

Table Of Contents

Previous topic

pygerrit Package

This Page