Add models for file and collection requests
This commit is contained in:
parent
2f0f417c8a
commit
1e2ad3067c
3 changed files with 86 additions and 0 deletions
13
internal/api/collection.go
Normal file
13
internal/api/collection.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package api
|
||||
|
||||
import "context"
|
||||
|
||||
func (c *Client) GetCollections(ctx context.Context, sinceTime int) ([]Collection, error) {
|
||||
var collections []Collection
|
||||
_, err := c.restClient.R().
|
||||
SetContext(ctx).
|
||||
SetQueryParam("since", string(sinceTime)).
|
||||
SetResult(&collections).
|
||||
Get("/collections")
|
||||
return collections, err
|
||||
}
|
42
internal/api/collection_type.go
Normal file
42
internal/api/collection_type.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package api
|
||||
|
||||
// Collection represents a collection
|
||||
type Collection struct {
|
||||
ID int64 `json:"id"`
|
||||
Owner CollectionUser `json:"owner"`
|
||||
EncryptedKey string `json:"encryptedKey" binding:"required"`
|
||||
KeyDecryptionNonce string `json:"keyDecryptionNonce,omitempty" binding:"required"`
|
||||
Name string `json:"name"`
|
||||
EncryptedName string `json:"encryptedName"`
|
||||
NameDecryptionNonce string `json:"nameDecryptionNonce"`
|
||||
Type string `json:"type" binding:"required"`
|
||||
Sharees []CollectionUser `json:"sharees"`
|
||||
UpdationTime int64 `json:"updationTime"`
|
||||
IsDeleted bool `json:"isDeleted,omitempty"`
|
||||
MagicMetadata *MagicMetadata `json:"magicMetadata,omitempty"`
|
||||
PublicMagicMetadata *MagicMetadata `json:"pubMagicMetadata,omitempty"`
|
||||
SharedMagicMetadata *MagicMetadata `json:"sharedMagicMetadata,omitempty"`
|
||||
}
|
||||
|
||||
// CollectionUser represents the owner of a collection
|
||||
type CollectionUser struct {
|
||||
ID int64 `json:"id"`
|
||||
Email string `json:"email"`
|
||||
// Deprecated
|
||||
Name string `json:"name"`
|
||||
Role string `json:"role"`
|
||||
}
|
||||
|
||||
type MagicMetadata struct {
|
||||
Version int `json:"version,omitempty" binding:"required"`
|
||||
Count int `json:"count,omitempty" binding:"required"`
|
||||
Data string `json:"data,omitempty" binding:"required"`
|
||||
Header string `json:"header,omitempty" binding:"required"`
|
||||
}
|
||||
|
||||
// CollectionFileItem represents a file in an AddFilesRequest and MoveFilesRequest
|
||||
type CollectionFileItem struct {
|
||||
ID int64 `json:"id" binding:"required"`
|
||||
EncryptedKey string `json:"encryptedKey" binding:"required"`
|
||||
KeyDecryptionNonce string `json:"keyDecryptionNonce" binding:"required"`
|
||||
}
|
31
internal/api/file_type.go
Normal file
31
internal/api/file_type.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package api
|
||||
|
||||
// File represents an encrypted file in the system
|
||||
type File struct {
|
||||
ID int64 `json:"id"`
|
||||
OwnerID int64 `json:"ownerID"`
|
||||
CollectionID int64 `json:"collectionID"`
|
||||
CollectionOwnerID *int64 `json:"collectionOwnerID"`
|
||||
EncryptedKey string `json:"encryptedKey"`
|
||||
KeyDecryptionNonce string `json:"keyDecryptionNonce"`
|
||||
File FileAttributes `json:"file" binding:"required"`
|
||||
Thumbnail FileAttributes `json:"thumbnail" binding:"required"`
|
||||
Metadata FileAttributes `json:"metadata" binding:"required"`
|
||||
IsDeleted bool `json:"isDeleted"`
|
||||
UpdationTime int64 `json:"updationTime"`
|
||||
MagicMetadata *MagicMetadata `json:"magicMetadata,omitempty"`
|
||||
PubicMagicMetadata *MagicMetadata `json:"pubMagicMetadata,omitempty"`
|
||||
Info *FileInfo `json:"info,omitempty"`
|
||||
}
|
||||
|
||||
// FileInfo has information about storage used by the file & it's metadata(future)
|
||||
type FileInfo struct {
|
||||
FileSize int64 `json:"fileSize,omitempty"`
|
||||
ThumbnailSize int64 `json:"thumbSize,omitempty"`
|
||||
}
|
||||
|
||||
// FileAttributes represents a file item
|
||||
type FileAttributes struct {
|
||||
EncryptedData string `json:"encryptedData,omitempty"`
|
||||
DecryptionHeader string `json:"decryptionHeader" binding:"required"`
|
||||
}
|
Loading…
Add table
Reference in a new issue