[copr] master: W: 67, 8: Unused variable 's' (unused-variable) (73f5a40)
by frostyx@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 73f5a401d47e5858a3517cf13b3ee7ad3b3a8361
Author: Jakub Kadl����k <jkadlcik(a)redhat.com>
Date: Wed Nov 18 13:18:13 2015 +0100
W: 67, 8: Unused variable 's' (unused-variable)
>---------------------------------------------------------------
python/copr/test/client_v2/test_net_client.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/python/copr/test/client_v2/test_net_client.py b/python/copr/test/client_v2/test_net_client.py
index 6f17500..826452f 100644
--- a/python/copr/test/client_v2/test_net_client.py
+++ b/python/copr/test/client_v2/test_net_client.py
@@ -55,7 +55,7 @@ class TestNetClient(object):
self.nc.request(self.base_url, method="non_existing_method")
# some coverage for Request error
- s = str(exc_info.value)
+ assert str(exc_info.value) is not None
with pytest.raises(ValueError):
# import ipdb; ipdb.set_trace()
assert exc_info.value.response_json
8 years, 5 months
[copr] master: Too few public methods (0/1) (too-few-public-methods) (9628bb9)
by frostyx@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 9628bb96531162a1de90a8ceaf2ffc594b96538a
Author: Jakub Kadl����k <jkadlcik(a)redhat.com>
Date: Wed Nov 18 12:53:38 2015 +0100
Too few public methods (0/1) (too-few-public-methods)
>---------------------------------------------------------------
python/copr/client/responses.py | 1 +
python/copr/client_v2/common.py | 1 +
python/copr/client_v2/resources.py | 1 +
python/copr/util.py | 1 +
4 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/python/copr/client/responses.py b/python/copr/client/responses.py
index 23f6016..45eb6d6 100644
--- a/python/copr/client/responses.py
+++ b/python/copr/client/responses.py
@@ -1,3 +1,4 @@
+# pylint: disable=R0903
"""
Wrappers for Copr api response.
Response classes provide convenient representation of received data
diff --git a/python/copr/client_v2/common.py b/python/copr/client_v2/common.py
index 8f64195..615ca6a 100644
--- a/python/copr/client_v2/common.py
+++ b/python/copr/client_v2/common.py
@@ -1,3 +1,4 @@
+# pylint: disable=R0903
# coding: utf-8
from copr.util import UnicodeMixin
diff --git a/python/copr/client_v2/resources.py b/python/copr/client_v2/resources.py
index 528b08a..2bbd963 100644
--- a/python/copr/client_v2/resources.py
+++ b/python/copr/client_v2/resources.py
@@ -1,3 +1,4 @@
+# pylint: disable=R0903
# coding: utf-8
from collections import Iterable
from six import with_metaclass
diff --git a/python/copr/util.py b/python/copr/util.py
index 632ebe8..f627f73 100644
--- a/python/copr/util.py
+++ b/python/copr/util.py
@@ -2,6 +2,7 @@
import sys
+# pylint: disable=R0903
class UnicodeMixin(object):
# http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/
"""Mixin class to handle defining the proper __str__/__unicode__
8 years, 5 months
[copr] master: Use % formatting in logging functions but pass the % parameters as arguments (8ea6b3c)
by frostyx@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 8ea6b3c4410bd9da422bdb86660506e208672ac2
Author: Jakub Kadl����k <jkadlcik(a)redhat.com>
Date: Wed Nov 18 12:46:13 2015 +0100
Use % formatting in logging functions but pass the % parameters as arguments
>---------------------------------------------------------------
python/copr/client/client.py | 1 +
python/copr/client_v2/net_client.py | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/python/copr/client/client.py b/python/copr/client/client.py
index ce7cd9b..01929b1 100644
--- a/python/copr/client/client.py
+++ b/python/copr/client/client.py
@@ -1,4 +1,5 @@
# -*- coding: UTF-8 -*-
+# pylint: disable=W1202
from __future__ import print_function
from __future__ import unicode_literals
diff --git a/python/copr/client_v2/net_client.py b/python/copr/client_v2/net_client.py
index 07e22bd..4e68100 100644
--- a/python/copr/client_v2/net_client.py
+++ b/python/copr/client_v2/net_client.py
@@ -1,4 +1,5 @@
# coding: utf-8
+# pylint: disable=W1202
from collections import namedtuple
import json
8 years, 5 months
[copr] master: W: 70,12: Unused variable 'x' (unused-variable) (857414a)
by frostyx@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 857414a8ddaad181303648ee55c52294495e8e04
Author: Jakub Kadl����k <jkadlcik(a)redhat.com>
Date: Wed Nov 18 13:04:26 2015 +0100
W: 70,12: Unused variable 'x' (unused-variable)
>---------------------------------------------------------------
python/copr/test/client_v2/test_net_client.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/python/copr/test/client_v2/test_net_client.py b/python/copr/test/client_v2/test_net_client.py
index c574d37..6f17500 100644
--- a/python/copr/test/client_v2/test_net_client.py
+++ b/python/copr/test/client_v2/test_net_client.py
@@ -58,4 +58,4 @@ class TestNetClient(object):
s = str(exc_info.value)
with pytest.raises(ValueError):
# import ipdb; ipdb.set_trace()
- x = exc_info.value.response_json
+ assert exc_info.value.response_json
8 years, 5 months
[copr] master: [python] add Entity tests (177ef3a)
by frostyx@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 177ef3a473b3a7576b2620fed55e3e74dac35bc6
Author: Jakub Kadl����k <jkadlcik(a)redhat.com>
Date: Wed Nov 18 12:31:32 2015 +0100
[python] add Entity tests
>---------------------------------------------------------------
python/copr/test/client_v2/test_entities.py | 40 +++++++++++++++++++++++++++
1 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/python/copr/test/client_v2/test_entities.py b/python/copr/test/client_v2/test_entities.py
new file mode 100644
index 0000000..44b008d
--- /dev/null
+++ b/python/copr/test/client_v2/test_entities.py
@@ -0,0 +1,40 @@
+# coding: utf-8
+# pylint: disable=E1101, C0102
+import pytest
+from copr.client_v2.schemas import Schema, fields
+from copr.client_v2.entities import Entity
+
+
+class FooSchema(Schema):
+ foo = fields.Str()
+ bar = fields.Int()
+
+
+class FooEntity(Entity):
+ _schema = FooSchema()
+
+
+class TestEntities(object):
+
+ entity = None
+
+ # pylint: disable=W0613
+ def setup_method(self, method):
+ self.entity = FooEntity.from_dict({"foo": "baz", "bar": 123, "non_existing_attribute": None})
+
+ def test_from_dict(self):
+ assert self.entity.foo == "baz"
+ assert self.entity.bar == 123
+ assert not hasattr(self.entity, "non_existing_attribute")
+
+ with pytest.raises(AttributeError):
+ assert self.entity.non_existing_attribute
+
+ def test_to_dict(self):
+ assert set(self.entity.to_dict().items()) == \
+ set([("foo", "baz"), ("bar", 123)])
+
+ def test_to_json(self):
+ assert self.entity.to_json() == \
+ '{"foo": "baz", "bar": 123}'
+
8 years, 5 months
[copr] master: Instance of '...Entity' has no '...' member (no-member) (da604f5)
by frostyx@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit da604f5c707617840121f19c8a93eeada4be77d6
Author: Jakub Kadl����k <jkadlcik(a)redhat.com>
Date: Wed Nov 18 12:39:34 2015 +0100
Instance of '...Entity' has no '...' member (no-member)
>---------------------------------------------------------------
python/copr/client_v2/entities.py | 1 +
python/copr/client_v2/resources.py | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/python/copr/client_v2/entities.py b/python/copr/client_v2/entities.py
index 5e0597a..e62c91e 100644
--- a/python/copr/client_v2/entities.py
+++ b/python/copr/client_v2/entities.py
@@ -39,6 +39,7 @@ class Link(UnicodeMixin):
}
+# pylint: disable=E1101
class Entity(UnicodeMixin):
_schema = EmptySchema()
diff --git a/python/copr/client_v2/resources.py b/python/copr/client_v2/resources.py
index d0d1370..528b08a 100644
--- a/python/copr/client_v2/resources.py
+++ b/python/copr/client_v2/resources.py
@@ -41,6 +41,7 @@ class EntityFieldsMetaClass(type):
return type.__new__(mcs, class_name, bases, class_attrs)
+# pylint: disable=E1101
class IndividualResource(with_metaclass(EntityFieldsMetaClass, UnicodeMixin)):
"""
:type handle: client_v2.handlers.AbstractHandle or None
8 years, 5 months
[copr] master: workaround for BZ 1283101 (2e51251)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 2e512518b230af9dd5b108d1ec6968946818ded7
Author: Miroslav Such�� <msuchy(a)redhat.com>
Date: Wed Nov 18 10:44:13 2015 +0100
workaround for BZ 1283101
>---------------------------------------------------------------
dist-git/dist_git/srpm_import.py | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/dist-git/dist_git/srpm_import.py b/dist-git/dist_git/srpm_import.py
index ec015a2..f99846c 100644
--- a/dist-git/dist_git/srpm_import.py
+++ b/dist-git/dist_git/srpm_import.py
@@ -86,7 +86,8 @@ def actual_do_git_srpm_import(opts, src_filepath, task, tmp_dir, result):
log.info("save the source files into lookaside cache")
commands.upload(upload_files, replace=True)
log.debug("git push")
- message = "Import of {} {}".format(task.package_name, task.package_version)
+ #message = "Import of {} {}".format(task.package_name, task.package_version)
+ message = "import_srpm"
try:
commands.commit(message)
commands.push()
8 years, 5 months
[copr] master: use the same variable as defined in route (0b900e1)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 0b900e1dbf5782c568f7dc88021db8ba57336d43
Author: Miroslav Such�� <msuchy(a)redhat.com>
Date: Wed Nov 18 10:41:59 2015 +0100
use the same variable as defined in route
>---------------------------------------------------------------
.../coprs/views/tmp_ns/tmp_general.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/views/tmp_ns/tmp_general.py b/frontend/coprs_frontend/coprs/views/tmp_ns/tmp_general.py
index 4571447..8feda21 100644
--- a/frontend/coprs_frontend/coprs/views/tmp_ns/tmp_general.py
+++ b/frontend/coprs_frontend/coprs/views/tmp_ns/tmp_general.py
@@ -3,7 +3,7 @@ import os
from coprs.views.tmp_ns import tmp_ns
from coprs import app
-(a)tmp_ns.route("/<directory>/<file>")
+(a)tmp_ns.route("/<directory>/<file_path>")
def give_srpm(directory, file_path):
path = os.path.join(app.config["SRPM_STORAGE_DIR"], directory)
return flask.send_from_directory(path, file_path)
8 years, 5 months
[copr] master: [python] initial documentation for ClientV2 (b5c406e)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit b5c406e4ed7db8e5b6d0d38c1117a6bf57ffb535
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Tue Nov 17 23:13:24 2015 +0100
[python] initial documentation for ClientV2
>---------------------------------------------------------------
python/copr/client_v2/client.py | 30 ++++++++++--
python/copr/client_v2/handlers.py | 39 ++++++++++-----
python/copr/client_v2/net_client.py | 7 ++-
python/copr/client_v2/resources.py | 29 +++++++++--
python/docs/ClientV1.rst | 21 ++++++++
python/docs/ClientV2.rst | 31 ++++++++++++
python/docs/{ => client_v1}/CoprClient.rst | 0
python/docs/{ => client_v1}/Examples.rst | 0
python/docs/{ => client_v1}/Responses.rst | 0
python/docs/client_v2/errors.rst | 4 ++
python/docs/client_v2/general.rst | 16 ++++++
python/docs/client_v2/handlers.rst | 23 +++++++++
python/docs/client_v2/initialization.rst | 14 +++++
python/docs/client_v2/project.rst | 72 ++++++++++++++++++++++++++++
python/docs/client_v2/resources.rst | 9 ++++
python/docs/client_v2/resources_usage.rst | 53 ++++++++++++++++++++
python/docs/index.rst | 64 +-----------------------
python/docs/installation.rst | 28 +++++++++++
18 files changed, 354 insertions(+), 86 deletions(-)
diff --git a/python/copr/client_v2/client.py b/python/copr/client_v2/client.py
index afa7045..95ff21c 100644
--- a/python/copr/client_v2/client.py
+++ b/python/copr/client_v2/client.py
@@ -78,10 +78,10 @@ class CoprClient(UnicodeMixin, HandlersProvider):
:param bool no_config: helper flag to indicate that no config was provided
Could be created:
- - using static method :py:meth:`CoprClient.create_from_file_config`
- - using static method :py:meth:`CoprClient.create_from_params`
+ - using static method :meth:`~copr.client_v2.client.CoprClient.create_from_file_config`
+ - using static method :meth:`~copr.client_v2.client.CoprClient.create_from_params`
- If you create Client directly call post_init() method after the creation.
+ If you create Client directly call :meth:`CoprClient.post_init` method after the creation.
"""
def __init__(self, net_client, root_url=None, no_config=False):
@@ -110,21 +110,33 @@ class CoprClient(UnicodeMixin, HandlersProvider):
@property
def projects(self):
+ """
+ :rtype: :py:class:`~copr.client_v2.handlers.ProjectHandle`
+ """
self._check_client_init()
return self._projects
@property
def project_chroots(self):
+ """
+ :rtype: :py:class:`~copr.client_v2.handlers.ProjectChrootHandle`
+ """
self._check_client_init()
return self._project_chroots
@property
def builds(self):
+ """
+ :rtype: :py:class:`~copr.client_v2.handlers.BuildHandle`
+ """
self._check_client_init()
return self._builds
@property
def mock_chroots(self):
+ """
+ :rtype: :py:class:`~copr.client_v2.handlers.MockChrootHandle`
+ """
self._check_client_init()
return self._mock_chroots
@@ -143,6 +155,14 @@ class CoprClient(UnicodeMixin, HandlersProvider):
@classmethod
def create_from_params(cls, root_url=None, login=None, token=None):
+ """ Create client instance using the given parameters
+
+ :param str root_url: Url to the Copr service, default: "http://copr.fedoraproject.org"
+ :param str login: api login
+ :param str token: api token
+
+ :rtype: :py:class:`.client_v2.client.CoprClient`
+ """
nc = NetClient(login, token)
client = cls(nc, root_url, no_config=True)
client.post_init()
@@ -160,7 +180,7 @@ class CoprClient(UnicodeMixin, HandlersProvider):
:param bool ignore_error: When true and config is missing,
creates default Client without credentionals
- :rtype: :py:class:`~.client.CoprClient`
+ :rtype: :py:class:`.client_v2.client.CoprClient`
"""
raw_config = configparser.ConfigParser()
if not filepath:
@@ -196,6 +216,8 @@ class CoprClient(UnicodeMixin, HandlersProvider):
return client
def post_init(self):
+ """ Finalizes client initialization be querying API root info
+ """
log.debug("Getting root resources")
diff --git a/python/copr/client_v2/handlers.py b/python/copr/client_v2/handlers.py
index 67c6be9..9978ace 100644
--- a/python/copr/client_v2/handlers.py
+++ b/python/copr/client_v2/handlers.py
@@ -180,13 +180,14 @@ class ProjectHandle(AbstractHandle):
return self._base_url
def get_list(self, search_query=None, owner=None, name=None, limit=None, offset=None):
- """
- :param search_query:
- :param owner:
- :param name:
- :param limit:
- :param offset:
- :rtype: ProjectsList
+ """ Retrieves projects object according to the given parameters
+ :param str search_query: search projects with such string
+ :param str owner: owner username
+ :param str name: project name
+ :param int limit: limit number of projects
+ :param int offset: number of projects to skip
+
+ :rtype: :py:class:`~.resources.ProjectsList`
"""
options = {
"search_query": search_query,
@@ -199,15 +200,18 @@ class ProjectHandle(AbstractHandle):
response = self.nc.request(self.get_base_url(), query_params=options)
return ProjectsList.from_response(self, response, options)
- def get_one(self, project_id, show_builds=False, show_chroots=False):
- """
+ def get_one(self, project_id):
+ # todo: implement: , show_builds=False, show_chroots=False):
+ """ Retrieves project object.
+
:type project_id: int
+ :rtype: :py:class:`~.resources.Project`
"""
query_params = {
- "show_builds": show_builds,
- "show_chroots": show_chroots
+ # "show_builds": show_builds,
+ # "show_chroots": show_chroots
}
- # import ipdb; ipdb.set_trace()
+
url = "{}/{}".format(self.get_base_url(), project_id)
response = self.nc.request(url, query_params=query_params)
return Project.from_response(
@@ -218,8 +222,10 @@ class ProjectHandle(AbstractHandle):
)
def update(self, project_entity):
- """
+ """ Updates project.
+
:type project_entity: ProjectEntity
+ :rtype: OperationResult
"""
url = "{}/{}".format(self.get_base_url(), project_entity.id)
data = project_entity.to_json()
@@ -228,6 +234,11 @@ class ProjectHandle(AbstractHandle):
return OperationResult(self, response)
def delete(self, project_id):
+ """ Deletes project.
+
+ :param int project_id: project identifier
+ :rtype: OperationResult
+ """
url = "{}/{}".format(self.get_base_url(), project_id)
response = self.nc.request(url, method="delete", do_auth=True)
return OperationResult(self, response, expected_status=204)
@@ -292,6 +303,8 @@ class ProjectChrootHandle(AbstractHandle):
def enable(self, project, name, buildroot_pkgs=None):
"""
:type project: copr.client_v2.resources.Project
+
+ :rtype:
"""
new_entity = ProjectChrootEntity(
diff --git a/python/copr/client_v2/net_client.py b/python/copr/client_v2/net_client.py
index d58ec4b..07e22bd 100644
--- a/python/copr/client_v2/net_client.py
+++ b/python/copr/client_v2/net_client.py
@@ -94,8 +94,8 @@ class NetClient(object):
"""
Abstraction around python-requests
- :param unicode login: login for BasicAuth
- :param unicode password: password for BasicAuth
+ :param str login: login for BasicAuth
+ :param str password: password for BasicAuth
"""
def __init__(self, login=None, password=None):
@@ -120,6 +120,9 @@ class NetClient(object):
data=data, do_auth=do_auth, headers=headers)
def request(self, url, method=None, query_params=None, data=None, do_auth=False, headers=None):
+ """
+ :raises: RequestError
+ """
if method is None:
method = "get"
diff --git a/python/copr/client_v2/resources.py b/python/copr/client_v2/resources.py
index 0412548..d0d1370 100644
--- a/python/copr/client_v2/resources.py
+++ b/python/copr/client_v2/resources.py
@@ -144,13 +144,23 @@ class Project(IndividualResource):
self._handle = handle
def update(self):
+ """ Updates project using the current state.
+
+ Shortcut for for :py:meth:`.ProjectHandle.update`
+
+ :rtype: :py:class:`~copr.client_v2.resources.OperationResult`
+ """
return self._handle.update(self._entity)
def delete(self):
+ """ Updates project using the current state
+
+ :rtype: :py:class:`~copr.client_v2.resources.OperationResult`
+ """
return self._handle.delete(self.id)
def get_self(self):
- return self._handle.get_one(self.id, **self._options)
+ return self._handle.get_one(self.id)
def get_project_chroot(self, name):
handle = self._handle.get_project_chroots_handle()
@@ -160,9 +170,13 @@ class Project(IndividualResource):
handle = self._handle.get_project_chroots_handle()
return handle.get_list(self)
- def enable_project_chroot(self, *args, **kwargs):
+ def enable_project_chroot(self, name):
+ """
+ :param str name: mock chroot name
+ :rtype: :py:class:`~copr.client_v2.resources.OperationResult`
+ """
handle = self._handle.get_project_chroots_handle()
- return handle.enable(self, *args, **kwargs)
+ return handle.enable(self, name)
# TODO: remove proxy methods on the handle classes
def create_build_from_file(self, *args, **kwargs):
@@ -319,6 +333,7 @@ class ProjectsList(CollectionResource):
@property
def projects(self):
+ """ :rtype: list of :py:class:`~.resources.Project` """
return self._individuals
@classmethod
@@ -335,7 +350,7 @@ class ProjectsList(CollectionResource):
)
for dict_part in data_dict["projects"]
],
- options=None
+ options=options
)
return result
@@ -365,7 +380,8 @@ class BuildList(CollectionResource):
data_dict=dict_part,
)
for dict_part in data_dict["builds"]
- ]
+ ],
+ options=options
)
return result
@@ -432,5 +448,6 @@ class MockChrootList(CollectionResource):
data_dict=dict_part,
)
for dict_part in data_dict["chroots"]
- ]
+ ],
+ options=options
)
diff --git a/python/docs/ApiV2.rst b/python/docs/ApiV2.rst
deleted file mode 100644
index e69de29..0000000
diff --git a/python/docs/ClientV1.rst b/python/docs/ClientV1.rst
new file mode 100644
index 0000000..b95bdbb
--- /dev/null
+++ b/python/docs/ClientV1.rst
@@ -0,0 +1,21 @@
+Legacy client
+=============
+
+All interaction are done through copr.CoprClient.
+It can be created directly or using config file :file:`/etc/copr.conf`
+
+*CoprClient* offers methods that directly reflect Copr api. Received data
+are wrapped into the Response object.
+Depending on used methods Responses will have different set of
+provided attributes and methods.
+
+.. toctree::
+ client_v1/Examples
+
+See method signatures and response objects in
+the auto generated documentation:
+
+
+.. toctree::
+ client_v1/CoprClient
+ client_v1/Responses
diff --git a/python/docs/ClientV2.rst b/python/docs/ClientV2.rst
new file mode 100644
index 0000000..8925854
--- /dev/null
+++ b/python/docs/ClientV2.rst
@@ -0,0 +1,31 @@
+Client version 2
+================
+
+New package copr.ClientV2 supports APIv2 and should eventually replace older one.
+New API and Client_v2 provides more simple and uniform approach for communication with the Copr service.
+
+
+
+
+Client mostly reflects resource based API nature. Client object offers range of methods to query from service.
+Response objects contains requested information and also provides helper methods to execute new requests in the context
+of retrieved objects.
+
+
+.. toctree::
+ :maxdepth: 1
+
+ client_v2/initialization.rst
+ client_v2/resources_usage.rst
+ client_v2/errors.rst
+ client_v2/project.rst
+
+
+Autodoc
+-------
+
+.. toctree::
+
+ client_v2/general.rst
+ client_v2/handlers.rst
+ client_v2/resources.rst
diff --git a/python/docs/CoprClient.rst b/python/docs/client_v1/CoprClient.rst
similarity index 100%
rename from python/docs/CoprClient.rst
rename to python/docs/client_v1/CoprClient.rst
diff --git a/python/docs/Examples.rst b/python/docs/client_v1/Examples.rst
similarity index 100%
rename from python/docs/Examples.rst
rename to python/docs/client_v1/Examples.rst
diff --git a/python/docs/Responses.rst b/python/docs/client_v1/Responses.rst
similarity index 100%
rename from python/docs/Responses.rst
rename to python/docs/client_v1/Responses.rst
diff --git a/python/docs/client_v2/errors.rst b/python/docs/client_v2/errors.rst
new file mode 100644
index 0000000..15b44dc
--- /dev/null
+++ b/python/docs/client_v2/errors.rst
@@ -0,0 +1,4 @@
+Error handling
+==============
+
+.. todo:: implement
diff --git a/python/docs/client_v2/general.rst b/python/docs/client_v2/general.rst
new file mode 100644
index 0000000..23d1001
--- /dev/null
+++ b/python/docs/client_v2/general.rst
@@ -0,0 +1,16 @@
+General
+=======
+
+.. autofunction:: copr.create_client2_from_params
+.. autofunction:: copr.create_client2_from_file_config
+
+
+CoprClient
+==========
+
+
+.. autoclass:: copr.client_v2.client.CoprClient
+ :members: projects, builds, project_chroots, mock_chroots, create_from_file_config, create_from_params, post_init
+ :undoc-members:
+
+
diff --git a/python/docs/client_v2/handlers.rst b/python/docs/client_v2/handlers.rst
new file mode 100644
index 0000000..e830dc1
--- /dev/null
+++ b/python/docs/client_v2/handlers.rst
@@ -0,0 +1,23 @@
+Handlers
+========
+
+.. autoclass:: copr.client_v2.handlers.ProjectHandle
+ :members: get_list, get_one, update, delete
+ :undoc-members:
+
+.. autoclass:: copr.client_v2.handlers.ProjectChrootHandle
+ :members: get_list, get_one
+ :undoc-members:
+
+
+.. autoclass:: copr.client_v2.handlers.BuildHandle
+ :members: get_list, get_one
+ :undoc-members:
+
+.. autoclass:: copr.client_v2.handlers.MockChrootHandle
+ :members: get_list, get_one
+ :undoc-members:
+
+
+
+
diff --git a/python/docs/client_v2/initialization.rst b/python/docs/client_v2/initialization.rst
new file mode 100644
index 0000000..e241dc8
--- /dev/null
+++ b/python/docs/client_v2/initialization.rst
@@ -0,0 +1,14 @@
+Client initialization
+=====================
+
+To create client instance use either of two functions:
+ - :py:meth:`copr.create_client2_from_params`
+ - :py:meth:`copr.create_client2_from_file_config`
+
+Config file should be generated by the Copr service itself (`Api info page`_). Don't forget to login.
+
+
+
+
+
+.. _`Api info page`: https://copr.fedoraproject.org/api/
diff --git a/python/docs/client_v2/project.rst b/python/docs/client_v2/project.rst
new file mode 100644
index 0000000..9d3cb48
--- /dev/null
+++ b/python/docs/client_v2/project.rst
@@ -0,0 +1,72 @@
+Project
+=======
+
+Access to project resources is done through :py:meth:`~copr.client_v2.client.CoprClient.projects`.
+property of initialized :py:class:`~copr.client_v2.client.CoprClient`.
+
+Individual Attributes
+---------------------
+
+.. copied from frontend docs, don't forget to update
+
+================== ==================== ========= =================================================================================
+Field Type Can edit? Description
+================== ==================== ========= =================================================================================
+id number no unique identifier
+owner string no username of the project owner
+group string no name of the group which owns the project, value is null for non-group projects
+ - MAY be specified during a project creation to create a group managed project
+name string no name of the project
+ - MUST be specified during a project creation
+description string yes project description
+instructions string yes installation instructions
+homepage string(URL) yes project homepage URL
+contact string(URL or email) yes contact with the project maintainer
+disable_createrepo bool yes disables automatic repository metadata generation
+build_enable_net bool yes set default value for new builds option `enable_net`
+repos list of string yes list of additional repositories to be enabled during the build
+================== ==================== ========= =================================================================================
+
+
+.. note:: all following examples assume that we use `cl` as an instance of :py:class:`.client_v2.client.CoprClient`
+
+Get one project
+---------------
+
+ .. sourcecode:: python
+
+ >>> p = cl.projects.get_one(1835)
+
+Modify project parameters
+-------------------------
+
+ .. sourcecode:: python
+
+ >>> p.description = "Nothing"
+ >>> p.update()
+
+Delete project
+--------------
+
+ .. sourcecode:: python
+
+ >>> p.delete()
+
+Create new project
+------------------
+
+ .. todo:: Not Implemented yet
+
+
+Fetch projects
+--------------
+
+ .. sourcecode:: python
+
+ >>> plist_1 = cl.project.get_list(limit=10)
+ # filter by name
+ >>> plist_2 = cl.project.get_list(name="copr")
+ # search by string
+ >>> plist_2 = cl.project.get_list(name="copr")
+
+
diff --git a/python/docs/client_v2/resources.rst b/python/docs/client_v2/resources.rst
new file mode 100644
index 0000000..3693426
--- /dev/null
+++ b/python/docs/client_v2/resources.rst
@@ -0,0 +1,9 @@
+Resources
+=========
+
+.. autoclass:: copr.client_v2.resources.Project
+ :members: update, delete
+ :undoc-members:
+
+.. autoclass:: copr.client_v2.resources.ProjectsList
+ :members:
diff --git a/python/docs/client_v2/resources_usage.rst b/python/docs/client_v2/resources_usage.rst
new file mode 100644
index 0000000..dc95fa2
--- /dev/null
+++ b/python/docs/client_v2/resources_usage.rst
@@ -0,0 +1,53 @@
+Resources
+~~~~~~~~~
+
+Client represents API with two kinds of resources: Individuals and Collections. For example when we request
+all projects with name `copr` we would receive collection ProjectsList_ resource:
+
+ .. sourcecode:: python
+
+ >>> from copr import create_client2_from_params
+ # using dev server for test
+ >>> cl = create_client2_from_params(root_url="http://copr-fe-dev.cloud.fedoraproject.org/")
+
+ >>> projects = cl.projects.get_list(name="copr", limit=3)
+ >>> for p in projects:
+ >>> print(p)
+ <Project #1: msuchy/copr>
+ <Project #1503: vgologuz/copr>
+ <Project #2796: mosquito/copr>
+
+
+Access to elements in collection is done through iterator interface. Since API limits number of elements
+retrieved in the one request, collections has method `next_page()` to retrieve more objects:
+
+ .. sourcecode:: python
+
+ >>> more_projects = projects.next_page()
+ >>> for p in more_projects:
+ >>> print(p)
+ <Project #2805: esmil/copr>
+ <Project #4266: frostyx/copr>
+
+
+
+If we already knew project id we could get an individual Project_ resource:
+
+ .. sourcecode:: python
+
+ >>> p = cl.projects.get_one(1835)
+
+Individual resource allows to directly access entity properties and also provides some helper functions:
+
+ .. sourcecode:: python
+
+ >>> print(p.owner, p.name)
+ (u'saltstack', u'salt')
+ # obtain active build chroots
+ >>> print("\n".join(map(str, p.get_project_chroot_list())))
+ <Project chroot: fedora-22-x86_64, additional packages: [], comps size if any: 0>
+ <Project chroot: fedora-22-i386, additional packages: [], comps size if any: 0>
+ # change project description (require auth)
+ >>> p.description = u"Hello world!"
+ >>> p.update()
+
diff --git a/python/docs/index.rst b/python/docs/index.rst
index 0f3dcbe..d23535d 100644
--- a/python/docs/index.rst
+++ b/python/docs/index.rst
@@ -12,35 +12,7 @@ through its `API <http://copr.fedoraproject.org/api>`_.
Python-copr right now is in alpha stage, so expect lot of changes. Now it targets python 2.6+
and python3.3+.
-
-Installation
-============
-
-Dependencies:
--------------
-::
-
- python2.6+
- python-requests
- python-six
-
-repo
-----
-Available for fedora 21+
-::
-
- dnf install python-copr python-copr-doc
-
-source
-------
-
-.. code-block:: bash
-
- git clone https://git.fedorahosted.org/git/copr.git
- cd python
- # enable virtualenv if needed
- pip install -r requirements.txt
- python setup.py install
+.. include:: installation.rst
Contact
=======
@@ -59,38 +31,8 @@ Usage
Recently Copr started to offer an alternative REST-like APIv2_.
New API is provided by mostly independent `client_v2` package.
-Legacy client
--------------
-All interaction are done through copr.CoprClient.
-It can be created directly or using config file :file:`/etc/copr.conf`
-
-*CoprClient* offers methods that directly reflect Copr api. Received data
-are wrapped into the Response object.
-Depending on used methods Responses will have different set of
-provided attributes and methods.
-
-.. toctree::
- Examples
-
-See method signatures and response objects in
-the auto generated documentation:
-
-
-.. toctree::
- CoprClient
- Responses
-
-Client_v2
----------
-Main object for interaction is copr.ClientV2
-It can be created using either of two functions:
- - create_client2_from_params
- - create_client2_from_file_config
-
-New API and Client_v2 provides more simple and uniform approach for communication with the Copr service.
-See `auto-generated docs`_ and `usage examples`_
-
-
+.. include:: ClientV1.rst
+.. include:: ClientV2.rst
Indices and tables
diff --git a/python/docs/installation.rst b/python/docs/installation.rst
new file mode 100644
index 0000000..479de72
--- /dev/null
+++ b/python/docs/installation.rst
@@ -0,0 +1,28 @@
+Installation
+============
+
+Dependencies:
+-------------
+::
+
+ python2.6+
+ python-requests
+ python-six
+
+repo
+----
+Available for fedora 21+
+::
+
+ dnf install python-copr python-copr-doc
+
+source
+------
+
+.. code-block:: bash
+
+ git clone https://git.fedorahosted.org/git/copr.git
+ cd python
+ # enable virtualenv if needed
+ pip install -r requirements.txt
+ python setup.py install
8 years, 5 months