Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
a93358e
Update README.md
pac0san Nov 14, 2018
d0ae772
Update README.md
pac0san Nov 16, 2018
a879801
Update README.md
pac0san Nov 16, 2018
2597548
Starting out with 'push' function
Nov 17, 2018
601018a
Update README.md
pac0san Nov 17, 2018
7eafca0
Updating setup.py for libary packaging
pac0san Nov 17, 2018
123b1e6
Importing 'client.py' from UCDavisLibrary/almapipy/tree/dev branch
pac0san Nov 17, 2018
3a4db00
Updates to 'push' function
pac0san Nov 17, 2018
25cad0d
General 'char coding' change to UTF8
pac0san Nov 17, 2018
99df9e2
General 'char coding' change to UTF8
pac0san Nov 17, 2018
f7cec08
General 'char coding' change to UTF8
pac0san Nov 17, 2018
dc6ee7c
General 'char coding' change to UTF8
pac0san Nov 17, 2018
4f3d24b
Remove 'intruder' directory
pac0san Nov 17, 2018
9bd26a2
Remove 'intruder' directory
pac0san Nov 17, 2018
80fdd2b
Just Testing POST Access
Nov 19, 2018
2af0d2a
Just Testing POST Access
Nov 19, 2018
7f9facb
'post' Changes
Nov 20, 2018
618fd81
'post' Changes
Nov 20, 2018
1a33e59
'requests.delete' skelleton init
Nov 20, 2018
ba1127a
'requests.delete' skelleton init
Nov 20, 2018
078d638
Avoid sending 'API Key' in URL, but in Headers
Nov 21, 2018
f05fcd2
Avoid sending 'API Key' in URL, but in Headers
Nov 21, 2018
ddef942
Include 'User-Agent' in Headers
Nov 21, 2018
b930104
Include 'User-Agent' in Headers
Nov 21, 2018
7552070
Changed some functions names - Be carefull
pac0san Nov 25, 2018
444fd13
Changed some functions names - Be carefull
pac0san Nov 25, 2018
e01a5ad
Following with the efforts in POST and DELETE and Changed some functi…
pac0san Nov 25, 2018
0749198
Following with the efforts in POST and DELETE and Changed some functi…
pac0san Nov 25, 2018
8799340
Remove intruder directory
pac0san Nov 25, 2018
9d100c5
Remove intruder directory
pac0san Nov 25, 2018
b8e700d
Changes in comments and other minor issues.
pac0san Nov 26, 2018
77b9087
Merged master fixed conflict.
pac0san Nov 26, 2018
7d72dc7
Update users.py
pac0san Nov 26, 2018
078e866
Update setup.py
pac0san Nov 26, 2018
c52f4a3
Update setup.py
pac0san Nov 26, 2018
30ec4ad
Update __init__.py
pac0san Nov 26, 2018
c5b2045
Style format adjustments
Nov 27, 2018
7378001
Style format adjustments
Nov 27, 2018
aa2258e
CRUD getting on
Nov 27, 2018
7111fba
CRUD getting on
Nov 27, 2018
a0d2f6b
Some cleaning
Nov 28, 2018
cd65249
Increasing the version to 1.0.1.dev0
Nov 28, 2018
9203762
Update README.md
pac0san Mar 27, 2019
857a64a
Update __init__.py
pac0san Mar 27, 2019
d885d0c
Update __init__.py
pac0san Mar 27, 2019
c604e5c
Update README.md
pac0san Mar 27, 2019
2b0213e
Update README.md
pac0san Mar 27, 2019
db88abd
Update README.md
pac0san Mar 27, 2019
3f7b5a3
Update README.md
pac0san Mar 27, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
425 changes: 223 additions & 202 deletions README.md

Large diffs are not rendered by default.

178 changes: 95 additions & 83 deletions almapipy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,83 +1,95 @@
"""
Python client for Ex Libris Alma
"""
__author__ = "Steve Pelkey (spelkey@ucdavis.edu)"
__version__ = "0.0.9"

import os

from .client import Client
from .bibs import SubClientBibs
from .analytics import SubClientAnalytics
from .courses import SubClientCourses
from .users import SubClientUsers
from .acquisitions import SubClientAcquistions
from .conf import SubClientConfiguration
from .partners import SubClientPartners
from .electronic import SubClientElectronic
from .task_lists import SubClientTaskList
from . import utils


class AlmaCnxn(Client):
""""Interface with Alma APIs.

Various Apis are namespaced beneath this object according to documentation
at https://developers.exlibrisgroup.com/alma/apis.

E.g.
> alma = AlmaCnxn(your_api_key)
> alma.bibs.catalog.get_record(bib_id) # returns bibliographic records

Args:
api_key (str): Your Api Key
Location (str): Geographic location of library.
data_format (str): Format of returned data. json or xml.
If xml is selected, data will be returned as python xml ElementTree.
"""

def __init__(self, apikey, location='America', data_format='json'):

super(AlmaCnxn, self).__init__()

# determine base uri based on location
locations = {'America': 'https://api-na.hosted.exlibrisgroup.com',
'Europe': 'https://api-eu.hosted.exlibrisgroup.com',
'Asia Pacific': 'https://api-ap.hosted.exlibrisgroup.com',
'Canada': 'https://api-ca.hosted.exlibrisgroup.com',
'China': 'https://api-cn.hosted.exlibrisgroup.com'}
if location != 'America':
if location not in locations.keys():
message = "Valid location arguments are "
message += ", ".join(locations.keys())
raise utils.ArgError(message=message)
self.cnxn_params['location'] = location
self.cnxn_params['base_uri'] = locations[location]

# handle preferred format
if data_format not in ['json', 'xml']:
message = "Format argument must be either 'json' or 'xml'"
raise utils.ArgError(message)
self.cnxn_params['format'] = data_format
ns = {'header': 'http://com/exlibris/urm/general/xmlbeans'}
self.cnxn_params['xml_ns'] = ns

# TODO: validate api key. return list of accessible endpoints
# call __validate_key__
self.cnxn_params['api_key'] = apikey

# Hook in the various Alma APIs based on what API key can access
self.bibs = SubClientBibs(self.cnxn_params)
self.analytics = SubClientAnalytics(self.cnxn_params)
self.courses = SubClientCourses(self.cnxn_params)
self.users = SubClientUsers(self.cnxn_params)
self.acq = SubClientAcquistions(self.cnxn_params)
self.conf = SubClientConfiguration(self.cnxn_params)
self.partners = SubClientPartners(self.cnxn_params)
self.electronic = SubClientElectronic(self.cnxn_params)
self.task_lists = SubClientTaskList(self.cnxn_params)

def __validate_key__(self, apikey):
# loop through each api and access the /test endpoint.
# return list of accessible apis.
pass
# -*- coding: utf-8 -*-

"""
Python requests wrapper for the Ex Libris Alma API
"""


from .client import Client
from .bibs import SubClientBibs
from .analytics import SubClientAnalytics
from .courses import SubClientCourses
from .users import SubClientUsers
from .acquisitions import SubClientAcquistions
from .conf import SubClientConfiguration
from .partners import SubClientPartners
from .electronic import SubClientElectronic
from .task_lists import SubClientTaskList
from . import utils


__author__ = "Steve Pelkey, Fco. Sanchez"
__author_email__ = "spelkey@ucdavis.edu, GitHub@minarnet.es"
__project_name__ = "almapipy"
__project_description__ = "Python requests wrapper for the Ex Libris Alma API"
__project_url__ = "https://github.com/pac0san/almapipy"
__license__ = "MIT License"
__version__ = "1.0.1.dev0"
__status__ = "Development"


class AlmaCnxn(Client):
""""Interface with Alma APIs.

Various Apis are namespaced beneath this object according to documentation
at https://developers.exlibrisgroup.com/alma/apis.

E.g.
> alma = AlmaCnxn(your_api_key)
> alma.bibs.catalog.get_record(bib_id) # returns bibliographic records

Args:
api_key (str): Your Api Key
Location (str): Geographic location of library.
data_format (str): Format of returned data. json or xml.
If xml is selected, data will be returned as python xml ElementTree.
"""

def __init__(self, apikey, location='America', data_format='json'):

super(AlmaCnxn, self).__init__()

# determine base uri based on location
locations = {'America': 'https://api-na.hosted.exlibrisgroup.com',
'Europe': 'https://api-eu.hosted.exlibrisgroup.com',
'Asia Pacific': 'https://api-ap.hosted.exlibrisgroup.com',
'Canada': 'https://api-ca.hosted.exlibrisgroup.com',
'China': 'https://api-cn.hosted.exlibrisgroup.com'}
if location != 'America':
if location not in locations.keys():
message = "Valid location arguments are "
message += ", ".join(locations.keys())
raise utils.ArgError(message=message)
self.cnxn_params['location'] = location
self.cnxn_params['base_uri'] = locations[location]

# handle preferred format
if data_format not in ['json', 'xml']:
message = "Format argument must be either 'json' or 'xml'"
raise utils.ArgError(message)
self.cnxn_params['format'] = data_format
ns = {'header': 'http://com/exlibris/urm/general/xmlbeans'}
self.cnxn_params['xml_ns'] = ns

# TODO: validate api key. return list of accessible endpoints
# call __validate_key__
self.cnxn_params['api_key'] = apikey

# Set 'User-Agent' for REST queries
self.cnxn_params['User-Agent'] = '{}/{}'.format(__name__,__version__)

# Hook in the various Alma APIs based on what API key can access
self.bibs = SubClientBibs(self.cnxn_params)
self.analytics = SubClientAnalytics(self.cnxn_params)
self.courses = SubClientCourses(self.cnxn_params)
self.users = SubClientUsers(self.cnxn_params)
self.acq = SubClientAcquistions(self.cnxn_params)
self.conf = SubClientConfiguration(self.cnxn_params)
self.partners = SubClientPartners(self.cnxn_params)
self.electronic = SubClientElectronic(self.cnxn_params)
self.task_lists = SubClientTaskList(self.cnxn_params)

def __validate_key__(self, apikey):
# loop through each api and access the /test endpoint.
# return list of accessible apis.
pass
Loading