InstitutionMethods¶

Class in module ibisclient.methods

class InstitutionMethods(conn)¶

Bases: object

Methods for querying and manipulating institutions.

The fetch parameter for institutions

All methods that return institutions also accept an optional fetch parameter that may be used to request additional information about the institutions returned. For more details about the general rules that apply to the fetch parameter, refer to the PersonMethods documentation.

For institutions the fetch parameter may be used to fetch any institution attribute by specifying the schemeid of an institution attribute scheme. Examples include "address", "jpegPhoto", "universityPhone", "instPhone", "landlinePhone", "mobilePhone", "faxNumber", "email" and "labeledURI". The full list (which may be extended over time) may be obtained using InstitutionMethods.allAttributeSchemes().

In addition the following pseudo-attributes are supported:

  • "phone_numbers" - fetches all phone numbers. This is equivalent to "universityPhone,instPhone,landlinePhone,mobilePhone".

  • "all_attrs" - fetches all attributes from all institution attribute schemes. This does not include references.

  • "contact_rows" - fetches all institution contact rows. Any chained fetches from contact rows are used to fetch attributes from any people referred to by the contact rows.

The fetch parameter may also be used to fetch referenced people, institutions or groups. This will only include references to non-cancelled entities. The following references are supported:

  • "all_members" - fetches all the people who are members of the institution.

  • "parent_insts" - fetches all the parent institutions. Note that currently all institutions have only one parent, but this may change in the future, and client applications should be prepared to handle multiple parents.

  • "child_insts" - fetches all the child institutions.

  • "inst_groups" - fetches all the groups that belong to the institution.

  • "members_groups" - fetches all the groups that form the institution's membership list.

  • "managed_by_groups" - fetches all the groups that manage the institution's data (commonly called "Editor" groups).

As with person fetch parameters, the references may be used in a chain by using the "dot" notation to fetch additional information about referenced people, institutions or groups. For example "all_members.email" will fetch the email addresses of all members of the institution. For more information about what can be fetched from referenced people and groups, refer to the documentation for PersonMethods and GroupMethods.

Code author: Dean Rasheed (dev-group@ucs.cam.ac.uk)

addAttribute(instid, attr, position=None, allowDuplicates=None, commitComment=None)¶

Add an attribute to an institution. By default, this will not add the attribute again if it already exists.

When adding an attribute, the new attribute's scheme must be set. In addition, either its value or its binaryData field should be set. All the remaining fields of the attribute are optional.

[ HTTP: POST /api/v1/inst/{instid}/add-attribute ]

Parameters
instidstr

[required] The ID of the institution.

attrIbisAttribute

[required] The new attribute to add.

positionint

[optional] The position of the new attribute in the list of attributes of the same attribute scheme (1, 2, 3,...). A value of 0 (the default) will cause the new attribute to be added to the end of the list of existing attributes for the scheme.

allowDuplicatesbool

[optional] If True, the new attribute will always be added, even if another identical attribute already exists. If False (the default), the new attribute will only be added if it doesn't already exist.

commitCommentstr

[recommended] A short textual description of the change made (will be visible on the history tab in the web application).

Returns
IbisAttribute

The newly created or existing attribute.

allAttributeSchemes()¶

Return a list of all the institution attribute schemes available. The schemeid values of these schemes may be used in the fetch parameter of other methods that return institutions.

[ HTTP: GET /api/v1/inst/all-attr-schemes ]

Returns
list of IbisAttributeScheme

All the available institution attribute schemes (in precedence order).

allInsts(includeCancelled, fetch=None)¶

Return a list of all institutions.

By default, only a few basic details about each institution are returned, but the optional fetch parameter may be used to fetch additional attributes or references.

[ HTTP: GET /api/v1/inst/all-insts ]

Parameters
includeCancelledbool

[optional] Whether or not to include cancelled institutions. By default, only live institutions are returned.

fetchstr

[optional] A comma-separated list of any additional attributes or references to fetch.

Returns
list of IbisInstitution

The requested institutions (in instid order).

createGroup(instid, name, title, description, managedBy=None, commitComment=None)¶

Create a group owned by an institution.

A new group will be created with the institution being its only owner.

Only limited attributes (short hyphenated name, title and description) of the new group can be specified when creating a group. The GroupMethod's update methods be used to modify other attributes. The new group will have membership visibility of 'university' and be managed by the same groups as its owning institution.

[ HTTP: POST /api/v1/inst/{instid}/create-group ]

Parameters
instidstr

[required] The ID of the institution.

namestr

[required] A short hyphenated name for the new group. Must be in lower case and begin with the instid followed by a hyphen.

titlestr

[required] A title for the new group.

descriptionstr

[required] A more detailed description of the new group.

managedBystr

[optional] The sole group that will manage group data for the new group. If not provided, the new group will be managed by the same groups as its owning institution.

