LogicalSet class

class almapiwrapper.config.LogicalSet(set_id: Optional[str] = None, zone: Optional[str] = None, env: Literal['P', 'S'] = 'P', name: Optional[str] = None, data: Optional[XmlData] = None)

Bases: RecSet

Class representing a logical set of records

Parameters
  • set_id – ID of the set

  • zone – zone of the set

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

  • name – name of the set, can be used instead of the set_id

  • dataalmapiwrapper.record.XmlData with the data describing the set. If provided, the set_id and name are not required.

Variables
  • set_id – initial value: ID of the set

  • zone – initial value: zone of the set

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

  • name – initial value: name of the set

  • data – initial value: data describing the set

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

Delete a set

Returns

None

Note

If the record encountered an error, this method will be skipped.

get_content_type() str

Return the type of the set

Returns

str indicating the type of the set

Note

If the record encountered an error, this method will be skipped.

get_members() list[Record]

Return a list with all the records of the set

Returns

list of records depending on the type of the set

Note

If the record encountered an error, this method will be skipped.

get_members_number() int

Return the number of members

Returns

int with the number of records

Note

If the record encountered an error, this method will be skipped.

get_set_type() str

Return the type of the set

Returns

str indicating the type of the set

Note

If the record encountered an error, this method will be skipped.

property name: str

Property returning the name of the set.

Returns

str containing set name

save() Union['RecSet', 'ItemizedSet', 'LogicalSet']

Save a set record in the ‘records’ folder

When saved, a suffix is added to the file path with the version. Example: records/set_<IZ>_<set_id>_<version>.xml

Returns

object almapiwrapper.users.Fee

Note

If the record encountered an error, this method will be skipped.

property set_id: str

Property returning the name of the set.

Returns

str containing set name

update() Union['RecSet', 'ItemizedSet', 'LogicalSet']

Update set data.

Returns

the updated set object

Note

If the record encountered an error, this method will be skipped.

ItemizedSet class

class almapiwrapper.config.ItemizedSet(set_id: Optional[str] = None, zone: Optional[str] = None, env: Literal['P', 'S'] = 'P', name: Optional[str] = None, data: Optional[XmlData] = None)

Bases: RecSet

Class representing an itemized set of records

Parameters
  • set_id – ID of the set

  • zone – zone of the set

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

  • name – name of the set, can be used instead of the set_id

  • dataalmapiwrapper.record.XmlData with the data describing the set. If provided, the set_id and name are not required.

Variables
  • set_id – initial value: ID of the set

  • zone – initial value: zone of the set

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

  • name – initial value: name of the set

  • data – initial value: data describing the set

add_members(record_ids: List[str], fail_on_invalid_id: Optional[bool] = True) 'ItemizedSet'

Add members to a set

Parameters
  • record_ids – list of record ids to add to the set

  • fail_on_invalid_id – if True, raise an error if one of the record id is invalid

Returns

ItemizedSet object

Note

If the record encountered an error, this method will be skipped.

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

Delete a set

Returns

None

Note

If the record encountered an error, this method will be skipped.

get_content_type() str

Return the type of the set

Returns

str indicating the type of the set

Note

If the record encountered an error, this method will be skipped.

get_members() list[Record]

Return a list with all the records of the set

Returns

list of records depending on the type of the set

Note

If the record encountered an error, this method will be skipped.

get_members_number() int

Return the number of members

Returns

int with the number of records

Note

If the record encountered an error, this method will be skipped.

get_set_type() str

Return the type of the set

Returns

str indicating the type of the set

Note

If the record encountered an error, this method will be skipped.

property name: str

Property returning the name of the set.

Returns

str containing set name

save() Union['RecSet', 'ItemizedSet', 'LogicalSet']

Save a set record in the ‘records’ folder

When saved, a suffix is added to the file path with the version. Example: records/set_<IZ>_<set_id>_<version>.xml

Returns

object almapiwrapper.users.Fee

Note

If the record encountered an error, this method will be skipped.

property set_id: str

Property returning the name of the set.

Returns

str containing set name

update() Union['RecSet', 'ItemizedSet', 'LogicalSet']

Update set data.

Returns

the updated set object

Note

If the record encountered an error, this method will be skipped.

NewLogicalSet class

class almapiwrapper.config.NewLogicalSet(zone: str, env: Literal['P', 'S'] = 'P', name: Optional[str] = None, description: Optional[str] = None, query: Optional[str] = None, created_by: Optional[str] = None, private: Optional[bool] = False, data: Optional[XmlData] = None)

Class representing a new logical set of records

To create a new set, it is possible to provide directly the XML data or to give all the required parameters.

Parameters
  • name – name of the set

  • zone – zone of the set

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

  • description – description of the set

  • query – query to build the set

  • created_by – user who created the set

  • private – set as private or not

  • dataalmapiwrapper.record.XmlData object, can be used instead of the XML data of the set

