Skip to content

Use *Unit classes as templates in search criteria #64

@rbikar

Description

@rbikar

Summary

To avoid using raw dicts searching in Pulp we could use *Unit classes as templates in search criteria.
So we can introduce a class method Criteria.for_units() that will accept list of units for which criteria should be created, unset fields in unit instance will be interpreted as "match any value for this field"
E.g. we can do this for copying or removing or searching units:

unit = RpmUnit(name='bash')
crit = Criteria.for_units([unit])
# This kind of criteria can be used in
# various APIs like:
# copy all bash from repo1 to repo2
repo1.copy_content(criteria=crit, to_repo=repo2)
# remove all bash RPMs
repo1.remove_content(criteria=crit)
# search all bash RPMs
repo1.search_content(criteria=crit)

This should copy all RPMs named "bash" from one repo to another, or it should search in similar manner.

Issue Type

  • Feature Request

Current behavior

Currently creation Criteria instance for units is no much convenient.

Desired behavior

  • Lib supports creation of criteria with *Unit classes used as templates (Criteria.for_units([unit1, unit2]))
  • Unset filed in unit are interpreted as match any value for this field

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions