There are many Services in Fedora. Many of these have an interface that we can query and get back information as JSON data. There is documentation here about both the services and the client modules that can access them.
FAS is the Fedora Account System. It holds the account data for all of our contributors.
An object for querying the Fedora Account System.
The Account System object provides a python API for talking to the Fedora Account System. It abstracts the http requests, cookie handling, and other details so you can concentrate on the methods that are important to your program.
Warning
If your code is trying to use the AccountSystem object to connect to fas for multiple users you probably want to use FasProxyClient instead. If your code is trying to reuse a single instance of AccountSystem for multiple users you definitely want to use FasProxyClient instead. Using AccountSystem in these cases may result in a user being logged in as a different user. (This may be the case even if you instantiate a new AccountSystem object for each user if :attr:cache_session: is True since that creates a file on the file system that can end up loading session credentials for the wrong person.
Changed in version 0.3.26: Added gravatar_url() that returns a url to a gravatar for a user.
Changed in version 0.3.33: Renamed gravatar_url() to avatar_url().
Returns a URL to an avatar for a given username.
Avatars are drawn from third party services.
Parameters: |
|
---|---|
Raises ValueError: | |
if the size parameter is not allowed or if the service is not one of ‘libravatar’ or ‘gravatar’ |
|
Return type: | str |
Returns: | url of a avatar for the user |
If that user has no avatar entry, instruct the remote service to redirect us to the Fedora logo.
If that user has no email attribute, then make a fake request to the third party service.
New in version 0.3.26.
Creates a FAS group.
Parameters: |
|
---|---|
Return type: | munch.Munch |
Returns: | A Munch containing information about the group that was created. |
New in version 0.3.29.
Return the config entry for the key values.
Parameters: |
|
---|---|
Raises AppError: | |
if the server returns an exception |
|
Returns: | The unicode string that describes the value. If no entry matched the username, application, and attribute then None is returned. |
Return the config entries that match the keys and the pattern.
Note: authentication on the server will prevent anyone but the user or a fas admin from viewing or changing their configs.
Parameters: |
|
---|---|
Raises AppError: | |
if the server returns an exception |
|
Returns: | A dict mapping attribute to value. |
Deprecated - Use avatar_url.
New in version 0.3.26.
Returns a group object based on its id
Returns a group object based on its name
Return administrators/sponsors/users and group type for all groups
Parameters: | force_refresh – If true, the returned data will be queried from the database, as opposed to memcached. |
---|---|
Raises AppError: | |
if the query failed on the server | |
Returns: | A dict mapping group names to the group type and the user IDs of the administrator, sponsors, and users of the group. |
New in version 0.3.8.
Return a list of people approved for a group.
This method returns a list of people who are in the requested group. The people are all approved in the group. Unapproved people are not shown. The format of data is:
\[{'username': 'person1', 'role_type': 'user'},
\{'username': 'person2', 'role_type': 'sponsor'}]
role_type can be one of ‘user’, ‘sponsor’, or ‘administrator’.
New in version 0.3.2.
Changed in version 0.3.21: Return a Bunch instead of a DictContainer
If this attribute is set to True, do not check server certificates against their CA’s. This means that man-in-the-middle attacks are possible. You might turn this option on for testing against a local version of a server with a self-signed certificate but it should be off in production.
Return a list of persons for the given groupname.
Parameters: | groupname – Name of the group to look up |
---|---|
Returns: | A list of person objects from the group. If the group contains no entries, then an empty list is returned. |
Deprecated Use people_by_key() instead.
Returns a dict relating user IDs to human_name, email, username, and bugzilla email
Changed in version 0.3.21: Return a Bunch instead of a DictContainer
Return a dict of people
For example:
>>> ret_val = FASCLIENT.people_by_key(
... key='email', search='toshio*', fields='id')
>>> ret_val.keys()
a.badger@[...].com
a.badger+test1@[...].com
a.badger+test2@[...].com
>>> ret_val.values()
100068
102023
102434
Parameters: |
|
---|---|
Returns: | a dict relating the key value to the fields. |
Changed in version 0.3.21: Return a Bunch instead of a DictContainer
Changed in version 0.3.26: Fixed to return a list with both people who have signed the CLA and have not
Returns a list of dicts representing database rows
Parameters: |
|
---|---|
Raises AppError: | |
if the query failed on the server (most likely because the server was given a bad query) |
|
Returns: | A list of dicts representing database rows (the keys of the dict are the columns requested) |
New in version 0.3.12.1.
Returns a person object based on its id
Returns a person object based on its username
Set a config entry in FAS for the user.
Note: authentication on the server will prevent anyone but the user or a fas admin from viewing or changing their configs.
Parameters: |
|
---|---|
Raises AppError: | |
if the server returns an exception |
Return user data for all users in FAS
Note: If the user is not authorized to see password hashes, ‘*’ is returned for the hash.
Raises AppError: | |
---|---|
if the query failed on the server | |
Returns: | A dict mapping user IDs to a username, password hash, SSH public key, email address, and status. |
New in version 0.3.8.
Generate a cert for a user
Returns a dict relating user IDs to usernames
Return whether the username and password pair are valid.
Parameters: |
|
---|---|
Returns: | True if the username/password are valid. False otherwise. |
It is not safe to use a single instance of the AccountSystem object in multiple threads. This is because instance variables are used to hold some connection-specific information (for instance, the user who is logging in). For this reason, we also provide the fedora.client.FasProxyClient object.
This is especially handy when writing authn and authz adaptors that talk to fas from a multithreaded webserver.
A threadsafe client to the Fedora Account System.
Retrieve information about a logged in user.
Parameters: | auth_params – Auth information for a particular user. For instance, this can be a username/password pair or a session_id. Refer to fedora.client.proxyclient.ProxyClient.send_request() for all the legal values for this. |
---|---|
Returns: | a tuple of session_id and information about the user. |
Raises AuthError: | |
if the auth_params do not give access |
Retrieve a list of groups
Parameters: | auth_params – Auth information for a particular user. For instance, this can be a username/password pair or a session_id. Refer to fedora.client.proxyclient.ProxyClient.send_request() for all the legal values for this. | ||||
---|---|---|---|---|---|
Returns: | a tuple of session_id and information about groups. The
groups information is in two fields:
|
||||
Raises AuthError: | |||||
if the auth_params do not give access |
Login to the Account System
Parameters: |
|
---|---|
Returns: | a tuple of the session id FAS has associated with the user and the user’s account information. This is similar to what is returned by fedora.client.proxyclient.ProxyClient.get_user_info() |
Raises AuthError: | |
if the username and password do not work |
Logout of the Account System
Parameters: | session_id – a FAS session_id to remove from FAS |
---|
Retrieve information about a particular person
Parameters: | auth_params – Auth information for a particular user. For instance, this can be a username/password pair or a session_id. Refer to fedora.client.proxyclient.ProxyClient.send_request() for all the legal values for this. |
---|---|
Returns: | a tuple of session_id and information about the user. |
Raises: |
|
Try to refresh a session_id to prevent it from timing out
Parameters: | session_id – FAS session_id to refresh |
---|---|
Returns: | session_id that FAS has set now |
Return whether the username and password pair are valid.
Parameters: |
|
---|---|
Returns: | True if the username/password are valid. False otherwise. |
Verify that a session is active.
Parameters: | session_id – session_id to verify is currently associated with a logged in user |
---|---|
Returns: | True if the session_id is valid. False otherwise. |
The Package Database holds information about packages in Fedora. It currently has a developer-centric view of packages that concentrates on who the owner is of a particular package.
Plans to add an end-user view to packages is ongoing.
Changed in version 0.3.21: Added PackageDB.add_comaintainers() Added PackageDB.change_owner()
Add comaintainers to all packagelistings that the owner either is the owner or has approveacls on. Then email comaintainers/owners on those packages that the maintainer has changed the acls.
Parameters: |
|
---|
New in version 0.3.21.
Add a package to the database.
Parameters: |
|
---|---|
Raises AppError: | |
If the server returns an error |
New in version 0.3.13.
Return collection branch information from the packagedb.
This method caches the branch information from the packagedb in self._branches. It returns that information when called.
Parameters: | refresh – If refresh is set to True, contact the server even if the information was previously cached |
---|---|
Returns: | dictionary of branches keyed by their shortname |
Change a branch abbreviation into a name and version.
Parameters: | branch – branch abbreviation |
---|---|
Return type: | tuple |
Returns: | tuple of branch name and branch version. |
Example: >>> name, version = canonical_branch_name(‘FC-6’) >>> name Fedora >>> version 6
Change the owner of all packagelistings that the owner either is the owner or has approveacls on. Then email comaintainers/owners on those packages that the owner has changed the owner.
Parameters: |
|
---|
New in version 0.3.21.
Set a branch’s permissions from a pre-existing branch.
Parameters: |
|
---|---|
Raises AppError: | |
If the server returns an exceptiom |
Edit a package.
Parameters: |
|
---|---|
Raises AppError: | |
If the server returns an error |
This method takes information about a package and either edits the package to reflect the changes to information.
Note: This method will be going away in favor of methods that do smaller chunks of work:
New in version 0.3.13.
Return the package attributes used by bugzilla.
Return type: | Bunch | ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | Bunch contains information needed to setup bugzilla
for every collection. It looks like this:
data[collctn][pkg][attribute] where attribute is one of:
|
New in version 0.3.15.
Changed in version 0.3.21: Return Bunch instead of DictContainer
Retrieve a list of all collections.
Parameters: | eol – Default True. If set to False, do not return collections marked eol. |
---|---|
Returns: | list of collections |
Return names of packages marked critical path.
Parameters: | collctn_list – When set to a list of Collection names, only retrieve packages which are marked critpath in any of the collections. Defaults to retrieving critpath packages in all non-EOL releases |
---|---|
Return type: | Bunch |
Returns: | Keys of the returned dict are collection simple names. The values are lists of package names that are marked critpath |
New in version 0.3.17.
Changed in version 0.3.21: Return Bunch instead of DictContainer
Return the package attibutes used by notify
Parameters: |
|
---|---|
Return type: | Bunch |
Returns: | Bunch keyed on package name. Each entry has a list of people to be notified for this package. |
New in version 0.3.15.
Changed in version 0.3.21: Return Bunch instead of DictContainer
Retrieve the ownership information for a package.
Parameters: |
|
---|---|
Kward collection_ver: | |
old/deprecated argument; use collctn_ver |
|
Raises AppError: | |
If the server returns an error |
|
Return type: | Bunch |
Returns: | dict of ownership information for the package |
Changed in version 0.3.17: Rename collection and collection_ver to collctn_name and collctn_ver
Changed in version 0.3.21: Return Bunch instead of DictContainer
Get information about the package.
Parameters: |
|
---|---|
Raises AppError: | |
If the server returns an exceptiom |
|
Returns: | Package ownership information |
Return type: | Bunch |
Changed in version 0.3.21: Return Bunch instead of DictContainer
Retrieve a list of all package names in a collection.
Parameters: |
|
---|---|
Returns: | list of package names present in the collection. |
New in version 0.3.15.
Changed in version 0.3.17: Rename collectn to collctn
Return the acls for the version control system.
Note: the return values from this function will be changing when the PackageDB updates to 0.5.x. The return data will look like this:
data[pkg][branch].people
data[pkg][branch].groups
Return type: | Bunch |
---|---|
Returns: | Bunch representing the vcs acls for every person.
It looks like this: data[pkg][branch][‘commit’].people list of
users who can commit to the package. Example:>>> print data['bzr']['devel']['commit'].people
['toshio', 'hno', 'shahms', 'toshio']
>>> print data['bzr']['devel']['commit'].groups
['provenpackager']
|
New in version 0.3.15.
Changed in version 0.3.21: Return Bunch instead of DictContainer
Branch all unblocked packages for a new release.
Mass branching always works against the devel branch.
Parameters: | branch – Branch name to create branches for. Names are listed in COLLECTIONMAP |
---|---|
Raises AppError: | |
If the server returns an exceptiom. The ‘extras’ attribute will contain a list of unbranched packages if some of the packages were branched |
List the packages which are orphaned
Returns: | List of pkgs which are orphaned in any non-EOL release. |
---|
Remove user from a package
Parameters: |
|
---|---|
Returns: | status code from the request |
New in version 0.3.12.
Changed in version 0.3.17: Rename collectn_list to collctn_list
Mark packages as being in the critical path.
Critical path packages are subject to more testing or stringency of criteria for updating when a release occurs.
Parameters: |
|
---|
New in version 0.3.17.
Retrieve information about the packages a user owns
Parameters: |
|
---|---|
Returns: | packages that the user has acls on |
New in version 0.3.14.
Bodhi is used to push updates from the build system to the download repositories. It lets packagers send packages to the testing repository or to the update repository.
pythyon-fedora currently supports both the old Bodhi1 interface and the new Bodhi2 interface. By using fedora.client.BodhiCLient, the correct one should be returned to you depending on what is running live on Fedora Infrastructure servers.