commitCommentstr

[recommended] A short textual description of the change made (will be visible on the history tab in the web application).

Returns
IbisGroup

The newly created group.

deleteAttribute(instid, attrid, commitComment=None)¶

Delete an attribute of an institution. It is not an error if the attribute does not exist.

Note that in this method, the commitComment is passed as a query parameter, rather than as a form parameter, for greater client compatibility.

[ HTTP: DELETE /api/v1/inst/{instid}/{attrid} ]

Parameters
instidstr

[required] The ID of the institution.

attridlong

[required] The ID of the attribute to delete.

commitCommentstr

[recommended] A short textual description of the change made (will be visible on the history tab in the web application).

Returns
bool

True if the attribute was deleted by this method, or False if it did not exist.

getAttribute(instid, attrid)¶

Get a specific attribute of an institution.

[ HTTP: GET /api/v1/inst/{instid}/{attrid} ]

Parameters
instidstr

[required] The ID of the institution.

attridlong

[required] The ID of the attribute to fetch.

Returns
IbisAttribute

The requested attribute.

getAttributes(instid, attrs)¶

Get one or more (possibly multi-valued) attributes of an institution. The returned attributes are sorted by attribute scheme precedence and then attribute precedence.

[ HTTP: GET /api/v1/inst/{instid}/get-attributes?attrs=... ]

Parameters
instidstr

[required] The ID of the institution.

attrsstr

[required] The attribute scheme(s) to fetch. This may include any number of the attributes or pseudo-attributes, but it may not include references or attribute chains (see the documentation for the fetch parameter in this class).

Returns
list of IbisAttribute

The requested attributes.

getCancelledMembers(instid, fetch=None)¶

Get all the cancelled members of the specified institution.

By default, only a few basic details about each member are returned, but the optional fetch parameter may be used to fetch additional attributes or references of each person.

Note

This method returns only cancelled people. It does not include people who were removed from the institution. Cancelled people are no longer considered to be current staff, students or accredited visitors, and are no longer regarded as belonging to any groups or institutions. The list returned here reflects their institutional memberships just before they were cancelled, and so is out-of-date data that should be used with caution.

[ HTTP: GET /api/v1/inst/{instid}/cancelled-members ]

Parameters
instidstr

[required] The ID of the institution.

fetchstr

[optional] A comma-separated list of any additional attributes or references to fetch for each person.

Returns
list of IbisPerson

The institution's cancelled members (in identifier order).

getContactRows(instid, fetch=None)¶

Get all the contact rows of the specified institution.

Any addresses, email addresses, phone numbers and web pages associated with the contact rows are automatically returned, as well as any people referred to by the contact rows.

If any of the contact rows refer to people, then only a few basic details about each person are returned, but the optional fetch parameter may be used to fetch additional attributes or references of each person.

Note

This method will not include cancelled people.

[ HTTP: GET /api/v1/inst/{instid}/contact-rows ]

Parameters
instidstr

[required] The ID of the institution.

fetchstr

[optional] A comma-separated list of any additional attributes or references to fetch for any people referred to by any of the contact rows.

Returns
list of IbisContactRow

The institution's contact rows.

getInst(instid, fetch=None)¶

Get the institution with the specified ID.

By default, only a few basic details about the institution are returned, but the optional fetch parameter may be used to fetch additional attributes or references of the institution.

Note

The institution returned may be a cancelled institution. It is the caller's responsibility to check its cancelled flag.

[ HTTP: GET /api/v1/inst/{instid} ]

Parameters
instidstr

[required] The ID of the institution to fetch.

fetchstr

[optional] A comma-separated list of any additional attributes or references to fetch.

Returns
IbisInstitution

The requested institution or None if it was not found.

getMembers(instid, fetch=None)¶

Get all the members of the specified institution.

By default, only a few basic details about each member are returned, but the optional fetch parameter may be used to fetch additional attributes or references of each person.

Note

This method will not include cancelled people.

[ HTTP: GET /api/v1/inst/{instid}/members ]

Parameters
instidstr

[required] The ID of the institution.

fetchstr

[optional] A comma-separated list of any additional attributes or references to fetch for each person.

Returns
list of IbisPerson

The institution's members (in identifier order).

listInsts(instids, fetch=None)¶

Get the institutions with the specified IDs.

By default, only a few basic details about each institution are returned, but the optional fetch parameter may be used to fetch additional attributes or references.

The results are sorted by ID.

Note

The URL path length is limited to around 8000 characters, and an instid is up to 8 characters long. Allowing for comma separators and URL encoding, this limits the number of institutions that this method may fetch to around 700.

Note

The institutions returned may include cancelled institutions. It is the caller's responsibility to check their cancelled flags.

[ HTTP: GET /api/v1/inst/list?instids=... ]

Parameters
instidsstr

[required] A comma-separated list of instids.

fetchstr

