Documentation ¶
Index ¶
- Constants
- Variables
- func AddSkykey(skykey string, opts AddSkykeyOptions) error
- func Convert(srcSiaPath, destSiaPath string, opts ConvertOptions) (string, error)
- func Download(skylink string, opts DownloadOptions) (io.ReadCloser, error)
- func DownloadFile(path, skylink string, opts DownloadOptions) (err error)
- func GetBlocklist(opts GetBlocklistOptions) ([]string, error)
- func GetStats(opts GetStatsOptions) error
- func Ls(siaPath string, opts LsOptions) error
- func Metadata(skylink string, opts MetadataOptions) error
- func Pin(skylink, destSiaPath string, opts PinOptions) error
- func Unpin(siaPath string, opts UnpinOptions) error
- func UpdateBlocklist(additions, removals []string, opts UpdateBlocklistOptions) error
- func UpdatePortals(additions []Portal, removals []string, opts UpdatePortalsOptions) error
- func Upload(uploadData UploadData, opts UploadOptions) (skylink string, err error)
- func UploadDirectory(path string, opts UploadOptions) (skylink string, err error)
- func UploadFile(path string, opts UploadOptions) (skylink string, err error)
- type AddSkykeyOptions
- type ConvertOptions
- type CreateSkykeyOptions
- type CreateSkykeyResponse
- type DownloadOptions
- type ErrorResponse
- type GetBlocklistOptions
- type GetPortalsOptions
- type GetSkykeyOptions
- type GetSkykeyResponse
- type GetSkykeysOptions
- type GetSkykeysResponse
- type GetStatsOptions
- type LsOptions
- type MetadataOptions
- type Options
- type PinOptions
- type Portal
- type Skykey
- type UnpinOptions
- type UpdateBlocklistOptions
- type UpdatePortalsOptions
- type UploadData
- type UploadOptions
- type UploadResponse
Constants ¶
const ( // DefaultPortalURL is the default URL of the portal to use. DefaultPortalURL = "https://siasky.net" // URISkynetPrefix is the URI prefix for Skynet. URISkynetPrefix = "sia://" )
Variables ¶
var ( // DefaultGetBlocklistOptions contains the default get blocklist options. DefaultGetBlocklistOptions = GetBlocklistOptions{ Options: DefaultOptions("/skynet/blocklist"), } // DefaultUpdateBlocklistOptions contains the default update blocklist // options. DefaultUpdateBlocklistOptions = GetBlocklistOptions{ Options: DefaultOptions("/skynet/blocklist"), } )
var ( // DefaultDownloadOptions contains the default download options. DefaultDownloadOptions = DownloadOptions{ Options: DefaultOptions("/"), SkykeyName: "", SkykeyID: "", } // DefaultMetadataOptions contains the default getting metadata options. DefaultMetadataOptions = MetadataOptions{ Options: DefaultOptions("/"), } )
var ( // DefaultAddSkykeyOptions contains the default addskykey options. DefaultAddSkykeyOptions = AddSkykeyOptions{ Options: DefaultOptions("/skynet/addskykey"), } // DefaultCreateSkykeyOptions contains the default createskykey options. DefaultCreateSkykeyOptions = CreateSkykeyOptions{ Options: DefaultOptions("/skynet/createskykey"), } // DefaultGetSkykeyOptions contains the default skykey GET options. DefaultGetSkykeyOptions = GetSkykeyOptions{ Options: DefaultOptions("/skynet/skykey"), } // DefaultGetSkykeysOptions contains the default skykeys options. DefaultGetSkykeysOptions = GetSkykeysOptions{ Options: DefaultOptions("/skynet/skykeys"), } )
var ( // DefaultPinOptions contains the default pin options DefaultPinOptions = PinOptions{ Options: DefaultOptions("/skynet/pin"), } // DefaultUnpinOptions contains the default unpin options. DefaultUnpinOptions = UnpinOptions{ Options: DefaultOptions(""), EndpointPathUnpinDir: "/renter/dir", EndpointPathUnpinFile: "/renter/delete", } )
var ( // DefaultGetPortalsOptions contains the default get portals options. DefaultGetPortalsOptions = GetPortalsOptions{ Options: DefaultOptions("/skynet/portals"), } // DefaultUpdatePortalsOptions contains the default update portals // options. DefaultUpdatePortalsOptions = GetPortalsOptions{ Options: DefaultOptions("/skynet/portals"), } )
var ( // DefaultConvertOptions contains the default convert options. DefaultConvertOptions = ConvertOptions{ Options: DefaultOptions("/skynet/skyfile"), } )
var ( // DefaultGetStatsOptions contains the default get stats options. DefaultGetStatsOptions = GetStatsOptions{ Options: DefaultOptions("/skynet/stats"), } )
var ( // DefaultLsOptions conains the default ls options. DefaultLsOptions = LsOptions{ Options: DefaultOptions(""), EndpointPathLsDir: "/renter/dir", EndpointPathLsFile: "/renter/file", } )
var ( // DefaultUploadOptions contains the default upload options. DefaultUploadOptions = UploadOptions{ Options: DefaultOptions("/skynet/skyfile"), PortalFileFieldName: "file", PortalDirectoryFileFieldName: "files[]", CustomFilename: "", CustomDirname: "", SkykeyName: "", SkykeyID: "", } )
var ( // ErrResponseError is the error for a response with a status code >= 400. ErrResponseError = errors.New("error response") )
Functions ¶
func AddSkykey ¶
func AddSkykey(skykey string, opts AddSkykeyOptions) error
AddSkykey stores the given base-64 encoded skykey with the skykey manager.
func Convert ¶
func Convert(srcSiaPath, destSiaPath string, opts ConvertOptions) (string, error)
Convert converts an existing siafile to a skyfile and skylink.
func Download ¶
func Download(skylink string, opts DownloadOptions) (io.ReadCloser, error)
Download downloads generic data.
func DownloadFile ¶
func DownloadFile(path, skylink string, opts DownloadOptions) (err error)
DownloadFile downloads a file from Skynet to path.
func GetBlocklist ¶
func GetBlocklist(opts GetBlocklistOptions) ([]string, error)
GetBlocklist returns the list of hashed merkleroots that are blocklisted.
func GetStats ¶
func GetStats(opts GetStatsOptions) error
GetStats returns statistical information about Skynet, e.g. number of files uplaoded.
func Metadata ¶
func Metadata(skylink string, opts MetadataOptions) error
Metadata downloads metadata from the given skylink.
func Pin ¶
func Pin(skylink, destSiaPath string, opts PinOptions) error
Pin pins the file associated with this skylink by re-uploading an exact copy.
func Unpin ¶
func Unpin(siaPath string, opts UnpinOptions) error
Unpin unpins the pinned skyfile or directory at the given siapath.
func UpdateBlocklist ¶
func UpdateBlocklist(additions, removals []string, opts UpdateBlocklistOptions) error
UpdateBlocklist updates the list of skylinks that should be blocklisted from Skynet. This function can be used to both add and remove skylinks from the blocklist.
func UpdatePortals ¶
func UpdatePortals(additions []Portal, removals []string, opts UpdatePortalsOptions) error
UpdatePortals updates the list of known portals. This function can be used to both add and remove portals from the list. Removals are provided in the form of addresses.
func Upload ¶
func Upload(uploadData UploadData, opts UploadOptions) (skylink string, err error)
Upload uploads the given generic data and returns the skylink.
func UploadDirectory ¶
func UploadDirectory(path string, opts UploadOptions) (skylink string, err error)
UploadDirectory uploads a local directory to Skynet and returns the skylink.
func UploadFile ¶
func UploadFile(path string, opts UploadOptions) (skylink string, err error)
UploadFile uploads a file to Skynet and returns the skylink.
Types ¶
type AddSkykeyOptions ¶
type AddSkykeyOptions struct {
Options
}
AddSkykeyOptions contains the options used for addskykey.
type ConvertOptions ¶
type ConvertOptions struct {
Options
}
ConvertOptions contains the options used for convert.
type CreateSkykeyOptions ¶
type CreateSkykeyOptions struct {
Options
}
CreateSkykeyOptions contains the options used for createskykey.
type CreateSkykeyResponse ¶
type CreateSkykeyResponse Skykey
CreateSkykeyResponse contains the response for creating a skykey.
type DownloadOptions ¶
type DownloadOptions struct { Options // SkykeyName is the name of the skykey used to encrypt the upload. SkykeyName string // SkykeyID is the ID of the skykey used to encrypt the upload. SkykeyID string }
DownloadOptions contains the options used for downloads.
type ErrorResponse ¶
type ErrorResponse struct { // Message is the error message of the response. Message string `json:"message"` }
ErrorResponse contains the response for an error.
type GetBlocklistOptions ¶
type GetBlocklistOptions struct {
Options
}
GetBlocklistOptions contains the options used for get blocklist.
type GetPortalsOptions ¶
type GetPortalsOptions struct {
Options
}
GetPortalsOptions contains the options used for get portals.
type GetSkykeyOptions ¶
type GetSkykeyOptions struct {
Options
}
GetSkykeyOptions contains the options used for skykey GET.
type GetSkykeyResponse ¶
type GetSkykeyResponse Skykey
GetSkykeyResponse contains the response for getting a skykey.
type GetSkykeysOptions ¶
type GetSkykeysOptions struct {
Options
}
GetSkykeysOptions contains the options used for skykeys GET.
type GetSkykeysResponse ¶
type GetSkykeysResponse struct { // Skykeys is the returned list of skykeys. Skykeys []Skykey `json:"skykeys"` }
GetSkykeysResponse contains the response for listing skykeys.
type GetStatsOptions ¶
type GetStatsOptions struct {
Options
}
GetStatsOptions contains the options used for get stats.
type MetadataOptions ¶
type MetadataOptions struct {
Options
}
MetadataOptions contains the options used for getting metadata.
type Options ¶
type Options struct { // PortalURL is the URL of the portal to use. PortalURL string // EndpointPath is the relative URL path of the portal endpoint to // contact. EndpointPath string // APIKey is the API password to use for authentication. APIKey string // CustomUserAgent is the custom user agent to use. CustomUserAgent string // contains filtered or unexported fields }
Options contains options used for connecting to a Skynet portal and endpoint.
func DefaultOptions ¶
DefaultOptions returns the default options with the given endpoint path.
type Portal ¶
type Portal struct { // Address is the IP or domain name and the port of the portal. Must be // a valid network address. Address string // Public indicates whether the portal can be accessed publicly or not. Public bool }
Portal contains information about a known portal.
func GetPortals ¶
func GetPortals(opts GetPortalsOptions) ([]Portal, error)
GetPortals returns the list of known Skynet portals.
type Skykey ¶
type Skykey struct { Skykey string `json:"skykey"` Name string `json:"name"` ID string `json:"id"` Type string `json:"type"` }
Skykey contains information about a skykey.
func CreateSkykey ¶
func CreateSkykey(name, skykeyType string, opts CreateSkykeyOptions) (Skykey, error)
CreateSkykey returns a new skykey created and stored under the given name with the given type. skykeyType can be either "public-id" or "private-id".
func GetSkykeyByID ¶
func GetSkykeyByID(id string, opts GetSkykeyOptions) (Skykey, error)
GetSkykeyByID returns the given skykey given its ID.
func GetSkykeyByName ¶
func GetSkykeyByName(name string, opts GetSkykeyOptions) (Skykey, error)
GetSkykeyByName returns the given skykey given its name.
func GetSkykeys ¶
func GetSkykeys(opts GetSkykeysOptions) ([]Skykey, error)
GetSkykeys returns a list of all skykeys.
type UnpinOptions ¶
UnpinOptions contains the options used for unpin.
type UpdateBlocklistOptions ¶
type UpdateBlocklistOptions struct {
Options
}
UpdateBlocklistOptions contains the options used for update blocklist.
type UpdatePortalsOptions ¶
type UpdatePortalsOptions struct {
Options
}
UpdatePortalsOptions contains the options used for update portals.
type UploadData ¶
UploadData contains data to upload, indexed by filenames.
type UploadOptions ¶
type UploadOptions struct { Options // PortalFileFieldName is the fieldName for files on the portal. PortalFileFieldName string // PortalDirectoryFileFieldName is the fieldName for directory files on // the portal. PortalDirectoryFileFieldName string // CustomFilename is the custom filename to use for the upload. If this // is empty, the filename of the file being uploaded will be used by // default. CustomFilename string // CustomDirname is the custom name of the directory. If this is empty, // the base name of the directory being uploaded will be used by // default. CustomDirname string // SkykeyName is the name of the skykey used to encrypt the upload. SkykeyName string // SkykeyID is the ID of the skykey used to encrypt the upload. SkykeyID string }
UploadOptions contains the options used for uploads.
type UploadResponse ¶
type UploadResponse struct { // Skylink is the returned skylink. Skylink string `json:"skylink"` }
UploadResponse contains the response for uploads.