Documentation ¶
Overview ¶
Package rspace is an API client for interacting with the RSpace Electronic Lab Notebook (ELN - see https://www.researchspace.com).
It simplifies making API requests to RSpace from a program written in Go by:
- validating arguments
- parsing error responses
- converting raw JSON responses into convenient data types.
The central type is RsWebClient which is a facade to lower level services.
In order to make requests the RsWebClient needs to be instantiated with 2 arguments:
- the URL of the RSpace server you want to connect to, e.g. https://community.researchspace.com/api/v1
- an API token
package main import ( "fmt" "net/url" ) func main() { // url should end in 'api/v1' url, _ := url.Parse("https://community.researchspace.com/api/v1") // don't put your API key in code! use environment variable or a config file apiKey := "myapikey" // this is facade to access API services webClient = rspace.NewWebClient(url, apiKey) fmt.Println(webClient.Status()) }
All calls can return an error if the call fails. If the error is a 400 or 500 error from the RSpace server, the error will be of type RSpaceError with more detailed information.
Please be aware that RSpace API has usage limits. In the event that usage limits are exceeded, the RSpaceError will have status 429 (TooManyRequests) along with fields stating the minimum waiting time before another request can be made.
For complex requests (e.g. searching Activity, or complex document search queries), Builder classes are provided to help construct the query correctly.
Index ¶
- Constants
- Variables
- func HttpClientNew(timeOutSeconds int) *http.Client
- func Marshal(anything interface{}) string
- func Unmarshal(resp *http.Response, result interface{})
- type Activity
- type ActivityList
- type ActivityQuery
- type ActivityQueryBuilder
- func (b *ActivityQueryBuilder) Action(action string) *ActivityQueryBuilder
- func (b *ActivityQueryBuilder) Build() (*ActivityQuery, error)
- func (b *ActivityQueryBuilder) DateFrom(dateFrom time.Time) *ActivityQueryBuilder
- func (b *ActivityQueryBuilder) DateTo(dateTo time.Time) *ActivityQueryBuilder
- func (b *ActivityQueryBuilder) Domain(domain string) *ActivityQueryBuilder
- func (b *ActivityQueryBuilder) Oid(oid GlobalId) *ActivityQueryBuilder
- func (b *ActivityQueryBuilder) User(user string) *ActivityQueryBuilder
- type ActivityService
- type BaseService
- type BasicInfo
- type ClientEx
- type DelayClientEx
- type Document
- type DocumentInfo
- type DocumentList
- type DocumentPost
- type DocumentService
- func (ds *DocumentService) AdvancedSearchDocuments(config RecordListingConfig, searchQuery *SearchQuery) (*DocumentList, error)
- func (ds *DocumentService) DeleteDocument(documentId int) (bool, error)
- func (ds *DocumentService) DocumentById(docId int) (*Document, error)
- func (ds *DocumentService) DocumentEdit(docId int, putData *DocumentPost) (*Document, error)
- func (ds *DocumentService) DocumentNew(post *DocumentPost) (*Document, error)
- func (ds *DocumentService) Documents(config RecordListingConfig) (*DocumentList, error)
- func (ds *DocumentService) GetStatus() (*Status, error)
- func (ds *DocumentService) NewBasicDocumentWithContent(name string, tags string, contentHtml string) (*Document, error)
- func (ds *DocumentService) NewEmptyBasicDocument(name string, tags string) (*Document, error)
- func (ds *DocumentService) SearchDocuments(config RecordListingConfig, searchTerm string) (*DocumentList, error)
- type DurationTestResult
- type Email
- type ExportFormat
- type ExportPost
- type ExportScope
- type ExportService
- type Field
- type FieldContent
- type FileInfo
- type FileList
- type FileService
- func (fs *FileService) DownloadFile(fileId int, outDir string) (*FileInfo, error)
- func (fs *FileService) FileById(fileId int) (*FileInfo, error)
- func (fs *FileService) Files(config RecordListingConfig, mediaType string) (*FileList, error)
- func (fs *FileService) UploadFile(config FileUploadConfig) (*FileInfo, error)
- func (fs *FileService) UploadFileNewVersion(path string, fileToReplaceId int) (*FileInfo, error)
- type FileUploadConfig
- type Folder
- type FolderList
- type FolderPost
- type FolderService
- func (fs *FolderService) DeleteFolder(folderId int) (bool, error)
- func (fs *FolderService) FolderById(folderId int) (*Folder, error)
- func (fs *FolderService) FolderNew(post *FolderPost) (*Folder, error)
- func (fs *FolderService) FolderTree(config RecordListingConfig, folderId int, typesToInclude []string) (*FolderList, error)
- type FolderTreeItem
- type Form
- type FormId
- type FormList
- type FormService
- func (fs *FormService) CreateFormJson(jsonFormDef io.Reader) (*Form, error)
- func (fs *FormService) CreateFormYaml(yamlFormDef io.Reader) (*Form, error)
- func (fs *FormService) Forms(config RecordListingConfig, query string) (*FormList, error)
- func (fs *FormService) PublishForm(formId int) (*Form, error)
- type GlobalId
- type GroupInfo
- type GroupList
- type GroupPost
- type GroupService
- type GroupShare
- type IdentifiableNamable
- type ImportService
- type IntTestResult
- type Job
- type JobResult
- type Link
- type Permission
- type QueryType
- type RSpaceError
- type RateLimitData
- type RecordListingConfig
- type RetryClientEx
- type RsWebClient
- func (ds *RsWebClient) Activities(query *ActivityQuery, pgCrit RecordListingConfig) (*ActivityList, error)
- func (ds *RsWebClient) AdvancedSearchDocuments(config RecordListingConfig, searchQuery *SearchQuery) (*DocumentList, error)
- func (fs *RsWebClient) CreateFormJson(jsonFormDef io.Reader) (*Form, error)
- func (fs *RsWebClient) CreateFormYaml(yamlFormDef io.Reader) (*Form, error)
- func (fs *RsWebClient) DeleteFolder(folderId int) (bool, error)
- func (ds *RsWebClient) DocumentById(docId int) (*Document, error)
- func (ds *RsWebClient) DocumentEdit(docId int, docPost *DocumentPost) (*Document, error)
- func (ds *RsWebClient) Documents(config RecordListingConfig) (*DocumentList, error)
- func (fs *RsWebClient) Download(id int, path string) (*FileInfo, error)
- func (client *RsWebClient) DownloadExport(link *url.URL, writer io.Writer) error
- func (client *RsWebClient) Export(post ExportPost, waitForDone bool, progressWriter func(string)) (*Job, error)
- func (fs *RsWebClient) FileById(id int) (*FileInfo, error)
- func (fs *RsWebClient) Files(config RecordListingConfig, mediaType string) (*FileList, error)
- func (fs *RsWebClient) FolderById(folderId int) (*Folder, error)
- func (fs *RsWebClient) FolderNew(post *FolderPost) (*Folder, error)
- func (fs *RsWebClient) FolderTree(config RecordListingConfig, folderId int, typesToInclude []string) (*FolderList, error)
- func (fs *RsWebClient) FormSearch(config RecordListingConfig, query string) (*FormList, error)
- func (fs *RsWebClient) Forms(config RecordListingConfig) (*FormList, error)
- func (client *RsWebClient) GetJob(jobId int) (*Job, error)
- func (ws *RsWebClient) GroupNew(groupPost *GroupPost) (*GroupInfo, error)
- func (ws *RsWebClient) Groups() (*GroupList, error)
- func (fs *RsWebClient) ImportWord(path string, folderId int, imageFolderId int) (*DocumentInfo, error)
- func (ds *RsWebClient) NewBasicDocumentWithContent(name, tags, content string) (*Document, error)
- func (ds *RsWebClient) NewDocumentWithContent(docPost *DocumentPost) (*Document, error)
- func (ds *RsWebClient) NewEmptyBasicDocument(name, tags string) (*Document, error)
- func (fs *RsWebClient) PublishForm(formId int) (*Form, error)
- func (ds *RsWebClient) SearchDocuments(config RecordListingConfig, searchTerm string) (*DocumentList, error)
- func (client *RsWebClient) Share(post *SharePost) (*ShareInfoList, error)
- func (client *RsWebClient) ShareList(query string, cfg RecordListingConfig) (*SharedItemList, error)
- func (ds *RsWebClient) Status() (*Status, error)
- func (client *RsWebClient) Unshare(shareId int) (bool, error)
- func (fs *RsWebClient) UploadFile(config FileUploadConfig) (*FileInfo, error)
- func (fs *RsWebClient) UploadFileNewVersion(path string, fileToReplaceId int) (*FileInfo, error)
- func (ws *RsWebClient) UserNew(userPost *UserPost) (*UserInfo, error)
- func (ws *RsWebClient) Users(lastLoginBefore time.Time, creationDateBefore time.Time, ...) (*UserList, error)
- type STerm
- type SearchOperator
- type SearchQuery
- type SearchQueryBuilder
- type SearchTerm
- type ShareInfoList
- type SharePost
- type ShareResult
- type SharedItemList
- type SharingService
- type Status
- type StringTestResult
- type SysadminService
- type Testable
- type UserGroupPost
- type UserInfo
- type UserList
- type UserPost
- type UserPostBuilder
- func (b *UserPostBuilder) Affiliation(affiliation string) *UserPostBuilder
- func (b *UserPostBuilder) ApiKey(apiKey string) *UserPostBuilder
- func (b *UserPostBuilder) Build() (*UserPost, error)
- func (b *UserPostBuilder) Email(emailAddress Email) *UserPostBuilder
- func (b *UserPostBuilder) FirstName(firstName string) *UserPostBuilder
- func (b *UserPostBuilder) LastName(lastName string) *UserPostBuilder
- func (b *UserPostBuilder) Password(password string) *UserPostBuilder
- func (b *UserPostBuilder) Role(role UserRoleType) *UserPostBuilder
- func (b *UserPostBuilder) Username(username string) *UserPostBuilder
- type UserRoleType
- type UserShare
Constants ¶
const ( APIKEY_ENV_NAME = "RSPACE_API_KEY" BASE_URL_ENV_NAME = "RSPACE_URL" RATE_LIMIT_WAIT_TIME = "X-Rate-Limit-WaitTimeMillis" DEFAULT_TIMEOUT_SECONDS = 15 )
Variables ¶
var Log = logging.MustGetLogger("rs-client")
Functions ¶
func HttpClientNew ¶ added in v0.0.17
HttpClientNew creates a new http.Client with specified timeout in seconds
Types ¶
type Activity ¶
type Activity struct {
Username, FullName, Domain, Action string
Timestamp string
Payload interface{}
}
Activity holds information abuot a particular audit event. The Payload field holds arbitrary data that is specific for each event type.
type ActivityList ¶
type ActivityList struct { Activities []Activity Links []Link `json:"_links"` TotalHits int PageNumber int }
ActivityList encapsulates search results for audit events
type ActivityQuery ¶
type ActivityQuery struct { Domains []string Actions []string Oid string Users []string DateFrom time.Time DateTo time.Time }
ActivityQuery encapsulates a query to the /activities endpoint. Either use directly or use the ActivityQueryBuilder, which provides more convenient construction and validation
type ActivityQueryBuilder ¶
type ActivityQueryBuilder struct {
// contains filtered or unexported fields
}
ActivityQueryBuilder provides convenient methods to construct a query to the /activities endpoint
func (*ActivityQueryBuilder) Action ¶
func (b *ActivityQueryBuilder) Action(action string) *ActivityQueryBuilder
func (*ActivityQueryBuilder) Build ¶
func (b *ActivityQueryBuilder) Build() (*ActivityQuery, error)
Build generates an ActivityQuery from the builder, that is validated and ready to send.
func (*ActivityQueryBuilder) DateFrom ¶
func (b *ActivityQueryBuilder) DateFrom(dateFrom time.Time) *ActivityQueryBuilder
DateFrom specifies a lower bound on the time stamp of an activity
func (*ActivityQueryBuilder) DateTo ¶
func (b *ActivityQueryBuilder) DateTo(dateTo time.Time) *ActivityQueryBuilder
DateTo specifies an upper bound on the time stamp of an activity.
func (*ActivityQueryBuilder) Domain ¶
func (b *ActivityQueryBuilder) Domain(domain string) *ActivityQueryBuilder
func (*ActivityQueryBuilder) Oid ¶
func (b *ActivityQueryBuilder) Oid(oid GlobalId) *ActivityQueryBuilder
Oid restricts the search to activities involving the specific item.
func (*ActivityQueryBuilder) User ¶
func (b *ActivityQueryBuilder) User(user string) *ActivityQueryBuilder
type ActivityService ¶
type ActivityService struct {
BaseService
}
func (*ActivityService) Activities ¶
func (as *ActivityService) Activities(q *ActivityQuery, pgCrit RecordListingConfig) (*ActivityList, error)
Activities queries the audit trail for activities, by user, date or activity type
type BaseService ¶
type ClientEx ¶ added in v0.0.17
type ClientEx interface { //Do follows the same contract as http.Client.Do() Do(req *http.Request) (*http.Response, error) }
ClientEx abstracts out the http.Client Do() method into an interface for decorating with resilience patterhs
func NewResilientClient ¶ added in v0.0.17
NewResilientClient decorates an http.Client with retry and 429 too-many-requests handler Will make requests 3 times in total if necessary; for 429 responses will wait for the amount of time specified in the response header.
type DelayClientEx ¶ added in v0.0.17
type DelayClientEx struct {
// contains filtered or unexported fields
}
DelayClientEx listens to response headers for wait time until next client request is available.
type Document ¶
type Document struct { *DocumentInfo Fields []Field }
Full document including content
type DocumentInfo ¶
type DocumentInfo struct { *IdentifiableNamable Created string LastModified string ParentFolderId int Signed bool Tags string Form Form `json:"form"` UserInfo UserInfo `json:"owner"` }
Summary information about a Document
func (*DocumentInfo) CreatedTime ¶
func (di *DocumentInfo) CreatedTime() (time.Time, error)
func (*DocumentInfo) LastModifiedTime ¶
func (di *DocumentInfo) LastModifiedTime() (time.Time, error)
type DocumentList ¶
type DocumentList struct { Documents []DocumentInfo TotalHits int PageNumber int Links []Link `json:"_links"` }
type DocumentPost ¶
type DocumentPost struct { Name string `json:"name,omitempty"` Tags string `json:"tags,omitempty"` FormID FormId `json:"form,omitempty"` Fields []FieldContent `json:"fields,omitempty"` ParentFolderId int `json:"parentFolderId,omitempty"` }
DocumentPost contains optional data for creating or updating an RSpace document
func BasicPost ¶
func BasicPost(name string, tags string) *DocumentPost
func DocumentPostNew ¶
func DocumentPostNew(name string, tags string, formId int, content []string, parentFolderId int) *DocumentPost
constructor for a new document
type DocumentService ¶
type DocumentService struct {
BaseService
}
func (*DocumentService) AdvancedSearchDocuments ¶
func (ds *DocumentService) AdvancedSearchDocuments(config RecordListingConfig, searchQuery *SearchQuery) (*DocumentList, error)
func (*DocumentService) DeleteDocument ¶
func (ds *DocumentService) DeleteDocument(documentId int) (bool, error)
DeleteDocument attempts to delete the document with the specified ID
func (*DocumentService) DocumentById ¶
func (ds *DocumentService) DocumentById(docId int) (*Document, error)
DocumentById retrieves full document content
func (*DocumentService) DocumentEdit ¶ added in v0.0.17
func (ds *DocumentService) DocumentEdit(docId int, putData *DocumentPost) (*Document, error)
DocumentEdit updates an existing RSpace document
func (*DocumentService) DocumentNew ¶
func (ds *DocumentService) DocumentNew(post *DocumentPost) (*Document, error)
DocumentNew creates a new RSpace document
func (*DocumentService) Documents ¶
func (ds *DocumentService) Documents(config RecordListingConfig) (*DocumentList, error)
Paginated listing of Documents
func (*DocumentService) GetStatus ¶
func (ds *DocumentService) GetStatus() (*Status, error)
GetStatus returns the result of the /status endpoint
func (*DocumentService) NewBasicDocumentWithContent ¶
func (ds *DocumentService) NewBasicDocumentWithContent(name string, tags string, contentHtml string) (*Document, error)
NewBasicDocumentWithContent creates a new BasicDocument document with name, tags(optional) and content in a single text field.
func (*DocumentService) NewEmptyBasicDocument ¶
func (ds *DocumentService) NewEmptyBasicDocument(name string, tags string) (*Document, error)
NewEmptyBasicDocument creates a new, empty BasicDocument with no content.
func (*DocumentService) SearchDocuments ¶
func (ds *DocumentService) SearchDocuments(config RecordListingConfig, searchTerm string) (*DocumentList, error)
SearchDocuments performs basic search of a single search term, performing a global search
type DurationTestResult ¶ added in v0.0.19
func (DurationTestResult) IsEqual ¶ added in v0.0.19
func (r DurationTestResult) IsEqual() bool
func (DurationTestResult) String ¶ added in v0.0.19
func (r DurationTestResult) String() string
type ExportFormat ¶ added in v0.0.17
type ExportFormat int
const ( XML_FORMAT ExportFormat = iota HTML_FORMAT )
func (ExportFormat) String ¶ added in v0.0.17
func (scope ExportFormat) String() string
type ExportPost ¶ added in v0.0.17
type ExportPost struct { // XML, HTML Format ExportFormat // user,group Scope ExportScope // The id of a user or group to export Id int // a list of items to export ItemIds []int //Link depth to follow MaxLinkLevel int }
func NewExportPost ¶ added in v0.0.17
func NewExportPost() ExportPost
NewExportPost generates an ExportPost of type USER_EXPORT_SCOPE to HTML format, set as defaults, with link depth 1
func (ExportPost) ItemIdsToRequest ¶ added in v0.0.17
func (post ExportPost) ItemIdsToRequest() string
type ExportScope ¶ added in v0.0.17
type ExportScope int
const ( USER_EXPORT_SCOPE ExportScope = iota GROUP_EXPORT_SCOPE SELECTION_EXPORT_SCOPE )
func (ExportScope) String ¶ added in v0.0.17
func (scope ExportScope) String() string
type ExportService ¶ added in v0.0.17
type ExportService struct {
BaseService
}
func (*ExportService) DownloadExport ¶ added in v0.0.17
func (es *ExportService) DownloadExport(url string, outWriter io.Writer) error
Download export downloads to the supplied filepath on local device
func (*ExportService) Export ¶ added in v0.0.17
func (fs *ExportService) Export(post ExportPost, waitForComplete bool, reporter func(string)) (*Job, error)
Export does an export, blocking till job has finished. The returned job, if completed successfully, will contain a download link. reporter callback can be used to report or log progress to client
type Field ¶
type Field struct { *IdentifiableNamable Type string Content string LastModified string Files []FileInfo }
type FieldContent ¶
type FileInfo ¶
type FileInfo struct { *IdentifiableNamable ContentType string Size int Caption string Created string Version int }
FileInfo holds metadata about Files
type FileService ¶
type FileService struct {
BaseService
}
func (*FileService) DownloadFile ¶
func (fs *FileService) DownloadFile(fileId int, outDir string) (*FileInfo, error)
DownloadFile retrieves the given file from RSpace and downloads to the specified directory on local machine, which must be a writable file. Returns the FileInfo metadata for the downloaded file
func (*FileService) FileById ¶
func (fs *FileService) FileById(fileId int) (*FileInfo, error)
FileById retrieves file information for a single File
func (*FileService) Files ¶
func (fs *FileService) Files(config RecordListingConfig, mediaType string) (*FileList, error)
Paginated listing of Files. Optionally the listing can be filtered by a media type of 'document', image', or 'av'
func (*FileService) UploadFile ¶
func (fs *FileService) UploadFile(config FileUploadConfig) (*FileInfo, error)
UploadFile uploads the file specified to the 'ApiInbox' subfolder of the appropriate Gallery section Returns either a FileInfo of the created file or an error if operation did not succeed.
func (*FileService) UploadFileNewVersion ¶
func (fs *FileService) UploadFileNewVersion(path string, fileToReplaceId int) (*FileInfo, error)
UploadFileNewVersion replaces the RSpace file of the given ID with the new file. The new version can have a different name but must be same filetype (i.e. have the same suffix)
type FileUploadConfig ¶ added in v0.0.17
FileUploadConfig configures file upload. filePath is required, other properties are optional.
type Folder ¶
type Folder struct { *IdentifiableNamable Created string LastModified string IsNotebook bool `json:"notebook"` ParentFolderId int }
type FolderList ¶
type FolderList struct { Records []FolderTreeItem TotalHits int PageNumber int Links []Link `json:"_links"` }
type FolderPost ¶
type FolderService ¶
type FolderService struct {
BaseService
}
func (*FolderService) DeleteFolder ¶
func (fs *FolderService) DeleteFolder(folderId int) (bool, error)
DeleteFolder attempts to delete the folder or noteboon with the specified ID
func (*FolderService) FolderById ¶
func (fs *FolderService) FolderById(folderId int) (*Folder, error)
FolderById retrieves full information about the folder
func (*FolderService) FolderNew ¶
func (fs *FolderService) FolderNew(post *FolderPost) (*Folder, error)
FolderNew creates a new folder or notebook with the given name. If a parentFolderId is specified then the folder is created in that folder
func (*FolderService) FolderTree ¶
func (fs *FolderService) FolderTree(config RecordListingConfig, folderId int, typesToInclude []string) (*FolderList, error)
FolderTree produces paginated listing of items in folder. If folderId is 0 then Home Folder is lister
type FolderTreeItem ¶
type FolderTreeItem struct { *IdentifiableNamable Created string LastModified string IsNotebook bool `json:"notebook"` Type string }
func (*FolderTreeItem) CreatedTime ¶
func (f *FolderTreeItem) CreatedTime() (time.Time, error)
func (*FolderTreeItem) LastModifiedTime ¶
func (f *FolderTreeItem) LastModifiedTime() (time.Time, error)
type Form ¶
type Form struct { *IdentifiableNamable Version int FormState string StableId string Links []Link `json:"_links"` Tags string }
Form holds basic information about a Form
type FormService ¶
type FormService struct {
BaseService
}
func (*FormService) CreateFormJson ¶ added in v0.0.17
func (fs *FormService) CreateFormJson(jsonFormDef io.Reader) (*Form, error)
func (*FormService) CreateFormYaml ¶ added in v0.0.17
func (fs *FormService) CreateFormYaml(yamlFormDef io.Reader) (*Form, error)
func (*FormService) Forms ¶
func (fs *FormService) Forms(config RecordListingConfig, query string) (*FormList, error)
Forms produces paginated listing of items in form
func (*FormService) PublishForm ¶ added in v0.0.17
func (fs *FormService) PublishForm(formId int) (*Form, error)
type GlobalId ¶
type GlobalId string
GlobalId is a Unique identifier for an RSpace object, e.g. 'GL1234' or 'SD5678'
type GroupPost ¶
type GroupPost struct { DisplayName string `json:"displayName"` Members []UserGroupPost `json:"members"` }
GroupPost is serialized to JSON. Client code should use GroupPostNew to create this object.
func GroupPostNew ¶
func GroupPostNew(name string, userGroups []UserGroupPost) (*GroupPost, error)
GroupPostNew performs validated construction of a GroupPost object
type GroupService ¶ added in v0.0.11
type GroupService struct {
BaseService
}
func (*GroupService) Groups ¶ added in v0.0.11
func (fs *GroupService) Groups() (*GroupList, error)
FormTree produces paginated listing of items in form
type GroupShare ¶ added in v0.0.17
type GroupShare struct {}
type IdentifiableNamable ¶
func (IdentifiableNamable) GetGlobalId ¶
func (item IdentifiableNamable) GetGlobalId() string
func (IdentifiableNamable) GetId ¶
func (item IdentifiableNamable) GetId() int
func (IdentifiableNamable) GetName ¶
func (item IdentifiableNamable) GetName() string
type ImportService ¶
type ImportService struct {
BaseService
}
func (*ImportService) ImportWord ¶
func (fs *ImportService) ImportWord(path string, folderId int, imageFolderId int) (*DocumentInfo, error)
ImportWord takes an MSWord or rich text file and imports it as a native RSpace document. If `folderId` is not specified, the document will be created in RSpace Home folder If `imageFolderId` is not specified, any images embedded in the original document will be put in the `ApiInbox` folder of the Image Gallery.
type IntTestResult ¶
func (IntTestResult) IsEqual ¶
func (r IntTestResult) IsEqual() bool
func (IntTestResult) String ¶
func (r IntTestResult) String() string
type Job ¶ added in v0.0.17
type Job struct { Status string Id int PercentComplete float32 Links []Link `json:"_links"` Result JobResult }
Job holds information about a long-running request
func (*Job) DownloadLink ¶ added in v0.0.17
DownloadLink returns a URL of the link to access the export, if the Job is in COMPLETED state and has a download link. Otherwise returns nil
func (*Job) IsCompleted ¶ added in v0.0.17
Boolean query for Job completed successfully
func (*Job) IsTerminated ¶ added in v0.0.17
Boolean query for job no longer running.
type RSpaceError ¶
type RSpaceError struct { Status string HttpCode int InternalCode int Message string Errors []string Timestamp string `json:"iso8601Timestamp"` // This will be set in the event that 429 TooManyRequests has been received MillisTillNextCall int }
RSpaceError encapsulates server or client side errors leading to a request being rejected.
func (*RSpaceError) CreatedTime ¶
func (f *RSpaceError) CreatedTime() (time.Time, error)
func (*RSpaceError) Error ¶
func (rsError *RSpaceError) Error() string
func (*RSpaceError) String ¶
func (rsError *RSpaceError) String() string
type RateLimitData ¶ added in v0.0.11
type RateLimitData struct {
WaitTimeMillis int
}
RateLimitData stores information received in HTTP Response Headers about API usage rates. If this information could not be retrieved from a response then value will be -100
func NewRateLimitData ¶ added in v0.0.11
func NewRateLimitData(resp *http.Response) RateLimitData
func (RateLimitData) String ¶ added in v0.0.11
func (rld RateLimitData) String() string
Stringer implementation
type RecordListingConfig ¶
configures pagination and verbosity for listings
func NewRecordListingConfig ¶
func NewRecordListingConfig() RecordListingConfig
factory method to return a RecordListingConfig with default values
type RetryClientEx ¶ added in v0.0.17
type RetryClientEx struct {
// contains filtered or unexported fields
}
RetryClientEx performs a fixed number of attempts to call clientEx.Do()
func RetryClientExNew ¶ added in v0.0.17
func RetryClientExNew(retries int, wrappedRequest ClientEx) (*RetryClientEx, error)
RetryClientExNew is constructor for RetryClientEx. It validates the number of retries >= 1
type RsWebClient ¶
type RsWebClient struct {
// contains filtered or unexported fields
}
func NewWebClient ¶
func NewWebClient(baseUrl *url.URL, apiKey string) *RsWebClient
create new web client with a default timeout (15s)
func NewWebClientCustomTimeout ¶ added in v0.0.17
func NewWebClientCustomTimeout(baseUrl *url.URL, apiKey string, timeout int) *RsWebClient
create new web client with custom timeout ( must be > default timeout)
func (*RsWebClient) Activities ¶
func (ds *RsWebClient) Activities(query *ActivityQuery, pgCrit RecordListingConfig) (*ActivityList, error)
Activities queries the audit trail and returns a list of events.
func (*RsWebClient) AdvancedSearchDocuments ¶
func (ds *RsWebClient) AdvancedSearchDocuments(config RecordListingConfig, searchQuery *SearchQuery) (*DocumentList, error)
AdvancedSearchDocuments performs a search for the terms specified in 'searchQuery'
func (*RsWebClient) CreateFormJson ¶ added in v0.0.17
func (fs *RsWebClient) CreateFormJson(jsonFormDef io.Reader) (*Form, error)
func (*RsWebClient) CreateFormYaml ¶ added in v0.0.17
func (fs *RsWebClient) CreateFormYaml(yamlFormDef io.Reader) (*Form, error)
func (*RsWebClient) DeleteFolder ¶
func (fs *RsWebClient) DeleteFolder(folderId int) (bool, error)
DeleteFolder deletes the given folder
func (*RsWebClient) DocumentById ¶ added in v0.0.17
func (ds *RsWebClient) DocumentById(docId int) (*Document, error)
func (*RsWebClient) DocumentEdit ¶ added in v0.0.17
func (ds *RsWebClient) DocumentEdit(docId int, docPost *DocumentPost) (*Document, error)
func (*RsWebClient) Documents ¶
func (ds *RsWebClient) Documents(config RecordListingConfig) (*DocumentList, error)
Documents returns a paginated listing of RSpace documents
func (*RsWebClient) Download ¶
func (fs *RsWebClient) Download(id int, path string) (*FileInfo, error)
Download downloads a file attachment with the given ID to the location set by the path.
func (*RsWebClient) DownloadExport ¶ added in v0.0.17
Download the export link to specified file
func (*RsWebClient) Export ¶ added in v0.0.17
func (client *RsWebClient) Export(post ExportPost, waitForDone bool, progressWriter func(string)) (*Job, error)
Submit an export job, optionally blocking till complete
func (*RsWebClient) FileById ¶
func (fs *RsWebClient) FileById(id int) (*FileInfo, error)
Lists Gallery files, optionally filtered by a media type
func (*RsWebClient) Files ¶
func (fs *RsWebClient) Files(config RecordListingConfig, mediaType string) (*FileList, error)
Lists Gallery files, optionally filtered by a media type
func (*RsWebClient) FolderById ¶
func (fs *RsWebClient) FolderById(folderId int) (*Folder, error)
FolderById returns information about the folder specified by folderId
func (*RsWebClient) FolderNew ¶
func (fs *RsWebClient) FolderNew(post *FolderPost) (*Folder, error)
FolderNew creates a new folder or notebook
func (*RsWebClient) FolderTree ¶
func (fs *RsWebClient) FolderTree(config RecordListingConfig, folderId int, typesToInclude []string) (*FolderList, error)
FolderTree returns a list of items in the specified folder
func (*RsWebClient) FormSearch ¶ added in v0.0.17
func (fs *RsWebClient) FormSearch(config RecordListingConfig, query string) (*FormList, error)
FormSearch returns a paginated listing of Forms filtered by optional search query
func (*RsWebClient) Forms ¶
func (fs *RsWebClient) Forms(config RecordListingConfig) (*FormList, error)
Forms returns a paginated listing of Forms
func (*RsWebClient) GetJob ¶ added in v0.0.17
func (client *RsWebClient) GetJob(jobId int) (*Job, error)
gets current state of job
func (*RsWebClient) GroupNew ¶
func (ws *RsWebClient) GroupNew(groupPost *GroupPost) (*GroupInfo, error)
GroupNew creates a new group with the specified users and PI. Requires sysadmin role
func (*RsWebClient) Groups ¶ added in v0.0.11
func (ws *RsWebClient) Groups() (*GroupList, error)
func (*RsWebClient) ImportWord ¶
func (fs *RsWebClient) ImportWord(path string, folderId int, imageFolderId int) (*DocumentInfo, error)
func (*RsWebClient) NewBasicDocumentWithContent ¶
func (ds *RsWebClient) NewBasicDocumentWithContent(name, tags, content string) (*Document, error)
func (*RsWebClient) NewDocumentWithContent ¶ added in v0.0.17
func (ds *RsWebClient) NewDocumentWithContent(docPost *DocumentPost) (*Document, error)
func (*RsWebClient) NewEmptyBasicDocument ¶
func (ds *RsWebClient) NewEmptyBasicDocument(name, tags string) (*Document, error)
NewEmptyBasicDocument creates a Basic (single text field) document with no content
func (*RsWebClient) PublishForm ¶ added in v0.0.17
func (fs *RsWebClient) PublishForm(formId int) (*Form, error)
func (*RsWebClient) SearchDocuments ¶
func (ds *RsWebClient) SearchDocuments(config RecordListingConfig, searchTerm string) (*DocumentList, error)
SearchDocuments performs a global search for 'searchTerm' across all searchable fields
func (*RsWebClient) Share ¶ added in v0.0.17
func (client *RsWebClient) Share(post *SharePost) (*ShareInfoList, error)
Share shares one or more items with one or more groups and users. Sharer and sharee must have a group in common.
func (*RsWebClient) ShareList ¶ added in v0.0.17
func (client *RsWebClient) ShareList(query string, cfg RecordListingConfig) (*SharedItemList, error)
List shared items
func (*RsWebClient) Status ¶
func (ds *RsWebClient) Status() (*Status, error)
Status returns simple information about the current server
func (*RsWebClient) Unshare ¶ added in v0.0.17
func (client *RsWebClient) Unshare(shareId int) (bool, error)
func (*RsWebClient) UploadFile ¶
func (fs *RsWebClient) UploadFile(config FileUploadConfig) (*FileInfo, error)
Uploads a single file
func (*RsWebClient) UploadFileNewVersion ¶
func (fs *RsWebClient) UploadFileNewVersion(path string, fileToReplaceId int) (*FileInfo, error)
func (*RsWebClient) UserNew ¶
func (ws *RsWebClient) UserNew(userPost *UserPost) (*UserInfo, error)
UserNew creates a new user account. Requires sysadmin role
func (*RsWebClient) Users ¶
func (ws *RsWebClient) Users(lastLoginBefore time.Time, creationDateBefore time.Time, cfg RecordListingConfig) (*UserList, error)
type SearchOperator ¶
type SearchOperator int
Boolean combinator - AND or OR
const ( And SearchOperator = iota Or )
type SearchQuery ¶
func (*SearchQuery) String ¶
func (q *SearchQuery) String() string
type SearchQueryBuilder ¶
type SearchQueryBuilder struct {
// contains filtered or unexported fields
}
func (*SearchQueryBuilder) AddGlobalTerm ¶
func (qb *SearchQueryBuilder) AddGlobalTerm(term string) *SearchQueryBuilder
func (*SearchQueryBuilder) AddTerm ¶
func (qb *SearchQueryBuilder) AddTerm(term string, queryType QueryType) *SearchQueryBuilder
addTerm appends a search term in the given category. If the term is empty or nil the term is not added
func (*SearchQueryBuilder) Build ¶
func (qb *SearchQueryBuilder) Build() *SearchQuery
build generates a SearchQuery object and returns its pointer
func (*SearchQueryBuilder) Operator ¶
func (qb *SearchQueryBuilder) Operator(op SearchOperator) *SearchQueryBuilder
operator sets the boolean type of the search query
type SearchTerm ¶
SearchTerm is used by SearchQueryBuilder to construct a valid search query
func (SearchTerm) String ¶
func (op SearchTerm) String() string
Stringer implementation for SearchTerm
type ShareInfoList ¶ added in v0.0.17
type ShareInfoList struct {}
ShareInfoList represents the results of posting a /share request
type ShareResult ¶ added in v0.0.17
type ShareResult struct {}
ShareResult represents a successful share of a single resource
type SharedItemList ¶ added in v0.0.17
type SharedItemList struct {}
type SharingService ¶ added in v0.0.17
type SharingService struct {
BaseService
}
func (*SharingService) Share ¶ added in v0.0.17
func (fs *SharingService) Share(post *SharePost) (*ShareInfoList, error)
Share an item with a group or user Id
func (*SharingService) SharedItemList ¶ added in v0.0.17
func (fs *SharingService) SharedItemList(query string, cfg RecordListingConfig) (*SharedItemList, error)
type StringTestResult ¶
func (StringTestResult) IsEqual ¶
func (r StringTestResult) IsEqual() bool
func (StringTestResult) String ¶
func (r StringTestResult) String() string
type SysadminService ¶
type SysadminService struct {
BaseService
}
func (*SysadminService) GroupNew ¶
func (ds *SysadminService) GroupNew(post *GroupPost) (*GroupInfo, error)
GroupNew creates a new group from existing users
func (*SysadminService) UserNew ¶
func (ds *SysadminService) UserNew(post *UserPost) (*UserInfo, error)
UserNew creates a new user account.
func (*SysadminService) Users ¶
func (ds *SysadminService) Users(lastLoginBefore time.Time, creationDateBefore time.Time, pgConfig RecordListingConfig) (*UserList, error)
Users lists users' biographical information
type UserGroupPost ¶
type UserGroupPost struct { Username string `json:"username"` RoleInGroup string `json:"roleInGroup"` }
UserGroup post defines a single user's membership role within a group.
type UserPost ¶
type UserPost struct { Username string `json:"username"` Email string `json:"email"` FirstName string `json:"firstName"` LastName string `json:"lastName"` Password string `json:"password"` Role string `json:"role"` Affiliation string `json:"affiliation,omitempty"` ApiKey string `json:"apiKey,omitempty"` }
type UserPostBuilder ¶
type UserPostBuilder struct {
// contains filtered or unexported fields
}
Use this to build a UserPost object to create a new user from.
func (*UserPostBuilder) Affiliation ¶
func (b *UserPostBuilder) Affiliation(affiliation string) *UserPostBuilder
func (*UserPostBuilder) ApiKey ¶
func (b *UserPostBuilder) ApiKey(apiKey string) *UserPostBuilder
func (*UserPostBuilder) Build ¶
func (b *UserPostBuilder) Build() (*UserPost, error)
func (*UserPostBuilder) Email ¶
func (b *UserPostBuilder) Email(emailAddress Email) *UserPostBuilder
func (*UserPostBuilder) FirstName ¶
func (b *UserPostBuilder) FirstName(firstName string) *UserPostBuilder
func (*UserPostBuilder) LastName ¶
func (b *UserPostBuilder) LastName(lastName string) *UserPostBuilder
func (*UserPostBuilder) Password ¶
func (b *UserPostBuilder) Password(password string) *UserPostBuilder
func (*UserPostBuilder) Role ¶
func (b *UserPostBuilder) Role(role UserRoleType) *UserPostBuilder
func (*UserPostBuilder) Username ¶
func (b *UserPostBuilder) Username(username string) *UserPostBuilder