Proxies

User interface is separated among multiple proxy classes such as ProjectProxy, BuildProxy, etc, which provide API operations on given resource.

There are several methods available across majority (there are some corner cases where it wouldn’t make sense) of proxies. Naturally, all methods (e.g. auth_check) from BaseProxy are available everywhere. Moreover, proxies implement get method to get one specific object and get_list to get multiple objects that meet some criteria (e.g. all successful builds from a project). When it makes sense, proxies also implement an edit method that modifies an object. Exception for this is for example, a BuildProxy because it shouldn’t be possible to change a build. Similarly, most of the proxies have a delete method except for e.g. BuildChrootProxy.

Base

class copr.v3.proxies.BaseProxy(config)[source]

Parent class for all other proxies

home()[source]

Call the Copr APIv3 base URL

Returns:Munch
auth_check()[source]

Call an endpoint protected by login to check whether the user auth key is valid

Returns:Munch
auth_username()[source]

Return the username (string) assigned to this configuration. May contact the server and authenticate if needed.

Project

class copr.v3.proxies.project.ProjectProxy(config)[source]
get(ownername, projectname)[source]

Return a project

Parameters:
  • ownername (str) –
  • projectname (str) –
Returns:

Munch

get_list(ownername=None, pagination=None)[source]

Return a list of projects

Parameters:
  • ownername (str) –
  • pagination
Returns:

Munch

search(query, pagination=None)[source]

Return a list of projects based on fulltext search

Parameters:
  • query (str) –
  • pagination
Returns:

Munch

add(ownername, projectname, chroots, description=None, instructions=None, homepage=None, contact=None, additional_repos=None, unlisted_on_hp=False, enable_net=False, persistent=False, auto_prune=True, use_bootstrap_container=None, devel_mode=False, delete_after_days=None, multilib=False, module_hotfixes=False, bootstrap=None, bootstrap_image=None, isolation=None, fedora_review=None, appstream=False, runtime_dependencies=None, packit_forge_projects_allowed=None)[source]

Create a project

Parameters:
  • ownername (str) –
  • projectname (str) –
  • chroots (list) –
  • description (str) –
  • instructions (str) –
  • homepage (str) –
  • contact (str) –
  • additional_repos (list) –
  • unlisted_on_hp (bool) – project will not be shown on Copr homepage
  • enable_net (bool) – if builder can access net for builds in this project
  • persistent (bool) – if builds and the project are undeletable
  • auto_prune (bool) – if backend auto-deletion script should be run for the project
  • use_bootstrap_container (bool) – obsoleted, use the ‘bootstrap’ argument and/or the ‘bootstrap_image’.
  • devel_mode (bool) – if createrepo should run automatically
  • delete_after_days (int) – delete the project after the specfied period of time
  • module_hotfixes (bool) – allow packages from this project to override packages from active module streams.
  • bootstrap (str) – Mock bootstrap feature setup. Possible values are ‘default’, ‘on’, ‘off’, ‘image’.
  • bootstrap_image (str) – Name of the container image to initialize the bootstrap chroot from. This also implies ‘bootstrap=image’. This is a noop parameter and its value is ignored.
  • isolation (str) – Mock isolation feature setup. Possible values are ‘default’, ‘simple’, ‘nspawn’.
  • fedora_review (bool) – Run fedora-review tool for packages in this project
  • appstream (bool) – Disable or enable generating the appstream metadata
  • runtime_dependencies (string) – List of external repositories (== dependencies, specified as baseurls) that will be automatically enabled together with this project repository.
  • packit_forge_projects_allowed (list) – List of forge projects that will be allowed to build in the project via Packit
Returns:

Munch

edit(ownername, projectname, chroots=None, description=None, instructions=None, homepage=None, contact=None, additional_repos=None, unlisted_on_hp=None, enable_net=None, auto_prune=None, use_bootstrap_container=None, devel_mode=None, delete_after_days=None, multilib=None, module_hotfixes=None, bootstrap=None, bootstrap_image=None, isolation=None, fedora_review=None, appstream=None, runtime_dependencies=None, packit_forge_projects_allowed=None)[source]

Edit a project

Parameters:
  • ownername (str) –
  • projectname (str) –
  • chroots (list) –
  • description (str) –
  • instructions (str) –
  • homepage (str) –
  • contact (str) –
  • repos (list) –
  • unlisted_on_hp (bool) – project will not be shown on Copr homepage
  • enable_net (bool) – if builder can access net for builds in this project
  • auto_prune (bool) – if backend auto-deletion script should be run for the project
  • use_bootstrap_container (bool) – obsoleted, use the ‘bootstrap’ argument and/or the ‘bootstrap_image’.
  • devel_mode (bool) – if createrepo should run automatically
  • delete_after_days (int) – delete the project after the specfied period of time
  • module_hotfixes (bool) – allow packages from this project to override packages from active module streams.
  • bootstrap (str) – Mock bootstrap feature setup. Possible values are ‘default’, ‘on’, ‘off’, ‘image’.
  • isolation (str) – Mock isolation feature setup. Possible values are ‘default’, ‘simple’, ‘nspawn’.
  • bootstrap_image (str) – Name of the container image to initialize the bootstrap chroot from. This also implies ‘bootstrap=image’. This is a noop parameter and its value is ignored.
  • fedora_review (bool) – Run fedora-review tool for packages in this project
  • appstream (bool) – Disable or enable generating the appstream metadata
  • runtime_dependencies (string) – List of external repositories (== dependencies, specified as baseurls) that will be automatically enabled together with this project repository.
  • packit_forge_projects_allowed (list) – List of forge projects that will be allowed to build in the project via Packit
Returns:

Munch

delete(ownername, projectname)[source]

Delete a project

Parameters:
  • ownername (str) –
  • projectname (str) –
Returns:

Munch

fork(ownername, projectname, dstownername, dstprojectname, confirm=False)[source]

Fork a project

Parameters:
  • ownername (str) – owner of a source project
  • projectname (str) – name of a source project
  • dstownername (str) – owner of a destination project
  • dstprojectname (str) – name of a destination project
  • confirm (bool) – if forking into a existing project, this needs to be set to True, to confirm that user is aware of that
Returns:

Munch

get_permissions(ownername, projectname)[source]

Get project permissions

Parameters:
  • ownername (str) – owner of the project
  • projectname (str) – name of the project
Return Munch:

a dictionary in format {username: {permission: state, ... }, ...} where username identifies an existing copr user, permission is one of admin|builder and state is one of nothing|approved|request.

set_permissions(ownername, projectname, permissions)[source]

Set (or change) permissions for a project

Parameters:
  • ownername (str) – owner of the updated project
  • projectname (str) – name of the updated project
  • permissions (dict) – the expected format is {username: {permission: state, ...}, ...} where username identifies an existing copr user, permission is one of builder|admin and state value is one of nothing|request|approved. It is OK to set only bulider or only admin permission; any unspecified permission is then (a) set to nothing (if the permission entry is newly created), or (b) kept unchanged (if an existing permission entry is edited). If more than one username is specified in single set_permissions() request, the approach is to configure all-or-nothing (any error makes the whole operation fail and no-op).
request_permissions(ownername, projectname, permissions)[source]

Request/cancel request/drop your permissions on project

Parameters:
  • ownername (str) – owner of the requested project
  • projectname (str) – name of the requested project
  • permissions (dict) – the desired permissions user wants to have on the requested copr project. The format is {permission: bool, ...}, where permission is one of builder|admin and bool is (a) True for requesting the role or (b) False for dropping the role (or for cancelling of previous request).
regenerate_repos(ownername, projectname)[source]

Regenerate repositories for a project

Parameters:
  • ownername (str) – owner of the project to regenerate
  • projectname (str) – name of the project to regenerate

Build

class copr.v3.proxies.build.BuildProxy(config)[source]
get(build_id)[source]

Return a build

Parameters:build_id (int) –
Returns:Munch
get_source_chroot(build_id)[source]

Return a source build

Parameters:build_id (int) –
Returns:Munch
get_source_build_config(build_id)[source]

Return a config for source build

Parameters:build_id (int) –
Returns:Munch
get_built_packages(build_id)[source]

Return built packages (NEVRA dicts) for a given build

Parameters:build_id (int) –
Returns:Munch
get_list(ownername, projectname, packagename=None, status=None, pagination=None)[source]

Return a list of packages

Parameters:
  • ownername (str) –
  • projectname (str) –
  • packagename (str) –
  • status (str) –
  • pagination
Returns:

Munch

cancel(build_id)[source]

Cancel a build

Parameters:build_id (int) –
Returns:Munch
create_from_urls(ownername, projectname, urls, buildopts=None, project_dirname=None)[source]

Create builds from a list of URLs

Parameters:
Returns:

Munch

create_from_url(ownername, projectname, url, buildopts=None, project_dirname=None)[source]

Create a build from URL

Parameters:
Returns:

