-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: migrate API projects namespace to flask-restx
- Loading branch information
Showing
4 changed files
with
134 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,11 @@ | |
example="@copr", | ||
) | ||
|
||
fullname_field = String( | ||
description="Full name of the project", | ||
example="@copr/pull-requests", | ||
) | ||
|
||
projectname_field = String( | ||
description="Name of the project", | ||
example="copr-dev", | ||
|
@@ -281,6 +286,56 @@ | |
example="DESC", | ||
) | ||
|
||
homepage_field = Url( | ||
description="Homepage URL of Copr project", | ||
example="https://github.com/fedora-copr", | ||
) | ||
|
||
contact_field = String( | ||
description="Contact email", | ||
example="[email protected]", | ||
) | ||
|
||
description_field = String( | ||
description="Description of Copr project", | ||
) | ||
|
||
instructions_field = String( | ||
description="Instructions how to install and use Copr project", | ||
) | ||
|
||
persistent_field = Boolean( | ||
description="Build and project is immune against deletion", | ||
) | ||
|
||
unlisted_on_hp_field = Boolean( | ||
description="Don't list Copr project on home page", | ||
) | ||
|
||
auto_prune_field = Boolean( | ||
description="Automatically delete builds in this project", | ||
) | ||
|
||
build_enable_net_field = Boolean( | ||
description="Enable networking for the builds", | ||
) | ||
|
||
appstream_field = Boolean( | ||
description="Enable Appstream for this project", | ||
) | ||
|
||
packit_forge_projects_allowed_field = String( | ||
description="Whitespace separated list of forge projects that will be " | ||
"allowed to build in the project via Packit", | ||
example="github.com/fedora-copr/copr github.com/another/project", | ||
) | ||
|
||
follow_fedora_branching_field = Boolean( | ||
description="If chroots for the new branch should be auto-enabled and populated from " | ||
"rawhide ones", | ||
) | ||
|
||
|
||
pagination_schema = { | ||
"limit_field": limit_field, | ||
"offset_field": offset_field, | ||
|
@@ -404,6 +459,33 @@ | |
package_model = api.model("Package", package_schema) | ||
|
||
|
||
project_schema = { | ||
"id": id_field, | ||
"name": projectname_field, | ||
"ownername": ownername_field, | ||
"full_name": fullname_field, | ||
"homepage": homepage_field, | ||
"contact": contact_field, | ||
"description": description_field, | ||
"instructions": instructions_field, | ||
"devel_mode": Boolean, | ||
"persistent": persistent_field, | ||
"unlisted_on_hp": unlisted_on_hp_field, | ||
"auto_prune": auto_prune_field, | ||
"chroot_repos": Raw, | ||
"additional_repos": additional_repos_field, | ||
"enable_net": build_enable_net_field, | ||
"bootstrap": String, | ||
"isolation": isolation_field, | ||
"module_hotfixes": module_hotfixes_field, | ||
"appstream": appstream_field, | ||
"packit_forge_projects_allowed": packit_forge_projects_allowed_field, | ||
"follow_fedora_branching": follow_fedora_branching_field, | ||
} | ||
|
||
project_model = api.model("Project", project_schema) | ||
|
||
|
||
def clone(field): | ||
""" | ||
Return a copy of a field | ||
|
@@ -412,9 +494,13 @@ def clone(field): | |
return field.__class__(**kwargs) | ||
|
||
|
||
add_package_params = { | ||
fullname_params = { | ||
"ownername": ownername_field.description, | ||
"projectname": projectname_field.description, | ||
} | ||
|
||
add_package_params = { | ||
**fullname_params, | ||
"package_name": packagename_field.description, | ||
"source_type_text": source_type_field.description, | ||
} | ||
|
@@ -551,3 +637,12 @@ def project_chroot_parser(): | |
arg.required = True | ||
parser.add_argument(arg) | ||
return parser | ||
|
||
|
||
def project_parser(): | ||
# pylint: disable=missing-function-docstring | ||
parser = RequestParser() | ||
parser.add_argument(field2arg("ownername", ownername_field, required=True)) | ||
parser.add_argument(field2arg("projectname", projectname_field, required=True)) | ||
|
||
return parser |