pixelapi

package
v0.0.0-...-325e8d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrIsClientError

func ErrIsClientError(err error) bool

ErrIsClientError returns true if the error is a client-side error

func ErrIsServerError

func ErrIsServerError(err error) bool

ErrIsServerError returns true if the error is a server-side error

Types

type AdminAbuseReport

type AdminAbuseReport struct {
	FileInstanceID gocql.UUID `json:"file_id"`
	IPAddress      string     `json:"ip_address"`
	Time           time.Time  `json:"time"`
	Status         string     `json:"status"` // pending, rejected, granted
	Type           string     `json:"type"`
	EMail          string     `json:"email"`
	Description    string     `json:"description"`
}

AdminAbuseReport is a report someone submitted for a file

type AdminAbuseReportContainer

type AdminAbuseReportContainer struct {
	ID              gocql.UUID         `json:"id"`
	Reports         []AdminAbuseReport `json:"reports"`
	File            FileInfo           `json:"file"`
	Type            string             `json:"type"`
	Status          string             `json:"status"`
	FirstReportTime time.Time          `json:"first_report_time"`
}

type AdminAbuseReporter

type AdminAbuseReporter struct {
	FromAddress        string    `json:"from_address"`
	Name               string    `json:"name"`
	Status             string    `json:"status"`
	Created            time.Time `json:"created"`
	ReportsSent        int       `json:"reports_sent"`
	FilesBlocked       int       `json:"files_blocked"`
	LastUsed           time.Time `json:"last_used"`
	LastMessageSubject string    `json:"last_message_subject"`
	LastMessageText    string    `json:"last_message_text"`
	LastMessageHTML    string    `json:"last_message_html"`
}

AdminAbuseReporter is an e-mail address which is allowed to send abuse reports to abuse@pixeldrain.com

type AdminBanOffence

type AdminBanOffence struct {
	BanTime    time.Time  `json:"ban_time"`
	ExpireTime time.Time  `json:"expire_time"`
	Reason     string     `json:"reason"`
	Reporter   string     `json:"reporter"`
	FileID     gocql.UUID `json:"file_id"`
	FileLink   string     `json:"file_link"`
	FileName   string     `json:"file_name"`
}

type AdminBlockFiles

type AdminBlockFiles struct {
	FilesBlocked           []string `json:"files_blocked"`
	FilesystemNodesBlocked []string `json:"filesystem_nodes_blocked"`
}

AdminBlockFiles is an array of files which were blocked

type AdminGlobal

type AdminGlobal struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

AdminGlobal is a global setting in pixeldrain's back-end

type AdminIPBan

type AdminIPBan struct {
	Address  string            `json:"address"`
	Offences []AdminBanOffence `json:"offences"`
}

type AdminUserBan

type AdminUserBan struct {
	UserID   string            `json:"user_id"`
	User     UserInfo          `json:"user"`
	Offences []AdminBanOffence `json:"offences"`
}

type ClusterSpeed

type ClusterSpeed struct {
	ServerTX  int64 `json:"server_tx"`
	ServerRX  int64 `json:"server_rx"`
	CacheTX   int64 `json:"cache_tx"`
	CacheRX   int64 `json:"cache_rx"`
	StorageTX int64 `json:"storage_tx"`
	StorageRX int64 `json:"storage_rx"`
}

type CouponCode

type CouponCode struct {
	ID     string `json:"id"`
	Credit int64  `json:"credit"`
	Uses   int    `json:"uses"`
}

type Error

type Error struct {
	Status     int    `json:"-"` // One of the http.Status types
	Success    bool   `json:"success"`
	StatusCode string `json:"value"`
	Message    string `json:"message"`

	// In case of the multiple_errors code this array will be populated with
	// more errors
	Errors []Error `json:"errors,omitempty"`

	// Metadata regarding the error
	Extra map[string]interface{} `json:"extra,omitempty"`
}

Error is an error returned by the pixeldrain API. If the request failed before it could reach the API the error will be on a different type

func (Error) Error

func (e Error) Error() string

type FileID

type FileID struct {
	ID string `json:"id"`
}

FileID is returned when a file has been sucessfully uploaded

type FileInfo