Munch

create_from_file(ownername, projectname, path, buildopts=None, project_dirname=None)[source]

Create a build from local SRPM file

Parameters:
Returns:

Munch

create_from_scm(ownername, projectname, clone_url, committish='', subdirectory='', spec='', scm_type='git', source_build_method='rpkg', buildopts=None, project_dirname=None)[source]

Create a build from SCM repository

Parameters:
  • ownername (str) –
  • projectname (str) –
  • clone_url (str) – url to a project versioned by Git or SVN
  • committish (str) – name of a branch, tag, or a git hash
  • subdirectory (str) – path to a subdirectory with package content
  • spec (str) – path to spec file, relative to ‘subdirectory’
  • scm_type (str) –
  • source_build_method (str) –
  • buildoptshttp://python-copr.readthedocs.io/en/latest/client_v3/build_options.html
  • project_dirname (str) –
Returns:

Munch

create_from_distgit(ownername, projectname, packagename, committish=None, namespace=None, distgit=None, buildopts=None, project_dirname=None)[source]

Create a build from a DistGit repository

Parameters:
Returns:

Munch

create_from_pypi(ownername, projectname, pypi_package_name, pypi_package_version=None, spec_template='', python_versions=None, buildopts=None, project_dirname=None, spec_generator=None)[source]

Create a build from PyPI - https://pypi.org/

Parameters:
  • ownername (str) –
  • projectname (str) –
  • pypi_package_name (str) –
  • pypi_package_version (str) – PyPI package version (None means “latest”)
  • spec_template (str) – what pyp2rpm spec template to use
  • python_versions (list) – list of python versions to build for
  • buildoptshttp://python-copr.readthedocs.io/en/latest/client_v3/build_options.html
  • project_dirname (str) –
  • spec_generator (str) – what tool should be used for spec generation
Returns:

Munch

create_from_rubygems(ownername, projectname, gem_name, buildopts=None, project_dirname=None)[source]

Create a build from RubyGems - https://rubygems.org/

Parameters:
Returns:

Munch

create_from_custom(ownername, projectname, script, script_chroot=None, script_builddeps=None, script_resultdir=None, script_repos=None, buildopts=None, project_dirname=None)[source]

Create a build from custom script.

Parameters:
  • ownername (str) –
  • projectname (str) –
  • script – script to execute to generate sources
  • script_chroot – [optional] what chroot to use to generate sources (defaults to fedora-latest-x86_64)
  • script_builddeps – [optional] list of script’s dependencies
  • script_resultdir – [optional] where script generates results (relative to cwd)
  • buildoptshttp://python-copr.readthedocs.io/en/latest/client_v3/build_options.html
  • project_dirname (str) –
Parm script_repos:
 

[optional] external repositories containing script’s dependencies

Returns:

Munch

delete(build_id)[source]

Delete a build

Parameters:build_id (int) –
Returns:Munch
delete_list(build_ids)[source]

Delete multiple builds specified by a list of their ids.

Parameters:build_id (list[int]) –
Returns:Munch

Package

class copr.v3.proxies.package.PackageProxy(config)[source]
get(ownername, projectname, packagename, with_latest_build=False, with_latest_succeeded_build=False)[source]

Return a package

Parameters:
  • ownername (str) –
  • projectname (str) –
  • packagename (str) –
  • with_latest_build (bool) – The result will contain “builds” dictionary with the latest submitted build of this particular package within the project
  • with_latest_succeeded_build (bool) – The result will contain “builds” dictionary with the latest successful build of this particular package within the project.
Returns:

Munch

get_list(ownername, projectname, pagination=None, with_latest_build=False, with_latest_succeeded_build=False)[source]

Return a list of packages

Parameters:
  • ownername (str) –
  • projectname (str) –
  • pagination
  • with_latest_build (bool) – The result will contain “builds” dictionary with the latest submitted build of this particular package within the project
  • with_latest_succeeded_build (bool) – The result will contain “builds” dictionary with the latest successful build of this particular package within the project.
Returns:

Munch

add(ownername, projectname, packagename, source_type, source_dict)[source]

Add a package to a project

Parameters:
Returns:

Munch

edit(ownername, projectname, packagename, source_type=None, source_dict=None)[source]

Edit a package in a project

Parameters:
Returns:

Munch

reset(ownername, projectname, packagename)[source]

Reset a package configuration, meaning that previously selected source_type for the package and also all the source configuration previously defined by source_dict will be nulled.

