Documentation ¶
Overview ¶
irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.
@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>
Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/ irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.
@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>
Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.
@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>
Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.
@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>
Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.
@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>
Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.
@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>
Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.
@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>
Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
irdmtools is a package for working with institutional repositories and data management systems. Current implementation targets Invenio-RDM.
@author R. S. Doiel, <rsdoiel@caltech.edu> @author Tom Morrell, <tmorrell@caltech.edu>
Copyright (c) 2023, Caltech All rights not granted herein are expressly reserved by Caltech.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Index ¶
- Constants
- func AddAdditionalTitles(rec *simplified.Record, title *simplified.TitleDetail) error
- func AddDate(rec *simplified.Record, dt *simplified.DateType) error
- func AddFunder(rec *simplified.Record, funder *simplified.Funder) error
- func AddIdentifier(rec *simplified.Record, scheme string, identifier string) error
- func AddIdentifiers(rec *simplified.Record, identifiers []*simplified.Identifier) error
- func AddKeyword(rec *simplified.Record, keyword string) error
- func AddRelatedIdentifier(rec *simplified.Record, scheme string, relationType string, identifier string) error
- func AddRelatedIdentifiers(rec *simplified.Record, identifiers []*simplified.Identifier) error
- func AddRights(rec *simplified.Record, rights []*simplified.Right) error
- func AddSubject(rec *simplified.Record, subject string) error
- func AddSubjects(rec *simplified.Record, subjects []*simplified.Subject) error
- func CheckDOI(cfg *Config, doi string) ([]map[string]interface{}, error)
- func CheckWaitInterval(iTime time.Time, wait time.Duration) (time.Time, bool)
- func CrosswalkCrossRefWork(cfg *Config, work *crossrefapi.Works, resourceTypeMap map[string]string, ...) (*simplified.Record, error)
- func CrosswalkEPrintToRecord(eprint *eprinttools.EPrint, rec *simplified.Record, ...) error
- func DeleteEndpoint(cfg *Config, p string) ([]byte, error)
- func DeleteFiles(cfg *Config, recordId string, filenames []string, debug bool) ([]byte, error)
- func DiscardDraft(cfg *Config, recordId string, debug bool) (map[string]interface{}, error)
- func FmtHelp(src string, appName string, version string, releaseDate string, ...) string
- func GetAccess(cfg *Config, recordId string, accessType string) ([]byte, error)
- func GetDraft(cfg *Config, id string) (map[string]interface{}, error)
- func GetDraftFiles(cfg *Config, recordId string, debug bool) (map[string]interface{}, error)
- func GetEPrint(baseURL string, eprintID int, timeout time.Duration, retryCount int) (*eprinttools.EPrints, error)
- func GetEndpoint(cfg *Config, p string) ([]byte, error)
- func GetFile(cfg *Config, id string, fName string) (*simplified.Entry, error)
- func GetFiles(cfg *Config, recordId string, debug bool) (map[string]interface{}, error)
- func GetKeys(baseURL string, timeout time.Duration, retryCount int) ([]int, error)
- func GetModifiedRecordIds(cfg *Config, start string, end string) ([]string, error)
- func GetRawRecord(cfg *Config, id string) (map[string]interface{}, error)
- func GetRecord(cfg *Config, id string, draft bool) (*simplified.Record, error)
- func GetRecordIds(cfg *Config) ([]string, error)
- func GetReview(cfg *Config, recordId string, debug bool) (map[string]interface{}, error)
- func GetVersionLatest(cfg *Config, id string) (map[string]interface{}, error)
- func GetVersions(cfg *Config, id string) (map[string]interface{}, error)
- func Harvest(cfg *Config, fName string, debug bool) error
- func LoadTypesMap(fName string, mapTypes map[string]string) error
- func NewDraft(cfg *Config, recordId string) (map[string]interface{}, error)
- func NewRecord(cfg *Config, src []byte) (map[string]interface{}, error)
- func NewRecordVersion(cfg *Config, recordId string) (map[string]interface{}, error)
- func PatchEndpoint(cfg *Config, p string, payload []byte) ([]byte, error)
- func PostEndpoint(cfg *Config, p string, payload []byte) ([]byte, error)
- func ProgressETR(t0 time.Time, i int, tot int) string
- func ProgressIPS(t0 time.Time, i int, timeUnit time.Duration) string
- func PublishRecordVersion(cfg *Config, recordId string, version string, pubDate string, debug bool) (map[string]interface{}, error)
- func PutEndpoint(cfg *Config, p string, payload []byte) ([]byte, error)
- func Query(cfg *Config, q string, sort string) ([]map[string]interface{}, error)
- func QueryCrossRefWork(cfg *Config, doi string, mailTo string, dotInitials bool, ...) (*crossrefapi.Works, error)
- func QueryDataCite(cfg *Config, doi string, mailTo string, dotInitials bool, ...) (map[string]interface{}, error)
- func RequestLogger(targetMux http.Handler) http.Handler
- func RetrieveFile(cfg *Config, id string, fName string) ([]byte, error)
- func ReviewRequest(cfg *Config, recordId string, decision string, comment string, debug bool) (map[string]interface{}, error)
- func SampleConfig(configFName string) ([]byte, error)
- func SendToCommunity(cfg *Config, recordId string, communityId string, debug bool) (map[string]interface{}, error)
- func SetAccess(cfg *Config, recordId string, accessType string, accessValue string, ...) ([]byte, error)
- func SetArticleNumber(rec *simplified.Record, articleNo string) error
- func SetContributors(rec *simplified.Record, contributors []*simplified.Creator) error
- func SetCreators(rec *simplified.Record, creators []*simplified.Creator) error
- func SetCustomField(rec *simplified.Record, customField string, key string, value interface{}) error
- func SetDOI(rec *simplified.Record, doi string) error
- func SetDescription(rec *simplified.Record, description string) error
- func SetEdition(rec *simplified.Record, edition string) error
- func SetFilesEnable(cfg *Config, recordId string, enable bool, debug bool) (map[string]interface{}, error)
- func SetFullTextStatus(rec *simplified.Record, status bool) error
- func SetFunding(rec *simplified.Record, funding []*simplified.Funder) error
- func SetImprintField(rec *simplified.Record, key string, value interface{}) error
- func SetIssue(rec *simplified.Record, issue string) error
- func SetJournalField(rec *simplified.Record, key string, value interface{}) error
- func SetLanguages(rec *simplified.Record, key string, value interface{}) error
- func SetMonographType(rec *simplified.Record, monographType string) error
- func SetPageRange(rec *simplified.Record, pageRange string) error
- func SetPresentationType(rec *simplified.Record, presentationType string) error
- func SetProject(rec *simplified.Record, project string) error
- func SetPubDate(cfg *Config, recordId string, pubDate string, debug bool) (map[string]interface{}, error)
- func SetPublication(rec *simplified.Record, publication string) error
- func SetPublicationDate(rec *simplified.Record, pubDate string) error
- func SetPublicationDateByType(rec *simplified.Record, dt string, publicationType string) error
- func SetPublisher(rec *simplified.Record, publisher string) error
- func SetPublisherLocation(rec *simplified.Record, place string) error
- func SetReferred(rec *simplified.Record, referred bool) error
- func SetResourceType(rec *simplified.Record, resourceType string, resourceTypeMap map[string]string) error
- func SetSeries(rec *simplified.Record, series string) error
- func SetTitle(rec *simplified.Record, title string) error
- func SetVersion(cfg *Config, recordId string, version string, debug bool) (map[string]interface{}, error)
- func SetVolume(rec *simplified.Record, volume string) error
- func UpdateDraft(cfg *Config, recordId string, payloadSrc []byte, debug bool) (map[string]interface{}, error)
- func UploadFiles(cfg *Config, recordId string, filenames []string, debug bool) (map[string]interface{}, error)
- type Config
- type Doi2Rdm
- type EPrint2Rdm
- type EPrintKeysPage
- type EPrintRest
- func (app *EPrintRest) EPrintXMLPath(db *sql.DB, id string) (string, error)
- func (app *EPrintRest) ListenAndServe() error
- func (app *EPrintRest) LoadEnv()
- func (app *EPrintRest) MkDatasetPage(db *sql.DB, tmpl string, dataset string, label string) (string, error)
- func (app *EPrintRest) Run(in io.Reader, out io.Writer, eout io.Writer) error
- type Hits
- type Links
- type OAIHeader
- type OAIListIdentifiers
- type OAIListIdentifiersResponse
- type QueryResponse
- type RateLimit
- func (rl *RateLimit) Fprintf(out io.Writer)
- func (rl *RateLimit) FromHeader(header http.Header)
- func (rl *RateLimit) FromResponse(resp *http.Response)
- func (rl *RateLimit) ResetString() string
- func (rl *RateLimit) String() string
- func (rl *RateLimit) Throttle(i int, tot int)
- func (rl *RateLimit) TimeToReset() (time.Duration, time.Time)
- func (rl *RateLimit) TimeToWait(unit time.Duration) time.Duration
- type RdmUtil
- func (app *RdmUtil) CheckDOI(doi string) ([]byte, error)
- func (app *RdmUtil) Configure(configFName string, envPrefix string, debug bool) error
- func (app *RdmUtil) DeleteEndpoint(p string) ([]byte, error)
- func (app *RdmUtil) DeleteFiles(recordId string, filenames []string) ([]byte, error)
- func (app *RdmUtil) DiscardDraft(recordId string) ([]byte, error)
- func (app *RdmUtil) GetAccess(id string, accessType string) ([]byte, error)
- func (app *RdmUtil) GetDraft(id string) ([]byte, error)
- func (app *RdmUtil) GetDraftFiles(recordId string) ([]byte, error)
- func (app *RdmUtil) GetEndpoint(p string) ([]byte, error)
- func (app *RdmUtil) GetFile(id string, fName string) ([]byte, error)
- func (app *RdmUtil) GetFiles(recordId string) ([]byte, error)
- func (app *RdmUtil) GetModifiedIds(start string, end string) ([]byte, error)
- func (app *RdmUtil) GetRawRecord(id string) ([]byte, error)
- func (app *RdmUtil) GetRecord(id string) ([]byte, error)
- func (app *RdmUtil) GetRecordIds() ([]byte, error)
- func (app *RdmUtil) GetReview(recordId string) ([]byte, error)
- func (app *RdmUtil) GetVersionLatest(id string) ([]byte, error)
- func (app *RdmUtil) GetVersions(id string) ([]byte, error)
- func (app *RdmUtil) Harvest(fName string) error
- func (app *RdmUtil) NewDraft(recordId string) ([]byte, error)
- func (app *RdmUtil) NewRecord(src []byte) ([]byte, error)
- func (app *RdmUtil) NewRecordVersion(recordId string) ([]byte, error)
- func (app *RdmUtil) PatchEndpoint(p string, data []byte) ([]byte, error)
- func (app *RdmUtil) PostEndpoint(p string, data []byte) ([]byte, error)
- func (app *RdmUtil) PublishRecordVersion(recordId string, version string, pubDate string) ([]byte, error)
- func (app *RdmUtil) PutEndpoint(p string, data []byte) ([]byte, error)
- func (app *RdmUtil) Query(q string, sort string) ([]byte, error)
- func (app *RdmUtil) RetrieveFile(id string, fName string) ([]byte, error)
- func (app *RdmUtil) ReviewComment(recordId string, comment string) ([]byte, error)
- func (app *RdmUtil) ReviewRequest(recordId string, decision string, comment string) ([]byte, error)
- func (app *RdmUtil) Run(in io.Reader, out io.Writer, eout io.Writer, action string, params []string) error
- func (app *RdmUtil) SendToCommunity(recordId string, communityId string) ([]byte, error)
- func (app *RdmUtil) SetAccess(id string, accessType string, accessValue string) ([]byte, error)
- func (app *RdmUtil) SetFilesEnable(recordId string, enable bool) ([]byte, error)
- func (app *RdmUtil) SetPubDate(recordId string, pubDate string) ([]byte, error)
- func (app *RdmUtil) SetVersion(recordId string, version string) ([]byte, error)
- func (app *RdmUtil) UpdateDraft(recordId string, src []byte) ([]byte, error)
- func (app *RdmUtil) UploadFiles(recordId string, filenames []string) ([]byte, error)
- type RorOrgAPIResponse
Constants ¶
const ( // Version number of release Version = "0.0.52" // ReleaseDate, the date version.go was generated ReleaseDate = "2023-09-18" // ReleaseHash, the Git hash when version.go was generated ReleaseHash = "cb37632" LicenseText = `` /* 1430-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func AddAdditionalTitles ¶ added in v0.0.3
func AddAdditionalTitles(rec *simplified.Record, title *simplified.TitleDetail) error
func AddDate ¶ added in v0.0.5
func AddDate(rec *simplified.Record, dt *simplified.DateType) error
func AddFunder ¶
func AddFunder(rec *simplified.Record, funder *simplified.Funder) error
func AddIdentifier ¶ added in v0.0.44
func AddIdentifier(rec *simplified.Record, scheme string, identifier string) error
func AddIdentifiers ¶ added in v0.0.44
func AddIdentifiers(rec *simplified.Record, identifiers []*simplified.Identifier) error
func AddKeyword ¶
func AddKeyword(rec *simplified.Record, keyword string) error
func AddRelatedIdentifier ¶ added in v0.0.25
func AddRelatedIdentifiers ¶ added in v0.0.3
func AddRelatedIdentifiers(rec *simplified.Record, identifiers []*simplified.Identifier) error
func AddRights ¶ added in v0.0.5
func AddRights(rec *simplified.Record, rights []*simplified.Right) error
func AddSubject ¶
func AddSubject(rec *simplified.Record, subject string) error
func AddSubjects ¶ added in v0.0.5
func AddSubjects(rec *simplified.Record, subjects []*simplified.Subject) error
func CheckDOI ¶ added in v0.0.34
CheckDOI takes a DOI and does a lookup to see if there are any matching .pids.doi.indentifier values.
``` doi := "10.1126/science.82.2123.219" records, err := CheckDOI(cfg, doi)
if err != nil { // ... handle error ... }
for _, rec := ranges { // ... process results ... }
```
func CheckWaitInterval ¶ added in v0.0.4
CheckWaitInterval checks to see if an interval of time has been met or exceeded. It returns the remaining time interval (possibly reset) and a boolean. The boolean is true when the time interval has been met or exceeded, false otherwise.
``` tot := len(something) // calculate the total number of items to process t0 := time.Now() iTime := time.Now() reportProgress := false
for i, key := range records { // ... process stuff ... if iTime, reportProgress = CheckWaitInterval(rptTime, (30 * time.Second)); reportProgress { log.Printf("%s", ProgressETR(t0, i, tot)) } }
```
func CrosswalkCrossRefWork ¶
func CrosswalkCrossRefWork(cfg *Config, work *crossrefapi.Works, resourceTypeMap map[string]string, contributorTypeMap map[string]string) (*simplified.Record, error)
CrosswalkCrossRefWork takes a Works object from the CrossRef API and maps the fields into an simplified Record struct return a new struct or error.
func CrosswalkEPrintToRecord ¶
func CrosswalkEPrintToRecord(eprint *eprinttools.EPrint, rec *simplified.Record, resourceTypes map[string]string, contributorTypes map[string]string) error
CrosswalkEPrintToRecord implements a crosswalk between an EPrint 3.x EPrint XML record as struct to a Invenio RDM record as struct.
func DeleteEndpoint ¶ added in v0.0.31
DeleteEndpoint takes an access token and endpoint path along with JSON source as payload and returns JSON source and error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") p := "api/records/qez01-2309a/draft" src, err := DeleteEndpoint(cfg.InvenioToken, p)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func DeleteFiles ¶ added in v0.0.29
DeleteFiles takes a configuration object and record id, and list of files and removes from a draft.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" fNames := ["article.pdf", "data.zip" ] // add files to draft record in JSON src, _ := os.ReadFile(fName) draft, err := DeleteFiles(cfg, id, fNames)
if err != nil { // ... handle error ... }
fmt.Printf("%+v\n", draft) ```
func DiscardDraft ¶ added in v0.0.29
DiscardDraft takes a configuration object and record id, contacts an RDM instance and deletes a draft of a record and an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" debug := true _, err := DiscardDraft(cfg, id, debug)
if err != nil { // ... handle error ... }
```
func FmtHelp ¶ added in v0.0.11
func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string
FmtHelp lets you process a text block with simple curly brace markup.
func GetAccess ¶ added in v0.0.29
GetAccess takes an acces token, a record id and optionally a access type. Returns either the access object or attribute if type is specified. Also returns an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" src, err := GetAccess(cfg.InvenioToken, id, "")
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func GetDraft ¶ added in v0.0.28
GetDraft takes a configuration object and record id, contacts an RDM instance retrieves an existing draft of a record and an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" draft, err := GetDraft(cfg, id)
if err != nil { // ... handle error ... }
fmt.Printf("%+v\n", draft) ```
func GetDraftFiles ¶ added in v0.0.31
GetDraftFiles takes a configuration object and record id, contacts an RDM instance and returns the files metadata and an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" debug := true entries, err := GetDraftFiles(cfg, id, debug)
if err != nil { // ... handle error ... }
```
func GetEPrint ¶ added in v0.0.3
func GetEPrint(baseURL string, eprintID int, timeout time.Duration, retryCount int) (*eprinttools.EPrints, error)
GetEPrint fetches a single EPrint record via the EPrint REST API.
func GetEndpoint ¶ added in v0.0.29
GetEndpoint takes an access token and endpoint path and returns JSON source and error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") p := "api/records/qez01-2309a/draft" src, err := GetEndpoint(cfg.InvenioToken, p)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func GetFile ¶ added in v0.0.28
GetFile takes a configuration object, record id and filename, contacts an RDM instance and returns the specific file metadata and an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" fName := "article.pdf" entry, err := GetFile(cfg, id, fName)
if err != nil { // ... handle error ... }
```
func GetFiles ¶ added in v0.0.28
GetFiles takes a configuration object and record id, contacts an RDM instance and returns the files metadata and an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" debug := true entries, err := GetFiles(cfg, id, debug)
if err != nil { // ... handle error ... }
```
func GetKeys ¶ added in v0.0.3
GetKeys returns a list of eprint record ids from the EPrints REST API
func GetModifiedRecordIds ¶
GetModifiedRecordIds takes a configuration object, contacts am RDM instance and returns a list of ids created, deleted or updated in the time range specififed. I problem is encountered returns an error.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
NOTE: This method relies on OAI-PMH, this is a rate limited process so results can take quiet some time.
func GetRawRecord ¶ added in v0.0.5
GetRawRecord takes a configuration object and record id, contacts an RDM instance and returns a map[string]interface{} record
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" mapRecord, err := GetRawRecord(cfg, id)
if err != nil { // ... handle error ... }
```
func GetRecord ¶
GetRecord takes a configuration object and record id, contacts an RDM instance and returns a simplified record and an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" record, err := GetRecord(cfg, id, false)
if err != nil { // ... handle error ... }
```
func GetRecordIds ¶
GetRecordIds takes a configuration object, contacts am RDM instance and returns a list of ids and error.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
NOTE: This method relies on OAI-PMH, this is a rate limited process so results can take quiet some time.
func GetReview ¶ added in v0.0.31
GetReview takes a configuration object, record id and returns an review object (which includes a request id) and error code.
func GetVersionLatest ¶ added in v0.0.28
GetVersionLatest takes a configuration object and record id, contacts an RDM instance and returns the versons metadata and an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" versions, err := GetVersionLatest(cfg, id)
if err != nil { // ... handle error ... }
```
func GetVersions ¶ added in v0.0.28
GetVersions takes a configuration object and record id, contacts an RDM instance and returns the versons metadata and an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" versions, err := GetVersions(cfg, id)
if err != nil { // ... handle error ... }
```
func LoadTypesMap ¶ added in v0.0.3
```
func NewDraft ¶ added in v0.0.30
NewDraft takes a configuration object and record id, contacts an RDM instance and create a draft of an existing record and an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id = "38rg4-36m04" draft, err := NewDraft(cfg, id)
if err != nil { // ... handle error ... }
fmt.Printf("%+v\n", draft) ```
func NewRecord ¶ added in v0.0.30
NewRecord takes a configuration object and JSON record values. It contacts an RDM instance and create a new record return the JSON for the newly created record with a record id. When records are created they are in "draft" state.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") fName := "new_record.json" // A new record in JSON src, _ := os.ReadFile(fName) record, err := NewRecord(cfg, src)
if err != nil { // ... handle error ... }
fmt.Printf("%+v\n", record) ```
func NewRecordVersion ¶ added in v0.0.30
NewRecordVersion takes a configuration object and record id to create the new version draft. The returns JSON record values includes the new record id identifying the new version.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id = "38rg4-36m04" record, err := NewRecordVersion(cfg, id)
if err != nil { // ... handle error ... }
fmt.Printf("%+v\n", record) ```
func PatchEndpoint ¶ added in v0.0.30
PatchEndpoint takes an access token and endpoint path along with JSON source as payload and returns JSON source and error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") p := "api/records/qez01-2309a/draft" data := os.ReadFile("draft.json") src, err := PatchEndpoint(cfg.InvenioToken, p, data)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func PostEndpoint ¶ added in v0.0.30
PostEndpoint takes an access token and endpoint path along with JSON source as payload and returns JSON source and error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") p := "api/records/qez01-2309a/draft" data := os.ReadFile("draft.json") src, err := PostEndpoint(cfg.InvenioToken, p, data)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func ProgressETR ¶ added in v0.0.4
ProgressETR returns a string with the percentage processed and estimated time remaining. It requires the a counter of records processed, the total count of records and a time zero value.
``` tot := len(something) // calculate the total number of items to process t0 := time.Now() iTime := time.Now() reportProgress := false
for i, key := range records { // ... process stuff ... if iTime, reportProgress = CheckWaitInterval(rptTime, (30 * time.Second)); reportProgress { log.Printf("%s", ProgressETR(t0, i, tot)) } }
```
func ProgressIPS ¶ added in v0.0.4
ProgressIPS returns a string with the elapsed time and increments per second. Takes a time zero, a counter and time unit. Returns a string with count, running time and increments per time unit. ``` t0 := time.Now() iTime := time.Now() reportProgress := false
for i, key := range records { // ... process stuff ... if iTime, reportProgress = CheckWaitInterval(rptTime, (30 * time.Second)); reportProgress || i = 0 { log.Printf("%s", ProgressIPS(t0, i, time.Second)) } }
```
func PublishRecordVersion ¶ added in v0.0.32
func PublishRecordVersion(cfg *Config, recordId string, version string, pubDate string, debug bool) (map[string]interface{}, error)
PublishRecordVersion takes a configuration object and record id of a new version draft and publishes it. NOTE: creating a new version will clear .metadata.publication_date, version label and DOI. These can be replace when publishing in the version and pubDate parameter. If those values are empty string no change is made to the draft before publishing.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id = "38rg4-36m04" version, pubDate := "internal", "2022-08" record, err := PublicRecordVersion(cfg, id, version, pubDate)
if err != nil { // ... handle error ... }
fmt.Printf("%+v\n", record) ```
func PutEndpoint ¶ added in v0.0.30
PutEndpoint takes an access token and endpoint path along with JSON source as payload and returns JSON source and error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") p := "api/records/qez01-2309a/draft" data := os.ReadFile("draft.json") src, err := PutEndpoint(cfg.InvenioToken, p, data)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func Query ¶
Query takes a query string and returns the paged object results as a slice of `map[string]interface{}`
``` records, err := Query(cfg, "Geological History in Southern California", "newest")
if err != nil { // ... handle error ... } for _, rec := ranges { // ... process results ... }
```
func QueryCrossRefWork ¶
func QueryDataCite ¶
func RequestLogger ¶ added in v0.0.49
RequestLogger logs http request to service
func RetrieveFile ¶ added in v0.0.28
RetrieveFile takes a configuration object, record id and filename, contacts an RDM instance and returns the specific file and an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" fName := "article.pdf" data, err := RetrieveFile(cfg, id, fName)
if err != nil { // ... handle error ... }
os.WriteFile(fName, data, 0664) ```
func ReviewRequest ¶ added in v0.0.31
func ReviewRequest(cfg *Config, recordId string, decision string, comment string, debug bool) (map[string]interface{}, error)
ReviewRequest takes a configuration object and record id, a decision, and optional comment contacts an RDM instance and updates the review status for the submitted draft record.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" debug := true _, err := ReviewDraft(cfg, id, "accept", "", debug)
if err != nil { // ... handle error ... }
```
func SampleConfig ¶
SampleConfig display a minimal configuration for the rdmutil cli. The minimal values in the configuration are "invenio_api" url and "invenio_token" holding the access token.
```
src, err := SampleConfig("irdmtools.json") if err != nil { // ... handle error ... } fmt.Printf("%s\n", src)
```
func SendToCommunity ¶ added in v0.0.30
func SendToCommunity(cfg *Config, recordId string, communityId string, debug bool) (map[string]interface{}, error)
SendToCommunity sends a draft to an RDM community. This will trigger the review step need for publication. You need the record id and a community id (looks like a UUID). Returns a map[string]interface{} and error values.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" comminityId := ... // this is a UUID like value debug := true src, err := SendToCommunity(cfg, id, communityId, debug)
if err != nil { // ... handle error ... }
```
func SetAccess ¶ added in v0.0.29
func SetAccess(cfg *Config, recordId string, accessType string, accessValue string, debug bool) ([]byte, error)
SetAccess takes an access token, record id, a access type and value. Returns the updated access object and error value.
FIXME: Current this method only supports setting record and files attributes to "public" and "restricted". Future implementations may add support to set record embargos.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" debug := true src, err := SetAccess(cfg.InvenioToken, id, "", debug)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func SetArticleNumber ¶
func SetArticleNumber(rec *simplified.Record, articleNo string) error
func SetContributors ¶ added in v0.0.3
func SetContributors(rec *simplified.Record, contributors []*simplified.Creator) error
func SetCreators ¶ added in v0.0.3
func SetCreators(rec *simplified.Record, creators []*simplified.Creator) error
func SetCustomField ¶ added in v0.0.23
func SetCustomField(rec *simplified.Record, customField string, key string, value interface{}) error
func SetDOI ¶
func SetDOI(rec *simplified.Record, doi string) error
Wraps the simplified package with crosswalks
func SetDescription ¶
func SetDescription(rec *simplified.Record, description string) error
func SetEdition ¶
func SetEdition(rec *simplified.Record, edition string) error
func SetFilesEnable ¶ added in v0.0.30
func SetFilesEnable(cfg *Config, recordId string, enable bool, debug bool) (map[string]interface{}, error)
SetFilesEnable will set the metadata.files.enable value.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" enabled := true debug := true _, err := SetFilesEnable(cfg, id, enabled, debug)
if err != nil { // ... handle error ... }
```
func SetFullTextStatus ¶
func SetFullTextStatus(rec *simplified.Record, status bool) error
func SetFunding ¶
func SetFunding(rec *simplified.Record, funding []*simplified.Funder) error
func SetImprintField ¶ added in v0.0.25
func SetImprintField(rec *simplified.Record, key string, value interface{}) error
func SetJournalField ¶ added in v0.0.23
func SetJournalField(rec *simplified.Record, key string, value interface{}) error
func SetLanguages ¶ added in v0.0.27
func SetLanguages(rec *simplified.Record, key string, value interface{}) error
func SetMonographType ¶
func SetMonographType(rec *simplified.Record, monographType string) error
func SetPageRange ¶
func SetPageRange(rec *simplified.Record, pageRange string) error
func SetPresentationType ¶ added in v0.0.3
func SetPresentationType(rec *simplified.Record, presentationType string) error
func SetProject ¶
func SetProject(rec *simplified.Record, project string) error
func SetPubDate ¶ added in v0.0.32
func SetPubDate(cfg *Config, recordId string, pubDate string, debug bool) (map[string]interface{}, error)
SetPubDate will set the metadata.publication_date value.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" pubDate := "2016" debug := true _, err := SetPublicationDate(cfg, id, pubDate, debug)
if err != nil { // ... handle error ... }
```
func SetPublication ¶
func SetPublication(rec *simplified.Record, publication string) error
func SetPublicationDate ¶ added in v0.0.5
func SetPublicationDate(rec *simplified.Record, pubDate string) error
func SetPublicationDateByType ¶ added in v0.0.25
func SetPublicationDateByType(rec *simplified.Record, dt string, publicationType string) error
func SetPublisher ¶
func SetPublisher(rec *simplified.Record, publisher string) error
func SetPublisherLocation ¶
func SetPublisherLocation(rec *simplified.Record, place string) error
func SetReferred ¶
func SetReferred(rec *simplified.Record, referred bool) error
func SetResourceType ¶
func SetVersion ¶ added in v0.0.32
func SetVersion(cfg *Config, recordId string, version string, debug bool) (map[string]interface{}, error)
SetVersion will set the metadata.version value.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" versoin := 'public files' debug := true _, err := SetVersion(cfg, id, version, debug)
if err != nil { // ... handle error ... }
```
func UpdateDraft ¶ added in v0.0.28
func UpdateDraft(cfg *Config, recordId string, payloadSrc []byte, debug bool) (map[string]interface{}, error)
UpdateDraft takes a configuration object and record id, contacts an RDM instance and create a draft of a record and an error value.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" fName := "draft.json" // An updated draft record in JSON src, _ := os.ReadFile(fName) debug := true draft, err := UpdateDraft(cfg, id, src, debug)
if err != nil { // ... handle error ... }
fmt.Printf("%+v\n", draft) ```
func UploadFiles ¶ added in v0.0.29
func UploadFiles(cfg *Config, recordId string, filenames []string, debug bool) (map[string]interface{}, error)
UploadFiles takes a configuration object and record id, and a map to filename and paths contacts an RDM instance and adds the files to a draft record.
The configuration object must have the InvenioAPI and InvenioToken attributes set.
``` cfg, _ := LoadConfig("config.json") id := "qez01-2309a" fNames := ["article.pdf", "data.zip" ] // add files to draft record in JSON src, _ := os.ReadFile(fName) draft, err := UploadFiles(cfg, id, fNames)
if err != nil { // ... handle error ... }
fmt.Printf("%+v\n", draft) ```
Types ¶
type Config ¶
type Config struct { // Debug is set true then methods with access to the Config obect // can use this flag to implement addition logging to standard err Debug bool `json:"-"` // Repository Name, e.g. CaltechAUTHORS, CaltechTHESIS, CaltechDATA RepoName string `json:"repo_name,omitempty"` // InvenioAPI holds the URL to the InvenioAPI InvenioAPI string `json:"rdm_url,omitempty"` // InvenioToken is holds the token string to access the API InvenioToken string `json:"rdmtok,omitempty"` // Invenio DSN holds the data source name for the Postgres database storing the invenio records InvenioDSN string `json:"rdm_dsn,omitempty"` // InvenioStorage holds the URI to the default storage of Invenio RDM objects, e.g. local file system or S3 bucket InvenioStorage string `json:"rdm_storage,omitempty"` // CName holds the dataset collection name used when harvesting content CName string `json:"c_name,omitempty"` // MailTo holds an email address to use when an email (e.g. CrossRef API access) is needed MailTo string `json:"mailto,omitempty"` // contains filtered or unexported fields }
Config holds the common configuration used by all irdmtools
func NewConfig ¶ added in v0.0.5
func NewConfig() *Config
NewConfig generates an empty configuration struct.
func (*Config) LoadConfig ¶
LoadConfig reads the configuration file and initializes the attributes in the Config struct. It returns an error if problem were encounter. NOTE: It does NOT merge the settings in the environment.
```
cfg := NewConfig() if err := cfg.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... } fmt.Printf("Invenio RDM API UTL: %q\n", cfg.IvenioAPI) fmt.Printf("Invenio RDM token: %q\n", cfg.InvenioToken) fmt.Printf("Dataset Collection: %q\n", cfg.CName) fmt.Printf("MailTo: %q\n", cfg.MailTo)
```
type Doi2Rdm ¶
type Doi2Rdm struct {
Cfg *Config
}
Doi2Rdm holds the configuration for doi2rdm cli.
func (*Doi2Rdm) Configure ¶
Configure reads the configuration file and environtment initialing the Cfg attribute of a Doi2Rdm object. It returns an error if problem were encounter.
```
app := new(irdmtools.Doi2Rdm) if err := app.Configure("irdmtools.json", "TEST_"); err != nil { // ... handle error ... } fmt.Printf("Invenio RDM API UTL: %q\n", app.Cfg.IvenioAPI) fmt.Printf("Invenio RDM token: %q\n", app.Cfg.InvenioToken)
```
func (*Doi2Rdm) Run ¶
func (app *Doi2Rdm) Run(in io.Reader, out io.Writer, eout io.Writer, options map[string]string, doi string) error
Run implements the doi2rdm cli behaviors. With the exception of the "setup" action you should call `app.LoadConfig()` before execute Run.
```
app := new(irdmtools.Doi2Rdm) if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... } recordId := "wx0w-2231" src, err := app.Run(os.Stdin, os.Stdout, os.Stderr, "get_record", []string{recordId}) if err != nil { // ... handle error ... } fmt.Printf("%s\n", src)
```
type EPrint2Rdm ¶
type EPrint2Rdm struct {
Cfg *Config
}
EPrint2Rdm holds the configuration for rdmutil cli.
func (*EPrint2Rdm) Run ¶
func (app *EPrint2Rdm) Run(in io.Reader, out io.Writer, eout io.Writer, username string, password string, host string, eprintId string, resourceTypesFName string, contributorTypesFName string, allIds bool, idList string, cName string, debug bool) error
Run implements the eprint2rdm cli behaviors.
```
app := new(irdmtools.EPrint2Rdm) eprintUsername := os.Getenv("EPRINT_USERNAME") eprintPassword := os.Getenv("EPRINT_PASSWORD") eprintHost := "eprints.example.edu" eprintId := "11822" resourceTypes := map[string]string{} if err := LoadTypesMap("resource-types.csv", resourceTypes); err != nil { // ... handle error ... } contributorTypes := map[string]string{} if err := LoadTypesMap("contributor-types.csv", contributorTypes); err != nil { // ... handle error ... } src, err := app.Run(os.Stdin, os.Stdout, os.Stderr, eprintUser, eprintPassword, eprintHost, eprintId, resourceTypes, contributorsTypes, debug) if err != nil { // ... handle error ... } fmt.Printf("%s\n", src)
```
type EPrintKeysPage ¶ added in v0.0.2
EPrintKeysPage holds the structure of the HTML page with the EPrint IDs embedded from the EPrint REST API.
type EPrintRest ¶ added in v0.0.49
type EPrintRest struct { RepoID string `json:"repo_id,required"` EPrintArchivesPath string `json:"eprint_archives_path,required"` Port string `json:"rest_port,omitempty"` DbHost string `json:"db_host,omitempty` DbUser string `json:"db_user,omitempty` DbPassword string `json:"db_password,omitempty` // contains filtered or unexported fields }
EPrintRest the "app" structure for the service.
func (*EPrintRest) EPrintXMLPath ¶ added in v0.0.49
EPrintXMLPath takes the app setup and generates the path do the EPrintXML document from an id.
func (*EPrintRest) ListenAndServe ¶ added in v0.0.49
func (app *EPrintRest) ListenAndServe() error
Serve runs the web service minimally replicating the EPrints 3.x REST API.
func (*EPrintRest) LoadEnv ¶ added in v0.0.49
func (app *EPrintRest) LoadEnv()
LoadEnv settings from the enviroment to run a local host clone of the EPrints REST API using the archives content and MySQL database.
func (*EPrintRest) MkDatasetPage ¶ added in v0.0.49
func (app *EPrintRest) MkDatasetPage(db *sql.DB, tmpl string, dataset string, label string) (string, error)
MkDatasetPage takes the simple page template and maps the dataset and label rendering the HTML page as a string
type OAIHeader ¶
type OAIHeader struct { Status string `xml:"status,attr,omitempty" json:"status,omitempty"` Identifier string `xml:"identifier,omitempty" json:"identifier,omitempty"` DateStamp string `xml:"datestamp,omitempty" json:"datestamp,omitempty"` SetSpec []string `xml:"setSpec,omitempty" json:"set_spec,omitempty"` }
OAIHeader holds the response items for
type OAIListIdentifiers ¶
type OAIListIdentifiersResponse ¶
type OAIListIdentifiersResponse struct { XMLName xml.Name `xml:"OAI-PMH" json:"-"` XMLNS string `xml:"xmlns,attr,omitempty" json:"xmlns,omitempty"` ResponseDate string `xml:"responseDate,omitempty" json:"response_date,omitempty"` Request string `xml:"request,omitempty" json:"request,omitempty"` RequestAttr map[string]string `xml:"request,attr,omitempty" json:"request_attr,omitempty"` ListIdentifiers *OAIListIdentifiers `xml:"ListIdentifiers,omitempty" json:"list_identifiers,omitempty"` }
OAIListIdendifiersResponse
type QueryResponse ¶
type QueryResponse struct { // Hits *Hits `json:"hits,omitepmty"` Links *Links `json:"links,omitempty"` SortBy string `json:"sortBy,omitempty"` }
QueryResponse holds the response to /api/records?q=...
type RateLimit ¶
type RateLimit struct { // Limit maps to X-RateLimit-Limit Limit int `json:"limit,omitempty"` // OldLimit holds the last value of rate limit before change. OldLimit int `json:"-"` // Remaining maps to X-RateLimit-Remaining Remaining int `json:"remaining,omitempty"` // Reset maps to X-RateLimit-Reset Reset int `json:"reset,omitempty"` }
RateLimit holds the values used to play nice with OAI-PMH or REST API. It normally is extracted from the response header.
func (*RateLimit) FromHeader ¶
FromHeader takes an http.Header (e.g. http.Response.Header) and updates a rate limit struct.
``` rl := new(RateLimit) rl.FromHeader(header) ```
func (*RateLimit) FromResponse ¶
FromResponse takes an http.Response struct and extracts the header values realated to rate limits (e.g. X-RateLite-Limit)
``` rl := new(RateLimit) rl.FromResponse(response) ```
func (*RateLimit) ResetString ¶
func (*RateLimit) Throttle ¶
Throttle looks at the rate limit structure and implements an appropriate sleep time based on rate limits.
```
i, tot := 0, 1000 // This ith' iteration and total number of records rl := new(RateLimit) // Set our rate limit from rl.FromResponse(response) rl.Throttle(i, tot)
```
func (*RateLimit) TimeToWait ¶
SecondsToWait returns the number of seconds (as a time.Duratin) to wait to avoid a http status code 429 and a ratio (float64) of remaining per request limit.
``` rl := new(RateLimit) rl.FromHeader(response.Header) timeToWait := rl.TimeToWait() time.Sleep(timeToWait) ```
type RdmUtil ¶
RdmUtil holds the configuration for rdmutil cli.
func (*RdmUtil) CheckDOI ¶ added in v0.0.34
CheckDOI checks the .pids.doi.identifier and returns a record from the match DOI.
```
app := new(irdmtools.RdmUtil) if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... } doi := '10.1126/science.82.2123.219' src, err := app.CheckDOI(doi) if err != nil { // ... handle error ... } fmt.Printf("%s\n", src)
```
func (*RdmUtil) Configure ¶
Configure reads the configuration file and environtment initialing the Cfg attribute of a RdmUtil object. It returns an error if problem were encounter.
```
app := new(irdmtools.RdmUtil) if err := app.Configure("irdmtools.json", "TEST_"); err != nil { // ... handle error ... } fmt.Printf("Invenio RDM API UTL: %q\n", app.Cfg.IvenioAPI) fmt.Printf("Invenio RDM token: %q\n", app.Cfg.InvenioToken)
```
func (*RdmUtil) DeleteEndpoint ¶ added in v0.0.31
DeleteEndpoint performs a DELETE on the endpoint indicated by PATH provided.
func (*RdmUtil) DeleteFiles ¶ added in v0.0.29
DeleteFiles takes a RDM record id an list of files and removes them from a draft.
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
id := "woie-x0121" filenames := []string{ "article.pdf", "charts.zip", "data.zip" } src, err := app.DeleteFiles(id, filenames)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
func (*RdmUtil) DiscardDraft ¶ added in v0.0.29
DiscardDraft takes a record id and delete the draft.
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
id := "woie-x0121" src, err := app.DiscardDraft(id)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
func (*RdmUtil) GetAccess ¶ added in v0.0.29
GetAccess returns the JSON for the access attribute in a record if accessType parameter is an empty string or the specific access requested if not (e.g. "files", "record"). An error value is also returned.
``` app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
recordId := "woie-x0121" accessType := "" // accessType = "record" // accessType := "files" src, err := app.GetAccess(recordId, accessType)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func (*RdmUtil) GetDraft ¶ added in v0.0.28
GetDraft returns an existing draft of a record.
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
recordId := "woie-x0121" src, err := app.GetDraft(recordId)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
func (*RdmUtil) GetDraftFiles ¶ added in v0.0.31
GetDraftFiles returns the metadata for a draft's files
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
recordId := "woie-x0121" src, err := app.GetFiles(recordId)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
func (*RdmUtil) GetEndpoint ¶ added in v0.0.29
GetEndpoint performs a GET on the endpoint indicated by PATH provided.
func (*RdmUtil) GetFile ¶ added in v0.0.28
GetFile returns the metadata for a file
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
recordId := "woie-x0121" fName := "article.pdf" src, err := app.GetFile(recordId, fName)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
func (*RdmUtil) GetFiles ¶ added in v0.0.28
GetFiles returns the metadata for working with files
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
recordId := "woie-x0121" src, err := app.GetFiles(recordId)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
func (*RdmUtil) GetModifiedIds ¶
GetModified returns a byte slice for a JSON encode list of record ids modified (created, updated, deleted) in the given time range. If a problem occurs an error is returned.
```
app := new(irdmtools.RdmUtil) if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... } src, err := app.GetModifiedIds("2020-01-01", "2020-12-31") if err != nil { // ... handle error ... } fmt.Printf("%s\n", src)
```
func (*RdmUtil) GetRawRecord ¶ added in v0.0.5
GetRawRecord returns a byte slice for a JSON encoded record as a `map[string]interface{}` retrieved from the RDM API.
```
app := new(irdmtools.RdmUtil) if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... } recordId := "woie-x0121" src, err := app.GetRawRecord(recordId) if err != nil { // ... handle error ... } fmt.Printf("%s\n", src)
```
func (*RdmUtil) GetRecord ¶
GetRecord returns a byte slice for a JSON encoded record or an error.
```
app := new(irdmtools.RdmUtil) if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... } recordId := "woie-x0121" src, err := app.GetRecord(recordId) if err != nil { // ... handle error ... } fmt.Printf("%s\n", src)
```
func (*RdmUtil) GetRecordIds ¶
GetRecordIds returns a byte slice for a JSON encode list of record ids or an error.
```
app := new(irdmtools.RdmUtil) if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... } src, err := app.GetRecordIds() if err != nil { // ... handle error ... } fmt.Printf("%s\n", src)
```
func (*RdmUtil) GetReview ¶ added in v0.0.31
GetReview takes a record id and returns information about review requests.
``` app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
id := "woie-x0121" src, err := app.GetReview(id, "accept", "")
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func (*RdmUtil) GetVersionLatest ¶ added in v0.0.28
GetVersionLatest returns the latest version metadata for a record.
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
recordId := "woie-x0121" src, err := app.GetVersionLatest(recordId)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
func (*RdmUtil) GetVersions ¶ added in v0.0.28
GetVersions returns the versioning metadata for a record.
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
recordId := "woie-x0121" src, err := app.GetVersions(recordId)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
func (*RdmUtil) Harvest ¶
Harvest takes a JSON file contianing a list of record ids and harvests them into a dataset v2 collection. The dataset collection must exist and be configured in either the environment or configuration file.
func (*RdmUtil) NewDraft ¶ added in v0.0.30
NewDraft returns the a new draft of an existing record.
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
recordId = "woie-x0121" src, err := app.NewDraft(recordId)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
func (*RdmUtil) NewRecord ¶ added in v0.0.30
NewRecord create a new record from JSON source. It returns a created record including a record id.
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
jsonSrc, _ := os.ReadFile("new_record.json") src, err := app.NewRecord(jsonSrc)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
func (*RdmUtil) NewRecordVersion ¶ added in v0.0.30
NewRecordVersion create a new record version using record id. It returns a created record including a record id.
``` app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
recordId = "woie-x0121" src, err := app.NewRecordVersion(recordId)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func (*RdmUtil) PatchEndpoint ¶ added in v0.0.30
PatchEndpoint performs a PATCH on the endpoint indicated by PATH provided.
func (*RdmUtil) PostEndpoint ¶ added in v0.0.30
PostEndpoint performs a POST on the endpoint indicated by PATH provided.
func (*RdmUtil) PublishRecordVersion ¶ added in v0.0.32
func (app *RdmUtil) PublishRecordVersion(recordId string, version string, pubDate string) ([]byte, error)
PublishRecordVersion publish a new version draft using the version's record id.
``` app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
recordId = "woie-x0121" version, pubDate := "internal", "2022-08" src, err := app.PublishRecordVersion(recordId)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func (*RdmUtil) PutEndpoint ¶ added in v0.0.30
PutEndpoint performs a PUT on the endpoint indicated by PATH provided.
func (*RdmUtil) Query ¶
Query returns a byte slice for a JSON encode list of record summaries or an error.
```
app := new(irdmtools.RdmUtil) if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... } src, err := app.Query("My favorite book", -1, "newest") if err != nil { // ... handle error ... } fmt.Printf("%s\n", src)
```
func (*RdmUtil) RetrieveFile ¶ added in v0.0.28
RetrieveFile retrieves the file from an RDM instance.
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
recordId := "woie-x0121" fName := "article.pdf" data, err := app.RetrieveFile(recordId, fName)
if err != nil { // ... handle error ... }
os.WriteFile("article.pdf", data, 0664)
```
func (*RdmUtil) ReviewComment ¶ added in v0.0.40
ReviewComment takes a record id and a comment and submits the comment to the review process.
``` app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
id := "woie-x0121" src, err := app.ReviewComment(id, "Not sure about this one, but it is exciting")
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func (*RdmUtil) ReviewRequest ¶ added in v0.0.31
ReviewRequest takes a record id, a decision and a comment and submits it to the review process.
``` app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
id := "woie-x0121" src, err := app.ReviewRequest(id, "accept", "")
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src) ```
func (*RdmUtil) Run ¶
func (app *RdmUtil) Run(in io.Reader, out io.Writer, eout io.Writer, action string, params []string) error
Run implements the irdmapp cli behaviors. With the exception of the Run.
```
app := new(irdmtools.RdmUtil) if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... } recordId := "wx0w-2231" src, err := app.Run(os.Stdin, os.Stdout, os.Stderr, "get_record", []string{recordId}) if err != nil { // ... handle error ... } fmt.Printf("%s\n", src)
```
func (*RdmUtil) SendToCommunity ¶ added in v0.0.30
SendToCommunity takes a RDM record id and community UUID. It populates the the parent element approriately for draft to be submitted to a specific community.
func (*RdmUtil) SetAccess ¶ added in v0.0.29
SetAccess sets the access attribute for a record. The access type can be either record or files. The value can be either "public" or "restricted". An error value is also returned with the function.
```
app := new(irdmtools.RdmUtil) if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... } recordId := "woie-x0121" accessType := "record" src, err := app.SetAccess(recordId, accessType, "public") if err != nil { // ... handle error ... } fmt.Printf("%s\n", src) accessType = "files" src, err := app.SetAccess(recordId, accessType, "restricted") if err != nil { // ... handle error ... } fmt.Printf("%s\n", src)
```
func (*RdmUtil) SetFilesEnable ¶ added in v0.0.30
SetFilesEnable takes a RDM record id and either boolean setting the files.enabled value in a draft record. Returns the draft record and an error value.
func (*RdmUtil) SetPubDate ¶ added in v0.0.32
SetPubDate takes a RDM record id and publication date string setting the .metadata.publication_date in a draft record.
func (*RdmUtil) SetVersion ¶ added in v0.0.32
SetVersion takes a RDM record id and version string setting the .metadata.version in a draft record.
func (*RdmUtil) UpdateDraft ¶ added in v0.0.28
UpdateDraft returns takes a record id and returns a draft record.
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
id := "woie-x0121" jsonSrc, _ := os.ReadFile("draft.json") src, err := app.UpdateDraft(id, jsonSrc)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
func (*RdmUtil) UploadFiles ¶ added in v0.0.29
UploadFiles takes a RDM record id an list of files and uploads them to a draft.
```
app := new(irdmtools.RdmUtil)
if err := app.LoadConfig("irdmtools.json"); err != nil { // ... handle error ... }
id := "woie-x0121" filenames := []string{ "article.pdf", "charts.zip", "data.zip" } src, err := app.UploadFiles(id, filenames)
if err != nil { // ... handle error ... }
fmt.Printf("%s\n", src)
```
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
doi2rdm
doi2rdm is a command line program for harvesting DOI metadata from CrossRef and DataCite returning a JSON documentument sutiable for import into Invenio RDM.
|
doi2rdm is a command line program for harvesting DOI metadata from CrossRef and DataCite returning a JSON documentument sutiable for import into Invenio RDM. |
eprint2rdm
eprint2rdm is a command line program for harvesting an EPrint metadata record and return a Invenio RDM style record.
|
eprint2rdm is a command line program for harvesting an EPrint metadata record and return a Invenio RDM style record. |
eprintrest
eprintrest is a command line program that re-creates a EPrints 3.x REST API running on localhost.
|
eprintrest is a command line program that re-creates a EPrints 3.x REST API running on localhost. |
rdmutil
rdmutil is a command line program for working with Invenio RDM.
|
rdmutil is a command line program for working with Invenio RDM. |