Documentation
¶
Index ¶
- Variables
- func ParsePath(path string) (basePath, lastSegment string)
- type AuthManager
- type AuthManagerOption
- type AuthResponse
- type Cache
- type Client
- type ClientOption
- type DiskUsage
- type EditFileParams
- type Events
- type File
- type FileClient
- type Folder
- type FolderOpt
- type FolderResponse
- type ListResponse
- type RequestOpt
- type Response
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoToken = errors.New("could not find access token") ErrUnexpectedType = errors.New("expected context value to be string") ErrExpiredRefreshToken = errors.New("refresh token expired") )
var ( ErrUnknownType = errors.New("unknown content type") ErrUnexpectedStatus = errors.New("unexpected status") ErrNoFolder = errors.New("no folder found") ErrNoFile = errors.New("no file found") )
var ErrAuthFailed = errors.New("auth failed")
Functions ¶
Types ¶
type AuthManager ¶
type AuthManager interface {
Authenticate(ctx context.Context, username, password, twoFactorCode string) error
RefreshToken(ctx context.Context) error
GetToken(ctx context.Context) (string, error)
ClientID() string
}
func NewAuthManager ¶
func NewAuthManager(apiURL string, opts ...AuthManagerOption) AuthManager
NewAuthManager initializes the AuthManager.
type AuthManagerOption ¶
type AuthManagerOption func(*authManager)
AuthManagerOption configures AuthManager for usage
func WithAuthClient ¶
func WithAuthClient(client *http.Client) AuthManagerOption
WithAuthClient specifies the http client to use for authentication requests
func WithAuthStore ¶
func WithAuthStore(store Store) AuthManagerOption
WithAuthStore sets the auth store for caching/storage of auth tokens
func WithClientID ¶
func WithClientID(clientID string) AuthManagerOption
type AuthResponse ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache will be a caching implementation, populated on startup and then updated via SignalR events
type Client ¶
type Client interface {
FileClient
}
func NewClient ¶
func NewClient(apiURL string, authManager AuthManager, opts ...ClientOption) Client
NewClient creates a new Hoist client with the specified URL and auth manager
type ClientOption ¶
type ClientOption func(*client)
func WithHttpClient ¶
func WithHttpClient(httpClient *http.Client) ClientOption
WithHttpClient defines the http client to use for http requests
type DiskUsage ¶
type DiskUsage struct {
Allowed int64 `json:"allowed"`
Used int64 `json:"used"`
Mailboxes int64 `json:"mailboxes"`
Appointments int64 `json:"appointmentsUsed"`
Contacts int64 `json:"contactsUsed"`
Notes int64 `json:"notesUsed"`
Tasks int64 `json:"tasksUsed"`
FileStorage int64 `json:"fileStorageUsed"`
MeetingWorkspace int64 `json:"meetingWorkspaceUsed"`
ChatFiles int64 `json:"chatFilesUsed"`
}
type EditFileParams ¶
type Events ¶
type Events struct {
// contains filtered or unexported fields
}
Events is a helper for managing SignalR events from the server
func NewEventsClient ¶
func NewEventsClient(apiUrl string, authManager AuthManager) *Events
NewEventsClient creates a new event client, with apiUrl and authManager similar to client. Note that you must call Events.Connect yourself.
func (*Events) Authenticate ¶
Authenticate will send a `connect` method with the bearer token to the server
type File ¶
type File struct {
ID string `json:"id"`
Name string `json:"fileName"`
Type string `json:"type"`
Size int64 `json:"size"`
DateAdded time.Time `json:"dateAdded"`
FolderPath string `json:"folderPath"`
}
File represents a file object on the remote server, identified by `ID`
type FileClient ¶
type FileClient interface {
DiskUsageSummary(ctx context.Context) (*DiskUsage, error)
ChunkedUpload(ctx context.Context, in io.Reader, filePath string, fileSize int64) (*File, error)
ParsePath(path string) (basePath, lastSegment string)
GetFolders(ctx context.Context) ([]Folder, error)
GetFolder(ctx context.Context, folder string, opts ...FolderOpt) (*Folder, error)
GetFiles(ctx context.Context, ids ...string) ([]File, error)
DeleteFiles(ctx context.Context, ids ...string) error
DownloadFile(ctx context.Context, id string, opts ...RequestOpt) (io.ReadCloser, error)
GetFileID(ctx context.Context, dir, fileName string) (string, error)
Find(ctx context.Context, file string) (*Folder, *File, error)
CreateFolder(ctx context.Context, folder string) (*Folder, error)
DeleteFolder(ctx context.Context, folder string) error
MoveFiles(ctx context.Context, folder string, fileIDs ...string) error
RenameFile(ctx context.Context, fileID string, name string) error
EditFile(ctx context.Context, fileID string, params EditFileParams) error
GetLink(ctx context.Context, fileID string) (string, string, error)
MoveFolder(ctx context.Context, folder, newParentFolder, newName string) error
}
type Folder ¶
type Folder struct {
Name string `json:"name"`
Path string `json:"path"`
Size int64 `json:"size"`
Version string `json:"version"`
Count int `json:"count"`
Subfolders []Folder `json:"subfolders"`
Files []File `json:"files"`
}
Folder represents a folder object on the remote server
type FolderOpt ¶
type FolderOpt func(f *folderRequest)
FolderOpt allows defining folder request options
func WithStartIndex ¶
WithStartIndex sets the start index of a folder request
type FolderResponse ¶
type FolderResponse struct {
Folder Folder `json:"folder"`
// contains filtered or unexported fields
}
type ListResponse ¶
type ListResponse struct {
Files []File `json:"files"`
}
type RequestOpt ¶
RequestOpt is a quick helper for changing request options
func WithContentType ¶
func WithContentType(contentType string) RequestOpt
WithContentType overrides specified content types
func WithHeader ¶
func WithHeader(key, value string) RequestOpt
WithHeader sets header values on the request
func WithURLParameter ¶
func WithURLParameter(key string, value any) RequestOpt
WithURLParameter replaces a URL parameter encased in {} with the value
type Response ¶
Response wraps an *http.Response and provides extra functionality
type Store ¶
type Store interface {
// Set stores an authenticated user's access and refresh tokens
Set(username string, auth AuthResponse)
// Get retrieves an authenticated user's access and refresh token
// This MUST return nil, nil if a stored auth does not exist
Get(username string) (*AuthResponse, error)
}