Documentation ¶
Index ¶
- Constants
- Variables
- func ChiperToInt(c string) int32
- func ChiperToString(i int32) string
- func DecryptAES(in io.Reader, out, hashwriter io.Writer, keyAes, buff []byte, ...) (err error)
- func EncryptAES(in io.Reader, out io.Writer, keyAes, 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 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) GetProxy() 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) 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) 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) UpdateAttribute(attribute Attribute, namespace, name, newName string) (*RestRequestResponse, error)
- func (libdm LibDM) UpdateFile(name string, id uint, namespace string, all bool, changes FileChanges) (*CountResponse, error)
- func (libdm LibDM) UpdateNamespace(name, newName string) (*StringResponse, error)
- type LoginResponse
- type Method
- type NamespaceRequest
- type OptionalRequetsParameter
- type PingRequest
- type PublishResponse
- 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) 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 StringResponse
- type StringSliceResponse
- type UpdateAttributeRequest
- type UploadRequest
- func (uploadRequest *UploadRequest) BuildRequestStruct(Type UploadType) *UploadRequestStruct
- func (uploadRequest *UploadRequest) Do(body io.Reader, payload interface{}, contentType ContentType) (*UploadResponse, error)
- func (uploadRequest *UploadRequest) Encrypted(encryptionMethod string, key []byte) *UploadRequest
- func (uploadRequest *UploadRequest) GetBuffersize() int
- func (uploadRequest *UploadRequest) GetProxy() WriterProxy
- func (uploadRequest *UploadRequest) MakePublic(publicName string) *UploadRequest
- func (uploadRequest *UploadRequest) ReplaceFile(fileID uint) *UploadRequest
- func (uploadRequest *UploadRequest) SetFileSizeCallback(cb FileSizeCallback) *UploadRequest
- 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) (*UploadResponse, error)
- type UploadRequestStruct
- type UploadResponse
- type UploadType
- 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 Endpoint = EPUser + "/login" EPRegister Endpoint = EPUser + "/register" // Files EPFile Endpoint = "/file" EPFileList Endpoint = EPFile + "s" EPFileUpdate Endpoint = EPFile + "/update" EPFileDelete Endpoint = EPFile + "/delete" EPFileGet Endpoint = EPFile + "/get" EPFilePublish Endpoint = EPFile + "/publish" // Upload EPFileUpload Endpoint = "/upload" + EPFile // Attributes EPAttribute Endpoint = "/attribute" // Tags EPAttributeTag = EPAttribute + "/tag" EPTagUpdate = EPAttributeTag + "/update" EPTagDelete = EPAttributeTag + "/delete" EPTags = EPAttributeTag + "/get" // Group EPAttributeGroup = EPAttribute + "/group" 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" // HeaderContentLength request content length HeaderContentLength string = "ContentLength" // HeaderFileID fileid header HeaderFileID string = "X-FileID" // HeaderChecksum files checksum HeaderChecksum string = "Checksum" )
const (
Boundary = "MachliJalKiRaniHaiJeevanUskaPaaniHai"
)
Boundary boundary for the part
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 = []string{
"aes",
}
EncryptionCiphers supported encryption chipers
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 EncryptAES ¶ added in v1.1.14
EncryptAES 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 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 Proxy WriterProxy // 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) GetProxy ¶ added in v1.1.14
func (fileRequest *FileDownloadRequest) GetProxy() WriterProxy
GetProxy 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 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 string `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
}
LibDM data required in all requests
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) 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) 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) (*CountResponse, error)
UpdateFile updates a file on the server
func (LibDM) UpdateNamespace ¶
func (libdm LibDM) UpdateNamespace(name, newName string) (*StringResponse, error)
UpdateNamespace update a namespace
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 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 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 }
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) 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 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 Encryption string EncryptionKey []byte Buffersize int ProxyWriter WriterProxy // 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) 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 string, 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) GetProxy ¶ added in v1.1.14
func (uploadRequest *UploadRequest) GetProxy() WriterProxy
GetProxy returns proxywriter for uploadRequest
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) ReplaceFile ¶
func (uploadRequest *UploadRequest) ReplaceFile(fileID uint) *UploadRequest
ReplaceFile replace a file instead creating a new one
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) 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) (*UploadResponse, error)
UploadURL uploads an url
type UploadRequestStruct ¶ added in v1.1.12
type UploadRequestStruct struct { UploadType UploadType `json:"type"` URL string `json:"url,omitempty"` Name string `json:"name"` Public bool `json:"pb,omitempty"` PublicName string `json:"pbname,omitempty"` Attributes FileAttributes `json:"attr,omitempty"` Encryption string `json:"e,omitempty"` ReplaceFile uint `json:"r,omitempty"` Size int64 `json:"s"` }
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