Proxies — python-copr 1.63 documentation

# 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)

  Parent class for all other proxies

  `home`()

    Call the Copr APIv3 base URL

    Returns: | Munch

  `auth_check`()

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

    Returns: | Munch

## Project

class `copr.v3.proxies.project.` `ProjectProxy`(config)
  `get`(ownername, projectname)

    Return a project

    Parameters: | ownername (str) – projectname (str) –
    Returns: | Munch

  `get_list`(ownername=None, pagination=None)

    Return a list of projects

    Parameters: | ownername (str) – pagination –
    Returns: | Munch

  `search`(query, pagination=None)

    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=True, persistent=False, auto_prune=True, use_bootstrap_container=False, devel_mode=False, delete_after_days=None)

    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) – if mock bootstrap container is used to initialize the buildroot devel_mode (bool) – if createrepo should run automatically delete_after_days (int) – delete the project after the specfied period of time
    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)

    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) – if mock bootstrap container is used to initialize the buildroot devel_mode (bool) – if createrepo should run automatically delete_after_days (int) – delete the project after the specfied period of time
    Returns: | Munch

  `delete`(ownername, projectname)

    Delete a project

    Parameters: | ownername (str) – projectname (str) –
    Returns: | Munch

  `fork`(ownername, projectname, dstownername, dstprojectname, confirm=False)

    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)

    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)

    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)

    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).

## Build

class `copr.v3.proxies.build.` `BuildProxy`(config)
  `get`(build_id)

    Return a build

    Parameters: | build_id (int) –
    Returns: | Munch

  `get_source_chroot`(build_id)

    Return a source build

    Parameters: | build_id (int) –
    Returns: | Munch

  `get_source_build_config`(build_id)

    Return a config for source build

    Parameters: | build_id (int) –
    Returns: | Munch

  `get_list`(ownername, projectname, packagename=None, status=None, pagination=None)

    Return a list of packages

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

  `cancel`(build_id)

    Cancel a build

    Parameters: | build_id (int) –
    Returns: | Munch

  `create_from_urls`(ownername, projectname, urls, buildopts=None, project_dirname=None)

    Create builds from a list of URLs

    Parameters: | ownername (str) – projectname (str) – urls (list) – buildopts – http://python-copr.readthedocs.io/en/latest/client_v3/build_options.html project_dirname (str) –
    Returns: | Munch

  `create_from_url`(ownername, projectname, url, buildopts=None, project_dirname=None)

    Create a build from URL

    Parameters: | ownername (str) – projectname (str) – url (str) – buildopts – http://python-copr.readthedocs.io/en/latest/client_v3/build_options.html project_dirname (str) –
    Returns: | Munch

  `create_from_file`(ownername, projectname, path, buildopts=None, project_dirname=None)

    Create a build from local SRPM file

    Parameters: | ownername (str) – projectname (str) – path (str) – buildopts – http://python-copr.readthedocs.io/en/latest/client_v3/build_options.html project_dirname (str) –
    Returns: | Munch

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

    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) – buildopts – http://python-copr.readthedocs.io/en/latest/client_v3/build_options.html project_dirname (str) –
    Returns: | Munch

  `create_from_pypi`(ownername, projectname, pypi_package_name, pypi_package_version=None, spec_template='', python_versions=None, buildopts=None, project_dirname=None)

    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 buildopts – http://python-copr.readthedocs.io/en/latest/client_v3/build_options.html project_dirname (str) –
    Returns: | Munch

  `create_from_rubygems`(ownername, projectname, gem_name, buildopts=None, project_dirname=None)

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

    Parameters: | ownername (str) – projectname (str) – gem_name (str) – buildopts – http://python-copr.readthedocs.io/en/latest/client_v3/build_options.html project_dirname (str) –
    Returns: | Munch

  `create_from_custom`(ownername, projectname, script, script_chroot=None, script_builddeps=None, script_resultdir=None, buildopts=None, project_dirname=None)

    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) project_dirname (str) –
    Returns: | Munch

  `delete`(build_id)

    Delete a build

    Parameters: | build_id (int) –
    Returns: | Munch

## Package

class `copr.v3.proxies.package.` `PackageProxy`(config)
  `get`(ownername, projectname, packagename)

    Return a package

    Parameters: | ownername (str) – projectname (str) – packagename (str) –
    Returns: | Munch

  `get_list`(ownername, projectname, pagination=None)

    Return a list of packages

    Parameters: | ownername (str) – projectname (str) – pagination –
    Returns: | Munch

  `add`(ownername, projectname, packagename, source_type, source_dict)

    Add a package to a project

    Parameters: | ownername (str) – projectname (str) – packagename (str) – source_type (str) – http://python-copr.readthedocs.io/en/latest/client_v3/package_source_types.html source_dict (dict) – http://python-copr.readthedocs.io/en/latest/client_v3/package_source_types.html
    Returns: | Munch

  `edit`(ownername, projectname, packagename, source_type=None, source_dict=None)

    Edit a package in a project

    Parameters: | ownername (str) – projectname (str) – packagename (str) – source_type – http://python-copr.readthedocs.io/en/latest/client_v3/package_source_types.html source_dict (dict) – http://python-copr.readthedocs.io/en/latest/client_v3/package_source_types.html
    Returns: | Munch

  `reset`(ownername, projectname, packagename)

    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)

    Create a build from a package configuration

    Parameters: | ownername (str) – projectname (str) – packagename (str) – buildopts – http://python-copr.readthedocs.io/en/latest/client_v3/build_options.html project_dirname (str) –
    Returns: | Munch

  `delete`(ownername, projectname, packagename)

    Delete a package from a project

    Parameters: | ownername (str) – projectname (str) – packagename (str) –
    Returns: | Munch

## Module

class `copr.v3.proxies.module.` `ModuleProxy`(config)
  `build_from_url`(ownername, projectname, url, branch='master')

    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)

    Build a module from a local modulemd YAML file

    Parameters: | ownername (str) – projectname (str) – path (str) –
    Returns: | Munch

## Project Chroot

class `copr.v3.proxies.project_chroot.` `ProjectChrootProxy`(config)
  `get`(ownername, projectname, chrootname)

    Return a configuration of a chroot in a project

    Parameters: | ownername (str) – projectname (str) – chrootname (str) –
    Returns: | Munch

  `get_build_config`(ownername, projectname, chrootname)

    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, comps=None, delete_comps=False, with_opts=None, without_opts=None)

    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 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
    Returns: | Munch

## Build Chroot

class `copr.v3.proxies.build_chroot.` `BuildChrootProxy`(config)
  `get`(build_id, chrootname)

    Return a build chroot

    Parameters: | build_id (int) – chrootname (str) –
    Returns: | Munch

  `get_list`(build_id, pagination=None)

    Return a list of build chroots

    Parameters: | build_id (int) – chrootname (str) – pagination –
    Returns: | Munch

  `get_build_config`(build_id, chrootname)

    Return a build config for a build chroot

    Parameters: | build_id (int) – chrootname (str) –
    Returns: | Munch