type FileInfo struct {
	ID                string    `json:"id"`
	Name              string    `json:"name"`
	Size              int       `json:"size"`
	Views             int       `json:"views"`
	BandwidthUsed     int       `json:"bandwidth_used"`
	BandwidthUsedPaid int       `json:"bandwidth_used_paid"`
	Downloads         int       `json:"downloads"`
	DateUpload        time.Time `json:"date_upload"`
	DateLastView      time.Time `json:"date_last_view"`
	MimeType          string    `json:"mime_type"`
	ThumbnailHREF     string    `json:"thumbnail_href"`
	HashSHA256        string    `json:"hash_sha256"`

	// Custom deletion options
	DeleteAfterDate      time.Time `json:"delete_after_date"`
	DeleteAfterDownloads int       `json:"delete_after_downloads"`

	// Abuse report information
	Availability        string `json:"availability"`
	AvailabilityMessage string `json:"availability_message"`
	AbuseType           string `json:"abuse_type"`
	AbuseReporterName   string `json:"abuse_reporter_name"`

	// Personalization
	Branding map[string]string `json:"branding,omitempty"`

	// Based on user permissions
	CanEdit            bool `json:"can_edit"`
	CanDownload        bool `json:"can_download"`
	ShowAds            bool `json:"show_ads"`
	AllowVideoPlayer   bool `json:"allow_video_player"`
	DownloadSpeedLimit int  `json:"download_speed_limit"`
	SkipFileViewer     bool `json:"skip_file_viewer,omitempty"`
}

FileInfo is the public file information response

type FileInfoSlice

type FileInfoSlice struct {
	Files []FileInfo `json:"files"`
}

FileInfoSlice a collection of files which belong to a user

type FileStats

type FileStats struct {
	Views         int `json:"views"`
	Downloads     int `json:"downloads"`
	Bandwidth     int `json:"bandwidth"`
	BandwidthPaid int `json:"bandwidth_paid"`
}

FileStats contains realtime statistics for a file

type FileTimeSeries

type FileTimeSeries struct {
	Views         TimeSeries `json:"views"`
	Downloads     TimeSeries `json:"downloads"`
	Bandwidth     TimeSeries `json:"bandwidth"`
	BandwidthPaid TimeSeries `json:"bandwidth_paid"`
}

FileTimeSeries returns historic data for a file

type FilesystemContext

type FilesystemContext struct {
	PremiumTransfer bool `json:"premium_transfer"`
}

type FilesystemNode

type FilesystemNode struct {
	Type      string    `json:"type"`
	Path      string    `json:"path"`
	Name      string    `json:"name"`
	Created   time.Time `json:"created"`
	Modified  time.Time `json:"modified"`
	ModeStr   string    `json:"mode_string"`
	ModeOctal string    `json:"mode_octal"`
	CreatedBy string    `json:"created_by"`

	AbuseType       string     `json:"abuse_type,omitempty"`
	AbuseReportTime *time.Time `json:"abuse_report_time,omitempty"`

	// File params
	FileSize  int    `json:"file_size"`
	FileType  string `json:"file_type"`
	SHA256Sum string `json:"sha256_sum"`

	// Meta params
	ID                  string                 `json:"id,omitempty"`
	Properties          map[string]string      `json:"properties,omitempty"`
	LoggingEnabledAt    time.Time              `json:"logging_enabled_at"`
	LinkPermissions     *Permissions           `json:"link_permissions,omitempty"`
	UserPermissions     map[string]Permissions `json:"user_permissions,omitempty"`
	PasswordPermissions map[string]Permissions `json:"password_permissions,omitempty"`
}

FilesystemNode is the return value of the GET /filesystem/ API

type FilesystemPath

type FilesystemPath struct {
	Path        []FilesystemNode  `json:"path"`
	BaseIndex   int               `json:"base_index"`
	Children    []FilesystemNode  `json:"children"`
	Permissions Permissions       `json:"permissions"`
	Context     FilesystemContext `json:"context"`
}

FilesystemPath contains a filesystem with a bucket and all its children leading up to the requested node

type FilesystemTimeSeries

type FilesystemTimeSeries struct {
	Downloads    TimeSeries `json:"downloads"`
	TransferFree TimeSeries `json:"transfer_free"`
	TransferPaid TimeSeries `json:"transfer_paid"`
}

FileTimeSeries returns historic data for a filesystem node

type Invoice

type Invoice struct {
	ID            string    `json:"id"`
	Time          time.Time `json:"time"`
	Amount        int64     `json:"amount"`
	VAT           int64     `json:"vat"`
	Country       string    `json:"country"`
	PaymentMethod string    `json:"payment_method"`
	Status        string    `json:"status"`
}

type ListFile

type ListFile struct {
	DetailHREF  string `json:"detail_href"`
	Description string `json:"description"`
	FileInfo    `json:""`
}

ListFile information object from the pixeldrain API

type ListID

type ListID struct {
	ID string `json:"id"`
}

ListID is returned when a list has been sucessfully created

type ListInfo

