diff options
author | 2012-03-01 19:57:59 +0100 | |
---|---|---|
committer | 2012-03-01 19:57:59 +0100 | |
commit | b891dfb211f9a58e5d834ccd148943286c45f61c (patch) | |
tree | c90ab9489c5217151c1f1c716aea8fa39b303393 /pygithub3/services/base.py | |
parent | Repos.watchers service done (diff) | |
parent | Complete services.repos doc (diff) | |
download | python-github3-b891dfb211f9a58e5d834ccd148943286c45f61c.tar.xz python-github3-b891dfb211f9a58e5d834ccd148943286c45f61c.zip |
Merge branch 'docs'
Diffstat (limited to '')
-rw-r--r-- | pygithub3/services/base.py | 65 |
1 files changed, 60 insertions, 5 deletions
diff --git a/pygithub3/services/base.py b/pygithub3/services/base.py index 21b22eb..8602150 100644 --- a/pygithub3/services/base.py +++ b/pygithub3/services/base.py @@ -3,11 +3,39 @@ from pygithub3.core.client import Client from pygithub3.core.result import Result -from pygithub3.requests import Factory +from pygithub3.requests.base import Factory from pygithub3.core.errors import NotFound class Service(object): + """ + You can configure each service with this keyword variables: + + :param str login: Username to authenticate + :param str password: Username to authenticate + :param str user: Default username in requests + :param str repo: Default repository in requests + :param str token: Token to OAuth + :param int per_page: Items in each page of multiple returns + :param str base_url: To support another github-related API (untested) + :param stream verbose: Stream to write debug logs + + You can configure the **authentication** with BasicAuthentication (login + and password) and with `OAuth <http://developer.github.com/v3/oauth/>`_ ( + token). + If you include ``login``, ``password`` and ``token`` in config; Oauth has + precedence + + Some API requests need ``user`` and/or ``repo`` arguments (e.g + :ref:`repos service <config precedence>`). + You can configure the default value here to avoid repeating + + Some API requests return multiple resources with pagination. You can + configure how many items has each page. + + You can configure ``verbose`` logging like `requests library <http://docs. + python-requests.org/en/v0.10.6/user/advanced/#verbose-logging>`_ + """ def __init__(self, **config): self._client = Client(**config) @@ -17,18 +45,35 @@ class Service(object): return self._client.user def set_user(self, user): + """ Set user + + :param str user: Default username in requests + """ self._client.user = user def get_repo(self): return self._client.repo def set_repo(self, repo): + """ Set repository + + :param str repo: Default repository in requests + """ self._client.repo = repo def set_credentials(self, login, password): + """ Set Basic Authentication + + :param str login: Username to authenticate + :param str password: Username to authenticate + """ self._client.set_credentials(login, password) def set_token(self, token): + """ Set OAuth token + + :param str token: Token to OAuth + """ self._client.set_token(token) def make_request(self, request, **kwargs): @@ -90,6 +135,11 @@ class Service(object): class MimeTypeMixin(object): + """ + Mimetype support to Services + + Adds 4 public functions to service: + """ VERSION = 'beta' @@ -97,16 +147,21 @@ class MimeTypeMixin(object): self.mimetype = 'application/vnd.github.%s.%s+json' % ( self.VERSION, mimetype) - def set_raw_mimetype(self): + def set_raw(self): + """ Resource will have ``body`` attribute """ self.__set_mimetype('raw') - def set_text_mimetype(self): + def set_text(self): + """ Resource will have ``body_text`` attribute """ self.__set_mimetype('text') - def set_html_mimetype(self): + def set_html(self): + """ Resource will have ``body_html`` attribute """ self.__set_mimetype('html') - def set_full_mimetype(self): + def set_full(self): + """ Resource will have ``body`` ``body_text`` and ``body_html`` + attributes """ self.__set_mimetype('full') def _get_mimetype_as_header(self): |