IzBib class

class almapiwrapper.inventory.IzBib(mms_id: str, zone: str, env: Literal['P', 'S'] = 'P', from_nz_mms_id: Optional[bool] = False, copy_nz_rec: Optional[bool] = False, data: Optional[XmlData] = None)

Class representing bibliographic record of the IZ

It inherits from Bib for common methods with NzBib.

Variables
  • mms_id – record mms_id

  • zone – zone of the record

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

  • dataalmapiwrapper.record.XmlData object, useful to force update a record from a backup

Parameters
  • from_nz_mms_id – if this parameter is True the system assumes that the provided MMS ID is a network ID and fetch data from it

  • copy_nz_rec – if this parameter is True, if no record exists in the IZ for the provided NZ ID, the CZ record is copied from NZ

add_fields(self, fields: Union[etree.Element, List[etree.Element]]) 'Bib'

Add fields to the data of the current record

Parameters

fields – must be an etree element or a list of etree elements

Returns

Bib

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 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(force: Optional[bool] = False) None

Delete bibliographic record in the IZ

To delete locally a record, it needs to be unlinked from the NZ and without holdings and items.

Parameters

force – when True delete also holdings and items

Returns

None

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

Delete all holdings of the record with items if ‘force’ is True.

Parameters

force – when True delete the items too.

Returns

None

static get_data_from_disk(mms_id, holding_id, item_id, zone)

Fetch the data of the described record

Parameters
  • mms_id – bib record mms_id

  • zone – zone of the record

Returns

almapiwrapper.record.XmlData or None

get_holdings(self) List['inventory.Holding']

Get list of holdings and store it in ‘_holdings’ attribute

It avoids having to reload it.

Returns

list of almapiwrapper.inventory.Holding objects

get_local_fields(self) List[etree.Element]

Fetch the list of the local fields of the records

It looks for subfield “9” and then get the parent.

Returns

list of etree.Element

get_mms_id(self) str

Fetch the MMS ID in controlfield 001

Useful when fetching the bibliographic record with the NZ ID.

Returns

string with MMS ID of 001 controlfield

get_nz_mms_id(self) Optional[str]

Fetch the NZ MMS ID of the IZ bib record

Returns

string with NZ record MMS ID.

save(self) 'Bib'

Save a record in the ‘records’ folder

Versioning is supported. A suffix is added to the file path.

Example: records/NZ_991170519490005501/bib_991170519490005501_01.xml

Returns

Bib

sort_fields(self) 'Bib'

Sort all the fields and subfields of the record

Returns

Bib

update(self) 'Bib'

Update data

On BibIz records this method is used to change local fields. On BibNz records, other fields can be changed.

Returns

Bib

NzBib class

class almapiwrapper.inventory.NzBib(mms_id: Optional[str] = None, env: Literal['P', 'S'] = 'P', data: Optional[XmlData] = None, create_bib: Optional[bool] = False)

Class representing a NZ bibliographic record.

It inherits from Bib for common methods with IzBib.

Variables
  • mms_id – record mms_id

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

  • dataalmapiwrapper.record.XmlData object, useful to force update a record from a backup

Parameters

create_bib – bool, if True, create a new bib record in the NZ

add_fields(self, fields: Union[etree.Element, List[etree.Element]]) 'Bib'

Add fields to the data of the current record

Parameters

fields – must be an etree element or a list of etree elements

Returns

Bib

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 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) None

Delete bibliographic record in the IZ

To delete locally a record, it needs to be unlinked from the NZ and without holdings and items.

Parameters

force – when True delete also holdings and items

Returns

None

static get_data_from_disk(mms_id, holding_id, item_id, zone)

Fetch the data of the described record

Parameters
  • mms_id – bib record mms_id

  • zone – zone of the record

Returns

almapiwrapper.record.XmlData or None

get_mms_id(self) str

Fetch the MMS ID in controlfield 001

Useful when fetching the bibliographic record with the NZ ID.

Returns

string with MMS ID of 001 controlfield

save(self) 'Bib'

Save a record in the ‘records’ folder

Versioning is supported. A suffix is added to the file path.

Example: records/NZ_991170519490005501/bib_991170519490005501_01.xml

Returns

Bib

sort_fields(self) 'Bib'

Sort all the fields and subfields of the record

Returns

Bib

update(self) 'Bib'

Update data

On BibIz records this method is used to change local fields. On BibNz records, other fields can be changed.

Returns

Bib