type ListInfo struct {
	ID          string     `json:"id"`
	Title       string     `json:"title"`
	DateCreated time.Time  `json:"date_created"`
	FileCount   int        `json:"file_count"`
	Files       []ListFile `json:"files"`
	CanEdit     bool       `json:"can_edit"`
}

ListInfo information object from the pixeldrain API

type ListInfoSlice

type ListInfoSlice struct {
	Lists []ListInfo `json:"lists"`
}

ListInfoSlice is a collection of lists which belong to a user

type Patron

type Patron struct {
	PatreonUserID           string           `json:"patreon_user_id"`
	FullName                string           `json:"full_name"`
	LastChargeDate          time.Time        `json:"last_charge_date"`
	LastChargeStatus        string           `json:"last_charge_status"`
	LifetimeSupportCents    int              `json:"lifetime_support_cents"`
	PatronStatus            string           `json:"patron_status"`
	PledgeAmountCents       int              `json:"pledge_amount_cents"`
	PledgeRelationshipStart time.Time        `json:"pledge_relationship_start"`
	UserEmail               string           `json:"user_email"`
	Subscription            SubscriptionType `json:"subscription"`
}

Patron is a backer on pixeldrain's patreon campaign

type Permissions

type Permissions struct {
	Owner  bool `json:"owner"`
	Read   bool `json:"read"`
	Write  bool `json:"write"`
	Delete bool `json:"delete"`
}

Permissions contains the actions a user can perform on an object

type PixelAPI

type PixelAPI struct {
	// contains filtered or unexported fields
}

PixelAPI is the Pixeldrain API client

func New

func New(apiEndpoint string) (api PixelAPI)

New creates a new Pixeldrain API client to query the Pixeldrain API with

func (*PixelAPI) AdminBlockFiles

func (p *PixelAPI) AdminBlockFiles(text, abuseType, reporter string) (bl AdminBlockFiles, err error)

AdminBlockFiles blocks files from being downloaded

func (*PixelAPI) AdminGetGlobals

func (p *PixelAPI) AdminGetGlobals() (resp []AdminGlobal, err error)

AdminGetGlobals returns the global API settings

func (*PixelAPI) AdminSetGlobals

func (p *PixelAPI) AdminSetGlobals(key, value string) (err error)

AdminSetGlobals sets a global API setting

func (*PixelAPI) DeleteUserSession

func (p *PixelAPI) DeleteUserSession(key string) (err error)

DeleteUserSession destroys an API key so it can no longer be used to perform actions

func (*PixelAPI) GetBTCPayInvoices

func (p *PixelAPI) GetBTCPayInvoices() (resp []Invoice, err error)

func (*PixelAPI) GetCouponID

func (p *PixelAPI) GetCouponID(id string) (resp CouponCode, err error)

func (*PixelAPI) GetFile

func (p *PixelAPI) GetFile(id string) (io.ReadCloser, error)

GetFile makes a file download request and returns a readcloser. Don't forget to close it!

func (*PixelAPI) GetFileInfo

func (p *PixelAPI) GetFileInfo(id string) (resp FileInfo, err error)

GetFileInfo gets the FileInfo from the pixeldrain API

func (*PixelAPI) GetFilesystemPath

func (p *PixelAPI) GetFilesystemPath(path string) (resp FilesystemPath, err error)

GetFilesystemPath opens a filesystem path

func (*PixelAPI) GetFilesystems

func (p *PixelAPI) GetFilesystems() (resp []FilesystemNode, err error)

GetFilesystemBuckets returns a list of filesystems for the user. You need to be authenticated

func (*PixelAPI) GetListID

func (p *PixelAPI) GetListID(id string) (resp ListInfo, err error)

GetListID get a List from the pixeldrain API

func (*PixelAPI) GetMiscClusterSpeed

func (p *PixelAPI) GetMiscClusterSpeed() (s ClusterSpeed, err error)

func (*PixelAPI) GetMiscRateLimits

func (p *PixelAPI) GetMiscRateLimits() (rl RateLimits, err error)

func (*PixelAPI) GetMiscRecaptcha

func (p *PixelAPI) GetMiscRecaptcha() (resp Recaptcha, err error)

GetMiscRecaptcha gets the reCaptcha site key from the pixelapi server. If reCaptcha is disabled the key will be empty

func (*PixelAPI) GetPatreonByID

func (p *PixelAPI) GetPatreonByID(id string) (resp Patron, err error)

GetPatreonByID returns information about a patron by the ID

func (*PixelAPI) GetSiaPrice

func (p *PixelAPI) GetSiaPrice() (resp float64, err error)

GetSiaPrice gets the price of one siacoin

func (*PixelAPI) GetSubscriptionID