[optional] A comma-separated list of any additional attributes or references to fetch.

Returns
list of IbisInstitution

The requested institutions (in instid order).

modifiedInsts(minTxId, maxTxId, instids=None, includeCancelled=None, contactRowChanges=None, membershipChanges=None, fetch=None)¶

Find all institutions modified between the specified pair of transactions.

The transaction IDs specified should be the IDs from two different requests for the last (most recent) transaction ID, made at different times, that returned different values, indicating that some Lookup data was modified in the period between the two requests. This method then determines which (if any) institutions were affected.

By default, only a few basic details about each institution are returned, but the optional fetch parameter may be used to fetch additional attributes or references.

Note

All data returned reflects the latest available data about each institution. It is not possible to query for old data, or more detailed information about the specific changes made.

[ HTTP: GET /api/v1/inst/modified-insts?minTxId=...&maxTxId=... ]

Parameters
minTxIdlong

[required] Include modifications made in transactions after (but not including) this one.

maxTxIdlong

[required] Include modifications made in transactions up to and including this one.

instidsstr

[optional] Only include institutions with instids in this list. By default, all modified institutions will be included.

includeCancelledbool

[optional] Include cancelled institutions. By default, cancelled institutions are excluded.

contactRowChangesbool

[optional] Include institutions whose contact rows have changed. By default, changes to institution contact rows are not taken into consideration.

membershipChangesbool

[optional] Include institutions whose members have changed. By default, changes to institutional memberships are not taken into consideration.

fetchstr

[optional] A comma-separated list of any additional attributes or references to fetch.

Returns
list of IbisInstitution

The modified institutions (in instid order).

search(query, approxMatches=None, includeCancelled=None, attributes=None, offset=None, limit=None, orderBy=None, fetch=None)¶

Search for institutions using a free text query string. This is the same search function that is used in the Lookup web application.

By default, only a few basic details about each institution are returned, but the optional fetch parameter may be used to fetch additional attributes or references.

Note

If the query string starts with the prefix "inst:", it is treated as an LQL query, allowing more advanced searches. An LQL query will ignore the approxMatches and attributes parameters, but it will respect the value of includeCancelled. In addition, an LQL query will ignore the orderBy parameter, since LQL queries always return results in ID order.

[ HTTP: GET /api/v1/inst/search?query=... ]

Parameters
querystr

[required] The search string.

approxMatchesbool

[optional] Flag to enable more approximate matching in the search, causing more results to be returned. Defaults to False. This is ignored for LQL queries.

includeCancelledbool

[optional] Flag to allow cancelled institutions to be included. Defaults to False.

attributesstr

[optional] A comma-separated list of attributes to consider when searching. If this is None (the default) then all attribute schemes marked as searchable will be included. This is ignored for LQL queries.

offsetint

[optional] The number of results to skip at the start of the search. Defaults to 0.

limitint

[optional] The maximum number of results to return. Defaults to 100.

orderBystr

[optional] The order in which to list the results. This may be either "instid" or "name" (the default for non-LQL queries). This is ignored for LQL queries, which always return results in instid order.

fetchstr

[optional] A comma-separated list of any additional attributes or references to fetch.

Returns
list of IbisInstitution

The matching institutions.

searchCount(query, approxMatches=None, includeCancelled=None, attributes=None)¶

Count the number of institutions that would be returned by a search using a free text query string.

Note

If the query string starts with the prefix "inst:", it is treated as an LQL query, allowing more advanced searches. An LQL query will ignore the approxMatches and attributes parameters, but it will respect the value of includeCancelled.

[ HTTP: GET /api/v1/inst/search-count?query=... ]

Parameters
querystr

[required] The search string.

approxMatchesbool

[optional] Flag to enable more approximate matching in the search, causing more results to be returned. Defaults to False. This is ignored for LQL queries.

includeCancelledbool

[optional] Flag to allow cancelled institutions to be included. Defaults to False.

attributesstr

[optional] A comma-separated list of attributes to consider when searching. If this is None (the default) then all attribute schemes marked as searchable will be included. This is ignored for LQL queries.

Returns
int

The number of matching institutions.

updateAttribute(instid, attrid, attr, commitComment=None)¶

Update an attribute of an institution.

The attribute's value, binaryData, comment and effective date fields will all be updated using the data supplied. All other fields will be left unchanged.

To avoid inadvertently changing fields of the attribute, it is recommended that getAttribute() be used to retrieve the current value of the attribute, before calling this method with the required changes.

[ HTTP: PUT /api/v1/inst/{instid}/{attrid} ]

Parameters
instidstr

[required] The ID of the institution.

attridlong

[required] The ID of the attribute to update.

attrIbisAttribute

[required] The new attribute values to apply.

commitCommentstr

[recommended] A short textual description of the change made (will be visible on the history tab in the web application).

Returns
IbisAttribute

The updated attribute.