LogicalSet class

class almapiwrapper.config.LogicalSet(set_id: str | None = None, zone: str | None = None, env: Literal['P', 'S'] = 'P', name: str | None = None, data: XmlData | None = 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 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

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

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

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

save() '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() '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: str | None = None, zone: str | None = None, env: Literal['P', 'S'] = 'P', name: str | None = None, data: XmlData | None = 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: bool | None = 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 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

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

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

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

save() '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() '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: str | None = None, description: str | None = None, query: str | None = None, created_by: str | None = None, private: bool | None = False, data: XmlData | None = 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 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

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

create() '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: 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

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

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

save() '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() '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: str | None = None, content: str | None = None, description: str | None = None, private: bool | None = False, members: List[str] | None = None, from_logical_set: Optional[Union[str, `LogicalSet`]]=None, data: XmlData | None = 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 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

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

create() '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: 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

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

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

save() '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() 'RecSet' | 'ItemizedSet' | 'LogicalSet'

Update set data.

Returns:

the updated set object

Note

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