Skip to content
This repository has been archived by the owner on Jul 24, 2018. It is now read-only.

Commit

Permalink
Merge pull request #71 from fedora-infra/namespacing
Browse files Browse the repository at this point in the history
Add namespacing support to pkgdb-cli and pkgdb-admin
  • Loading branch information
pypingou committed Dec 16, 2015
2 parents 53518f1 + b791b55 commit 478e77a
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 61 deletions.
82 changes: 65 additions & 17 deletions pkgdb2client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,9 @@ def create_collection(self, clt_name, version, clt_status, branchname,
return self.handle_api_call('/collection/new/', data=args)

def create_package(
self, pkgname, summary, description, review_url, status,
shouldopen, branches, poc, upstream_url, critpath=False):
self, pkgname, summary, description, review_url,
status, shouldopen, branches, poc, upstream_url,
critpath=False, namespace='rpms'):
''' Create a new package.
:arg pkgname: The name of the package
Expand Down Expand Up @@ -440,13 +441,16 @@ def create_package(
:kwarg critpath: A boolean specifying whether to add this
package to the critpath
:type critpath: bool
:kwarg namespace: The namespace of the package. Defaults to ``rpms``.
:type namespace: str
:return: the json object returned by the API
:rtype: dict
:raise PkgDBException: if the API call does not return a http code
200.
'''
args = {
'namespace': namespace,
'pkgname': pkgname,
'summary': summary,
'description': description,
Expand Down Expand Up @@ -521,7 +525,9 @@ def get_collections(self, pattern='*', clt_status=None):

return self.handle_api_call('/collections/', params=args)

def get_package(self, pkgname, branches=None, eol=False, acls=True):
def get_package(
self, pkgname, branches=None, eol=False, acls=True,
namespace='rpms'):
''' Return the information of a package matching the provided
criterias.
Expand All @@ -538,13 +544,16 @@ def get_package(self, pkgname, branches=None, eol=False, acls=True):
:kwarg acls: a boolean to specify whether to include ACLs in the
data returned. Defaults to ``True``.
:type acls: boolean
:kwarg namespace: The namespace of the package. Defaults to ``rpms``.
:type namespace: str
:return: the json object returned by the API
:rtype: dict
:raise PkgDBException: if the API call does not return a http code
200.
'''
args = {
'namespace': namespace,
'pkgname': pkgname,
'branches': branches,
'acls': acls,
Expand Down Expand Up @@ -703,9 +712,9 @@ def get_packager_package(self, packager, branches=None):
return self.handle_api_call('/packager/package/', params=args)

def get_packages(
self, pattern='*', branches=None, poc=None, status=None,
orphaned=False, critpath=None, acls=False, eol=False,
page=1, limit=250, count=False):
self, pattern='*', branches=None, poc=None,
status=None, orphaned=False, critpath=None, acls=False,
eol=False, page=1, limit=250, count=False, namespace='rpms'):
''' Return the list of packages matching the provided criterias.
To get information about what packages a person has acls on, you
Expand Down Expand Up @@ -750,6 +759,8 @@ def get_packages(
instead of the details. If count is True the page argument will
be ignored
:type count: bool
:kwarg namespace: The namespace of the package. Defaults to ``rpms``.
:type namespace: str
:return: the json object returned by the API
:rtype: dict
:raise PkgDBException: if the API call does not return a http code
Expand All @@ -763,6 +774,7 @@ def _get_pages(page):
'''
args = {
'namespace': namespace,
'pattern': pattern,
'branches': branches,
'poc': poc,
Expand Down Expand Up @@ -802,7 +814,8 @@ def _get_pages(page):

return output

def orphan_packages(self, pkgnames, branches, former_poc=None):
def orphan_packages(
self, pkgnames, branches, former_poc=None, namespace='rpms'):
''' Orphans the provided list of packages on the provided list of
branches.
Expand All @@ -815,6 +828,8 @@ def orphan_packages(self, pkgnames, branches, former_poc=None):
orphaning the branches where the specified user is POC, even
if the branches you specified are broader than reality.
:type former_poc: str
:kwarg namespace: The namespace of the package. Defauts to ``rpms``.
:type namespace: str
:return: the json object returned by the API
:rtype: dict
:raise PkgDBAuthException: if this method is called while the
Expand All @@ -824,6 +839,7 @@ def orphan_packages(self, pkgnames, branches, former_poc=None):
'''
args = {
'namespace': namespace,
'pkgnames': pkgnames,
'branches': branches,
}
Expand All @@ -833,7 +849,7 @@ def orphan_packages(self, pkgnames, branches, former_poc=None):

return self.handle_api_call('/package/orphan/', data=args)

def retire_packages(self, pkgnames, branches):
def retire_packages(self, pkgnames, branches, namespace='rpms'):
''' Retires the provided list of packages on the provided list of
branches.
Expand All @@ -842,6 +858,8 @@ def retire_packages(self, pkgnames, branches):
:arg branches: One or more branch names for the collections in
which to retire the packages
:type branches: str or list
:kwarg namespace: The namespace of the package. Defaults to ``rpms``.
:type namespace: str
:return: the json object returned by the API
:rtype: dict
:raise PkgDBAuthException: if this method is called while the
Expand All @@ -851,13 +869,14 @@ def retire_packages(self, pkgnames, branches):
'''
args = {
'namespace': namespace,
'pkgnames': pkgnames,
'branches': branches,
}

return self.handle_api_call('/package/retire/', data=args)

def unorphan_packages(self, pkgnames, branches, poc):
def unorphan_packages(self, pkgnames, branches, poc, namespace='rpms'):
''' Un orphan the provided list of packages on the provided list of
branches.
Expand All @@ -868,6 +887,8 @@ def unorphan_packages(self, pkgnames, branches, poc):
:type branches: str or list
:arg poc:
:type poc: str
:kwarg namespace: The namespace of the package. Defaults to ``rpms``.
:type namespace: str
:return: the json object returned by the API
:rtype: dict
:raise PkgDBAuthException: if this method is called while the
Expand All @@ -877,14 +898,15 @@ def unorphan_packages(self, pkgnames, branches, poc):
'''
args = {
'namespace': namespace,
'pkgnames': pkgnames,
'branches': branches,
'poc': poc,
}

return self.handle_api_call('/package/unorphan/', data=args)

def unretire_packages(self, pkgnames, branches):
def unretire_packages(self, pkgnames, branches, namespace='rpms'):
''' Un retires the provided list of packages on the provided list of
branches.
Expand All @@ -893,6 +915,8 @@ def unretire_packages(self, pkgnames, branches):
:arg branches: One or more branch names for the collections in
which to unretire the packages
:type branches: str or list
:kwarg namespace: The namespace of the package. Defaults to ``rpms``.
:type namespace: str
:return: the json object returned by the API
:rtype: dict
:raise PkgDBAuthException: if this method is called while the
Expand All @@ -902,13 +926,15 @@ def unretire_packages(self, pkgnames, branches):
'''
args = {
'namespace': namespace,
'pkgnames': pkgnames,
'branches': branches,
}

return self.handle_api_call('/package/unretire/', data=args)

def update_acl(self, pkgname, branches, acls, status, user):
def update_acl(
self, pkgname, branches, acls, status, user, namespace='rpms'):
''' Update the specified ACLs, on the specified Branches of the
specified package.
Expand All @@ -930,6 +956,8 @@ def update_acl(self, pkgname, branches, acls, status, user):
:arg user: The user for which to update the ACL (the person
requesting new ACLs or for which to approve/deny the ACLs)
:type user: str
:kwarg namespace: The namespace of the package. Defaults to ``rpms``.
:type namespace: str
:return: the json object returned by the API
:rtype: dict
:raise PkgDBAuthException: if this method is called while the
Expand All @@ -939,6 +967,7 @@ def update_acl(self, pkgname, branches, acls, status, user):
'''
args = {
'namespace': namespace,
'pkgname': pkgname,
'branches': branches,
'acl': acls,
Expand All @@ -951,6 +980,8 @@ def update_acl(self, pkgname, branches, acls, status, user):
def update_collection_status(self, branch, clt_status):
''' Update the status of the specified collection.
:arg namespace: The namespace of the package
:type namespace: str
:arg branch: The branch name of the collection for which to
update the status
:type branch: str
Expand All @@ -973,7 +1004,8 @@ def update_collection_status(self, branch, clt_status):
return self.handle_api_call('/collection/{0}/status/'.format(branch),
data=args)

def update_critpath(self, pkgname, branches, critpath=False):
def update_critpath(
self, pkgname, branches, critpath=False, namespace='rpms'):
''' Set / Remove critpath status of a package
:arg pkgname: The name of the package
Expand All @@ -984,16 +1016,21 @@ def update_critpath(self, pkgname, branches, critpath=False):
:arg critpath: A boolean corresponding to the critpath status to
set
:type critpath: bool
:kwarg namespace: The namespace of the package. Defaults to ``rpms``.
:type namespace: str
'''
args = {
'namespace': namespace,
'pkgnames': pkgname,
'branches': branches,
'critpath': critpath
}
return self.handle_api_call('/package/critpath/', data=args)

def update_package_poc(self, pkgnames, branches, poc, former_poc=None):
def update_package_poc(
self, pkgnames, branches, poc, former_poc=None,
namespace='rpms'):
''' Update the point of contact of the specified packages on the
specified branches.
Expand All @@ -1009,6 +1046,8 @@ def update_package_poc(self, pkgnames, branches, poc, former_poc=None):
changing branches where the specified former_poc is POC, even
if the branches you specified are broader.
:type former_poc: str
:kwarg namespace: The namespace of the package. Defaults to ``rpms``.
:type namespace: str
:return: the json object returned by the API
:rtype: dict
:raise PkgDBAuthException: if this method is called while the
Expand All @@ -1018,6 +1057,7 @@ def update_package_poc(self, pkgnames, branches, poc, former_poc=None):
'''
args = {
'namespace': namespace,
'pkgnames': pkgnames,
'branches': branches,
'poc': poc,
Expand Down Expand Up @@ -1095,14 +1135,16 @@ def get_pending_acls(self, username=None):
args['username'] = username
return self.handle_api_call('/pendingacls', params=args)

def set_monitoring_status(self, pkgname, monitoring):
def set_monitoring_status(self, pkgname, monitoring, namespace='rpms'):
''' Set / Remove the monitoring status of a package.
:arg pkgname: The name of the package
:type pkgname: str
:arg monitoring: The monitoring status to set the package to. Can
be any of: True, 1, False, 0, or 'nobuild'.
:type monitoring: str
:kwarg namespace: The namespace of the package. Defaults to ``rpms``.
:type namespace: str
'''
valid = ['true', '1', 'false', '0', 'nobuild']
Expand All @@ -1112,20 +1154,24 @@ def set_monitoring_status(self, pkgname, monitoring):
monitoring, ', '.join(valid))
)
args = {
'namespace': namespace,
'package': pkgname,
'status': monitoring,
}
return self.handle_api_call(
'/package/%s/monitor/%s' % (pkgname, monitoring), data=args)
'/package/%s/%s/monitor/%s' % (
namespace, pkgname, monitoring), data=args)

def set_koschei_status(self, pkgname, koschei):
def set_koschei_status(self, pkgname, koschei, namespace='rpms'):
''' Set / Remove the koschei status of a package.
:arg pkgname: The name of the package
:type pkgname: str
:arg koschei The koschei status to set the package to. Can
be any of: True, 1, False, 0.
:type koschei str
:kwarg namespace: The namespace of the package. Defaults to ``rpms``.
:type namespace: str
'''
valid = ['true', '1', 'false', '0']
Expand All @@ -1135,8 +1181,10 @@ def set_koschei_status(self, pkgname, koschei):
koschei, ', '.join(valid))
)
args = {
'namespace': namespace,
'package': pkgname,
'status': koschei,
}
return self.handle_api_call(
'/package/%s/koschei/%s' % (pkgname, koschei), data=args)
'/package/%s/%s/koschei/%s' % (
namespace, pkgname, koschei), data=args)
Loading

0 comments on commit 478e77a

Please sign in to comment.