Collection class
- class almapiwrapper.inventory.Collection(pid: str, zone: str, env: Literal['P', 'S'] = 'P')
Bases:
RecordClass representing a collection object
Collections can be in NZ and in IZ. They contain list of bibliographic records.
- Variables:
zone – zone of the record
env – environment of the entity: ‘P’ for production and ‘S’ for sandbox
data –
almapiwrapper.record.JsonDataobject or dict, useful to force update a record from a backuperror – boolean indicating if an error occurred during the last operation
error_msg – string containing the error message if an error occurred during the last operation
pid – collection ID
api_base_url_bibs – base URL for bibs API calls
area – area of the API
format – format of the data json for collections
- Parameters:
pid – collection ID
zone – zone of the record
env – environment of the entity: ‘P’ for production and ‘S’ for sandbox
- add_bib(bib: IzBib | NzBib | str) None
Add a bib to the collection
- Parameters:
bib –
almapiwrapper.inventory.IzBiboralmapiwrapper.inventory.NzBibto add to the collection- Returns:
None
- static api_call(method: Literal['get', 'put', 'post', 'delete'], *args, **kwargs) Response | None
Static method to handle http errors. Quit the program after 3 failed tries
- Parameters:
method – ‘get’, ‘put’, ‘post’ or ‘delete’ according to the api method call
- property bibs: List[IzBib | NzBib] | None
Property of the collection returning the list containing bib records
- Returns:
List containing
almapiwrapper.inventory.IzBibobjects oralmapiwrapper.inventory.NzBibobjects
- static build_headers(data_format: Literal['json', 'xml'], zone: str, area: str, rights: Literal['R', 'RW'] = 'RW', env: Literal['P', 'S'] | None = 'P') Dict
Build the headers for the API calls.
- Parameters:
data_format – “json” or “xml”
zone – optional, if indicated allow to make the query in an other IZ
area – area of the record, bibs, users for example
rights – “R” for read only or “RW” for write and read rights
env – environment of the api call: ‘P’ for production, ‘S’ for sandbox
- Returns:
dict with the headers
- property data: Dict | Element | DataFrame | None
Property that get xml data with API call. If not available, make an api call
- Returns:
xml data, dictionary or pandas dataframe
- static parse_data(data: JsonData | XmlData | Dict | str) JsonData | XmlData | None
Parse the data and return a parsed data object or None if an error occurs
- Parameters:
data – data to be parsed
- Returns:
parsed data object or None if an error occurs
- remove_bib(bib: IzBib | NzBib | str) None
Remove a bib from the collection
- Parameters:
bib –
almapiwrapper.inventory.IzBiboralmapiwrapper.inventory.NzBibto remove from the collection, can be either a NZ or an IZ bib or a mms_id- Returns:
None
- save() Collection
Save collection in a folder.
Example: records/UBS_9963486250105504/hol_22314215780005504_01.xml
- Returns:
almapiwrapper.inventory.Collectionobject