Parameters:
  • ownername (str) –
  • projectname (str) –
  • packagename (str) –
Returns:

Munch

build(ownername, projectname, packagename, buildopts=None, project_dirname=None)[source]

Create a build from a package configuration

Parameters:
Returns:

Munch

delete(ownername, projectname, packagename)[source]

Delete a package from a project

Parameters:
  • ownername (str) –
  • projectname (str) –
  • packagename (str) –
Returns:

Munch

Module

class copr.v3.proxies.module.ModuleProxy(config)[source]
build_from_url(ownername, projectname, url, branch='master', distgit=None)[source]

Build a module from a URL pointing to a modulemd YAML file

Parameters:
  • ownername (str) –
  • projectname (str) –
  • url (str) – URL pointing to a raw .yaml file
  • branch (str) –
Returns:

Munch

build_from_file(ownername, projectname, path, distgit=None)[source]

Build a module from a local modulemd YAML file

Parameters:
  • ownername (str) –
  • projectname (str) –
  • path (str) –
Returns:

Munch

Monitor

class copr.v3.proxies.monitor.MonitorProxy(config)[source]

Proxy to process /api_3/monitor requests.

monitor(ownername, projectname, project_dirname=None, additional_fields=None)[source]

Return a list of project packages, and corresponding info for the latest chroot builds.

Parameters:
  • ownername (str) –
  • projectname (str) –
  • project_dirname (str) –
  • additional_fields (list) – List of additional fields to return in the dictionary. Possible values: url_build_log, url_backend_log, build_url. Note that additional fields may significantly prolong the server response time.
Returns:

Munch a list of dictionaries, formatted like:

{
  "name": package_name,
    "chroots": {
      "fedora-rawhide-x86_64": {
          "build_id": 843616,
          "status": "succeeded",
          ... fields ...,
    }
  },
}

Project Chroot

class copr.v3.proxies.project_chroot.ProjectChrootProxy(config)[source]
get(ownername, projectname, chrootname)[source]

Return a configuration of a chroot in a project

Parameters:
  • ownername (str) –
  • projectname (str) –
  • chrootname (str) –
Returns:

Munch

get_build_config(ownername, projectname, chrootname)[source]

Return a build configuration of a chroot in a project

Parameters:
  • ownername (str) –
  • projectname (str) –
  • chrootname (str) –
Returns:

Munch

edit(ownername, projectname, chrootname, additional_packages=None, additional_repos=None, additional_modules=None, comps=None, delete_comps=False, with_opts=None, without_opts=None, bootstrap=None, bootstrap_image=None, isolation=None, reset_fields=None)[source]

Edit a chroot configuration in a project

Parameters:
  • ownername (str) –
  • projectname (str) –
  • chrootname (str) –
  • additional_packages (list) – buildroot packages for the chroot
  • additional_repos (list) – buildroot additional additional_repos
  • additional_modules (list) – list of modules that will be enabled or disabled in the given chroot, e.g. [‘module1:stream’, ‘!module2:stream’].
  • comps (str) – file path to the comps.xml file
  • delete_comps (bool) – if True, current comps.xml will be removed
  • with_opts (list) – Mock –with option
  • without_opts (list) – Mock –without option
  • bootstrap (str) – Allowed values ‘on’, ‘off’, ‘image’, ‘default’, ‘untouched’ (equivalent to None)
  • bootstrap_image (str) – Implies ‘bootstrap=image’.
  • isolation (str) – Mock isolation feature setup. Possible values are ‘default’, ‘simple’, ‘nspawn’.
  • reset_fields (list) – list of chroot attributes, that should be reseted to their respective defaults. Possible values are additional_packages, additional_modules, isolation, etc. See the output of ProjectProxy.get for all the possible field names.
Returns:

Munch

Build Chroot

class copr.v3.proxies.build_chroot.BuildChrootProxy(config)[source]
get(build_id, chrootname)[source]

Return a build chroot

Parameters:
  • build_id (int) –
  • chrootname (str) –
Returns:

Munch

get_list(build_id, pagination=None)[source]

Return a list of build chroots

Parameters:
  • build_id (int) –
  • chrootname (str) –
  • pagination
Returns:

Munch

get_build_config(build_id, chrootname)[source]

Return a build config for a build chroot

Parameters:
  • build_id (int) –
  • chrootname (str) –
Returns:

Munch

get_built_packages(build_id, chrootname)[source]

Return built packages (NEVRA dicts) for a given build chroot

Parameters:
  • build_id (int) –
  • chrootname (str) –
Returns:

Munch