A go library for interacting with Treeno

Few things are tested, some might work.




This section is empty.


View Source
var ErrNorImplemented = fmt.Errorf("Not Implemented")


This section is empty.


type AuthResp

type AuthResp struct {
	Authentication Authentication `json:"authentication"`
	HasError       bool           `json:"hasError"`
	ErrorMessage   string         `json:"errorMessage"`

AuthResp authentication response

type Authentication

type Authentication struct {
	User         User       `json:"user"`
	Token        string     `json:"token"`
	RefreshToken string     `json:"refreshToken"`
	Expiration   treenoTime `json:"expiration"`

Authentication authentication info

type CabinetSearchResponse

type CabinetSearchResponse struct {
	Results      []CabinetSearchResult `json:"results"`
	HasError     bool                  `json:"hasError"`
	ErrorMessage string                `json:"errorMessage"`

CabinetSearchResponse contains results from a search, and errors if there was errors

type CabinetSearchResult

type CabinetSearchResult struct {
	DocId   int     `json:"docId"`
	Indices Indices `json:"cabinetIndices"`

CabinetSearchResult is the contents of a Cabinet Search

type Cabinets

type Cabinets []struct {
	IsAutoComplete        bool     `json:"isAutoComplete"`
	SavedTabs             []string `json:"savedTabs"`
	DataTypeDefinitions   struct{} `json:"dataTypeDefinitions"`
	Indices               []string `json:"indices"`
	DepartmentRealName    string   `json:"departmentRealName"`
	DepartmentDisplayName string   `json:"departmentDisplayName"`
	IsDocumentView        bool     `json:"isDocumentView"`
	CabinetID             int      `json:"cabinetId"`
	RealName              string   `json:"realName"`
	DisplayName           string   `json:"displayName"`

Cabinets slice of cabinets for the department

type CabinetsResponse

type CabinetsResponse struct {
	Cabinets     Cabinets `json:"cabinets"`
	HasError     bool     `json:"hasError"`
	ErrorMessage string   `json:"errorMessage"`

CabinetsResponse response containing any errors and the Cabinets

type Client

type Client struct {
	Authentication Authentication

	DefaultDepartment string
	// contains filtered or unexported fields

Client treeno client containing an http.Client that makes requests

func NewService

func NewService(conf *Config, deptDefault string) (client *Client, err error)

NewService Create a new service with the config, and set a default department

func (*Client) AddFolder

func (client *Client) AddFolder(f Folder) (folder Folder, err error)

AddFolder Add a folder

func (Client) Do

func (client Client) Do(req *http.Request) (*http.Response, error)

Do Make the request with the client

func (*Client) FilesAdd

func (client *Client) FilesAdd(file FilesAddRequest) (err error)

FilesAdd Adds a selected file to specific subfolder/tab TODO NOT IMPLEMENTED and also not needed maybe?

func (*Client) FilesDownload

func (client *Client) FilesDownload(filesDownload FilesDownloadRequest) (file FilesDownloadResponse, err error)

FilesDownload download a file TODO NOT TESTED

func (*Client) FilesGetFilesInFolder

func (client *Client) FilesGetFilesInFolder(department string, cabinet string, folderId int) (files FilesInFolder, err error)

FilesGetFilesInFolder TODO NOT TESTED department real name cabinet real name

func (*Client) FilesUploadToFolder

func (client *Client) FilesUploadToFolder(file FilesUploadToFolderRequest) (fileId int, err error)

FilesUploadToFolder Upload a file to a folder

func (*Client) GetDepartments

func (client *Client) GetDepartments() (deps Departments, err error)

GetDepartments get departments

func (*Client) GetDocumentTypes

func (client *Client) GetDocumentTypes(department, cabinet string) (dTypes DocumentTypes, err error)

GetDocumentTypes Get a list of document types for a cabinet in a department TODO UNTESTED

func (*Client) GetFolders

func (client *Client) GetFolders(department string, cabinet string) (f Folders, err error)

GetFolders return list of folders in a cabinet

func (*Client) GetSavedTabs

func (client *Client) GetSavedTabs(department string, cabinet string) (f TabInfoList, err error)

GetSavedTabs Gets list of saved tabs name for a cabinet

func (Client) GetServerResponse

func (client Client) GetServerResponse(url string, method string, body io.Reader) (resp *http.Response, err error)

GetServerResponse by doing an auth request

func (*Client) GetTabInfo

func (client *Client) GetTabInfo(department string, cabinet string, folder string) (f TabInfoList, err error)

GetTabInfo UNTESTED, im not sure what this is for. I just noticed that it's a post not a get returns list of tabs for a folder in a cabinet.

func (*Client) ListCabinets

func (client *Client) ListCabinets() (cabinets Cabinets, err error)

ListCabinets Returns a list of cabinets in a department

func (Client) NewAuthRequest

func (client Client) NewAuthRequest(path string, method string, body io.Reader) (req *http.Request, err error)

NewAuthRequest with auth header and body

func (*Client) SearchCabinet

func (client *Client) SearchCabinet(cabinet string, query ...IndexQuery) (results []CabinetSearchResult, err error)

SearchCabinet Searches cabinet for folders by index value Gotcha: Cabinet index names are all lower case for some reason

type Config

type Config struct {
	Host     string
	Username string
	Email    string
	Password string

Config Config required to create a client

func (*Config) Authenticate

func (conf *Config) Authenticate() (*Authentication, error)

Authenticate authenticates to the treeno API

func (*Config) Token

func (conf *Config) Token() (*oauth2.Token, error)

Token Authenticates and creates a new oauth token

type DepartmentResponse

type DepartmentResponse struct {
	Departments  Departments `json:"departments"`
	HasError     bool        `json:"hasError"`
	ErrorMessage string      `json:"errorMessage"`

DepartmentResponse response for GetDepartments

type Departments

type Departments []struct {
	RealName string `json:"realName"`
	ArbName  string `json:"arbName"`

Departments slice of departments in treeno

type DocumentTypes

type DocumentTypes []struct {
	DocumentTypeID      int    `json:"documentTypeID"`
	DocumentTypeEnabled int    `json:"documentTypeEnabled"`
	InternalName        string `json:"internalName"`
	DisplayName         string `json:"displayName"`
	Indices             []struct {
		ID    int    `json:"id"`
		Index string `json:"index"`
		Value string `json:"value"`
	} `json:"indices"`
	DocTypeIndexDefs []struct {
		IndexName      string   `json:"indexName"`
		DefinitionList []string `json:"definitionList"`
	} `json:"docTypeIndexDefs"`

DocumentTypes in a given department and cabinet

type DocumentTypesResponse

type DocumentTypesResponse struct {
	DocumentTypes DocumentTypes `json:"documentTypes"`
	HasError      bool          `json:"hasError"`
	ErrorMessage  string        `json:"errorMessage"`

DocumentTypesResponse Response containing any errors and the DocumentTypes

type File

type File struct {
	FileID       int    `json:"fileId"`
	FileFullName string `json:"fileFullName"`
	Department   string `json:"department"`
	Cabinet      string `json:"cabinet"`
	FolderID     int    `json:"folderId"`
	TabID        int    `json:"tabId"`

File represents a file in treeno

type FilesAddRequest

type FilesAddRequest struct {

FilesAddRequest TODO seems like it's not finished

type FilesAddResponse

type FilesAddResponse struct {
	File         File   `json:"file"`
	HasError     bool   `json:"hasError"`
	ErrorMessage string `json:"errorMessage"`

FilesAddResponse Response containing any errors and the file that was added

type FilesDownloadRequest

type FilesDownloadRequest struct {
	Department string `json:"department"`
	Cabinet    string `json:"cabinet"`
	FileIds    []int  `json:"fileIds"`
	Format     string `json:"format"`   //optional
	Filename   string `json:"filename"` //optional

FilesDownloadRequest request for file download

type FilesDownloadResponse

type FilesDownloadResponse struct {
	DownloadFile FilesDownloadRequest `json:"downloadFile"`
	FileContent  []byte               `json:"fileContent"`
	HasError     bool                 `json:"hasError"`
	ErrorMessage string               `json:"errorMessage"`

FilesDownloadResponse Response containing any errors, the file contents and the request

type FilesGetFilesInFolderResponse

type FilesGetFilesInFolderResponse struct {
	Files        FilesInFolder `json:"files"`
	HasError     bool          `json:"hasError"`
	ErrorMessage string        `json:"errorMessage"`

FilesGetFilesInFolderResponse Response containing any errors and the files in the folder

type FilesInFolder

type FilesInFolder []struct {
	FileID    int    `json:"fileId"`
	Filename  string `json:"filename"`
	Subfolder string `json:"subfolder"`

FilesInFolder slice of filenames and ids

type FilesUploadToFolderRequest

type FilesUploadToFolderRequest struct {
	Department  string `json:"department"`
	CabinetID   int    `json:"cabinetId"`
	DocID       int    `json:"docId"`
	TabID       int    `json:"tabId,omitempty"`
	Filename    string `json:"filename"`
	FileContent []byte `json:"fileContent"`

FilesUploadToFolderRequest request for file upload

type FilesUploadToFolderResponse

type FilesUploadToFolderResponse struct {
	Upload       FilesUploadToFolderRequest `json:"upload"`
	FileID       int                        `json:"fileId"`
	HasError     bool                       `json:"hasError"`
	ErrorMessage string                     `json:"errorMessage"`

FilesUploadToFolderResponse Response containing any errors and the initial request

type Folder

type Folder struct {
	FolderID   int     `json:"folderId"`  //optional
	CabinetID  int     `json:"cabinetId"` //optional, this or cabinet might be required
	Department string  `json:"department"`
	Cabinet    string  `json:"cabinet"` //optional, this or cabinetId might be required
	Indices    Indices `json:"indices"`

Folder represents a folder in Treeno

func (*Folder) IndexValue

func (f *Folder) IndexValue(index string) (value string)

IndexValue Find the value for a given index, or empty string

type FolderAddResponse

type FolderAddResponse struct {
	Folder       Folder `json:"folder"`
	HasError     bool   `json:"hasError"`
	ErrorMessage string `json:"errorMessage"`

FolderAddResponse Response to add folder to cabinet

type Folders

type Folders []Folder

Folders slice of folders

type FoldersResponse

type FoldersResponse struct {
	Folders      Folders `json:"folders"`
	HasError     bool    `json:"hasError"`
	ErrorMessage string  `json:"errorMessage"`

FoldersResponse GetFolders response

type IndexQuery

type IndexQuery struct {
	Id       int    `json:"id,omitempty"`
	Index    string `json:"index"`
	Value    string `json:"value,omitempty"`
	Operator string `json:"operator,omitempty"`

IndexQuery index query parameters

type Indices

type Indices []struct {
	Index string `json:"index"`
	Value string `json:"value"` //optional?

Indices Indices

func (Indices) ToMap

func (wrs Indices) ToMap() (m map[string]string)

ToMap slice of Indices to map of indexes with values

type TabInfoList

type TabInfoList []struct {
	TabName    string `json:"tabName"`
	FileName   string `json:"fileName"`
	FileID     int    `json:"fileId"`
	DocID      int    `json:"docId"`
	FileSize   int    `json:"fileSize"`
	Department string `json:"department"`
	CabinetID  int    `json:"cabinetId"`

TabInfoList slice of tabs

type TabInfoResponse

type TabInfoResponse struct {
	TabInfoList  TabInfoList `json:"tabInfoList"`
	HasError     bool        `json:"hasError"`
	ErrorMessage string      `json:"errorMessage"`

TabInfoResponse response of getSavedTabs

type TabRequest

type TabRequest struct {
	TabName    string `json:"tabName,"`
	FileName   string `json:"fileName,"`
	FileID     int    `json:"fileId,"`
	DocID      int    `json:"docId,"`
	FileSize   int    `json:"fileSize,"`
	Department string `json:"department,"`
	CabinetID  int    `json:"cabinetId,"`

TabRequest Request for list of tabs

type User

type User struct {
	ID       int    `json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
	LdapID   int    `json:"ldapId"`
	Email    string `json:"email"`

User login acting user