Holding class

class almapiwrapper.inventory.Holding(mms_id: Optional[str] = None, holding_id: Optional[str] = None, zone: Optional[str] = None, env: Optional[Literal['P', 'S']] = 'P', bib: Optional[IzBib] = None, data: Optional[Union[XmlData, Element]] = None, create_holding: Optional[bool] = False)

Bases: Record

Class representing a holding object. Holdings are only in the IZ.

Several possibilities for building holdings: - ‘get_holdings’ method of IzBib object - Holding(mms_id, holding_id, zone, env) - Holding(bib=BibIz, holding_id=holding_id)

if no ‘holding_id’ is provided, but ‘data’ is provided and create_holding is True, then it creates a new holding.

Variables
  • holding_id – holding ID

  • zone – zone of the record

  • env – environment of the entity: ‘P’ for production and ‘S’ for sandbox

  • bib – class:almapiwrapper.inventory.IzBib object

  • dataalmapiwrapper.record.XmlData or etree.Element object,

useful to force update a record from a backup :param mms_id: record mms_id :param create_holding: boolean, if True try to create a new holding (if no ‘holding_id’ is provided)

static build_headers(data_format: Literal['json', 'xml'], zone: str, area: str, rights: Literal['R', 'RW'] = 'RW', env: Optional[Literal['P', 'S']] = '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 callnumber

Property of the holding returning the callnumber

Returns

str containing callnumber

property data: Optional[Union[Dict, Element, DataFrame]]

Property that get xml data with API call. If not available, make an api call

Returns

xml data, dictionary or pandas dataframe

delete(self, force: Optional[bool] = False) None

Delete holding

Returns

None

delete_items(self) None

Delete all items of the holding

Returns

None

static get_data_from_disk(mms_id, holding_id, zone)

Fetch the data of the described record

Parameters
  • mms_id – bib record mms_id

  • holding_id – holding record ID

  • zone – zone of the record

Returns

almapiwrapper.record.XmlData or None

get_holding_id(self) str

Fetch holding ID in the data of ‘data’ attribute.

Useful for creating a new holding.

Returns

str with holding id

get_items(self) List['inventory.Item']

This method is used to retrieve the list of items and loads the xml data of these items. To avoid reloading this information, the items references are stored in the private attribute ‘_items’.

Returns

list of almapiwrapper.bib.Item objects

property library

Property of the holding returning the library code

Returns

str containing library code

property location

Property of the holding returning the library code

Returns

str containing library code

save(self) 'Holding'

Save holding in a folder for each MMS ID. Example: records/UBS_9963486250105504/hol_22314215780005504_01.xml

Returns

Holding

update(self) 'Holding'

Update data of a holding.

Returns

Holding