func (p *PixelAPI) GetSubscriptionID(id string) (resp Subscription, err error)

GetSubscriptionID returns the subscription object identified by the given ID

func (*PixelAPI) GetUser

func (p *PixelAPI) GetUser() (resp UserInfo, err error)

GetUser returns information about the logged in user. Requires an API key

func (*PixelAPI) GetUserActivity

func (p *PixelAPI) GetUserActivity() (resp []UserActivity, err error)

func (*PixelAPI) GetUserFiles

func (p *PixelAPI) GetUserFiles() (resp FileInfoSlice, err error)

GetUserFiles gets files uploaded by a user

func (*PixelAPI) GetUserLists

func (p *PixelAPI) GetUserLists() (resp ListInfoSlice, err error)

GetUserLists gets lists created by a user

func (*PixelAPI) GetUserSession

func (p *PixelAPI) GetUserSession() (resp []UserSession, err error)

GetUserSession lists all active user sessions

func (*PixelAPI) GetUserTransactions

func (p *PixelAPI) GetUserTransactions() (resp []UserTransaction, err error)

func (PixelAPI) Login

func (p PixelAPI) Login(apiKey string) PixelAPI

Login logs a user into the pixeldrain API. The original PixelAPI does not get logged in, only the returned PixelAPI

func (*PixelAPI) PostCouponRedeem

func (p *PixelAPI) PostCouponRedeem(id string) (err error)

func (*PixelAPI) PostFileView

func (p *PixelAPI) PostFileView(id, viewtoken string) (err error)

PostFileView adds a view to a file

func (p *PixelAPI) PostPatreonLink(id string) (err error)

PostPatreonLink links a patreon subscription to the pixeldrain account which is logged into this API client

func (p *PixelAPI) PostSubscriptionLink(id string) (err error)

PostSubscriptionLink links a subscription to the logged in user account. Use Login() before calling this function to select the account to use. This action cannot be undone.

func (*PixelAPI) PostUserLogin

func (p *PixelAPI) PostUserLogin(username, password, app string) (resp UserSession, err error)

PostUserLogin logs a user in with the provided credentials. The response will contain the returned API key. The app name is saved in the database and can be found on the user's API keys page.

func (*PixelAPI) PostUserSession

func (p *PixelAPI) PostUserSession(app string) (resp UserSession, err error)

PostUserSession creates a new user sessions

func (*PixelAPI) PutUserEmailReset

func (p *PixelAPI) PutUserEmailReset(email string, delete bool) (err error)

PutUserEmailReset starts the e-mail change process. An email will be sent to the new address to verify that it's real. Once the link in the e-mail is clicked the key it contains can be sent to the API with UserEmailResetConfirm and the change will be applied

func (*PixelAPI) PutUserEmailResetConfirm

func (p *PixelAPI) PutUserEmailResetConfirm(key string) (err error)

PutUserEmailResetConfirm finishes process of changing a user's e-mail address

func (*PixelAPI) PutUserPassword

func (p *PixelAPI) PutUserPassword(oldPW, newPW string) (err error)

PutUserPassword changes the user's password

func (*PixelAPI) PutUserPasswordReset

func (p *PixelAPI) PutUserPasswordReset(email string, recaptchaResponse string) (err error)

PutUserPasswordReset starts the password reset process. An email will be sent the user to verify that it really wanted to reset the password. Once the link in the e-mail is clicked the key it contains can be sent to the API with UserPasswordResetConfirm and a new password can be set

func (*PixelAPI) PutUserPasswordResetConfirm

func (p *PixelAPI) PutUserPasswordResetConfirm(key string, newPassword string) (err error)

PutUserPasswordResetConfirm finishes process of resetting a user's password. If the key is valid the new_password parameter will be saved as the new password

func (*PixelAPI) PutUserUsername

func (p *PixelAPI) PutUserUsername(username string) (err error)

PutUserUsername changes the user's username.

func (PixelAPI) RealAgent

func (p PixelAPI) RealAgent(agent string) PixelAPI

RealAgent sets the real user agent to use when making API requests

func (PixelAPI) RealIP

func (p PixelAPI) RealIP(ip string) PixelAPI

RealIP sets the real IP address to use when making API requests

func (PixelAPI) UnixSocketPath

func (p PixelAPI) UnixSocketPath(socket string) PixelAPI

func (*PixelAPI) UserRegister

func (p *PixelAPI) UserRegister(username, email, password, captcha string) (err error)

UserRegister registers a new user on the Pixeldrain server. username and password are always required. email is optional, but without it you will not be able to reset your password in case you forget it. captcha depends on whether reCaptcha is enabled on the Pixeldrain server, this can be checked through the GetRecaptcha function.