Variables
  • zone – initial value: zone of the set

  • env – initial value: environment of the set: ‘P’ for production and ‘S’ for sandbox

  • data – initial value: almapiwrapper.record.XmlData

  • area – initial value: area of the set: will be “Conf”

  • format – initial value: data format of the set: will be “xml”

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

create() Union['LogicalSet', 'NewLogicalSet']

Create the logical set

Returns

almapiwrapper.config.LogicalSet or almapiwrapper.config.NewLogicalSet in case of error

Note

If the record encountered an error, this method will be skipped.

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

Delete a set

Returns

None

Note

If the record encountered an error, this method will be skipped.

get_content_type() str

Return the type of the set

Returns

str indicating the type of the set

Note

If the record encountered an error, this method will be skipped.

get_members() list[Record]

Return a list with all the records of the set

Returns

list of records depending on the type of the set

Note

If the record encountered an error, this method will be skipped.

get_members_number() int

Return the number of members

Returns

int with the number of records

Note

If the record encountered an error, this method will be skipped.

get_set_type() str

Return the type of the set

Returns

str indicating the type of the set

Note

If the record encountered an error, this method will be skipped.

property name: str

Property returning the name of the set.

Returns

str containing set name

save() Union['RecSet', 'ItemizedSet', 'LogicalSet']

Save a set record in the ‘records’ folder

When saved, a suffix is added to the file path with the version. Example: records/set_<IZ>_<set_id>_<version>.xml

Returns

object almapiwrapper.users.Fee

Note

If the record encountered an error, this method will be skipped.

property set_id: str

Property returning the name of the set.

Returns

str containing set name

update() Union['RecSet', 'ItemizedSet', 'LogicalSet']

Update set data.

Returns

the updated set object

Note

If the record encountered an error, this method will be skipped.

NewItemizedSet class

class almapiwrapper.config.NewItemizedSet(zone: str, env: Literal['P', 'S'] = 'P', name: Optional[str] = None, content: Optional[str] = None, description: Optional[str] = None, private: Optional[bool] = False, members: Optional[List[str]] = None, from_logical_set: Optional[Union[str, `LogicalSet`]] = None, data: Optional[XmlData] = None)

Class representing a new itemized set of records

To create a new set, it is possible to provide directly the XML data or to give all the required parameters.

Parameters
  • zone – zone of the set

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

  • name – name of the set

  • content – content of the set for example ‘BIB_MMS’ or ‘USER’

  • description – description of the set

  • query – query to build the set

  • private – set as private or not

  • members – list of members of the set, must be a list of primary ids

  • from_logical_set – set_id or almapiwrapper.config.LogicalSet object to create the set from

  • dataalmapiwrapper.record.XmlData object, can be used instead of the XML data of the set

Variables
  • zone – initial value: zone of the set

  • env – initial value: environment of the set: ‘P’ for production and ‘S’ for sandbox

  • data – initial value: almapiwrapper.record.XmlData

  • from_logical_set – initial value: set_id string of LogicalSet to create the ItemizedSet from

  • area – initial value: area of the set: will be “Conf”

  • members – initial value: list of members of the set, must be a list of primary ids

  • format – initial value: data format of the set: will be “xml”

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

create() Union['LogicalSet', 'NewLogicalSet']

Create the itemized set

Returns

almapiwrapper.config.ItemizedSet or almapiwrapper.config.NewItemizedSet in case of error

Note

If the record encountered an error, this method will be skipped.

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

Delete a set

Returns

None

Note

If the record encountered an error, this method will be skipped.

get_content_type() str

Return the type of the set

Returns

str indicating the type of the set

Note

If the record encountered an error, this method will be skipped.

get_members() list[Record]

Return a list with all the records of the set

Returns

list of records depending on the type of the set

Note

If the record encountered an error, this method will be skipped.

get_members_number() int

Return the number of members

Returns

int with the number of records

Note

If the record encountered an error, this method will be skipped.

get_set_type() str

Return the type of the set

Returns

str indicating the type of the set

Note

If the record encountered an error, this method will be skipped.

property name: str

Property returning the name of the set.

Returns

str containing set name

save() Union['RecSet', 'ItemizedSet', 'LogicalSet']

Save a set record in the ‘records’ folder

When saved, a suffix is added to the file path with the version. Example: records/set_<IZ>_<set_id>_<version>.xml

Returns

object almapiwrapper.users.Fee

Note

If the record encountered an error, this method will be skipped.

property set_id: str

Property returning the name of the set.

Returns

str containing set name

update() Union['RecSet', 'ItemizedSet', 'LogicalSet']

Update set data.

Returns

the updated set object

Note

If the record encountered an error, this method will be skipped.