ApiKeys
class
- class almapiwrapper.ApiKeys
Bases:
object
This class help to manage multiple API Keys
Note
The API keys should be stored in a json file. The path to this file has to be in alma_api_keys environment variable.
- Example
>>> from almapiwrapper import ApiKeys >>> k = ApiKeys() >>> api_key_1 = k.get_key('NZ', 'Users', 'RW', 'P')
Will get an API key for Network Zone with read and write rights on users in productive environment
>>> api_key_2 = k.get_key('UBS', 'Bibs', 'RW', 'S')
Will get an API key for UBS IZ with read and write rights on bibliographic data in productive environment.
- get_iz_codes(env: Optional[Literal['P', 'S']] = 'P') List[str]
Return the list of all IZ abbreviations :param env: “P” for production, “S” for sandbox. Default is production :return: Code of all IZ :rtype: str
- get_key(zone: str, area: str, permissions: str, env: str = 'P') str
Return the API key according to the requested parameters
- Parameters
zone – abbreviated form of the IZ or of the NZ
area – area of the API for example “Users”
permissions – read or read/write. It accepts only “R” and “RW”
env – production or sandbox environment, defaults to “P”
- Returns
API key
- Raise
KeyError: exception is risen when no corresponding key is found