Documentation
¶
Overview ¶
Package api provides an HTTP client which works with the Alma API.
Package api provides an HTTP client which works with the Alma API.
Package api provides an HTTP client which works with the Alma API.
Package api provides an HTTP client which works with the Alma API.
Package api provides an HTTP client which works with the Alma API.
Package api provides an HTTP client which works with the Alma API.
Package api provides an HTTP client which works with the Alma API.
Package api provides an HTTP client which works with the Alma API.
Index ¶
- Constants
- func DefaultProgressBar(max int) *progressbar.ProgressBar
- func StartConcurrent(ctx context.Context, numJobs int, desc string) (context.Context, context.CancelFunc, *sync.Mutex, *sync.Mutex, chan<- func(), ...)
- func StartWorkers(wg *sync.WaitGroup, jobs <-chan func())
- func StopConcurrent(jobs chan<- func(), wg *sync.WaitGroup)
- type Client
- func (c Client) BibMemberHoldingListMembers(ctx context.Context, member Member) (holdingListMembers []HoldingListMember, err error)
- func (c Client) BibMembersHoldingListMembers(ctx context.Context, members []Member) (holdingListMembers []HoldingListMember, errs []error)
- func (c *Client) CheckAPIandKey(ctx context.Context, readAccess, writeAccess []string) error
- func (c Client) CodeTable(ctx context.Context, name string) (table CodeTable, err error)
- func (c Client) CodeTables(ctx context.Context) (tables []CodeTable, errs []error)
- func (c Client) Departments(ctx context.Context) (departments Departments, err error)
- func (c *Client) Do(ctx context.Context, r *http.Request) (body []byte, err error)
- func (c Client) HoldingListMemberToHolding(ctx context.Context, holdingListMember HoldingListMember) (holding Holding, err error)
- func (c Client) HoldingListMembersToHoldings(ctx context.Context, holdingListMembers []HoldingListMember) (holdings []Holding, errs []error)
- func (c Client) HoldingUpdate(ctx context.Context, holding Holding) (updated Holding, err error)
- func (c Client) HoldingsUpdate(ctx context.Context, holdings []Holding) (updatedHoldings []Holding, errs []error)
- func (c Client) ItemMemberScanIn(ctx context.Context, member Member, circdesk, library string) (item Item, err error)
- func (c Client) ItemMemberUserRequests(ctx context.Context, member Member) (requests []UserRequest, err error)
- func (c Client) ItemMembersScanIn(ctx context.Context, members []Member, circdesk, library string) (scannedIn []Item, errs []error)
- func (c Client) ItemMembersUserRequests(ctx context.Context, members []Member) (requests []UserRequest, errs []error)
- func (c Client) Libraries(ctx context.Context) (libraries Libraries, err error)
- func (c Client) SetFromID(ctx context.Context, ID string) (set Set, err error)
- func (c Client) SetFromNameOrID(ctx context.Context, name, ID string) (set Set, err error)
- func (c Client) SetIDFromName(ctx context.Context, name string) (ID string, err error)
- func (c Client) SetMembers(ctx context.Context, set Set) (members []Member, errs []error)
- func (c Client) UserRequestCancel(ctx context.Context, request UserRequest, reason, note string) error
- func (c Client) UserRequestsCancel(ctx context.Context, requests []UserRequest, reason, note string) (cancelled []UserRequest, errs []error)
- type CodeTable
- type Department
- type Departments
- type Holding
- type HoldingListMember
- type Holdings
- type Item
- type Libraries
- type Library
- type Member
- type Members
- type Set
- type Sets
- type ThresholdReachedError
- type UserRequest
- type UserRequests
Constants ¶
const ( // RequestTimeout is the amount of time the tool will wait for API calls to complete before they are cancelled. RequestTimeout = 60 * time.Second // LimitParam is the limit parameter to offset+limit calls. LimitParam = 100 // LimiterRate is the maximum number of API calls per second the tool will allow. // Per https://developers.exlibrisgroup.com/alma/apis/#threshold, the real limit is 25, // but we want to allow other API calls to succeeed while the tool is running. LimiterRate = 15 // DefaultThreshold is the minimum number of API calls remaining before the tool automatically stops working. DefaultThreshold = 50000 // DefaultAlmaAPIHost is the default Alma API Server domain name. DefaultAlmaAPIHost = "api-ca.hosted.exlibrisgroup.com" )
const DefaultCircDesk = "DEFAULT_CIRC_DESK"
DefaultCircDesk is the default circulation desk code used when scanning an item in.
Variables ¶
This section is empty.
Functions ¶
func DefaultProgressBar ¶
func DefaultProgressBar(max int) *progressbar.ProgressBar
DefaultProgressBar returns a progress bar with common options already set.
func StartConcurrent ¶
func StartConcurrent(ctx context.Context, numJobs int, desc string) (context.Context, context.CancelFunc, *sync.Mutex, *sync.Mutex, chan<- func(), *sync.WaitGroup, *progressbar.ProgressBar)
StartConcurrent initializes the context, mutexes, job channel, wait group, and progress bar for concurrent job processing.
func StartWorkers ¶
StartWorkers starts NumCPU workers in a worker pool which run jobs from the jobs channel until it is closed.
func StopConcurrent ¶
StopConcurrent closes the jobs channel and waits for processing to end.
Types ¶
type Client ¶
type Client struct { // Client is the embedded http client. *http.Client // Host is the host name (domain name) for the Alma API we are calling. Host string // Key is the authorization key to use when calling the Alma API. Key string // Threshold is the minimum number of API calls remaining before // the Cancel function is called. Threshold int // contains filtered or unexported fields }
Client is a custom HTTP client for the Alma API.
func (Client) BibMemberHoldingListMembers ¶
func (c Client) BibMemberHoldingListMembers(ctx context.Context, member Member) (holdingListMembers []HoldingListMember, err error)
BibMemberHoldingListMembers returns the holding list members for a member of type BIB_MMS.
func (Client) BibMembersHoldingListMembers ¶
func (c Client) BibMembersHoldingListMembers(ctx context.Context, members []Member) (holdingListMembers []HoldingListMember, errs []error)
BibMembersHoldingListMembers returns the holding list members for the members. The members must be from a set with content BIB_MMS.
func (*Client) CheckAPIandKey ¶
CheckAPIandKey ensures the API is available and that the key provided has the right permissions.
func (Client) CodeTables ¶
CodeTables returns all known code tables.
func (Client) Departments ¶
func (c Client) Departments(ctx context.Context) (departments Departments, err error)
Departments returns the Departments configured for the Institution.
func (*Client) Do ¶
Do makes HTTP requests with the Client to the Host using the Key. If a request returns an error, it is retried until RequestTimeout is reached. The response bodies are copied or drained, then closed. See https://golang.org/pkg/net/http/#Client.Do
func (Client) HoldingListMemberToHolding ¶
func (c Client) HoldingListMemberToHolding(ctx context.Context, holdingListMember HoldingListMember) (holding Holding, err error)
HoldingListMemberToHolding returns the holding records refered to by a holding list member.
func (Client) HoldingListMembersToHoldings ¶
func (c Client) HoldingListMembersToHoldings(ctx context.Context, holdingListMembers []HoldingListMember) (holdings []Holding, errs []error)
HoldingListMembersToHoldings returns the holdings records refered to by a slice of holdings list members.
func (Client) HoldingUpdate ¶
HoldingUpdate PUTs the holding back to the API.
func (Client) HoldingsUpdate ¶
func (c Client) HoldingsUpdate(ctx context.Context, holdings []Holding) (updatedHoldings []Holding, errs []error)
HoldingsUpdate PUTs the holdings back to the API.
func (Client) ItemMemberScanIn ¶
func (c Client) ItemMemberScanIn(ctx context.Context, member Member, circdesk, library string) (item Item, err error)
ItemMemberScanIn POSTs the scan operation on an item member.
func (Client) ItemMemberUserRequests ¶
func (c Client) ItemMemberUserRequests(ctx context.Context, member Member) (requests []UserRequest, err error)
ItemMemberUserRequests returns user requests on a item member.
func (Client) ItemMembersScanIn ¶
func (c Client) ItemMembersScanIn(ctx context.Context, members []Member, circdesk, library string) (scannedIn []Item, errs []error)
ItemMembersScanIn scans members in. The members must be from a set with content ITEM.
func (Client) ItemMembersUserRequests ¶
func (c Client) ItemMembersUserRequests(ctx context.Context, members []Member) (requests []UserRequest, errs []error)
ItemMembersUserRequests returns user requests on item members.
func (Client) SetFromNameOrID ¶
SetFromNameOrID returns the set when provided the name or ID.
func (Client) SetIDFromName ¶
SetIDFromName returns the ID for the set with the given set name.
func (Client) SetMembers ¶
SetMembers returns the members of a set.
func (Client) UserRequestCancel ¶
func (c Client) UserRequestCancel(ctx context.Context, request UserRequest, reason, note string) error
UserRequestCancel cancels a user request.
func (Client) UserRequestsCancel ¶
func (c Client) UserRequestsCancel(ctx context.Context, requests []UserRequest, reason, note string) (cancelled []UserRequest, errs []error)
UserRequestsCancel cancels user requests.
type CodeTable ¶
type CodeTable struct { XMLName xml.Name `xml:"code_table"` Name string `xml:"name"` Description string `xml:"description"` SubSystem struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"sub_system"` PatronFacing string `xml:"patron_facing"` Language struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"language"` Scope struct { InstitutionID struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"institution_id"` LibraryID struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"library_id"` } `xml:"scope"` Rows []struct { Text string `xml:",chardata"` Code string `xml:"code"` Description string `xml:"description"` Default string `xml:"default"` Enabled string `xml:"enabled"` } `xml:"rows>row"` }
CodeTable stores data about codes and their related descriptions. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_code_table.xsd/
type Department ¶
type Department struct { Code string `xml:"code"` Name string `xml:"name"` Type struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"type"` WorkDays string `xml:"work_days"` Printer struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"printer"` Owner struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"owner"` ServedLibraries struct { Library []struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"library"` } `xml:"served_libraries"` // Contact Info is TODO //ContactInfo struct { // Addresses string `xml:"addresses"` // Emails string `xml:"emails"` // Phones string `xml:"phones"` //} `xml:"contact_info"` Operators struct { Operator []struct { Text string `xml:",chardata"` Link string `xml:"link,attr"` PrimaryID string `xml:"primary_id"` FullName string `xml:"full_name"` } `xml:"operator"` } `xml:"operators"` Description string `xml:"description"` }
Department stores data about a location within a library or institution where a service is performed. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_department.xsd/
type Departments ¶
type Departments struct { XMLName xml.Name `xml:"departments"` Text string `xml:",chardata"` TotalRecordCount string `xml:"total_record_count,attr"` Departments []Department `xml:"department"` }
Departments stores data for all Departments configured for the Institution. This is a little different than []Department for XML unmarshalling. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_departments.xsd/
type Holding ¶
type Holding struct { XMLName xml.Name `xml:"holding"` HoldingID string `xml:"holding_id"` CreatedBy string `xml:"created_by"` CreatedDate string `xml:"created_date"` OriginatingSystem string `xml:"originating_system"` OriginatingSystemID string `xml:"originating_system_id"` SuppressFromPublishing string `xml:"suppress_from_publishing"` Record struct { Text string `xml:",chardata"` Leader string `xml:"leader"` Controlfield []struct { Text string `xml:",chardata"` Tag string `xml:"tag,attr"` } `xml:"controlfield"` Datafield []struct { Text string `xml:",chardata"` Ind1 string `xml:"ind1,attr"` Ind2 string `xml:"ind2,attr"` Tag string `xml:"tag,attr"` Subfield []struct { Text string `xml:",chardata"` Code string `xml:"code,attr"` } `xml:"subfield"` } `xml:"datafield"` } `xml:"record"` // HoldingListMember is an optional field for the 'originating' holding list member. HoldingListMember HoldingListMember `xml:"-"` }
Holding stores data about a holding record. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_holding.xsd/
func (Holding) EightFiftyTwoSubHSubI ¶
EightFiftyTwoSubHSubI returns the h and i parts of the 852, seperated with a space.
type HoldingListMember ¶
type HoldingListMember struct { Link string `xml:"link,attr"` HoldingID string `xml:"holding_id"` Library struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"library"` Location struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"location"` CallNumber string `xml:"call_number"` SuppressFromPublishing string `xml:"suppress_from_publishing"` }
HoldingListMember stores data about a holding record when it's returned from the Holdings list. HoldingListMember != Holding https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_holdings.xsd
type Holdings ¶
type Holdings struct { XMLName xml.Name `xml:"holdings"` TotalRecordCount string `xml:"total_record_count,attr"` HoldingListMembers []HoldingListMember `xml:"holding"` BibData struct { Link string `xml:"link,attr"` MmsID string `xml:"mms_id"` Title string `xml:"title"` ISSN string `xml:"issn"` NetworkNumbers struct { Text string `xml:",chardata"` NetworkNumber string `xml:"network_number"` } `xml:"network_numbers"` Publisher string `xml:"publisher"` } `xml:"bib_data"` }
Holdings stores data about holdings under a bib record. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_holdings.xsd/
type Item ¶
type Item struct { XMLName xml.Name `xml:"item"` //the XML root element must have the name "item" or else Unmarshal returns an error. MMSID string `xml:"bib_data>mms_id"` Title string `xml:"bib_data>title"` Author string `xml:"bib_data>author"` CallNumber string `xml:"holding_data>call_number"` Barcode string `xml:"item_data>barcode"` // An optional attribute for the link to the item. Link string `xml:"-"` }
Item stores data about an item. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_sets.xsd/
type Libraries ¶
Libraries stores data about libraries configured for the Institution. This is a little different than []Library for XML unmarshalling. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_libraries.xsd/
type Library ¶
type Library struct { Link string `xml:"link,attr"` Code string `xml:"code"` Path string `xml:"path"` Name string `xml:"name"` Description string `xml:"description"` ResourceSharing string `xml:"resource_sharing"` Campus struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"campus"` Proxy string `xml:"proxy"` DefaultLocation struct { Text string `xml:",chardata"` Desc string `xml:"desc,attr"` } `xml:"default_location"` }
Library stores data about a library in Alma, which represents a physical library in the institution, which gives library services. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_library.xsd/
type Member ¶
Member stores data about members of sets. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_member.xsd/
type Members ¶
type Members struct { XMLName xml.Name `xml:"members"` //the XML root element must have the name "members" or else Unmarshal returns an error. Members []Member `xml:"member"` }
Members stores data about set members. This is a little different than []Member for safer XML unmarshalling. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_members.xsd/
type Set ¶
type Set struct { ID string `xml:"id"` Name string `xml:"name"` NumberOfMembers int `xml:"number_of_members"` Type string `xml:"type"` Content string `xml:"content"` Link string `xml:"link,attr"` }
Set stores data about sets. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_set.xsd/
type Sets ¶
type Sets struct { XMLName xml.Name `xml:"sets"` //the XML root element must have the name "sets" or else Unmarshal returns an error. Sets []Set `xml:"set"` }
Sets stores data about lists of sets as returned from the API. This is a little different than []Set for safer XML unmarshalling. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_sets.xsd/
type ThresholdReachedError ¶
type ThresholdReachedError struct { // Remaining is the number of calls remaining. Remaining int // Threshold is the call number minimum threshold. Threshold int }
ThresholdReachedError is an error returned when the API remaining call limit has been reached.
func (ThresholdReachedError) Error ¶
func (e ThresholdReachedError) Error() string
type UserRequest ¶
type UserRequest struct { ID string `xml:"request_id"` Type string `xml:"request_type"` SubType string `xml:"request_sub_type"` // Member is an optional field for the 'originating' item member. Member Member `xml:"-"` // Link is an optional field for the user request link. Link string `xml:"-"` }
UserRequest stores data about a user request on items. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_user_request.xsd/
func (UserRequest) MatchTypeSubType ¶
func (u UserRequest) MatchTypeSubType(rtype, subType string) bool
MatchTypeSubType returns true if rtype is empty or matches the request's Type and the subType is empty or matches the request's SubType.
type UserRequests ¶
type UserRequests struct { XMLName xml.Name `xml:"user_requests"` // The XML root element must have the name "item" or else Unmarshal returns an error. UserRequests []UserRequest `xml:"user_request"` }
UserRequests stores data about user requests on an item. This is a little different than []UserRequest for XML unmarshalling. https://developers.exlibrisgroup.com/alma/apis/docs/xsd/rest_user_requests.xsd/