Documentation
¶
Index ¶
- Constants
- Variables
- func IsValidOTP(otp string) bool
- func UploadPresigned(ctx context.Context, url string, path string, callback ProgressCallback) (*http.Response, error)
- func VerifyEmail(ctx context.Context, serverURL string, email string) error
- type AuthClaims
- type AuthTokenResponse
- type AuthTokenType
- type BlobAPI
- func (b *BlobAPI) Delete(ctx context.Context, params *DeleteParams) (*DeleteResponse, error)
- func (b *BlobAPI) DownloadPresigned(ctx context.Context, params *PresignedParams) (*PresignedResponse, error)
- func (b *BlobAPI) Upload(ctx context.Context, params *UploadParams) (*UploadResponse, error)
- func (b *BlobAPI) UploadPresigned(ctx context.Context, params *PresignedParams) (*PresignedResponse, error)
- type BlobError
- type BlobInfo
- type BlobUrl
- type DatasiteAPI
- type DatasiteViewParams
- type DatasiteViewResponse
- type DeleteParams
- type DeleteResponse
- type DownloadFileParams
- type DownloadFileResponse
- type DownloadJob
- type DownloadResult
- type Downloader
- func (d *Downloader) DownloadAll(ctx context.Context, files []*DownloadJob) <-chan *DownloadResult
- func (d *Downloader) DownloadAllC(ctx context.Context, files <-chan *DownloadJob) <-chan *DownloadResult
- func (d *Downloader) DownloadFile(ctx context.Context, url string, name string) (string, error)
- func (d *Downloader) Stop() error
- type EventMessage
- type EventsAPI
- type PresignedParams
- type PresignedResponse
- type ProgressCallback
- type RefreshTokenRequest
- type SyftSDK
- type SyftSDKConfig
- type SyftSDKError
- type UploadParams
- type UploadResponse
- type VerifyEmailCodeRequest
- type VerifyEmailRequest
Constants ¶
const ( AutoDetectWorkers = 0 DefaultWorkers = 8 )
const ( RetryInterval = 5 * time.Second TokenRefreshInterval = 24 * time.Hour )
const ( HeaderUserAgent = "User-Agent" HeaderSyftVersion = "X-Syft-Version" HeaderSyftUser = "X-Syft-User" HeaderSyftDeviceId = "X-Syft-Device-Id" )
const (
DefaultBaseURL = "https://syftbox.net"
)
Variables ¶
var ( // ErrEventsNotConnected is returned when trying to use events without an active connection ErrEventsNotConnected = errors.New("sdk: events: not connected") // ErrEventsMessageQueueFull is returned when the message queue is full ErrEventsMessageQueueFull = errors.New("sdk: events: message queue full") )
var ( ErrNoRefreshToken = errors.New("sdk: refresh token missing") ErrNoServerURL = errors.New("sdk: server url missing") ErrInvalidEmail = errors.New("sdk: invalid email") )
sdk common
var (
ErrInvalidOTP = errors.New("sdk: invalid otp")
)
auth
var (
ErrNoPermissions = errors.New("no permissions")
)
blob
Functions ¶
func IsValidOTP ¶
func UploadPresigned ¶
func UploadPresigned(ctx context.Context, url string, path string, callback ProgressCallback) (*http.Response, error)
Upload a file to a presigned url
Types ¶
type AuthClaims ¶
type AuthClaims struct {
Type AuthTokenType `json:"type"`
jwt.RegisteredClaims
}
type AuthTokenResponse ¶
type AuthTokenResponse struct {
AccessToken string `json:"accessToken"`
RefreshToken string `json:"refreshToken"`
}
func RefreshAuthTokens ¶
func VerifyEmailCode ¶
func VerifyEmailCode(ctx context.Context, serverURL string, codeReq *VerifyEmailCodeRequest) (*AuthTokenResponse, error)
type AuthTokenType ¶
type AuthTokenType string
const ( AccessToken AuthTokenType = "access" RefreshToken AuthTokenType = "refresh" )
type BlobAPI ¶
type BlobAPI struct {
// contains filtered or unexported fields
}
func (*BlobAPI) Delete ¶
func (b *BlobAPI) Delete(ctx context.Context, params *DeleteParams) (*DeleteResponse, error)
Delete deletes multiple blobs
func (*BlobAPI) DownloadPresigned ¶
func (b *BlobAPI) DownloadPresigned(ctx context.Context, params *PresignedParams) (*PresignedResponse, error)
DownloadPresigned gets presigned URLs for downloading multiple blobs
func (*BlobAPI) Upload ¶
func (b *BlobAPI) Upload(ctx context.Context, params *UploadParams) (*UploadResponse, error)
Upload uploads a file to the blob storage
func (*BlobAPI) UploadPresigned ¶
func (b *BlobAPI) UploadPresigned(ctx context.Context, params *PresignedParams) (*PresignedResponse, error)
UploadPresigned gets presigned URLs for uploading multiple blobs
type BlobInfo ¶
type BlobInfo struct {
Key string `json:"key"`
ETag string `json:"etag"`
Size int `json:"size"`
LastModified time.Time `json:"lastModified"`
}
BlobInfo represents information about a blob
type DatasiteAPI ¶
type DatasiteAPI struct {
// contains filtered or unexported fields
}
func (*DatasiteAPI) GetView ¶
func (d *DatasiteAPI) GetView(ctx context.Context, params *DatasiteViewParams) (*DatasiteViewResponse, error)
type DatasiteViewParams ¶
type DatasiteViewParams struct {
}
DataSiteViewInput represents the input parameters for the datasite view API
type DatasiteViewResponse ¶
type DatasiteViewResponse struct {
Files []BlobInfo `json:"files"`
}
DataSiteViewOutput represents the output from the datasite view API
type DeleteParams ¶
type DeleteParams struct {
Keys []string `json:"keys"`
}
DeleteParams represents the parameters for deleting blobs
type DeleteResponse ¶
type DeleteResponse struct {
Deleted []string `json:"deleted"`
Errors []*BlobError `json:"errors"`
}
DeleteResponse represents the response from a blob delete operation
type DownloadFileParams ¶
DownloadFileParams represents the parameters for downloading files
type DownloadFileResponse ¶
type DownloadFileResponse struct {
URLs []*BlobUrl `json:"urls"`
Errors []*BlobError `json:"errors"`
}
DownloadFileResponse represents the response from a file download request
type DownloadJob ¶
type DownloadResult ¶
type DownloadResult struct {
DownloadJob
DownloadPath string
Error error
}
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
func NewDownloader ¶
func NewDownloader(numWorkers int) (*Downloader, error)
func (*Downloader) DownloadAll ¶
func (d *Downloader) DownloadAll(ctx context.Context, files []*DownloadJob) <-chan *DownloadResult
func (*Downloader) DownloadAllC ¶
func (d *Downloader) DownloadAllC(ctx context.Context, files <-chan *DownloadJob) <-chan *DownloadResult
func (*Downloader) DownloadFile ¶
DownloadFile downloads a single file from the provided URL to the temp directory Returns the path to the downloaded file or an error
func (*Downloader) Stop ¶
func (d *Downloader) Stop() error
type EventMessage ¶
EventMessage represents a message sent or received via the events system
type EventsAPI ¶
type EventsAPI struct {
// contains filtered or unexported fields
}
EventsAPI manages real-time event communication
func (*EventsAPI) Close ¶
func (e *EventsAPI) Close()
Close terminates the WebSocket connection and cleans up
func (*EventsAPI) IsConnected ¶
IsConnected returns the current connection status
type PresignedParams ¶
type PresignedParams struct {
Keys []string `json:"keys"`
}
PresignedParams represents the parameters for getting presigned URLs
type PresignedResponse ¶
PresignedResponse represents the response from a presigned URL request
type ProgressCallback ¶
type RefreshTokenRequest ¶
type RefreshTokenRequest struct {
RefreshToken string `json:"refreshToken"`
}
type SyftSDK ¶
type SyftSDK struct {
Datasite *DatasiteAPI
Blob *BlobAPI
Events *EventsAPI
// contains filtered or unexported fields
}
SyftSDK is the main client for interacting with the Syft API
func (*SyftSDK) Authenticate ¶
Authenticate sets the user authentication for API calls and events
func (*SyftSDK) Close ¶
func (s *SyftSDK) Close()
Close terminates all connections and cleans up resources
func (*SyftSDK) OnAuthTokenUpdate ¶
type SyftSDKConfig ¶
type SyftSDKConfig struct {
BaseURL string // BaseURL is required
Email string // Email is required
RefreshToken string // RefreshToken is required
AccessToken string // AccessToken is optional
}
SyftSDKConfig is the configuration for the SyftSDK
func (*SyftSDKConfig) Validate ¶
func (c *SyftSDKConfig) Validate() error
type SyftSDKError ¶
type SyftSDKError struct {
Error string `json:"error"`
}
type UploadParams ¶
UploadParams represents the parameters for uploading a blob
type UploadResponse ¶
type UploadResponse struct {
Key string `json:"key"`
Version string `json:"version"`
ETag string `json:"etag"`
Size int64 `json:"size"`
LastModified string `json:"lastModified"`
}
UploadResponse represents the response from a blob upload
type VerifyEmailCodeRequest ¶
type VerifyEmailRequest ¶
type VerifyEmailRequest struct {
Email string `json:"email"`
}