Documentation
¶
Index ¶
- Constants
- Variables
- func ChiperToInt(c string) int8
- func DecryptAES(in io.Reader, out, hashwriter *io.Writer, keyAes, buff []byte, ...) (err error)
- func DecryptAGE(in io.Reader, out, hashwriter io.Writer, key, buff []byte, ...) (err error)
- func EncryptAES(out io.Writer, in io.Reader, keyAes, buff []byte, cancel chan bool) (err error)
- func EncryptAGE(out io.Writer, in io.Reader, key, buff []byte, cancel chan bool) (err error)
- func EncryptionIValid(i int32) bool
- func GetFilesizeFromDownloadRequest(resp *http.Response) int64
- func IsValidCipher(c string) bool
- type Attribute
- type Authorization
- type AuthorizationType
- type BulkPublishResponse
- type ContentType
- type CountResponse
- type CredentialsRequest
- type Endpoint
- type ErrorResponse
- type FileAttributes
- type FileChanges
- type FileDownloadRequest
- func (fileRequest *FileDownloadRequest) DecryptWith(key []byte) *FileDownloadRequest
- func (fileRequest *FileDownloadRequest) Do() (*FileDownloadResponse, error)
- func (fileRequest *FileDownloadRequest) DownloadToFile(localFilePath string, fmode os.FileMode, appendFilename ...bool) (*FileDownloadResponse, error)
- func (fileRequest *FileDownloadRequest) GetBuffersize() int
- func (fileRequest *FileDownloadRequest) GetReaderProxy() ReaderProxy
- func (fileRequest *FileDownloadRequest) GetWriterProxy() WriterProxy
- func (fileRequest *FileDownloadRequest) IgnoreChecksum() *FileDownloadRequest
- func (fileRequest *FileDownloadRequest) NoDecrypt() *FileDownloadRequest
- type FileDownloadResponse
- type FileListRequest
- type FileListResponse
- type FileRequest
- type FileResponseItem
- type FileSizeCallback
- type FileUpdateItem
- type IDsResponse
- type Keystore
- func (store *Keystore) AddKey(fileID uint, keyPath string) error
- func (store *Keystore) Close() error
- func (store *Keystore) DeleteKey(fileID uint) (*KeystoreFile, error)
- func (store *Keystore) GetFileInfo() *os.FileInfo
- func (store *Keystore) GetFiles() ([]KeystoreFile, error)
- func (store *Keystore) GetKey(fileID uint) ([]byte, error)
- func (store *Keystore) GetKeyCount(validKeysOnly ...bool) (int, error)
- func (store *Keystore) GetKeyFile(fileID uint) (*KeystoreFile, error)
- func (store *Keystore) GetKeystoreDataFile() string
- func (store *Keystore) GetKeystoreFile(file string) string
- func (store *Keystore) HasKey(fileID uint) (bool, error)
- func (store *Keystore) Open() error
- type KeystoreFile
- type LibDM
- func (libdm LibDM) CreateAttribute(attribute Attribute, namespace, name string) (*RestRequestResponse, error)
- func (libdm LibDM) CreateNamespace(name string) (*StringResponse, error)
- func (libdm LibDM) DeleteAttribute(attribute Attribute, namespace, name string) (*RestRequestResponse, error)
- func (libdm LibDM) DeleteFile(name string, id uint, all bool, attributes FileAttributes) (*IDsResponse, error)
- func (libdm LibDM) DeleteNamespace(name string) (*StringResponse, error)
- func (libdm LibDM) GetGroups(namespace string) ([]Attribute, error)
- func (libdm LibDM) GetNamespaces() (*StringSliceResponse, error)
- func (libdm LibDM) GetTags(namespace string) ([]Attribute, error)
- func (libdm LibDM) GetUserAttributeData() (*UserAttributeDataResponse, error)
- func (libdm LibDM) ListFiles(name string, id uint, allNamespaces bool, attributes FileAttributes, ...) (*FileListResponse, error)
- func (libdm LibDM) Login(username, password string) (*LoginResponse, error)
- func (libdm LibDM) NewFileRequest(id uint, name, namespace string) *FileDownloadRequest
- func (libdm LibDM) NewFileRequestByID(fileID uint) *FileDownloadRequest
- func (libdm LibDM) NewFileRequestByName(name, namespace string) *FileDownloadRequest
- func (limdm *LibDM) NewRequest(endpoint Endpoint, payload interface{}) *Request
- func (libdm LibDM) NewUploadRequest(name string, attributes FileAttributes) *UploadRequest
- func (libdm LibDM) Ping() (*StringResponse, error)
- func (libdm LibDM) PublishFile(name string, id uint, publicName string, all bool, attributes FileAttributes) (interface{}, error)
- func (libdm LibDM) Register(username, password string) (*RestRequestResponse, error)
- func (libdm LibDM) Request(ep Endpoint, payload, response interface{}, authorized bool) (*RestRequestResponse, error)
- func (libdm LibDM) Stats(namespace string) (*StatsResponse, error)
- func (libdm LibDM) UpdateAttribute(attribute Attribute, namespace, name, newName string) (*RestRequestResponse, error)
- func (libdm LibDM) UpdateFile(name string, id uint, namespace string, all bool, changes FileChanges) (*IDsResponse, error)
- func (libdm LibDM) UpdateNamespace(name, newName string) (*StringResponse, error)
- func (libdm *LibDM) WithMaxConnections(maxConnecetions int) *LibDM
- type LoginResponse
- type Method
- type NamespaceRequest
- type Namespaceinfo
- type OptionalRequetsParameter
- type PingRequest
- type PublishResponse
- type ReaderProxy
- type Request
- func (request *Request) BuildClient() *http.Client
- func (request Request) Do(retVar interface{}) (*RestRequestResponse, error)
- func (request *Request) DoHTTPRequest() (*http.Response, error)
- func (request *Request) WithAuth(a Authorization) *Request
- func (request *Request) WithAuthFromConfig() *Request
- func (request *Request) WithBenchCallback(c chan time.Time) *Request
- func (request *Request) WithCompression(compression bool) *Request
- func (request *Request) WithConnectionLimit(maxConnections int) *Request
- func (request *Request) WithContentType(ct ContentType) *Request
- func (request *Request) WithHeader(name string, value string) *Request
- func (request *Request) WithMethod(m Method) *Request
- func (request *Request) WithRequestType(rType RequestType) *Request
- type RequestConfig
- type RequestType
- type ResponseErr
- type ResponseStatus
- type RestRequestResponse
- type SortByName
- type StatsRequestStruct
- type StatsResponse
- type StringResponse
- type StringSliceResponse
- type UpdateAttributeRequest
- type UploadRequest
- func (uploadRequest *UploadRequest) BuildRequestStruct(Type UploadType) *UploadRequestStruct
- func (uploadRequest *UploadRequest) Compress() *UploadRequest
- func (uploadRequest *UploadRequest) Do(body io.Reader, payload interface{}, contentType ContentType) (*UploadResponse, error)
- func (uploadRequest *UploadRequest) Encrypted(encryptionMethod int8, key []byte) *UploadRequest
- func (uploadRequest *UploadRequest) GetBuffersize() int
- func (uploadRequest *UploadRequest) GetReaderProxy() ReaderProxy
- func (uploadRequest *UploadRequest) GetWriterProxy() WriterProxy
- func (uploadRequest *UploadRequest) HandleAll() *UploadRequest
- func (uploadRequest *UploadRequest) MakePublic(publicName string) *UploadRequest
- func (uploadRequest *UploadRequest) ReplaceFileByID(fileID uint) *UploadRequest
- func (uploadRequest *UploadRequest) ReplaceFileWithSameName() *UploadRequest
- func (uploadRequest *UploadRequest) SetFileSizeCallback(cb FileSizeCallback) *UploadRequest
- func (uploadRequest *UploadRequest) UploadArchivedFolder(uri string, uploadDone chan string, cancel chan bool) (*UploadResponse, error)
- func (uploadRequest *UploadRequest) UploadBodyBuilder(reader io.Reader, inpSize int64, doneChan chan string, cancel chan bool) (r *io.PipeReader, contentType string, size int64)
- func (uploadRequest *UploadRequest) UploadFile(f *os.File, uploadDone chan string, cancel chan bool) (*UploadResponse, error)
- func (uploadRequest *UploadRequest) UploadFromReader(r io.Reader, size int64, uploadDone chan string, cancel chan bool) (*UploadResponse, error)
- func (uploadRequest UploadRequest) UploadURL(u *url.URL, uploadDone chan string, cancel chan bool) (*UploadResponse, error)
- type UploadRequestStruct
- type UploadResponse
- type UploadType
- type UserAttributeDataResponse
- type UserAttributesRequest
- type WriterProxy
Constants ¶
const ( // KeystoreDBFile the sqlite DB containing the file-key associations KeystoreDBFile = ".keys.db" // KeyringService the servicename for the keyring KeyringService = "DataManagerCLI-keystore" )
const ( // Ping EPPing Endpoint = "/ping" // User EPUser Endpoint = "/user" EPLogin = EPUser + "/login" EPRegister = EPUser + "/register" EPUserStats = EPUser + "/stats" // Files EPFile Endpoint = "/file" EPFileList = EPFile + "s" EPFileUpdate = EPFile + "/update" EPFileDelete = EPFile + "/delete" EPFileGet = "/download/file" EPFilePublish = EPFile + "/publish" // Upload EPFileUpload Endpoint = "/upload" + EPFile // Attribute EPAttribute Endpoint = "/attribute" EPAttributes Endpoint = "/attributes" // Tags EPAttributeTag = EPAttribute + "/tag" EPTagCreate = EPAttributeTag + "/create" EPTagUpdate = EPAttributeTag + "/update" EPTagDelete = EPAttributeTag + "/delete" EPTags = EPAttributeTag + "/get" // Group EPAttributeGroup = EPAttribute + "/group" EPGroupCreate = EPAttributeGroup + "/create" EPGroupUpdate = EPAttributeGroup + "/update" EPGroupDelete = EPAttributeGroup + "/delete" EPGroups = EPAttributeGroup + "/get" // Namespace EPNamespace Endpoint = "/namespace" EPNamespaceCreate = EPNamespace + "/create" EPNamespaceUpdate = EPNamespace + "/update" EPNamespaceDelete = EPNamespace + "/delete" EPNamespaceList = EPNamespace + "s" )
Remote endpoints
const ( // HeaderStatus headername for status in response HeaderStatus string = "X-Response-Status" // HeaderStatusMessage headername for status in response HeaderStatusMessage string = "X-Response-Message" // HeaderContentType contenttype of response HeaderContentType string = "Content-Type" // HeaderFileName filename header HeaderFileName string = "X-Filename" // HeaderRequest request content HeaderRequest string = "Request" // HeaderEncryption encryption header HeaderEncryption string = "X-Encryption" // HeaderFileType filetype header HeaderFileType string = "X-FileType" // HeaderContentLength request content length HeaderContentLength string = "ContentLength" // HeaderFileID fileid header HeaderFileID string = "X-FileID" // HeaderChecksum files checksum HeaderChecksum string = "Checksum" )
const (
// DefaultBuffersize The default buffersize for filestreams
DefaultBuffersize = 10 * 1024
)
Variables ¶
var ( // ErrInvalidResponseHeaders error on missing or malformed response headers ErrInvalidResponseHeaders = errors.New("Invalid response headers") // ErrResponseError response returned an error ErrResponseError = errors.New("response returned an error") // ErrResponseFilenameInvalid if server returns no filename ErrResponseFilenameInvalid = errors.New("invalid filename received") )
var ( // ErrChecksumNotMatch error if the checksum of the downloaded // file doesn't match with the checksum of the remote file ErrChecksumNotMatch = errors.New("generated checksum not match") // ErrCipherNotSupported if cipher is not supported ErrCipherNotSupported = errors.New("cipher not supported") // ErrFileEncrypted error if no key was given and nodecrypt is false ErrFileEncrypted = errors.New("file is encrypted but no key was given") )
var ( errors.New("keyring key is unavailable") // ErrKeystoreNoDir error if keystore is no directory ErrKeystoreNoDir = errors.New("Keystore is not a directory") // ErrKeyAlreadyexists error if keystore already contains an entry for the given fileid ErrKeyAlreadyexists = errors.New("Keystore already contains given key") )ErrKeyUnavailable =
Errors
var EncryptionCiphers = map[int8]string{
1: "aes",
2: "age",
}
EncryptionCiphers supported encryption method
var ( // ErrCancelled if something was cancelled ErrCancelled = errors.New("cancelled") )
var ( // ErrUnsupportedScheme error if url has an unsupported scheme ErrUnsupportedScheme = errors.New("Unsupported scheme") )
Functions ¶
func DecryptAES ¶ added in v1.1.14
func DecryptAES(in io.Reader, out, hashwriter *io.Writer, keyAes, buff []byte, cancelChan chan bool) (err error)
DecryptAES decrypt stuff
func DecryptAGE ¶ added in v1.3.9
func DecryptAGE(in io.Reader, out, hashwriter io.Writer, key, buff []byte, cancelChan chan bool) (err error)
DecryptAGE decrypt stuff
func EncryptAES ¶ added in v1.1.14
EncryptAES encrypts input stream and writes it to out
func EncryptAGE ¶ added in v1.3.9
EncryptAGE encrypts input stream and writes it to out
func EncryptionIValid ¶
EncryptionIValid return true if encryption i is valid
func GetFilesizeFromDownloadRequest ¶ added in v1.1.10
GetFilesizeFromDownloadRequest returns the filesize from a file from the response headers
func IsValidCipher ¶
IsValidCipher return true if given cipher is valid
Types ¶
type Authorization ¶
type Authorization struct { Type AuthorizationType Palyoad string }
Authorization the authorization params for a server request
type AuthorizationType ¶
type AuthorizationType string
AuthorizationType authorization type
const ( Bearer AuthorizationType = "Bearer" Basic AuthorizationType = "Basic" )
Authorizanion types
type BulkPublishResponse ¶
type BulkPublishResponse struct {
Files []UploadResponse `json:"files"`
}
BulkPublishResponse response for publishing a file
type ContentType ¶
type ContentType string
ContentType contenttype header of request
const (
JSONContentType ContentType = "application/json"
)
Content types
type CountResponse ¶
type CountResponse struct {
Count uint32 `json:"count"`
}
CountResponse response containing a count of changed items
type CredentialsRequest ¶
type CredentialsRequest struct { MachineID string `json:"mid,omitempty"` Username string `json:"username"` Password string `json:"pass"` }
CredentialsRequest request containing credentials
type ErrorResponse ¶ added in v1.4.2
type FileAttributes ¶
type FileAttributes struct { Tags []string `json:"tags,omitempty"` Groups []string `json:"groups,omitempty"` Namespace string `json:"ns"` }
FileAttributes attributes for a file
type FileChanges ¶
type FileChanges struct { NewName string NewNamespace string AddTags, AddGroups []string RemoveTags, RemoveGroups []string SetPublic, SetPrivate bool }
FileChanges file changes for updating a file
type FileDownloadRequest ¶ added in v1.1.14
type FileDownloadRequest struct { LibDM ID uint Name string Namespace string Decrypt bool Key []byte Buffersize int CancelDownload chan bool WriterProxy WriterProxy ReaderProxy ReaderProxy // contains filtered or unexported fields }
FileDownloadRequest request for downloading a file
func (*FileDownloadRequest) DecryptWith ¶ added in v1.1.14
func (fileRequest *FileDownloadRequest) DecryptWith(key []byte) *FileDownloadRequest
DecryptWith sets key to decrypt file with. If key is nil, no decryption will be performed
func (*FileDownloadRequest) Do ¶ added in v1.1.14
func (fileRequest *FileDownloadRequest) Do() (*FileDownloadResponse, error)
Do requests a filedownload and returns the response The response body must be closed
func (*FileDownloadRequest) DownloadToFile ¶ added in v1.1.14
func (fileRequest *FileDownloadRequest) DownloadToFile(localFilePath string, fmode os.FileMode, appendFilename ...bool) (*FileDownloadResponse, error)
DownloadToFile downloads and saves a file to the given localFilePath. If the file exists, it will be overwritten
func (*FileDownloadRequest) GetBuffersize ¶ added in v1.1.14
func (fileRequest *FileDownloadRequest) GetBuffersize() int
GetBuffersize gets the buffersize
func (*FileDownloadRequest) GetReaderProxy ¶ added in v1.3.0
func (fileRequest *FileDownloadRequest) GetReaderProxy() ReaderProxy
GetReaderProxy of request
func (*FileDownloadRequest) GetWriterProxy ¶ added in v1.3.0
func (fileRequest *FileDownloadRequest) GetWriterProxy() WriterProxy
GetWriterProxy returns proxywriter of request
func (*FileDownloadRequest) IgnoreChecksum ¶ added in v1.1.14
func (fileRequest *FileDownloadRequest) IgnoreChecksum() *FileDownloadRequest
IgnoreChecksum ignores the checksum
func (*FileDownloadRequest) NoDecrypt ¶ added in v1.1.14
func (fileRequest *FileDownloadRequest) NoDecrypt() *FileDownloadRequest
NoDecrypt don't decrypt file while downloading
type FileDownloadResponse ¶ added in v1.1.14
type FileDownloadResponse struct { Response *http.Response ServerFileName string LocalChecksum string ServerChecksum string Size int64 Encryption string FileID uint Extract bool FileType string DownloadRequest *FileDownloadRequest }
FileDownloadResponse response for downloading a file
func (*FileDownloadResponse) SaveTo ¶ added in v1.1.14
func (fileresponse *FileDownloadResponse) SaveTo(w io.Writer, cancelChan chan bool) error
SaveTo download a file and write it to the writer while
func (*FileDownloadResponse) VerifyChecksum ¶ added in v1.1.14
func (fileresponse *FileDownloadResponse) VerifyChecksum() bool
VerifyChecksum Return if checksums are equal and not empty
func (*FileDownloadResponse) WriteToFile ¶ added in v1.1.14
func (fileresponse *FileDownloadResponse) WriteToFile(localFilePath string, fmode os.FileMode, cancelChan chan bool) error
WriteToFile saves a file to the given localFilePath containing the body of the given response
type FileListRequest ¶
type FileListRequest struct { FileID uint `json:"fid"` Name string `json:"name"` AllNamespaces bool `json:"allns"` OptionalParams OptionalRequetsParameter `json:"opt"` Order string `json:"order,omitempty"` Attributes FileAttributes `json:"attributes"` }
FileListRequest contains file info (and a file)
type FileListResponse ¶
type FileListResponse struct {
Files []FileResponseItem
}
FileListResponse response for listing files
type FileRequest ¶
type FileRequest struct { FileID uint `json:"fid"` Name string `json:"name,omitempty"` PublicName string `json:"pubname,omitempty"` Updates FileUpdateItem `json:"updates,omitempty"` All bool `json:"all"` Attributes FileAttributes `json:"attributes"` }
FileRequest contains data to update a file
type FileResponseItem ¶
type FileResponseItem struct { ID uint `json:"id"` Size int64 `json:"size"` CreationDate time.Time `json:"creation"` Name string `json:"name"` IsPublic bool `json:"isPub"` PublicName string `json:"pubname"` Attributes FileAttributes `json:"attrib"` Encryption int8 `json:"e"` Checksum string `json:"checksum"` }
FileResponseItem file item for file response
type FileSizeCallback ¶ added in v1.1.14
type FileSizeCallback func(int64)
FileSizeCallback gets called if the filesize is known
type FileUpdateItem ¶
type FileUpdateItem struct { IsPublic string `json:"ispublic,omitempty"` NewName string `json:"name,omitempty"` NewNamespace string `json:"namespace,omitempty"` RemoveTags []string `json:"rem_tags,omitempty"` RemoveGroups []string `json:"rem_groups,omitempty"` AddTags []string `json:"add_tags,omitempty"` AddGroups []string `json:"add_groups,omitempty"` }
FileUpdateItem lists changes to a file
type IDsResponse ¶ added in v1.1.2
type IDsResponse struct {
IDs []uint `json:"ids"`
}
IDsResponse response containing a list of ids
type Keystore ¶ added in v1.1.1
Keystore a place to store keys
func NewKeystore ¶ added in v1.1.1
NewKeystore create a new keystore
func (*Keystore) DeleteKey ¶ added in v1.1.1
func (store *Keystore) DeleteKey(fileID uint) (*KeystoreFile, error)
DeleteKey Inserts key into keystore
func (*Keystore) GetFileInfo ¶ added in v1.1.7
GetFileInfo returns fileinfo for the keystore
func (*Keystore) GetFiles ¶ added in v1.1.7
func (store *Keystore) GetFiles() ([]KeystoreFile, error)
GetFiles returns a slice containing all keystore Files
func (*Keystore) GetKey ¶ added in v1.1.1
GetKey returns the key assigned to the fileID. If FileID or key was not found, error is not nil
func (*Keystore) GetKeyCount ¶ added in v1.1.13
GetKeyCount reutrns count of keys
func (*Keystore) GetKeyFile ¶ added in v1.1.1
func (store *Keystore) GetKeyFile(fileID uint) (*KeystoreFile, error)
GetKeyFile returns a keyfile with assigned to the fileID
func (*Keystore) GetKeystoreDataFile ¶ added in v1.1.1
GetKeystoreDataFile returns the keystore db filepath
func (*Keystore) GetKeystoreFile ¶ added in v1.1.1
GetKeystoreFile returns the full path of file
type KeystoreFile ¶ added in v1.1.1
KeystoreFile the keystore row
type LibDM ¶
type LibDM struct { Config *RequestConfig MaxConnectionsPerHost int }
LibDM data required in all requests
func (LibDM) CreateAttribute ¶ added in v1.2.4
func (libdm LibDM) CreateAttribute(attribute Attribute, namespace, name string) (*RestRequestResponse, error)
CreateAttribute update an attribute
func (LibDM) CreateNamespace ¶
func (libdm LibDM) CreateNamespace(name string) (*StringResponse, error)
CreateNamespace creates a namespace
func (LibDM) DeleteAttribute ¶
func (libdm LibDM) DeleteAttribute(attribute Attribute, namespace, name string) (*RestRequestResponse, error)
DeleteAttribute update an attribute
func (LibDM) DeleteFile ¶
func (libdm LibDM) DeleteFile(name string, id uint, all bool, attributes FileAttributes) (*IDsResponse, error)
DeleteFile deletes the desired file(s)
func (LibDM) DeleteNamespace ¶
func (libdm LibDM) DeleteNamespace(name string) (*StringResponse, error)
DeleteNamespace update a namespace
func (LibDM) GetGroups ¶ added in v1.0.7
GetGroups returns an array of attributes containing groups available in given namespace
func (LibDM) GetNamespaces ¶
func (libdm LibDM) GetNamespaces() (*StringSliceResponse, error)
GetNamespaces get all namespaces
func (LibDM) GetTags ¶ added in v1.0.7
GetTags returns an array of attributes containing tags available in given namespace
func (LibDM) GetUserAttributeData ¶ added in v1.2.2
func (libdm LibDM) GetUserAttributeData() (*UserAttributeDataResponse, error)
GetUserAttributeData get attribute data for an user
func (LibDM) ListFiles ¶
func (libdm LibDM) ListFiles(name string, id uint, allNamespaces bool, attributes FileAttributes, verbose uint8) (*FileListResponse, error)
ListFiles lists the files corresponding to the args
func (LibDM) Login ¶
func (libdm LibDM) Login(username, password string) (*LoginResponse, error)
Login login into the server
func (LibDM) NewFileRequest ¶ added in v1.1.14
func (libdm LibDM) NewFileRequest(id uint, name, namespace string) *FileDownloadRequest
NewFileRequest create a new filerequest
func (LibDM) NewFileRequestByID ¶ added in v1.1.14
func (libdm LibDM) NewFileRequestByID(fileID uint) *FileDownloadRequest
NewFileRequestByID create a new filerequest by file id
func (LibDM) NewFileRequestByName ¶ added in v1.1.14
func (libdm LibDM) NewFileRequestByName(name, namespace string) *FileDownloadRequest
NewFileRequestByName create a new filerequest by name
func (*LibDM) NewRequest ¶ added in v1.1.13
NewRequest creates a new post request
func (LibDM) NewUploadRequest ¶ added in v1.1.12
func (libdm LibDM) NewUploadRequest(name string, attributes FileAttributes) *UploadRequest
NewUploadRequest create a new uploadrequest
func (LibDM) Ping ¶ added in v1.1.13
func (libdm LibDM) Ping() (*StringResponse, error)
Ping pings a server the REST way to ensure it is reachable
func (LibDM) PublishFile ¶
func (libdm LibDM) PublishFile(name string, id uint, publicName string, all bool, attributes FileAttributes) (interface{}, error)
PublishFile publishs a file. If "all" is true, the response object is BulkPublishResponse. Else it is PublishResponse
func (LibDM) Register ¶
func (libdm LibDM) Register(username, password string) (*RestRequestResponse, error)
Register create a new account. Return true on success
func (LibDM) Request ¶
func (libdm LibDM) Request(ep Endpoint, payload, response interface{}, authorized bool) (*RestRequestResponse, error)
Request do a request using libdm
func (LibDM) Stats ¶ added in v1.3.7
func (libdm LibDM) Stats(namespace string) (*StatsResponse, error)
Stats for user
func (LibDM) UpdateAttribute ¶
func (libdm LibDM) UpdateAttribute(attribute Attribute, namespace, name, newName string) (*RestRequestResponse, error)
UpdateAttribute update an attribute
func (LibDM) UpdateFile ¶
func (libdm LibDM) UpdateFile(name string, id uint, namespace string, all bool, changes FileChanges) (*IDsResponse, error)
UpdateFile updates a file on the server
func (LibDM) UpdateNamespace ¶
func (libdm LibDM) UpdateNamespace(name, newName string) (*StringResponse, error)
UpdateNamespace update a namespace
func (*LibDM) WithMaxConnections ¶ added in v1.3.0
WithMaxConnections per host
type LoginResponse ¶
LoginResponse response for login
type NamespaceRequest ¶
type NamespaceRequest struct { Namespace string `json:"ns"` NewName string `json:"newName,omitempty"` }
NamespaceRequest namespace action request
type Namespaceinfo ¶ added in v1.2.2
Namespaceinfo info for namespace
type OptionalRequetsParameter ¶
type OptionalRequetsParameter struct {
Verbose uint8 `json:"verb"`
}
OptionalRequetsParameter optional request parameter
type PublishResponse ¶
type PublishResponse struct {
PublicFilename string `json:"pubName"`
}
PublishResponse response for publishing a file
type ReaderProxy ¶ added in v1.3.0
ReaderProxy proxy writing
var NoProxyReader ReaderProxy = func(r io.Reader) io.Reader {
return r
}
NoProxyReader use to fill proxyWriter arg in UpdloadFile
type Request ¶
type Request struct { RequestType RequestType Endpoint Endpoint Payload interface{} Config *RequestConfig Method Method ContentType ContentType Authorization *Authorization Headers map[string]string BenchChan chan time.Time Compressed bool MaxConnectionsPerHost int }
Request a rest server request
func (*Request) BuildClient ¶
BuildClient return client
func (Request) Do ¶
func (request Request) Do(retVar interface{}) (*RestRequestResponse, error)
Do a better request method
func (*Request) DoHTTPRequest ¶
DoHTTPRequest do plain http request
func (*Request) WithAuth ¶
func (request *Request) WithAuth(a Authorization) *Request
WithAuth with authorization
func (*Request) WithAuthFromConfig ¶
WithAuthFromConfig with authorization
func (*Request) WithBenchCallback ¶
WithBenchCallback with bench
func (*Request) WithCompression ¶ added in v1.4.2
WithCompression use a different method
func (*Request) WithConnectionLimit ¶ added in v1.3.0
WithConnectionLimit set limit of max connectionts per host
func (*Request) WithContentType ¶
func (request *Request) WithContentType(ct ContentType) *Request
WithContentType with contenttype
func (*Request) WithHeader ¶
WithHeader add header to request
func (*Request) WithMethod ¶
WithMethod use a different method
func (*Request) WithRequestType ¶
func (request *Request) WithRequestType(rType RequestType) *Request
WithRequestType use different request type
type RequestConfig ¶
type RequestConfig struct { IgnoreCert bool URL string MachineID string Username string SessionToken string }
RequestConfig configurations for requests
func (RequestConfig) GetBearerAuth ¶
func (rc RequestConfig) GetBearerAuth() Authorization
GetBearerAuth returns bearer authorization from config
type RequestType ¶
type RequestType uint8
RequestType type of request
const ( JSONRequestType RequestType = iota RawRequestType )
Request types
type ResponseErr ¶
type ResponseErr struct { Response *RestRequestResponse Err error }
ResponseErr response error
func NewErrorFromResponse ¶
func NewErrorFromResponse(r *RestRequestResponse, err ...error) *ResponseErr
NewErrorFromResponse return error from response
func (*ResponseErr) Error ¶
func (reserr *ResponseErr) Error() string
type ResponseStatus ¶
type ResponseStatus uint8
ResponseStatus the status of response
const ( // ResponseError if there was an error ResponseError ResponseStatus = 0 // ResponseSuccess if the response is successful ResponseSuccess ResponseStatus = 1 )
type RestRequestResponse ¶
type RestRequestResponse struct { HTTPCode int Status ResponseStatus Message string Headers *http.Header }
RestRequestResponse the response of a rest call
type SortByName ¶ added in v1.2.3
type SortByName []Namespaceinfo
SortByName sorts NamespaceInfo by name
func (SortByName) Len ¶ added in v1.2.3
func (a SortByName) Len() int
func (SortByName) Less ¶ added in v1.2.3
func (a SortByName) Less(i, j int) bool
func (SortByName) Swap ¶ added in v1.2.3
func (a SortByName) Swap(i, j int)
type StatsRequestStruct ¶ added in v1.3.7
type StatsRequestStruct struct {
Namespace string `json:"ns,omitempty"`
}
StatsRequestStruct informations about a stat-request
type StatsResponse ¶ added in v1.3.7
type StatsResponse struct { TrafficUsed int64 // Files FilesUploaded int64 DeletedFiles int64 FileCount int64 TotalFileSize int64 // Namespace NamespaceCount int64 GroupCount int64 TagCount int64 }
StatsResponse for user stats request
type StringResponse ¶
type StringResponse struct {
String string `json:"content"`
}
StringResponse response containing only one string
type StringSliceResponse ¶
type StringSliceResponse struct {
Slice []string `json:"slice"`
}
StringSliceResponse response containing only one string slice
type UpdateAttributeRequest ¶
type UpdateAttributeRequest struct { Name string `json:"name"` NewName string `json:"newname"` Namespace string `json:"namespace"` }
UpdateAttributeRequest contains data to update a tag
type UploadRequest ¶
type UploadRequest struct { LibDM Name string Publicname string Public bool Attribute FileAttributes ReplaceFileID uint ReplaceEqualName bool All bool Encryption int8 EncryptionKey []byte Buffersize int ProxyWriter WriterProxy ProxyReader ReaderProxy Archive bool Compressed bool // contains filtered or unexported fields }
UploadRequest a uploadrequest
func (*UploadRequest) BuildRequestStruct ¶ added in v1.1.12
func (uploadRequest *UploadRequest) BuildRequestStruct(Type UploadType) *UploadRequestStruct
BuildRequestStruct create a uploadRequset struct using Type
func (*UploadRequest) Compress ¶ added in v1.2.9
func (uploadRequest *UploadRequest) Compress() *UploadRequest
Compress the uploaded file
func (*UploadRequest) Do ¶ added in v1.1.12
func (uploadRequest *UploadRequest) Do(body io.Reader, payload interface{}, contentType ContentType) (*UploadResponse, error)
Do does the final upload http request and uploads the src
func (*UploadRequest) Encrypted ¶ added in v1.1.12
func (uploadRequest *UploadRequest) Encrypted(encryptionMethod int8, key []byte) *UploadRequest
Encrypted Upload a file encrypted
func (*UploadRequest) GetBuffersize ¶ added in v1.1.14
func (uploadRequest *UploadRequest) GetBuffersize() int
GetBuffersize returns the buffersize
func (*UploadRequest) GetReaderProxy ¶ added in v1.3.0
func (uploadRequest *UploadRequest) GetReaderProxy() ReaderProxy
GetReaderProxy returns proxyReader for uploadRequest
func (*UploadRequest) GetWriterProxy ¶ added in v1.3.0
func (uploadRequest *UploadRequest) GetWriterProxy() WriterProxy
GetWriterProxy returns proxywriter for uploadRequest
func (*UploadRequest) HandleAll ¶ added in v1.3.8
func (uploadRequest *UploadRequest) HandleAll() *UploadRequest
HandleAll applies action to all files
func (*UploadRequest) MakePublic ¶ added in v1.1.12
func (uploadRequest *UploadRequest) MakePublic(publicName string) *UploadRequest
MakePublic upload and publish a file. If publciName is empty a random public name will be created serverside
func (*UploadRequest) ReplaceFileByID ¶ added in v1.3.8
func (uploadRequest *UploadRequest) ReplaceFileByID(fileID uint) *UploadRequest
ReplaceFileByID replace a file instead creating a new one
func (*UploadRequest) ReplaceFileWithSameName ¶ added in v1.3.8
func (uploadRequest *UploadRequest) ReplaceFileWithSameName() *UploadRequest
ReplaceFileWithSameName replace files with same name
func (*UploadRequest) SetFileSizeCallback ¶ added in v1.1.14
func (uploadRequest *UploadRequest) SetFileSizeCallback(cb FileSizeCallback) *UploadRequest
SetFileSizeCallback sets the callback if the filesize is known
func (*UploadRequest) UploadArchivedFolder ¶ added in v1.2.9
func (uploadRequest *UploadRequest) UploadArchivedFolder(uri string, uploadDone chan string, cancel chan bool) (*UploadResponse, error)
UploadArchivedFolder uploads the given folder to the server
func (*UploadRequest) UploadBodyBuilder ¶ added in v1.1.17
func (uploadRequest *UploadRequest) UploadBodyBuilder(reader io.Reader, inpSize int64, doneChan chan string, cancel chan bool) (r *io.PipeReader, contentType string, size int64)
UploadBodyBuilder build the body for the upload file request
func (*UploadRequest) UploadFile ¶ added in v1.1.12
func (uploadRequest *UploadRequest) UploadFile(f *os.File, uploadDone chan string, cancel chan bool) (*UploadResponse, error)
UploadFile uploads the given file to the server
func (*UploadRequest) UploadFromReader ¶ added in v1.1.12
func (uploadRequest *UploadRequest) UploadFromReader(r io.Reader, size int64, uploadDone chan string, cancel chan bool) (*UploadResponse, error)
UploadFromReader upload a file using r as data source
func (UploadRequest) UploadURL ¶ added in v1.1.12
func (uploadRequest UploadRequest) UploadURL(u *url.URL, uploadDone chan string, cancel chan bool) (*UploadResponse, error)
UploadURL make a get request and forward the responsebody to a datavault upload
type UploadRequestStruct ¶ added in v1.1.12
type UploadRequestStruct struct { // Required fields UploadType UploadType `json:"type"` Name string `json:"name"` // Optional fields URL string `json:"url,omitempty"` Public bool `json:"pb,omitempty"` PublicName string `json:"pbname,omitempty"` Attributes FileAttributes `json:"attr,omitempty"` Encryption int8 `json:"e,omitempty"` Compressed bool `json:"compr,omitempty"` Archived bool `json:"arved,omitempty"` ReplaceFileByID uint `json:"r,omitempty"` ReplaceEqualNames bool `json:"ren"` All bool `json:"a"` }
UploadRequestStruct contains file info (and a file)
type UploadResponse ¶
type UploadResponse struct { FileID uint `json:"fileID"` Filename string `json:"filename"` PublicFilename string `json:"publicFilename,omitempty"` Checksum string `json:"checksum"` FileSize int64 `json:"size"` Namespace string `json:"ns"` }
UploadResponse response for uploading file
type UploadType ¶
type UploadType uint8
UploadType type of upload
const ( FileUploadType UploadType = iota URLUploadType )
Available upload types
type UserAttributeDataResponse ¶ added in v1.2.2
type UserAttributeDataResponse struct {
Namespace []Namespaceinfo `json:"nsData"`
}
UserAttributeDataResponse response for userattribute data
type UserAttributesRequest ¶ added in v1.2.4
type UserAttributesRequest struct {
Mode uint `json:"m"`
}
UserAttributesRequest request for getting namespaces and groups