gerrit.utils package

Submodules

gerrit.utils.common module

gerrit.utils.common.check(fn)[source]
gerrit.utils.common.decode_response(response)[source]

Strip off Gerrit’s magic prefix and decode a response. :returns:

Decoded JSON content as a dict, or raw text if content could not be decoded as JSON.

Raises:

requests.HTTPError if the response contains an HTTP error status code.

gerrit.utils.common.params_creator(tuples, pattern_types, pattern_dispatcher)[source]
gerrit.utils.common.strip_trailing_slash(url)[source]

remove url’s trailing slash :param url: url :return:

gerrit.utils.entity module

class gerrit.utils.entity.Entity(**kwargs)[source]

Bases: object

optional = ()
required = ()

gerrit.utils.exceptions module

Module for custom exceptions.

Where possible we try to throw exceptions with non-generic, meaningful names.

exception gerrit.utils.exceptions.AuthError[source]

Bases: ClientError

403 Forbidden is returned if the operation is not allowed because the calling user does not have sufficient permissions.

exception gerrit.utils.exceptions.ClientError[source]

Bases: GerritAPIException

exception gerrit.utils.exceptions.ConflictError[source]

Bases: ClientError

409 Conflict is returned if the request cannot be completed because the current state of the resource doesn’t allow the operation.

exception gerrit.utils.exceptions.GerritAPIException[source]

Bases: Exception

Base class for all errors

exception gerrit.utils.exceptions.NotAllowedError[source]

Bases: ClientError

405 Method Not Allowed is returned if the resource exists but doesn’t support the operation.

exception gerrit.utils.exceptions.NotFoundError[source]

Bases: ClientError

Resource cannot be found

exception gerrit.utils.exceptions.ServerError[source]

Bases: GerritAPIException

exception gerrit.utils.exceptions.UnauthorizedError[source]

Bases: GerritAPIException

401 Unauthorized

exception gerrit.utils.exceptions.UnknownBranch[source]

Bases: KeyError, NotFoundError

Gerrit does not recognize the branch requested.

exception gerrit.utils.exceptions.UnknownFile[source]

Bases: KeyError, NotFoundError

Gerrit does not recognize the revision file requested.

exception gerrit.utils.exceptions.UnknownTag[source]

Bases: KeyError, NotFoundError

Gerrit does not recognize the tag requested.

exception gerrit.utils.exceptions.ValidationError[source]

Bases: ClientError

400 Bad Request is returned if the request is not understood by the server due to malformed syntax. E.g. 400 Bad Request is returned if JSON input is expected but the ‘Content-Type’ of the request

is not ‘application/json’ or the request body doesn’t contain valid JSON.

400 Bad Request is also returned if required input fields are not set or if options are set which cannot be used together.

gerrit.utils.models module

class gerrit.utils.models.BaseModel(json=None, **kwargs)[source]

Bases: object

classmethod parse_dict(data, **kwargs)[source]

Parse a dict of JSON objects into a result set of model instances.

classmethod parse_list(data, **kwargs)[source]

Parse a list of JSON objects into a result set of model instances.

to_dict()[source]
class gerrit.utils.models.ResultSet(iterable=(), /)[source]

Bases: list

A list like object that holds results from a Gerrit API query.

gerrit.utils.requester module

class gerrit.utils.requester.Requester(**kwargs)[source]

Bases: object

A class which carries out HTTP requests. You can replace this class with one of your own implementation if you require some other way to access Gerrit. This default class can handle simple authentication only.

VALID_STATUS_CODES = [200]
static confirm_status(res)[source]

check response status code :param res: :return:

delete(url, headers=None, allow_redirects=True, **kwargs)[source]
Parameters:
  • url

  • headers

  • allow_redirects

  • kwargs

Returns:

get(url, params=None, headers=None, allow_redirects=True, stream=False, **kwargs)[source]
Parameters:
  • url

  • params

  • headers

  • allow_redirects

  • stream

  • kwargs

Returns:

get_request_dict(params=None, data=None, json=None, headers=None, **kwargs)[source]
Parameters:
  • params

  • data

  • json

  • headers

  • kwargs

Returns:

post(url, params=None, data=None, json=None, files=None, headers=None, allow_redirects=True, **kwargs)[source]
Parameters:
  • url

  • params

  • data

  • json

  • files

  • headers

  • allow_redirects

  • kwargs

Returns:

put(url, params=None, data=None, json=None, files=None, headers=None, allow_redirects=True, **kwargs)[source]
Parameters:
  • url

  • params

  • data

  • json

  • files

  • headers

  • allow_redirects

  • kwargs

Returns:

Module contents