The register API can return multiple errors, which will be stored in the Errors array. Check for len(Errors) == 0 to see if an error occurred. If err != nil it means a connection error occurred

type RateLimits

type RateLimits struct {
	ServerOverload    bool `json:"server_overload"`
	SpeedLimit        int  `json:"speed_limit"`
	DownloadLimit     int  `json:"download_limit"`
	DownloadLimitUsed int  `json:"download_limit_used"`
	TransferLimit     int  `json:"transfer_limit"`
	TransferLimitUsed int  `json:"transfer_limit_used"`
}

type Recaptcha

type Recaptcha struct {
	SiteKey string `json:"site_key"`
}

Recaptcha stores the reCaptcha site key

type SiaPrice

type SiaPrice struct {
	Price float64 `json:"price"`
}

SiaPrice is the price of one siacoin

type Subscription

type Subscription struct {
	ID               gocql.UUID       `json:"id"`
	Used             bool             `json:"used"`
	DurationDays     int              `json:"duration_days"`
	StartTime        time.Time        `json:"start_date"`
	WarningDate      time.Time        `json:"warning_date"`
	EndDate          time.Time        `json:"end_date"`
	SubscriptionType SubscriptionType `json:"subscription_type"`
}

Subscription contains information about a user's subscription. When it started, when it ends, and what type of subscription it is

type SubscriptionType

type SubscriptionType struct {
	ID                     string `json:"id"`
	Name                   string `json:"name"`
	Type                   string `json:"type"`
	FileSizeLimit          int64  `json:"file_size_limit"`
	FileExpiryDays         int64  `json:"file_expiry_days"`
	StorageSpace           int64  `json:"storage_space"`
	PricePerTBStorage      int64  `json:"price_per_tb_storage"`
	PricePerTBBandwidth    int64  `json:"price_per_tb_bandwidth"`
	MonthlyTransferCap     int64  `json:"monthly_transfer_cap"`
	FileViewerBranding     bool   `json:"file_viewer_branding"`
	FilesystemAccess       bool   `json:"filesystem_access"`
	FilesystemStorageLimit int64  `json:"filesystem_storage_limit"`
}

SubscriptionType contains information about a subscription type. It's not the active subscription itself, only the properties of the subscription. Like the perks and cost

type TimeSeries

type TimeSeries struct {
	Timestamps []time.Time `json:"timestamps"`
	Amounts    []int       `json:"amounts"`
}

TimeSeries contains data captures over a time span

type UserActivity

type UserActivity struct {
	Time              time.Time `json:"time"`
	Event             string    `json:"event"`
	FileID            string    `json:"file_id"`
	FileName          string    `json:"file_name"`
	FileRemovalReason string    `json:"file_removal_reason"`
}

type UserInfo

type UserInfo struct {
	Username              string            `json:"username"`
	Email                 string            `json:"email"`
	Subscription          SubscriptionType  `json:"subscription"`
	StorageSpaceUsed      int               `json:"storage_space_used"`
	FilesystemStorageUsed int               `json:"filesystem_storage_used"`
	IsAdmin               bool              `json:"is_admin"`
	BalanceMicroEUR       int64             `json:"balance_micro_eur"`
	Hotlinking            bool              `json:"hotlinking_enabled"`
	MonthlyTransferCap    int               `json:"monthly_transfer_cap"`
	MonthlyTransferUsed   int               `json:"monthly_transfer_used"`
	FileViewerBranding    map[string]string `json:"file_viewer_branding"`
	FileEmbedDomains      string            `json:"file_embed_domains"`
	SkipFileViewer        bool              `json:"skip_file_viewer"`
}

UserInfo contains information about the logged in user

type UserSession

type UserSession struct {
	AuthKey      gocql.UUID `json:"auth_key"`
	CreationIP   string     `json:"creation_ip_address"`
	UserAgent    string     `json:"user_agent"`
	AppName      string     `json:"app_name"`
	CreationTime time.Time  `json:"creation_time"`
	LastUsedTime time.Time  `json:"last_used_time"`
}

UserSession is one user session

type UserTransaction

type UserTransaction struct {
	Time               time.Time `json:"time"`
	NewBalance         int64     `json:"new_balance"`
	DepositAmount      int64     `json:"deposit_amount"`
	SubscriptionCharge int64     `json:"subscription_charge"`
	StorageCharge      int64     `json:"storage_charge"`
	StorageUsed        int       `json:"storage_used"`
	BandwidthCharge    int64     `json:"bandwidth_charge"`
	BandwidthUsed      int       `json:"bandwidth_used"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL