rspace

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2022 License: Apache-2.0 Imports: 21 Imported by: 2

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

View Source
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

View Source
var Log = logging.MustGetLogger("rs-client")

Functions

func HttpClientNew added in v0.0.17

func HttpClientNew(timeOutSeconds int) *http.Client

HttpClientNew creates a new http.Client with specified timeout in seconds

func Marshal

func Marshal(anything interface{}) string

func Unmarshal

func Unmarshal(resp *http.Response, result interface{})

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.

func (*Activity) TimestampTime

func (a *Activity) TimestampTime() (time.Time, error)

TimestampTime offers the timestamp of the audit event.

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 (*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

DateTo specifies an upper bound on the time stamp of an activity.

func (*ActivityQueryBuilder) Domain

func (*ActivityQueryBuilder) Oid

Oid restricts the search to activities involving the specific item.

func (*ActivityQueryBuilder) User

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 BaseService struct {
	Delay   time.Duration
	ApiKey  string
	BaseUrl *url.URL
	// request timeout in seconds
	TimeoutSeconds int
}

type BasicInfo

type BasicInfo interface {
	GetName() string
	GetId() int
	GetGlobalId() string
}

BasicInfo provides simple information common to many RSpace resources

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

func NewResilientClient(toWrap *http.Client) ClientEx

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.

func (*DelayClientEx) Do added in v0.0.17

func (this *DelayClientEx) Do(req *http.Request) (*http.Response, error)

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

type DurationTestResult struct {
	Expected time.Duration
	Actual   time.Duration
}

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 Email

type Email 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

func (*ExportService) GetJob added in v0.0.17

func (es *ExportService) GetJob(jobId int) (*Job, error)

type Field

type Field struct {
	*IdentifiableNamable
	Type         string
	Content      string
	LastModified string
	Files        []FileInfo
}

func (*Field) LastModifiedTime

func (f *Field) LastModifiedTime() (time.Time, error)

type FieldContent

type FieldContent struct {
	Content string `json:"content"`
	//Id will be null when posting, can be set if editing a specific field
	Id int `json:"id,omitempty"`
}

type FileInfo

type FileInfo struct {
	*IdentifiableNamable
	ContentType string
	Size        int
	Caption     string
	Created     string
	Version     int
}

FileInfo holds metadata about Files

func (*FileInfo) CreatedTime

func (fi *FileInfo) CreatedTime() (time.Time, error)

type FileList

type FileList struct {
	TotalHits  int
	PageNumber int
	Links      []Link `json:"_links"`
	Files      []FileInfo
}

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

type FileUploadConfig struct {
	Caption  string
	FilePath string
	FolderId int
}

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
}

func (*Folder) CreatedTime

func (f *Folder) CreatedTime() (time.Time, error)

func (*Folder) LastModifiedTime

func (f *Folder) LastModifiedTime() (time.Time, error)

type FolderList

type FolderList struct {
	Records    []FolderTreeItem
	TotalHits  int
	PageNumber int
	Links      []Link `json:"_links"`
}

type FolderPost

type FolderPost struct {
	Name           string `json:"name,omitempty"`
	IsNotebook     bool   `json:"notebook,omitempty"`
	ParentFolderId int    `json:"parentFolderId,omitempty"`
}

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 FormId

type FormId struct {
	Id int `json:"id,omitempty"`
}

type FormList

type FormList struct {
	TotalHits  int
	PageNumber int
	Forms      []Form
	Links      []Link `json:"_links"`
}

FormList holds the results of listing Forms

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 GroupInfo

type GroupInfo struct {
	Id             int
	Name           string
	Type           string
	SharedFolderId int
	Members        []struct {
		Id       int
		Username string
		Role     string
	}
}

type GroupList added in v0.0.11

type GroupList struct {
	Groups []*GroupInfo
}

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 {
	Id             int    `json:"id"`
	Permission     string `json:"permission"`
	SharedFolderId int    `json:"sharedFolderId"`
}

type IdentifiableNamable

type IdentifiableNamable struct {
	Id       int
	GlobalId string
	Name     string
}

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

type IntTestResult struct {
	Expected int
	Actual   int
}

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 *Job) DownloadLink() *url.URL

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

func (job *Job) IsCompleted() bool

Boolean query for Job completed successfully

func (*Job) IsTerminated added in v0.0.17

func (job *Job) IsTerminated() bool

Boolean query for job no longer running.

type JobResult added in v0.0.17

type JobResult struct {
	ExpiryDate string
	Size       int
	Checksum   string
	Algorithm  string
}
type Link struct {
	Link string
	Rel  string
}

type Permission added in v0.0.17

type Permission int
const (
	Read Permission = iota
	Edit
)

type QueryType

type QueryType int

QueryType restricts search to a particular category

const (
	GLOBAL QueryType = iota
	FULL_TEXT
	TAG
	NAME
	CREATED
	LAST_MODIFIED
	FORM
	ATTACHMENT
	OWNER
)

func (QueryType) String

func (op QueryType) String() string

Stringer implementation

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

type RecordListingConfig struct {
	SortOrder  string
	PageSize   int
	PageNumber int
	OrderBy    string
}

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

func (RetryClientEx) Do added in v0.0.17

func (ex RetryClientEx) Do(req *http.Request) (*http.Response, error)

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

func (client *RsWebClient) DownloadExport(link *url.URL, writer io.Writer) error

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 STerm

type STerm struct {
	Term      string `json:"query"`
	QueryType string `json:"queryType"`
}

type SearchOperator

type SearchOperator int

Boolean combinator - AND or OR

const (
	And SearchOperator = iota
	Or
)

func (SearchOperator) String

func (op SearchOperator) String() string

Stringer implementation

type SearchQuery

type SearchQuery struct {
	Operator string  `json:"operator"`
	Terms    []STerm `json:"terms"`
}

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

operator sets the boolean type of the search query

type SearchTerm

type SearchTerm struct {
	QueryType QueryType
	Term      string
}

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 {
	ShareInfos   []*ShareResult
	FailedShares []int
	Links        []string `json:"_links"`
}

ShareInfoList represents the results of posting a /share request

type SharePost added in v0.0.17

type SharePost struct {
	ItemsToShare []int        `json:"itemsToShare"`
	Groups       []GroupShare `json:"groups"`
	Users        []UserShare  `json:"users"`
}

type ShareResult added in v0.0.17

type ShareResult struct {
	Id         int
	ItemId     int    `json:"sharedItemId"`
	ItemName   string `json:"shareItemName"`
	TargetType string `json:"sharedTargetType"`
	Permission string
	Links      []string `json:"_links"`
}

ShareResult represents a successful share of a single resource

type SharedItemList added in v0.0.17

type SharedItemList struct {
	Shares     []*ShareResult
	TotalHits  int
	PageNumber int
	Links      []string `json:"_links"`
}

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)

func (*SharingService) Unshare added in v0.0.17

func (fs *SharingService) Unshare(shareId int) (bool, error)

Unshare unshares an item from a user or group. The id to be passed is the id of a ShareInfo, not the the Id of an RSpace document.

type Status

type Status struct {
	Message       string `json:"message"`
	RSpaceVersion string `json:"rspaceVersion"`
}

Status stores response from /status endpoint

type StringTestResult

type StringTestResult struct {
	Expected string
	Actual   string
}

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 Testable

type Testable interface {
	IsEqual() bool
	String() string
}

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 UserInfo

type UserInfo struct {
	Id           int
	Username     string
	Email        string
	FirstName    string
	LastName     string
	HomeFolderId int
}

type UserList

type UserList struct {
	Users      []UserInfo
	TotalHits  int
	PageNumber int
	Links      []Link `json:"_links"`
}

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"`
}

func (*UserPost) String

func (upost *UserPost) String() string

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 (*UserPostBuilder) Username

func (b *UserPostBuilder) Username(username string) *UserPostBuilder

type UserRoleType

type UserRoleType int
const (
	User UserRoleType = iota
	Pi
	Admin
	Sysadmin
)

type UserShare added in v0.0.17

type UserShare struct {
	Id         int    `json:"id"`
	Permission string `json:"permission"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL