[copr] master: Warn user if he use rpmfusion repository for building. (d2f9159)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit d2f915967fdee7515274da6e22510e17d9874881
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Sep 3 16:40:04 2015 +0200
Warn user if he use rpmfusion repository for building.
>---------------------------------------------------------------
.../coprs/views/coprs_ns/coprs_general.py | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py b/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
index a665099..7d90c0b 100644
--- a/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
+++ b/frontend/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
@@ -161,6 +161,7 @@ def copr_new(username):
db.session.commit()
flask.flash("New project has been created successfully.", "success")
+ _check_rpmfusion(copr.repos)
if form.initial_pkgs.data:
pkgs = form.initial_pkgs.data.replace("\n", " ").split(" ")
@@ -330,6 +331,11 @@ def copr_edit(username, coprname, form=None):
form=form)
+def _check_rpmfusion(repos):
+ if "rpmfusion" in repos:
+ message = flask.Markup('Using rpmfusion as dependency is nearly always wrong. Please see <a href="https://fedorahosted.org/copr/wiki/UserDocs#WhatIcanbuildinCopr">What I can build in Copr</a>.')
+ flask.flash(message, "error")
+
@coprs_ns.route("/<username>/<coprname>/update/", methods=["POST"])
@login_required
def copr_update(username, coprname):
@@ -361,6 +367,7 @@ def copr_update(username, coprname):
else:
flask.flash("Project has been updated successfully.", "success")
db.session.commit()
+ _check_rpmfusion(copr.repos)
return flask.redirect(flask.url_for("coprs_ns.copr_detail",
username=username,
8 years, 9 months
[copr] master: Give user hint how to give permission to somebody else (34def29)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 34def29f1291e34c8e62b73ce2c48face90a802d
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Sep 3 16:08:15 2015 +0200
Give user hint how to give permission to somebody else
>---------------------------------------------------------------
.../coprs/templates/coprs/detail/permissions.html | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/templates/coprs/detail/permissions.html b/frontend/coprs_frontend/coprs/templates/coprs/detail/permissions.html
index 994f742..f7256fd 100644
--- a/frontend/coprs_frontend/coprs/templates/coprs/detail/permissions.html
+++ b/frontend/coprs_frontend/coprs/templates/coprs/detail/permissions.html
@@ -16,5 +16,9 @@
{{ permissions_table(permissions, current_user_permissions, copr, permissions_applier_form, permissions_form) }}
{% else %}
<h3>No permissions yet</h3>
+ <p>You could not grant permission directly. First the other user have to navigate to this project and open this
+ tab. Then he can apply for permission. You will then receive email. Once you return to this page you can either
+ approve or reject this request.
+ </p>
{% endif %}
{% endblock %}
8 years, 9 months
[copr] master: [frontend][API] added query arg `show_chroots` for GET /api_2/builds/<build_id>; fix tests (babe31b)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit babe31b0ce1a78e02105dd472b0d37c83533a913
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Sep 3 15:39:33 2015 +0200
[frontend][API] added query arg `show_chroots` for GET /api_2/builds/<build_id>; fix tests
>---------------------------------------------------------------
frontend/coprs_frontend/coprs/rest_api/common.py | 25 ++++++++++++++++++-
.../coprs/rest_api/resources/build.py | 23 +++++++++++++++---
.../coprs/rest_api/resources/build_chroot.py | 21 +---------------
frontend/coprs_frontend/coprs/rest_api/schemas.py | 1 +
.../tests/test_api/test_build_chroot_r.py | 3 +-
.../coprs_frontend/tests/test_api/test_build_r.py | 15 ++++++++++++
6 files changed, 62 insertions(+), 26 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/rest_api/common.py b/frontend/coprs_frontend/coprs/rest_api/common.py
index da57710..124ed83 100644
--- a/frontend/coprs_frontend/coprs/rest_api/common.py
+++ b/frontend/coprs_frontend/coprs/rest_api/common.py
@@ -3,6 +3,8 @@ import base64
import datetime
import functools
from logging import getLogger
+from coprs.rest_api.schemas import BuildChrootSchema
+from coprs.rest_api.util import mm_serialize_one
log = getLogger(__name__)
@@ -27,11 +29,13 @@ def render_copr_chroot(chroot):
}
-def render_build(build):
+def render_build(build, self_params=None):
+ if self_params is None:
+ self_params = {}
return {
"build": BuildSchema().dump(build)[0],
"_links": {
- "self": {"href": url_for(".buildr", build_id=build.id)},
+ "self": {"href": url_for(".buildr", build_id=build.id, **self_params)},
"project": {"href": url_for(".projectr", project_id=build.copr_id)},
"chroots": {"href": url_for(".buildchrootlistr", build_id=build.id)}
}
@@ -52,6 +56,22 @@ def render_project(copr, self_params=None):
}
+def render_build_chroot(chroot):
+ """
+ :type chroot: models.BuildChroot
+ """
+ return {
+ "chroot": mm_serialize_one(BuildChrootSchema, chroot),
+ "_links": {
+ "project": {"href": url_for(".projectr", project_id=chroot.build.copr_id)},
+ "self": {"href": url_for(".buildchrootr",
+ build_id=chroot.build.id,
+ name=chroot.name)},
+ }
+ }
+
+
+
def rest_api_auth_required(f):
# todo: move to common.py and test this
@functools.wraps(f)
@@ -85,3 +105,4 @@ def rest_api_auth_required(f):
raise AuthFailed(message)
return f(*args, **kwargs)
return decorated_function
+
diff --git a/frontend/coprs_frontend/coprs/rest_api/resources/build.py b/frontend/coprs_frontend/coprs/rest_api/resources/build.py
index b948a98..dfd5868 100644
--- a/frontend/coprs_frontend/coprs/rest_api/resources/build.py
+++ b/frontend/coprs_frontend/coprs/rest_api/resources/build.py
@@ -5,14 +5,13 @@ from flask import url_for, make_response
# from flask_restful_swagger import swagger
-from coprs import db
+from coprs import db, models
from coprs.exceptions import ActionInProgressException, InsufficientRightsException, RequestCannotBeExecuted
from coprs.logic.coprs_logic import CoprsLogic
from coprs.logic.builds_logic import BuildsLogic
from coprs.logic.users_logic import UsersLogic
from coprs.rest_api.exceptions import MalformedRequest, CannotProcessRequest, AccessForbidden
-from ..common import render_build, rest_api_auth_required
-
+from ..common import render_build, rest_api_auth_required, render_build_chroot
from coprs.rest_api.schemas import BuildSchema, BuildCreateSchema, BuildCreateFromUrlSchema
@@ -164,10 +163,26 @@ class BuildListR(Resource):
class BuildR(Resource):
def get(self, build_id):
+ parser = reqparse.RequestParser()
+ parser.add_argument('show_chroots', type=bool, default=False)
+ req_args = parser.parse_args()
+
build = get_one_safe(BuildsLogic.get(build_id),
"Not found build with id: {}".format(build_id))
+ """:type : models.Build """
+
+ self_params = {}
+ if req_args["show_chroots"]:
+ self_params["show_chroots"] = req_args["show_chroots"]
+
+ result = render_build(build, self_params)
+ if req_args["show_chroots"]:
+ result["build_chroots"] = [
+ render_build_chroot(chroot)
+ for chroot in build.build_chroots
+ ]
- return render_build(build)
+ return result
@rest_api_auth_required
def delete(self, build_id):
diff --git a/frontend/coprs_frontend/coprs/rest_api/resources/build_chroot.py b/frontend/coprs_frontend/coprs/rest_api/resources/build_chroot.py
index 7d04edd..3f6da84 100644
--- a/frontend/coprs_frontend/coprs/rest_api/resources/build_chroot.py
+++ b/frontend/coprs_frontend/coprs/rest_api/resources/build_chroot.py
@@ -3,28 +3,11 @@
from flask import url_for
from flask_restful import Resource
-from ... import models
+from coprs.rest_api.common import render_build_chroot
from ...exceptions import MalformedArgumentException
from ...logic.builds_logic import BuildsLogic, BuildChrootsLogic
-
from ..exceptions import MalformedRequest
-from ..schemas import BuildChrootSchema
-from ..util import get_one_safe, mm_serialize_one
-
-
-def render_build_chroot(chroot):
- """
- :type chroot: models.BuildChroot
- """
- return {
- "chroot": mm_serialize_one(BuildChrootSchema, chroot),
- "_links": {
- "project": {"href": url_for(".projectr", project_id=chroot.build.copr_id)},
- "self": {"href": url_for(".buildchrootr",
- build_id=chroot.build.id,
- name=chroot.name)},
- }
- }
+from ..util import get_one_safe
class BuildChrootListR(Resource):
diff --git a/frontend/coprs_frontend/coprs/rest_api/schemas.py b/frontend/coprs_frontend/coprs/rest_api/schemas.py
index 4af3e2c..a11bbcd 100644
--- a/frontend/coprs_frontend/coprs/rest_api/schemas.py
+++ b/frontend/coprs_frontend/coprs/rest_api/schemas.py
@@ -115,6 +115,7 @@ class BuildChrootSchema(Schema):
result_dir_url = fields.Str(dump_only=True)
+
class BuildSchema(Schema):
id = fields.Int(dump_only=True)
diff --git a/frontend/coprs_frontend/tests/test_api/test_build_chroot_r.py b/frontend/coprs_frontend/tests/test_api/test_build_chroot_r.py
index 5709b1e..8b1b40a 100644
--- a/frontend/coprs_frontend/tests/test_api/test_build_chroot_r.py
+++ b/frontend/coprs_frontend/tests/test_api/test_build_chroot_r.py
@@ -61,7 +61,8 @@ class TestBuildChrootResource(CoprsTestCase):
r0 = self.tc.get(href)
assert r0.status_code == 200
obj = json.loads(r0.data)
- assert obj["chroot"] == expected_dict
+ for k in expected_fields:
+ assert obj["chroot"][k] == expected_dict[k]
def test_get_one_bad_name(self, f_users, f_coprs, f_mock_chroots, f_builds, f_db,
f_users_api):
diff --git a/frontend/coprs_frontend/tests/test_api/test_build_r.py b/frontend/coprs_frontend/tests/test_api/test_build_r.py
index a2067eb..5c4512c 100644
--- a/frontend/coprs_frontend/tests/test_api/test_build_r.py
+++ b/frontend/coprs_frontend/tests/test_api/test_build_r.py
@@ -351,6 +351,21 @@ class TestBuildResource(CoprsTestCase):
assert obj["build"]["id"] == b_id
assert obj["_links"]["self"]["href"] == href
+ def test_get_one_build_with_chroots(self, f_users, f_coprs, f_builds, f_db,
+ f_users_api, f_mock_chroots):
+
+ build_id_list = [b.id for b in self.basic_builds]
+ self.db.session.commit()
+
+ for b_id in build_id_list:
+ href = "/api_2/builds/{}?show_chroots=True".format(b_id)
+ r = self.tc.get(href)
+ assert r.status_code == 200
+ obj = json.loads(r.data)
+ assert obj["build"]["id"] == b_id
+ assert obj["_links"]["self"]["href"] == href
+ assert "build_chroots" in obj
+
def test_get_one_build_not_found(self, f_users, f_coprs, f_builds, f_db,
f_users_api, f_mock_chroots):
build_id_list = [b.id for b in self.basic_builds]
8 years, 9 months
[copr] master: [frontend][old API] backported `result_dir_url` of BuildChroot to the build details: new field `results_by_chroot` (cadcedf)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit cadcedfae65d2692e84a9e9432dd82fb6eff2a3c
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Sep 3 14:10:53 2015 +0200
[frontend][old API] backported `result_dir_url` of BuildChroot to the build details: new field `results_by_chroot`
>---------------------------------------------------------------
frontend/coprs_frontend/coprs/models.py | 5 ---
.../coprs/templates/coprs/detail/build.html | 2 +-
.../coprs/views/api_ns/api_general.py | 31 +++++++++++--------
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/models.py b/frontend/coprs_frontend/coprs/models.py
index c423ef3..79fd77e 100644
--- a/frontend/coprs_frontend/coprs/models.py
+++ b/frontend/coprs_frontend/coprs/models.py
@@ -718,11 +718,6 @@ class BuildChroot(db.Model, helpers.Serializer):
return os.path.join(*parts)
- @property
- def result_url(self):
-
- return "{}/results/{}".format(app.config["BACKEND_BASE_URL"], self.result_dir)
-
def __str__(self):
return "<BuildChroot: {}>".format(self.to_dict())
diff --git a/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html b/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html
index 171f4a0..34e23e1 100644
--- a/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html
+++ b/frontend/coprs_frontend/coprs/templates/coprs/detail/build.html
@@ -149,7 +149,7 @@
<tr>
<td>
{% if chroot.started_on %}
- <a href="{{ chroot.result_url }}">
+ <a href="{{ chroot.result_dir_url }}">
<span class="pficon pficon-folder-open">
{{ chroot.name }}
</span>
diff --git a/frontend/coprs_frontend/coprs/views/api_ns/api_general.py b/frontend/coprs_frontend/coprs/views/api_ns/api_general.py
index eecb919..580c2bc 100644
--- a/frontend/coprs_frontend/coprs/views/api_ns/api_general.py
+++ b/frontend/coprs_frontend/coprs/views/api_ns/api_general.py
@@ -431,26 +431,31 @@ def build_detail(build_id):
if build:
httpcode = 200
chroots = {}
+ results_by_chroot = {}
for chroot in build.build_chroots:
chroots[chroot.name] = chroot.state
+ results_by_chroot[chroot.name] = chroot.result_dir_url
built_packages = None
if build.built_packages:
built_packages = build.built_packages.split("\n")
- output = {"output": "ok",
- "status": build.state,
- "project": build.copr.name,
- "owner": build.copr.owner.name,
- "results": build.results,
- "built_pkgs": built_packages,
- "src_version": build.pkg_version,
- "chroots": chroots,
- "submitted_on": build.submitted_on,
- "started_on": build.min_started_on,
- "ended_on": build.ended_on,
- "src_pkg": build.pkgs,
- "submitted_by": build.user.name}
+ output = {
+ "output": "ok",
+ "status": build.state,
+ "project": build.copr.name,
+ "owner": build.copr.owner.name,
+ "results": build.results,
+ "built_pkgs": built_packages,
+ "src_version": build.pkg_version,
+ "chroots": chroots,
+ "submitted_on": build.submitted_on,
+ "started_on": build.min_started_on,
+ "ended_on": build.ended_on,
+ "src_pkg": build.pkgs,
+ "submitted_by": build.user.name,
+ "results_by_chroot": results_by_chroot
+ }
else:
output = {"output": "notok", "error": "Invalid build"}
httpcode = 404
8 years, 9 months
[copr] master: [frontend][API] added read-only field `result_dir_url` to BuildChroot resource (81bc7c5)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 81bc7c5b7f57ad50eb03be98359e78b4c84d49b5
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Thu Sep 3 13:42:49 2015 +0200
[frontend][API] added read-only field `result_dir_url` to BuildChroot resource
>---------------------------------------------------------------
frontend/coprs_frontend/coprs/models.py | 6 ++++++
frontend/coprs_frontend/coprs/rest_api/schemas.py | 2 ++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/models.py b/frontend/coprs_frontend/coprs/models.py
index 945d9e2..c423ef3 100644
--- a/frontend/coprs_frontend/coprs/models.py
+++ b/frontend/coprs_frontend/coprs/models.py
@@ -692,6 +692,12 @@ class BuildChroot(db.Model, helpers.Serializer):
return None
@property
+ def result_dir_url(self):
+ return "/".join([app.config["BACKEND_BASE_URL"],
+ u"results",
+ self.result_dir])
+
+ @property
def result_dir(self):
# hide changes occurred after migration to dist-git
# if build has defined dist-git, it means that new schema should be used
diff --git a/frontend/coprs_frontend/coprs/rest_api/schemas.py b/frontend/coprs_frontend/coprs/rest_api/schemas.py
index cc2b446..4af3e2c 100644
--- a/frontend/coprs_frontend/coprs/rest_api/schemas.py
+++ b/frontend/coprs_frontend/coprs/rest_api/schemas.py
@@ -113,6 +113,7 @@ class BuildChrootSchema(Schema):
git_hash = fields.Str(dump_only=True)
name = fields.Str(dump_only=True)
+ result_dir_url = fields.Str(dump_only=True)
class BuildSchema(Schema):
@@ -129,6 +130,7 @@ class BuildSchema(Schema):
ended_on = fields.Int(dump_only=True)
results = fields.Str(dump_only=True)
+
timeout = fields.Int(dump_only=True)
enable_net = fields.Bool(dump_only=True)
8 years, 9 months
[copr] master: alter man page and state that package can be even local file (9069977)
by Miroslav Suchý
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 90699778f3fbcac73a070de10cf4fae6e8f89bc6
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Sep 3 11:31:41 2015 +0200
alter man page and state that package can be even local file
>---------------------------------------------------------------
cli/copr_cli/main.py | 2 +-
cli/man/copr-cli.1.asciidoc | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/cli/copr_cli/main.py b/cli/copr_cli/main.py
index 4320b12..64aefc5 100644
--- a/cli/copr_cli/main.py
+++ b/cli/copr_cli/main.py
@@ -348,7 +348,7 @@ def setup_parser():
help="The copr repo to build the package in. Can just name of project or even in format username/project."
)
parser_build.add_argument("pkgs", nargs="+",
- help="URL of packages to build")
+ help="filename of SRPM or URL of packages to build")
parser_build.add_argument(
"-r", "--chroot", dest="chroots", action="append",
help="If you don't need this build for all the project's chroots. You can use it several times for each"
diff --git a/cli/man/copr-cli.1.asciidoc b/cli/man/copr-cli.1.asciidoc
index a83c01d..e173f84 100644
--- a/cli/man/copr-cli.1.asciidoc
+++ b/cli/man/copr-cli.1.asciidoc
@@ -61,7 +61,7 @@ Modify existing copr
~~~~~~~~~~~~~~~~~~~~~~~~~~~
usage: copr-cli create [-h] --chroot CHROOTS [--repo REPOS]
- [--initial-pkgs URL_OF_INITIAL_PKGS]
+ [--initial-pkgs PKGS]
[--description DESCRIPTION]
[--instructions INSTRUCTIONS]
name
@@ -86,7 +86,7 @@ Instructions for the project.
~~~~~~~~~~~~~~~~~~~~~~~~~~
usage: copr-cli build [-h] [-r, --chroot CHROOTS] [--memory MEMORY] [--timeout TIMEOUT] [--nowait]
- project pkg_url [pkg_url ...]
+ project PKG [PKG ...]
-r, --chroot::
If you don't need this build for all the project's chroots. You can use it several times for each chroot you need.
@@ -106,8 +106,8 @@ your projects. Alternatively, you can specify it as username/project. This
way you can build into the project of another user provided you have the
permissions to do so.
-pkg_url::
-URL of the package to build. The package must be placed on a public web or
+PKG::
+This can be either file on your local workstation or URL of the package to build. When URL is used, then the package must be placed on a public web or
ftp server.
8 years, 9 months
[copr] master: [frontend][API] fix handling bad json; Updating documentation: PUT /projects/<id> (a41a07f)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit a41a07fa0699d0dcfa1c1471b4e9fedaeaadce1d
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Wed Sep 2 18:50:23 2015 +0200
[frontend][API] fix handling bad json; Updating documentation: PUT /projects/<id>
>---------------------------------------------------------------
frontend/coprs_frontend/coprs/rest_api/util.py | 7 +++-
.../tests/test_api/test_project_r.py | 8 ++++
frontend/docs/api_2/source/Resources/project.rst | 39 +++++++++++++++++++-
3 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/rest_api/util.py b/frontend/coprs_frontend/coprs/rest_api/util.py
index a7e77b6..eec3085 100644
--- a/frontend/coprs_frontend/coprs/rest_api/util.py
+++ b/frontend/coprs_frontend/coprs/rest_api/util.py
@@ -35,7 +35,12 @@ def json_loads_safe(raw, data_on_error=None):
def mm_deserialize(schema, json_string):
- result = schema.loads(json_string)
+ try:
+ result = schema.loads(json_string)
+ except ValueError as err:
+ raise MalformedRequest(data="Failed to parse request: {}"
+ .format(err))
+
if result.errors:
raise MalformedRequest(data="Failed to parse request: {}"
.format(result.errors))
diff --git a/frontend/coprs_frontend/tests/test_api/test_project_r.py b/frontend/coprs_frontend/tests/test_api/test_project_r.py
index 9a3fa0b..b73489c 100644
--- a/frontend/coprs_frontend/tests/test_api/test_project_r.py
+++ b/frontend/coprs_frontend/tests/test_api/test_project_r.py
@@ -144,6 +144,14 @@ class TestProjectResource(CoprsTestCase):
assert len(copr_chroots_dict["chroots"]) == 1
assert copr_chroots_dict["chroots"][0]["chroot"]["name"] == chroot_name
+ def test_project_create_bad_json(self, f_users, f_mock_chroots, f_users_api, f_db):
+ r = self.request_rest_api_with_auth(
+ "/api_2/projects",
+ data="fdf{fsd",
+ method="post")
+
+ assert r.status_code == 400
+
def test_project_create_bad_values(
self, f_users, f_mock_chroots,
f_users_api, f_db):
diff --git a/frontend/docs/api_2/source/Resources/project.rst b/frontend/docs/api_2/source/Resources/project.rst
index 944a51a..450e8f6 100644
--- a/frontend/docs/api_2/source/Resources/project.rst
+++ b/frontend/docs/api_2/source/Resources/project.rst
@@ -236,12 +236,13 @@ Delete project
**REQUIRE AUTH**
- Deletes copr project
+ Deletes Copr project
:param project_id: a unique identifier of the Copr project.
:statuscode 204: project was removed
:statuscode 400: could not delete build right now, most probably due to unfinished builds
+ :statuscode 403: authorization failed
:statuscode 404: project not found
**Example request**:
@@ -260,3 +261,39 @@ Delete project
Modify project
--------------
+.. http:put:: /api_2/projects/(int:project_id)
+
+ **REQUIRE AUTH**
+
+ Updates Copr project.
+
+ .. note:: You couldn't add or remove project chroots here, use ProjectChroots_ resource.
+
+ :param project_id: a unique identifier of the Copr project.
+
+ :statuscode 201: project was updated
+ :statuscode 400: malformed request, see response content for details
+ :statuscode 403: authorization failed
+ :statuscode 404: project not found
+
+ **Example request**:
+
+ .. sourcecode:: http
+
+ PUT /api_2/projects/1 HTTP/1.1
+ Host: copr.fedoraproject.org
+ Authorization: Basic base64=encoded=string
+ Accept: application/json
+
+ {
+ "disable_createrepo": true,
+ "build_enable_net": false,
+ "instructions": "foobar"
+ }
+
+ **Response**
+
+ .. sourcecode:: http
+
+ HTTP/1.1 201 NO CONTENT
+ Location: /api_2/projects/1
8 years, 9 months
[copr] master: [frontend][API] Updating documentation, added DELETE /projects/<id> (c3aa921)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit c3aa921d8ed4b7a3f267229fb6e2e5b37de61058
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Wed Sep 2 18:32:02 2015 +0200
[frontend][API] Updating documentation, added DELETE /projects/<id>
>---------------------------------------------------------------
.../api_2/source/Resources/build.rst} | 0
.../api_2/source/Resources/build_chroot.rst} | 0
.../api_2/source/Resources/mock_chroot.rst} | 0
frontend/docs/api_2/source/Resources/project.rst | 45 +++++++++++---
.../docs/api_2/source/Resources/project_chroot.rst | 4 +
frontend/docs/api_2/source/index.rst | 65 +++++++++++++++++---
6 files changed, 94 insertions(+), 20 deletions(-)
diff --git a/frontend/coprs_frontend/coprs/logic/__init__.py b/frontend/docs/api_2/source/Resources/build.rst
similarity index 100%
copy from frontend/coprs_frontend/coprs/logic/__init__.py
copy to frontend/docs/api_2/source/Resources/build.rst
diff --git a/frontend/coprs_frontend/coprs/logic/__init__.py b/frontend/docs/api_2/source/Resources/build_chroot.rst
similarity index 100%
copy from frontend/coprs_frontend/coprs/logic/__init__.py
copy to frontend/docs/api_2/source/Resources/build_chroot.rst
diff --git a/frontend/coprs_frontend/coprs/logic/__init__.py b/frontend/docs/api_2/source/Resources/mock_chroot.rst
similarity index 100%
copy from frontend/coprs_frontend/coprs/logic/__init__.py
copy to frontend/docs/api_2/source/Resources/mock_chroot.rst
diff --git a/frontend/docs/api_2/source/Resources/project.rst b/frontend/docs/api_2/source/Resources/project.rst
index 5de8178..944a51a 100644
--- a/frontend/docs/api_2/source/Resources/project.rst
+++ b/frontend/docs/api_2/source/Resources/project.rst
@@ -43,12 +43,20 @@ disable_createrepo bool yes disables automatic repository
build_enable_net bool yes set default value for new builds option `enable_net`
================== ==================== ========= ===============
-List projects collection
-------------------------
+List projects
+-------------
.. http:get:: /api_2/projects
Returns a list of Copr projects according to the given query parameters
+ :query str search_query: filter project using full-text search
+ :query str owner: select only projects owned by this user
+ :query str name: select only projects with this name
+ :query int offset: offset number, default value is 0
+ :query int limit: limit number, default value is 100
+
+ :statuscode 200: no error
+
**Example request**:
.. sourcecode:: http
@@ -89,14 +97,6 @@ List projects collection
]
}
- :query search_query: filter project using full-text search
- :query owner: select only projects owned by this user
- :query name: select only projects with this name
- :query offset: offset number, default value is 0
- :query limit: limit number, default value is 100
-
- :statuscode 200: no error
-
Create new project
------------------
.. http:post:: /api_2/projects
@@ -232,6 +232,31 @@ Get project details
Delete project
--------------
+.. http:delete:: /api_2/projects/(int:project_id)
+
+ **REQUIRE AUTH**
+
+ Deletes copr project
+
+ :param project_id: a unique identifier of the Copr project.
+
+ :statuscode 204: project was removed
+ :statuscode 400: could not delete build right now, most probably due to unfinished builds
+ :statuscode 404: project not found
+
+ **Example request**:
+
+ .. sourcecode:: http
+
+ DELETE /api_2/projects HTTP/1.1
+ Host: copr.fedoraproject.org
+ Authorization: Basic base64=encoded=string
+
+ **Response**
+
+ .. sourcecode:: http
+
+ HTTP/1.1 204 NO CONTENT
Modify project
--------------
diff --git a/frontend/docs/api_2/source/Resources/project_chroot.rst b/frontend/docs/api_2/source/Resources/project_chroot.rst
new file mode 100644
index 0000000..59da2f8
--- /dev/null
+++ b/frontend/docs/api_2/source/Resources/project_chroot.rst
@@ -0,0 +1,4 @@
+Project Chroot
+==============
+
+
diff --git a/frontend/docs/api_2/source/index.rst b/frontend/docs/api_2/source/index.rst
index 093433d..5570793 100644
--- a/frontend/docs/api_2/source/index.rst
+++ b/frontend/docs/api_2/source/index.rst
@@ -38,6 +38,53 @@ Here is a short example with the content of API root:
}
}
+Response structure
+------------------
+
+The API operates two kinds of resources: collections and individuals.
+
+Each entity is enveloped into json dict and accompanied with set of HETEOAS references.
+GET requests would return the following structures:
+
+**Collection structure**:
+
+.. code-block:: javascript
+
+ {
+ "_links" {
+ "self": {
+ "href": "<url which was used to obtain current collection>"
+ },
+ "<relation name>": {
+ "href": "<relation url>"
+ }
+ },
+ "<collection name>": [
+ {<individual 1>},
+ {<individual 2>},
+ {
+ "_links": {...},
+ "<entity name>": {<entity structure>}
+ }
+ ]
+ }
+
+**Individual structure**:
+
+.. code-block:: javascript
+
+ {
+ "_links": {
+ "self": {
+ "href": "<url which was used to obtain current collection>"
+ },
+ "<relation name>": {
+ "href": "<relation url>"
+ }
+ },
+ "<entity name>": {<entity structure>}
+ }
+
Errors
______
todo:
@@ -45,19 +92,17 @@ todo:
Resources
---------
-.. toctree::
- :maxdepth: 1
-
- Resources/project
-
-.. Indices and tables
- ==================
- * :ref:`genindex`
- * :ref:`modindex`
- * :ref:`search`
+================== ============
+Resource Description
+================== ============
+Project_ represents copr projects and operations with them.
+`Project Chroot`_ allows to view and edit project settings specific for different chroots
+================== ============
.. _BasicAuth: https://en.wikipedia.org/wiki/Basic_access_authentication
.. _CoprAPI: https://copr.fedoraproject.org/api
.. _HETEOAS: https://en.wikipedia.org/wiki/HATEOAS
+.. _Project: Resources/project.html
+.. _Project Chroot: Resources/project_chroot.html
8 years, 9 months
[copr] master: [frontend][API] Updating documentation (2fa812b)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 2fa812ba3469c6ff5feb0f4ac3a03dfa31ac110f
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Wed Sep 2 17:32:17 2015 +0200
[frontend][API] Updating documentation
>---------------------------------------------------------------
frontend/docs/api_2/source/Resources/project.rst | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/frontend/docs/api_2/source/Resources/project.rst b/frontend/docs/api_2/source/Resources/project.rst
index 2a9f31c..5de8178 100644
--- a/frontend/docs/api_2/source/Resources/project.rst
+++ b/frontend/docs/api_2/source/Resources/project.rst
@@ -40,10 +40,11 @@ instructions string yes installation instructions
homepage string(URL) yes project homepage
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``
+build_enable_net bool yes set default value for new builds option `enable_net`
================== ==================== ========= ===============
-
+List projects collection
+------------------------
.. http:get:: /api_2/projects
Returns a list of Copr projects according to the given query parameters
@@ -96,14 +97,16 @@ build_enable_net bool yes set default value for new bui
:statuscode 200: no error
+Create new project
+------------------
.. http:post:: /api_2/projects
**REQUIRE AUTH**
Creates new Copr project.
- Additionally to described before `Project fields`_ the user could specify field ``chroots`` which contains list of chroots to be enabled.
- Available chroots could be obtained from MockChrootResource_
+ Additionally to described before `Project fields`_ the user could specify field `chroots` which contains list of chroots to be enabled.
+ Available `chroot` names could be obtained from MockChrootResource_
**Example request**:
@@ -139,7 +142,8 @@ build_enable_net bool yes set default value for new bui
:statuscode 401: the user already has project with the same name
:statuscode 403: authorization failed
-
+Get project details
+-------------------
.. http:get:: /api_2/projects/(int:project_id)
Returns details about Copr project
@@ -163,6 +167,7 @@ build_enable_net bool yes set default value for new bui
**Response**
.. sourcecode:: http
+
HTTP/1.1 200 OK
Content-Type: application/json
@@ -225,6 +230,8 @@ build_enable_net bool yes set default value for new bui
}
}
+Delete project
+--------------
-
-
+Modify project
+--------------
8 years, 9 months
[copr] master: [frontend][API] requirements.txt for sphinx build at https://readthedocs.org (2bafdd5)
by vgologuz@fedoraproject.org
Repository : http://git.fedorahosted.org/cgit/copr.git
On branch : master
>---------------------------------------------------------------
commit 2bafdd55403f1ee7985deab06d8b39352ea785a5
Author: Valentin Gologuzov <vgologuz(a)redhat.com>
Date: Wed Sep 2 17:01:40 2015 +0200
[frontend][API] requirements.txt for sphinx build at https://readthedocs.org
>---------------------------------------------------------------
frontend/docs/api_2/requirements.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/frontend/docs/api_2/requirements.txt b/frontend/docs/api_2/requirements.txt
new file mode 100644
index 0000000..4df3b68
--- /dev/null
+++ b/frontend/docs/api_2/requirements.txt
@@ -0,0 +1 @@
+sphinxcontrib-httpdomain
8 years, 9 months